Job Expressions
Expressions can be triggered when jobs are created and closed
This commit is contained in:
@@ -68,5 +68,17 @@ namespace Disco.Data.Configuration.Modules
|
|||||||
get { return Get(new List<string>()); }
|
get { return Get(new List<string>()); }
|
||||||
set { Set(value); }
|
set { Set(value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string OnCreateExpression
|
||||||
|
{
|
||||||
|
get { return Get<string>(null); }
|
||||||
|
set { Set(value); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public string OnCloseExpression
|
||||||
|
{
|
||||||
|
get { return Get<string>(null); }
|
||||||
|
set { Set(value); }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ namespace Disco.Models.UI.Config.JobPreferences
|
|||||||
LocationModes LocationMode { get; set; }
|
LocationModes LocationMode { get; set; }
|
||||||
List<string> LocationList { get; set; }
|
List<string> LocationList { get; set; }
|
||||||
|
|
||||||
|
string OnCreateExpression { get; set; }
|
||||||
|
string OnCloseExpression { get; set; }
|
||||||
|
|
||||||
List<KeyValuePair<int, string>> LongRunningJobDaysThresholdOptions();
|
List<KeyValuePair<int, string>> LongRunningJobDaysThresholdOptions();
|
||||||
List<KeyValuePair<int, string>> StaleJobMinutesThresholdOptions();
|
List<KeyValuePair<int, string>> StaleJobMinutesThresholdOptions();
|
||||||
List<KeyValuePair<string, string>> LocationModeOptions();
|
List<KeyValuePair<string, string>> LocationModeOptions();
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
using Disco.Models.BI.Config;
|
using Disco.Models.BI.Config;
|
||||||
using Disco.Models.Repository;
|
using Disco.Models.Repository;
|
||||||
using Disco.Services.Authorization;
|
using Disco.Services.Authorization;
|
||||||
|
using Disco.Services.Logging;
|
||||||
using Disco.Services.Plugins;
|
using Disco.Services.Plugins;
|
||||||
using Disco.Services.Plugins.Features.RepairProvider;
|
using Disco.Services.Plugins.Features.RepairProvider;
|
||||||
using Disco.Services.Plugins.Features.WarrantyProvider;
|
using Disco.Services.Plugins.Features.WarrantyProvider;
|
||||||
@@ -491,13 +492,35 @@ namespace Disco.Services
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Close
|
#region Close
|
||||||
public static void OnCloseNormally(this Job j, User Technician)
|
public static void OnCloseNormally(this Job j, DiscoDataContext Database, User Technician)
|
||||||
{
|
{
|
||||||
if (!j.CanCloseNormally())
|
if (!j.CanCloseNormally())
|
||||||
throw new InvalidOperationException("Close was Denied");
|
throw new InvalidOperationException("Close was Denied");
|
||||||
|
|
||||||
j.ClosedDate = DateTime.Now;
|
j.ClosedDate = DateTime.Now;
|
||||||
j.ClosedTechUserId = Technician.UserId;
|
j.ClosedTechUserId = Technician.UserId;
|
||||||
|
j.ClosedTechUser = Technician;
|
||||||
|
|
||||||
|
// Evaluate OnClose Expression
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var onCloseResult = j.EvaluateOnCloseExpression(Database);
|
||||||
|
if (!string.IsNullOrWhiteSpace(onCloseResult))
|
||||||
|
{
|
||||||
|
var jl = new JobLog()
|
||||||
|
{
|
||||||
|
Job = j,
|
||||||
|
TechUser = Technician,
|
||||||
|
Timestamp = DateTime.Now,
|
||||||
|
Comments = onCloseResult
|
||||||
|
};
|
||||||
|
Database.JobLogs.Add(jl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
SystemLog.LogException("Job Expression - OnCloseExpression", ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool CanCloseNever(this Job j, JobQueueJob IgnoreJobQueueJob = null)
|
private static bool CanCloseNever(this Job j, JobQueueJob IgnoreJobQueueJob = null)
|
||||||
@@ -645,6 +668,28 @@ namespace Disco.Services
|
|||||||
|
|
||||||
j.ClosedDate = DateTime.Now;
|
j.ClosedDate = DateTime.Now;
|
||||||
j.ClosedTechUserId = Technician.UserId;
|
j.ClosedTechUserId = Technician.UserId;
|
||||||
|
j.ClosedTechUser = Technician;
|
||||||
|
|
||||||
|
// Evaluate OnClose Expression
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var onCloseResult = j.EvaluateOnCloseExpression(Database);
|
||||||
|
if (!string.IsNullOrWhiteSpace(onCloseResult))
|
||||||
|
{
|
||||||
|
var jl = new JobLog()
|
||||||
|
{
|
||||||
|
Job = j,
|
||||||
|
TechUser = Technician,
|
||||||
|
Timestamp = DateTime.Now,
|
||||||
|
Comments = onCloseResult
|
||||||
|
};
|
||||||
|
Database.JobLogs.Add(jl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
SystemLog.LogException("Job Expression - OnCloseExpression", ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
@@ -3,9 +3,11 @@ using Disco.Models.Repository;
|
|||||||
using Disco.Models.Services.Documents;
|
using Disco.Models.Services.Documents;
|
||||||
using Disco.Models.Services.Jobs.JobLists;
|
using Disco.Models.Services.Jobs.JobLists;
|
||||||
using Disco.Services.Authorization;
|
using Disco.Services.Authorization;
|
||||||
|
using Disco.Services.Expressions;
|
||||||
using Disco.Services.Interop.ActiveDirectory;
|
using Disco.Services.Interop.ActiveDirectory;
|
||||||
using Disco.Services.Plugins;
|
using Disco.Services.Plugins;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@@ -383,5 +385,39 @@ namespace Disco.Services
|
|||||||
return JobTypes;
|
return JobTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region Expressions
|
||||||
|
|
||||||
|
public static string EvaluateOnCreateExpression(this Job job, DiscoDataContext Database)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(Database.DiscoConfiguration.JobPreferences.OnCreateExpression))
|
||||||
|
{
|
||||||
|
Expression compiledExpression = Jobs.Jobs.OnCreateExpressionFromCache(Database);
|
||||||
|
IDictionary evaluatorVariables = Expression.StandardVariables(null, Database, job.OpenedTechUser, DateTime.Now, null);
|
||||||
|
object result = compiledExpression.EvaluateFirst<object>(job, evaluatorVariables);
|
||||||
|
if (result == null)
|
||||||
|
return null;
|
||||||
|
else
|
||||||
|
return result.ToString();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string EvaluateOnCloseExpression(this Job job, DiscoDataContext Database)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(Database.DiscoConfiguration.JobPreferences.OnCloseExpression))
|
||||||
|
{
|
||||||
|
Expression compiledExpression = Jobs.Jobs.OnCloseExpressionFromCache(Database);
|
||||||
|
IDictionary evaluatorVariables = Expression.StandardVariables(null, Database, job.OpenedTechUser, DateTime.Now, null);
|
||||||
|
object result = compiledExpression.EvaluateFirst<object>(job, evaluatorVariables);
|
||||||
|
if (result == null)
|
||||||
|
return null;
|
||||||
|
else
|
||||||
|
return result.ToString();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
using Disco.Data.Repository;
|
using Disco.Data.Repository;
|
||||||
using Disco.Models.Repository;
|
using Disco.Models.Repository;
|
||||||
|
using Disco.Services.Expressions;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@@ -120,5 +122,25 @@ namespace Disco.Services.Jobs
|
|||||||
return j;
|
return j;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Expression OnCreateExpressionFromCache(DiscoDataContext Database)
|
||||||
|
{
|
||||||
|
return ExpressionCache.GetValue("Job_OnCreateExpression", string.Empty, () => { return Expression.TokenizeSingleDynamic(null, Database.DiscoConfiguration.JobPreferences.OnCreateExpression, 0); });
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void OnCreateExpressionInvalidateCache()
|
||||||
|
{
|
||||||
|
ExpressionCache.InvalidateKey("Job_OnCreateExpression", string.Empty);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Expression OnCloseExpressionFromCache(DiscoDataContext Database)
|
||||||
|
{
|
||||||
|
return ExpressionCache.GetValue("Job_OnCloseExpression", string.Empty, () => { return Expression.TokenizeSingleDynamic(null, Database.DiscoConfiguration.JobPreferences.OnCloseExpression, 0); });
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void OnCloseExpressionInvalidateCache()
|
||||||
|
{
|
||||||
|
ExpressionCache.InvalidateKey("Job_OnCloseExpression", string.Empty);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using Disco.Services.Expressions;
|
|||||||
using Disco.Services.Logging;
|
using Disco.Services.Logging;
|
||||||
using Disco.Services.Users;
|
using Disco.Services.Users;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace Disco.Services
|
namespace Disco.Services
|
||||||
@@ -110,7 +111,6 @@ namespace Disco.Services
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
Database.SaveChanges();
|
Database.SaveChanges();
|
||||||
fa = Database.UserFlagAssignments.Where(ufa => ufa.Id == fa.Id).First();
|
|
||||||
var expressionResult = fa.EvaluateOnAssignmentExpression(Database, AddingUser, fa.AddedDate);
|
var expressionResult = fa.EvaluateOnAssignmentExpression(Database, AddingUser, fa.AddedDate);
|
||||||
if (!string.IsNullOrWhiteSpace(expressionResult))
|
if (!string.IsNullOrWhiteSpace(expressionResult))
|
||||||
{
|
{
|
||||||
@@ -145,19 +145,12 @@ namespace Disco.Services
|
|||||||
if (!string.IsNullOrEmpty(ufa.UserFlag.OnAssignmentExpression))
|
if (!string.IsNullOrEmpty(ufa.UserFlag.OnAssignmentExpression))
|
||||||
{
|
{
|
||||||
Expression compiledExpression = ufa.UserFlag.OnAssignmentExpressionFromCache();
|
Expression compiledExpression = ufa.UserFlag.OnAssignmentExpressionFromCache();
|
||||||
System.Collections.IDictionary evaluatorVariables = Expression.StandardVariables(null, Database, AddingUser, TimeStamp, null);
|
IDictionary evaluatorVariables = Expression.StandardVariables(null, Database, AddingUser, TimeStamp, null);
|
||||||
try
|
object result = compiledExpression.EvaluateFirst<object>(ufa, evaluatorVariables);
|
||||||
{
|
if (result == null)
|
||||||
object result = compiledExpression.EvaluateFirst<object>(ufa, evaluatorVariables);
|
return null;
|
||||||
if (result == null)
|
else
|
||||||
return null;
|
return result.ToString();
|
||||||
else
|
|
||||||
return result.ToString();
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -177,19 +170,12 @@ namespace Disco.Services
|
|||||||
if (!string.IsNullOrEmpty(ufa.UserFlag.OnUnassignmentExpression))
|
if (!string.IsNullOrEmpty(ufa.UserFlag.OnUnassignmentExpression))
|
||||||
{
|
{
|
||||||
Expression compiledExpression = ufa.UserFlag.OnUnassignmentExpressionFromCache();
|
Expression compiledExpression = ufa.UserFlag.OnUnassignmentExpressionFromCache();
|
||||||
System.Collections.IDictionary evaluatorVariables = Expression.StandardVariables(null, Database, RemovingUser, TimeStamp, null);
|
IDictionary evaluatorVariables = Expression.StandardVariables(null, Database, RemovingUser, TimeStamp, null);
|
||||||
try
|
object result = compiledExpression.EvaluateFirst<object>(ufa, evaluatorVariables);
|
||||||
{
|
if (result == null)
|
||||||
object result = compiledExpression.EvaluateFirst<object>(ufa, evaluatorVariables);
|
return null;
|
||||||
if (result == null)
|
else
|
||||||
return null;
|
return result.ToString();
|
||||||
else
|
|
||||||
return result.ToString();
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1684,7 +1684,7 @@ namespace Disco.Web.Areas.API.Controllers
|
|||||||
{
|
{
|
||||||
if (j.CanCloseForced())
|
if (j.CanCloseForced())
|
||||||
{
|
{
|
||||||
j.OnCloseForced(Database, CurrentUser, Reason);
|
j.OnCloseForced(Database, Database.Users.Find(CurrentUser.UserId), Reason);
|
||||||
|
|
||||||
Database.SaveChanges();
|
Database.SaveChanges();
|
||||||
if (redirect.HasValue && redirect.Value)
|
if (redirect.HasValue && redirect.Value)
|
||||||
@@ -1709,7 +1709,7 @@ namespace Disco.Web.Areas.API.Controllers
|
|||||||
{
|
{
|
||||||
if (j.CanCloseNormally())
|
if (j.CanCloseNormally())
|
||||||
{
|
{
|
||||||
j.OnCloseNormally(CurrentUser);
|
j.OnCloseNormally(Database, Database.Users.Find(CurrentUser.UserId));
|
||||||
|
|
||||||
Database.SaveChanges();
|
Database.SaveChanges();
|
||||||
if (redirect)
|
if (redirect)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using Disco.Models.Services.Job;
|
using Disco.Models.Services.Job;
|
||||||
using Disco.Services.Authorization;
|
using Disco.Services.Authorization;
|
||||||
|
using Disco.Services.Jobs;
|
||||||
using Disco.Services.Web;
|
using Disco.Services.Web;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -117,5 +118,53 @@ namespace Disco.Web.Areas.API.Controllers
|
|||||||
else
|
else
|
||||||
return Json("OK", JsonRequestBehavior.AllowGet);
|
return Json("OK", JsonRequestBehavior.AllowGet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[DiscoAuthorize(Claims.Config.JobPreferences.Configure)]
|
||||||
|
public virtual ActionResult UpdateOnCreateExpression(string OnCreateExpression, bool redirect = false)
|
||||||
|
{
|
||||||
|
string expression = null;
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(OnCreateExpression))
|
||||||
|
{
|
||||||
|
expression = OnCreateExpression.Trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Database.DiscoConfiguration.JobPreferences.OnCreateExpression != expression)
|
||||||
|
{
|
||||||
|
Database.DiscoConfiguration.JobPreferences.OnCreateExpression = expression;
|
||||||
|
Database.SaveChanges();
|
||||||
|
|
||||||
|
Jobs.OnCreateExpressionInvalidateCache();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (redirect)
|
||||||
|
return RedirectToAction(MVC.Config.JobPreferences.Index());
|
||||||
|
else
|
||||||
|
return Json("OK", JsonRequestBehavior.AllowGet);
|
||||||
|
}
|
||||||
|
|
||||||
|
[DiscoAuthorize(Claims.Config.JobPreferences.Configure)]
|
||||||
|
public virtual ActionResult UpdateOnCloseExpression(string OnCloseExpression, bool redirect = false)
|
||||||
|
{
|
||||||
|
string expression = null;
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(OnCloseExpression))
|
||||||
|
{
|
||||||
|
expression = OnCloseExpression.Trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Database.DiscoConfiguration.JobPreferences.OnCloseExpression != expression)
|
||||||
|
{
|
||||||
|
Database.DiscoConfiguration.JobPreferences.OnCloseExpression = expression;
|
||||||
|
Database.SaveChanges();
|
||||||
|
|
||||||
|
Jobs.OnCloseExpressionInvalidateCache();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (redirect)
|
||||||
|
return RedirectToAction(MVC.Config.JobPreferences.Index());
|
||||||
|
else
|
||||||
|
return Json("OK", JsonRequestBehavior.AllowGet);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -219,7 +219,7 @@ namespace Disco.Web.Areas.API.Controllers
|
|||||||
|
|
||||||
if (CloseJob.HasValue && CloseJob.Value && job.CanCloseNormally())
|
if (CloseJob.HasValue && CloseJob.Value && job.CanCloseNormally())
|
||||||
{
|
{
|
||||||
job.OnCloseNormally(CurrentUser);
|
job.OnCloseNormally(Database, Database.Users.Find(CurrentUser.UserId));
|
||||||
Database.SaveChanges();
|
Database.SaveChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,10 +2,6 @@
|
|||||||
using Disco.Services.Authorization;
|
using Disco.Services.Authorization;
|
||||||
using Disco.Services.Plugins.Features.UIExtension;
|
using Disco.Services.Plugins.Features.UIExtension;
|
||||||
using Disco.Services.Web;
|
using Disco.Services.Web;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Web;
|
|
||||||
using System.Web.Mvc;
|
using System.Web.Mvc;
|
||||||
|
|
||||||
namespace Disco.Web.Areas.Config.Controllers
|
namespace Disco.Web.Areas.Config.Controllers
|
||||||
@@ -21,7 +17,9 @@ namespace Disco.Web.Areas.Config.Controllers
|
|||||||
StaleJobMinutesThreshold = Database.DiscoConfiguration.JobPreferences.StaleJobMinutesThreshold,
|
StaleJobMinutesThreshold = Database.DiscoConfiguration.JobPreferences.StaleJobMinutesThreshold,
|
||||||
DefaultNoticeboardTheme = Database.DiscoConfiguration.JobPreferences.DefaultNoticeboardTheme,
|
DefaultNoticeboardTheme = Database.DiscoConfiguration.JobPreferences.DefaultNoticeboardTheme,
|
||||||
LocationMode = Database.DiscoConfiguration.JobPreferences.LocationMode,
|
LocationMode = Database.DiscoConfiguration.JobPreferences.LocationMode,
|
||||||
LocationList = Database.DiscoConfiguration.JobPreferences.LocationList
|
LocationList = Database.DiscoConfiguration.JobPreferences.LocationList,
|
||||||
|
OnCreateExpression = Database.DiscoConfiguration.JobPreferences.OnCreateExpression,
|
||||||
|
OnCloseExpression = Database.DiscoConfiguration.JobPreferences.OnCloseExpression
|
||||||
};
|
};
|
||||||
|
|
||||||
// UI Extensions
|
// UI Extensions
|
||||||
|
|||||||
@@ -17,6 +17,11 @@ namespace Disco.Web.Areas.Config.Models.JobPreferences
|
|||||||
public LocationModes LocationMode { get; set; }
|
public LocationModes LocationMode { get; set; }
|
||||||
public List<string> LocationList { get; set; }
|
public List<string> LocationList { get; set; }
|
||||||
|
|
||||||
|
[DataType(DataType.MultilineText)]
|
||||||
|
public string OnCreateExpression { get; set; }
|
||||||
|
[DataType(DataType.MultilineText)]
|
||||||
|
public string OnCloseExpression { get; set; }
|
||||||
|
|
||||||
public List<KeyValuePair<string, string>> DefaultNoticeboardThemeOptions()
|
public List<KeyValuePair<string, string>> DefaultNoticeboardThemeOptions()
|
||||||
{
|
{
|
||||||
return UIHelpers.NoticeboardThemes.ToList();
|
return UIHelpers.NoticeboardThemes.ToList();
|
||||||
|
|||||||
@@ -14,4 +14,5 @@
|
|||||||
Html.RenderPartial(MVC.Config.JobPreferences.Views.Parts.General);
|
Html.RenderPartial(MVC.Config.JobPreferences.Views.Parts.General);
|
||||||
Html.RenderPartial(MVC.Config.JobPreferences.Views.Parts.Reports);
|
Html.RenderPartial(MVC.Config.JobPreferences.Views.Parts.Reports);
|
||||||
Html.RenderPartial(MVC.Config.JobPreferences.Views.Parts.Locations);
|
Html.RenderPartial(MVC.Config.JobPreferences.Views.Parts.Locations);
|
||||||
|
Html.RenderPartial(MVC.Config.JobPreferences.Views.Parts.Expressions);
|
||||||
}
|
}
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// <auto-generated>
|
// <auto-generated>
|
||||||
// This code was generated by a tool.
|
// This code was generated by a tool.
|
||||||
// Runtime Version:4.0.30319.34014
|
// Runtime Version:4.0.30319.42000
|
||||||
//
|
//
|
||||||
// Changes to this file may cause incorrect behavior and will be lost if
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
// the code is regenerated.
|
// the code is regenerated.
|
||||||
@@ -27,7 +27,6 @@ namespace Disco.Web.Areas.Config.Views.JobPreferences
|
|||||||
using System.Web.UI;
|
using System.Web.UI;
|
||||||
using System.Web.WebPages;
|
using System.Web.WebPages;
|
||||||
using Disco;
|
using Disco;
|
||||||
using Disco.BI.Extensions;
|
|
||||||
using Disco.Models.Repository;
|
using Disco.Models.Repository;
|
||||||
using Disco.Services;
|
using Disco.Services;
|
||||||
using Disco.Services.Authorization;
|
using Disco.Services.Authorization;
|
||||||
@@ -61,6 +60,7 @@ namespace Disco.Web.Areas.Config.Views.JobPreferences
|
|||||||
Html.RenderPartial(MVC.Config.JobPreferences.Views.Parts.General);
|
Html.RenderPartial(MVC.Config.JobPreferences.Views.Parts.General);
|
||||||
Html.RenderPartial(MVC.Config.JobPreferences.Views.Parts.Reports);
|
Html.RenderPartial(MVC.Config.JobPreferences.Views.Parts.Reports);
|
||||||
Html.RenderPartial(MVC.Config.JobPreferences.Views.Parts.Locations);
|
Html.RenderPartial(MVC.Config.JobPreferences.Views.Parts.Locations);
|
||||||
|
Html.RenderPartial(MVC.Config.JobPreferences.Views.Parts.Expressions);
|
||||||
|
|
||||||
|
|
||||||
#line default
|
#line default
|
||||||
|
|||||||
@@ -0,0 +1,147 @@
|
|||||||
|
@model Disco.Web.Areas.Config.Models.JobPreferences.IndexModel
|
||||||
|
@{
|
||||||
|
Authorization.Require(Claims.Config.JobPreferences.Show);
|
||||||
|
|
||||||
|
var canConfig = Authorization.Has(Claims.Config.JobPreferences.Configure);
|
||||||
|
}
|
||||||
|
<div id="Config_JobPref_Expressions" class="form" style="width: 530px;">
|
||||||
|
<h2>Expressions</h2>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<th style="width: 200px">On Create:</th>
|
||||||
|
<td>
|
||||||
|
@if (canConfig)
|
||||||
|
{
|
||||||
|
@Html.EditorFor(model => model.OnCreateExpression)
|
||||||
|
@AjaxHelpers.AjaxRemove()
|
||||||
|
@AjaxHelpers.AjaxSave()
|
||||||
|
@AjaxHelpers.AjaxLoader()
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(function () {
|
||||||
|
var field = $('#OnCreateExpression');
|
||||||
|
var fieldRemove = field.next('.ajaxRemove');
|
||||||
|
var fieldOriginalWidth, fieldOriginalHeight;
|
||||||
|
|
||||||
|
document.DiscoFunctions.PropertyChangeHelper(
|
||||||
|
field,
|
||||||
|
'None',
|
||||||
|
'@Url.Action(MVC.API.JobPreferences.UpdateOnCreateExpression())',
|
||||||
|
'OnCreateExpression'
|
||||||
|
);
|
||||||
|
|
||||||
|
field.focus(function () {
|
||||||
|
fieldOriginalWidth = field.width();
|
||||||
|
fieldOriginalHeight = field.height();
|
||||||
|
field.css('overflow', 'visible').animate({ width: field.parent().width() - 42, height: 75 }, 200);
|
||||||
|
}).blur(function () {
|
||||||
|
field.css('overflow', 'hidden').animate({ width: fieldOriginalWidth, height: fieldOriginalHeight }, 200);
|
||||||
|
}).change(function () {
|
||||||
|
if (!!field.val()) {
|
||||||
|
fieldRemove.show();
|
||||||
|
} else {
|
||||||
|
fieldRemove.hide();
|
||||||
|
}
|
||||||
|
}).attr('placeholder', 'None').attr('spellcheck', 'false');
|
||||||
|
|
||||||
|
fieldRemove.click(function () {
|
||||||
|
field.val('').change();
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!!field.val()) {
|
||||||
|
fieldRemove.show();
|
||||||
|
} else {
|
||||||
|
fieldRemove.hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(Model.OnCreateExpression))
|
||||||
|
{
|
||||||
|
<span class="smallMessage"><None Specified></span>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<div class="code">
|
||||||
|
@Model.OnCreateExpression
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
<div class="info-box">
|
||||||
|
<p class="fa-p">
|
||||||
|
<i class="fa fa-fw fa-info-circle"></i>This expression will be evaluated whenever a job is created. If the expression has any output it will be added to the job log.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th style="width: 200px">On Close:</th>
|
||||||
|
<td>
|
||||||
|
@if (canConfig)
|
||||||
|
{
|
||||||
|
@Html.EditorFor(model => model.OnCloseExpression)
|
||||||
|
@AjaxHelpers.AjaxRemove()
|
||||||
|
@AjaxHelpers.AjaxSave()
|
||||||
|
@AjaxHelpers.AjaxLoader()
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(function () {
|
||||||
|
var field = $('#OnCloseExpression');
|
||||||
|
var fieldRemove = field.next('.ajaxRemove');
|
||||||
|
var fieldOriginalWidth, fieldOriginalHeight;
|
||||||
|
|
||||||
|
document.DiscoFunctions.PropertyChangeHelper(
|
||||||
|
field,
|
||||||
|
'None',
|
||||||
|
'@Url.Action(MVC.API.JobPreferences.UpdateOnCloseExpression())',
|
||||||
|
'OnCloseExpression'
|
||||||
|
);
|
||||||
|
|
||||||
|
field.focus(function () {
|
||||||
|
fieldOriginalWidth = field.width();
|
||||||
|
fieldOriginalHeight = field.height();
|
||||||
|
field.css('overflow', 'visible').animate({ width: field.parent().width() - 42, height: 75 }, 200);
|
||||||
|
}).blur(function () {
|
||||||
|
field.css('overflow', 'hidden').animate({ width: fieldOriginalWidth, height: fieldOriginalHeight }, 200);
|
||||||
|
}).change(function () {
|
||||||
|
if (!!field.val()) {
|
||||||
|
fieldRemove.show();
|
||||||
|
} else {
|
||||||
|
fieldRemove.hide();
|
||||||
|
}
|
||||||
|
}).attr('placeholder', 'None').attr('spellcheck', 'false');
|
||||||
|
|
||||||
|
fieldRemove.click(function () {
|
||||||
|
field.val('').change();
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!!field.val()) {
|
||||||
|
fieldRemove.show();
|
||||||
|
} else {
|
||||||
|
fieldRemove.hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(Model.OnCloseExpression))
|
||||||
|
{
|
||||||
|
<span class="smallMessage"><None Specified></span>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<div class="code">
|
||||||
|
@Model.OnCloseExpression
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
<div class="info-box">
|
||||||
|
<p class="fa-p">
|
||||||
|
<i class="fa fa-fw fa-info-circle"></i>This expression will be evaluated whenever a job is closed. If the expression has any output it will be added to the job log.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,438 @@
|
|||||||
|
#pragma warning disable 1591
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// This code was generated by a tool.
|
||||||
|
// Runtime Version:4.0.30319.42000
|
||||||
|
//
|
||||||
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
|
// the code is regenerated.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace Disco.Web.Areas.Config.Views.JobPreferences.Parts
|
||||||
|
{
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
|
using System.Text;
|
||||||
|
using System.Web;
|
||||||
|
using System.Web.Helpers;
|
||||||
|
using System.Web.Mvc;
|
||||||
|
using System.Web.Mvc.Ajax;
|
||||||
|
using System.Web.Mvc.Html;
|
||||||
|
using System.Web.Routing;
|
||||||
|
using System.Web.Security;
|
||||||
|
using System.Web.UI;
|
||||||
|
using System.Web.WebPages;
|
||||||
|
using Disco;
|
||||||
|
using Disco.Models.Repository;
|
||||||
|
using Disco.Services;
|
||||||
|
using Disco.Services.Authorization;
|
||||||
|
using Disco.Services.Web;
|
||||||
|
using Disco.Web;
|
||||||
|
using Disco.Web.Extensions;
|
||||||
|
|
||||||
|
[System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "2.0.0.0")]
|
||||||
|
[System.Web.WebPages.PageVirtualPathAttribute("~/Areas/Config/Views/JobPreferences/Parts/Expressions.cshtml")]
|
||||||
|
public partial class Expressions : Disco.Services.Web.WebViewPage<Disco.Web.Areas.Config.Models.JobPreferences.IndexModel>
|
||||||
|
{
|
||||||
|
public Expressions()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
public override void Execute()
|
||||||
|
{
|
||||||
|
|
||||||
|
#line 2 "..\..\Areas\Config\Views\JobPreferences\Parts\Expressions.cshtml"
|
||||||
|
|
||||||
|
Authorization.Require(Claims.Config.JobPreferences.Show);
|
||||||
|
|
||||||
|
var canConfig = Authorization.Has(Claims.Config.JobPreferences.Configure);
|
||||||
|
|
||||||
|
|
||||||
|
#line default
|
||||||
|
#line hidden
|
||||||
|
WriteLiteral("\r\n<div");
|
||||||
|
|
||||||
|
WriteLiteral(" id=\"Config_JobPref_Expressions\"");
|
||||||
|
|
||||||
|
WriteLiteral(" class=\"form\"");
|
||||||
|
|
||||||
|
WriteLiteral(" style=\"width: 530px;\"");
|
||||||
|
|
||||||
|
WriteLiteral(">\r\n <h2>Expressions</h2>\r\n <table>\r\n <tr>\r\n <th");
|
||||||
|
|
||||||
|
WriteLiteral(" style=\"width: 200px\"");
|
||||||
|
|
||||||
|
WriteLiteral(">On Create:</th>\r\n <td>\r\n");
|
||||||
|
|
||||||
|
|
||||||
|
#line 13 "..\..\Areas\Config\Views\JobPreferences\Parts\Expressions.cshtml"
|
||||||
|
|
||||||
|
|
||||||
|
#line default
|
||||||
|
#line hidden
|
||||||
|
|
||||||
|
#line 13 "..\..\Areas\Config\Views\JobPreferences\Parts\Expressions.cshtml"
|
||||||
|
if (canConfig)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
#line default
|
||||||
|
#line hidden
|
||||||
|
|
||||||
|
#line 15 "..\..\Areas\Config\Views\JobPreferences\Parts\Expressions.cshtml"
|
||||||
|
Write(Html.EditorFor(model => model.OnCreateExpression));
|
||||||
|
|
||||||
|
|
||||||
|
#line default
|
||||||
|
#line hidden
|
||||||
|
|
||||||
|
#line 15 "..\..\Areas\Config\Views\JobPreferences\Parts\Expressions.cshtml"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#line default
|
||||||
|
#line hidden
|
||||||
|
|
||||||
|
#line 16 "..\..\Areas\Config\Views\JobPreferences\Parts\Expressions.cshtml"
|
||||||
|
Write(AjaxHelpers.AjaxRemove());
|
||||||
|
|
||||||
|
|
||||||
|
#line default
|
||||||
|
#line hidden
|
||||||
|
|
||||||
|
#line 16 "..\..\Areas\Config\Views\JobPreferences\Parts\Expressions.cshtml"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#line default
|
||||||
|
#line hidden
|
||||||
|
|
||||||
|
#line 17 "..\..\Areas\Config\Views\JobPreferences\Parts\Expressions.cshtml"
|
||||||
|
Write(AjaxHelpers.AjaxSave());
|
||||||
|
|
||||||
|
|
||||||
|
#line default
|
||||||
|
#line hidden
|
||||||
|
|
||||||
|
#line 17 "..\..\Areas\Config\Views\JobPreferences\Parts\Expressions.cshtml"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#line default
|
||||||
|
#line hidden
|
||||||
|
|
||||||
|
#line 18 "..\..\Areas\Config\Views\JobPreferences\Parts\Expressions.cshtml"
|
||||||
|
Write(AjaxHelpers.AjaxLoader());
|
||||||
|
|
||||||
|
|
||||||
|
#line default
|
||||||
|
#line hidden
|
||||||
|
|
||||||
|
#line 18 "..\..\Areas\Config\Views\JobPreferences\Parts\Expressions.cshtml"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#line default
|
||||||
|
#line hidden
|
||||||
|
WriteLiteral(" <script");
|
||||||
|
|
||||||
|
WriteLiteral(" type=\"text/javascript\"");
|
||||||
|
|
||||||
|
WriteLiteral(@">
|
||||||
|
$(function () {
|
||||||
|
var field = $('#OnCreateExpression');
|
||||||
|
var fieldRemove = field.next('.ajaxRemove');
|
||||||
|
var fieldOriginalWidth, fieldOriginalHeight;
|
||||||
|
|
||||||
|
document.DiscoFunctions.PropertyChangeHelper(
|
||||||
|
field,
|
||||||
|
'None',
|
||||||
|
'");
|
||||||
|
|
||||||
|
|
||||||
|
#line 28 "..\..\Areas\Config\Views\JobPreferences\Parts\Expressions.cshtml"
|
||||||
|
Write(Url.Action(MVC.API.JobPreferences.UpdateOnCreateExpression()));
|
||||||
|
|
||||||
|
|
||||||
|
#line default
|
||||||
|
#line hidden
|
||||||
|
WriteLiteral("\',\r\n \'OnCreateExpression\'\r\n " +
|
||||||
|
" );\r\n\r\n field.focus(function () {\r\n " +
|
||||||
|
" fieldOriginalWidth = field.width();\r\n " +
|
||||||
|
" fieldOriginalHeight = field.height();\r\n " +
|
||||||
|
" field.css(\'overflow\', \'visible\').animate({ width: field.pa" +
|
||||||
|
"rent().width() - 42, height: 75 }, 200);\r\n }).blu" +
|
||||||
|
"r(function () {\r\n field.css(\'overflow\', \'hidd" +
|
||||||
|
"en\').animate({ width: fieldOriginalWidth, height: fieldOriginalHeight }, 200);\r\n" +
|
||||||
|
" }).change(function () {\r\n " +
|
||||||
|
" if (!!field.val()) {\r\n field" +
|
||||||
|
"Remove.show();\r\n } else {\r\n " +
|
||||||
|
" fieldRemove.hide();\r\n }" +
|
||||||
|
"\r\n }).attr(\'placeholder\', \'None\').attr(\'spellchec" +
|
||||||
|
"k\', \'false\');\r\n\r\n fieldRemove.click(function () {" +
|
||||||
|
"\r\n field.val(\'\').change();\r\n " +
|
||||||
|
" });\r\n\r\n if (!!field.val()) {\r\n " +
|
||||||
|
" fieldRemove.show();\r\n " +
|
||||||
|
" } else {\r\n fieldRemove.hide();\r\n " +
|
||||||
|
" }\r\n });\r\n " +
|
||||||
|
"</script>\r\n");
|
||||||
|
|
||||||
|
|
||||||
|
#line 57 "..\..\Areas\Config\Views\JobPreferences\Parts\Expressions.cshtml"
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(Model.OnCreateExpression))
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
#line default
|
||||||
|
#line hidden
|
||||||
|
WriteLiteral(" <span");
|
||||||
|
|
||||||
|
WriteLiteral(" class=\"smallMessage\"");
|
||||||
|
|
||||||
|
WriteLiteral("><None Specified></span>\r\n");
|
||||||
|
|
||||||
|
|
||||||
|
#line 63 "..\..\Areas\Config\Views\JobPreferences\Parts\Expressions.cshtml"
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
#line default
|
||||||
|
#line hidden
|
||||||
|
WriteLiteral(" <div");
|
||||||
|
|
||||||
|
WriteLiteral(" class=\"code\"");
|
||||||
|
|
||||||
|
WriteLiteral(">\r\n");
|
||||||
|
|
||||||
|
WriteLiteral(" ");
|
||||||
|
|
||||||
|
|
||||||
|
#line 67 "..\..\Areas\Config\Views\JobPreferences\Parts\Expressions.cshtml"
|
||||||
|
Write(Model.OnCreateExpression);
|
||||||
|
|
||||||
|
|
||||||
|
#line default
|
||||||
|
#line hidden
|
||||||
|
WriteLiteral("\r\n </div>\r\n");
|
||||||
|
|
||||||
|
|
||||||
|
#line 69 "..\..\Areas\Config\Views\JobPreferences\Parts\Expressions.cshtml"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#line default
|
||||||
|
#line hidden
|
||||||
|
WriteLiteral(" <div");
|
||||||
|
|
||||||
|
WriteLiteral(" class=\"info-box\"");
|
||||||
|
|
||||||
|
WriteLiteral(">\r\n <p");
|
||||||
|
|
||||||
|
WriteLiteral(" class=\"fa-p\"");
|
||||||
|
|
||||||
|
WriteLiteral(">\r\n <i");
|
||||||
|
|
||||||
|
WriteLiteral(" class=\"fa fa-fw fa-info-circle\"");
|
||||||
|
|
||||||
|
WriteLiteral("></i>This expression will be evaluated whenever a job is created. If the expressi" +
|
||||||
|
"on has any output it will be added to the job log.\r\n </p>\r\n " +
|
||||||
|
" </div>\r\n </td>\r\n </tr>\r\n <tr>\r\n " +
|
||||||
|
" <th");
|
||||||
|
|
||||||
|
WriteLiteral(" style=\"width: 200px\"");
|
||||||
|
|
||||||
|
WriteLiteral(">On Close:</th>\r\n <td>\r\n");
|
||||||
|
|
||||||
|
|
||||||
|
#line 81 "..\..\Areas\Config\Views\JobPreferences\Parts\Expressions.cshtml"
|
||||||
|
|
||||||
|
|
||||||
|
#line default
|
||||||
|
#line hidden
|
||||||
|
|
||||||
|
#line 81 "..\..\Areas\Config\Views\JobPreferences\Parts\Expressions.cshtml"
|
||||||
|
if (canConfig)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
#line default
|
||||||
|
#line hidden
|
||||||
|
|
||||||
|
#line 83 "..\..\Areas\Config\Views\JobPreferences\Parts\Expressions.cshtml"
|
||||||
|
Write(Html.EditorFor(model => model.OnCloseExpression));
|
||||||
|
|
||||||
|
|
||||||
|
#line default
|
||||||
|
#line hidden
|
||||||
|
|
||||||
|
#line 83 "..\..\Areas\Config\Views\JobPreferences\Parts\Expressions.cshtml"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#line default
|
||||||
|
#line hidden
|
||||||
|
|
||||||
|
#line 84 "..\..\Areas\Config\Views\JobPreferences\Parts\Expressions.cshtml"
|
||||||
|
Write(AjaxHelpers.AjaxRemove());
|
||||||
|
|
||||||
|
|
||||||
|
#line default
|
||||||
|
#line hidden
|
||||||
|
|
||||||
|
#line 84 "..\..\Areas\Config\Views\JobPreferences\Parts\Expressions.cshtml"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#line default
|
||||||
|
#line hidden
|
||||||
|
|
||||||
|
#line 85 "..\..\Areas\Config\Views\JobPreferences\Parts\Expressions.cshtml"
|
||||||
|
Write(AjaxHelpers.AjaxSave());
|
||||||
|
|
||||||
|
|
||||||
|
#line default
|
||||||
|
#line hidden
|
||||||
|
|
||||||
|
#line 85 "..\..\Areas\Config\Views\JobPreferences\Parts\Expressions.cshtml"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#line default
|
||||||
|
#line hidden
|
||||||
|
|
||||||
|
#line 86 "..\..\Areas\Config\Views\JobPreferences\Parts\Expressions.cshtml"
|
||||||
|
Write(AjaxHelpers.AjaxLoader());
|
||||||
|
|
||||||
|
|
||||||
|
#line default
|
||||||
|
#line hidden
|
||||||
|
|
||||||
|
#line 86 "..\..\Areas\Config\Views\JobPreferences\Parts\Expressions.cshtml"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#line default
|
||||||
|
#line hidden
|
||||||
|
WriteLiteral(" <script");
|
||||||
|
|
||||||
|
WriteLiteral(" type=\"text/javascript\"");
|
||||||
|
|
||||||
|
WriteLiteral(@">
|
||||||
|
$(function () {
|
||||||
|
var field = $('#OnCloseExpression');
|
||||||
|
var fieldRemove = field.next('.ajaxRemove');
|
||||||
|
var fieldOriginalWidth, fieldOriginalHeight;
|
||||||
|
|
||||||
|
document.DiscoFunctions.PropertyChangeHelper(
|
||||||
|
field,
|
||||||
|
'None',
|
||||||
|
'");
|
||||||
|
|
||||||
|
|
||||||
|
#line 96 "..\..\Areas\Config\Views\JobPreferences\Parts\Expressions.cshtml"
|
||||||
|
Write(Url.Action(MVC.API.JobPreferences.UpdateOnCloseExpression()));
|
||||||
|
|
||||||
|
|
||||||
|
#line default
|
||||||
|
#line hidden
|
||||||
|
WriteLiteral("\',\r\n \'OnCloseExpression\'\r\n " +
|
||||||
|
" );\r\n\r\n field.focus(function () {\r\n " +
|
||||||
|
" fieldOriginalWidth = field.width();\r\n " +
|
||||||
|
" fieldOriginalHeight = field.height();\r\n " +
|
||||||
|
" field.css(\'overflow\', \'visible\').animate({ width: field.par" +
|
||||||
|
"ent().width() - 42, height: 75 }, 200);\r\n }).blur" +
|
||||||
|
"(function () {\r\n field.css(\'overflow\', \'hidde" +
|
||||||
|
"n\').animate({ width: fieldOriginalWidth, height: fieldOriginalHeight }, 200);\r\n " +
|
||||||
|
" }).change(function () {\r\n " +
|
||||||
|
" if (!!field.val()) {\r\n fieldR" +
|
||||||
|
"emove.show();\r\n } else {\r\n " +
|
||||||
|
" fieldRemove.hide();\r\n }\r" +
|
||||||
|
"\n }).attr(\'placeholder\', \'None\').attr(\'spellcheck" +
|
||||||
|
"\', \'false\');\r\n\r\n fieldRemove.click(function () {\r" +
|
||||||
|
"\n field.val(\'\').change();\r\n " +
|
||||||
|
" });\r\n\r\n if (!!field.val()) {\r\n " +
|
||||||
|
" fieldRemove.show();\r\n " +
|
||||||
|
" } else {\r\n fieldRemove.hide();\r\n " +
|
||||||
|
" }\r\n });\r\n <" +
|
||||||
|
"/script>\r\n");
|
||||||
|
|
||||||
|
|
||||||
|
#line 125 "..\..\Areas\Config\Views\JobPreferences\Parts\Expressions.cshtml"
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(Model.OnCloseExpression))
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
#line default
|
||||||
|
#line hidden
|
||||||
|
WriteLiteral(" <span");
|
||||||
|
|
||||||
|
WriteLiteral(" class=\"smallMessage\"");
|
||||||
|
|
||||||
|
WriteLiteral("><None Specified></span>\r\n");
|
||||||
|
|
||||||
|
|
||||||
|
#line 131 "..\..\Areas\Config\Views\JobPreferences\Parts\Expressions.cshtml"
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
#line default
|
||||||
|
#line hidden
|
||||||
|
WriteLiteral(" <div");
|
||||||
|
|
||||||
|
WriteLiteral(" class=\"code\"");
|
||||||
|
|
||||||
|
WriteLiteral(">\r\n");
|
||||||
|
|
||||||
|
WriteLiteral(" ");
|
||||||
|
|
||||||
|
|
||||||
|
#line 135 "..\..\Areas\Config\Views\JobPreferences\Parts\Expressions.cshtml"
|
||||||
|
Write(Model.OnCloseExpression);
|
||||||
|
|
||||||
|
|
||||||
|
#line default
|
||||||
|
#line hidden
|
||||||
|
WriteLiteral("\r\n </div>\r\n");
|
||||||
|
|
||||||
|
|
||||||
|
#line 137 "..\..\Areas\Config\Views\JobPreferences\Parts\Expressions.cshtml"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#line default
|
||||||
|
#line hidden
|
||||||
|
WriteLiteral(" <div");
|
||||||
|
|
||||||
|
WriteLiteral(" class=\"info-box\"");
|
||||||
|
|
||||||
|
WriteLiteral(">\r\n <p");
|
||||||
|
|
||||||
|
WriteLiteral(" class=\"fa-p\"");
|
||||||
|
|
||||||
|
WriteLiteral(">\r\n <i");
|
||||||
|
|
||||||
|
WriteLiteral(" class=\"fa fa-fw fa-info-circle\"");
|
||||||
|
|
||||||
|
WriteLiteral("></i>This expression will be evaluated whenever a job is closed. If the expressio" +
|
||||||
|
"n has any output it will be added to the job log.\r\n </p>\r\n " +
|
||||||
|
" </div>\r\n </td>\r\n </tr>\r\n </table>\r\n</div>");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#pragma warning restore 1591
|
||||||
@@ -1344,6 +1344,16 @@ div.logEventsViewport table.logEventsViewport > tbody > tr > td.eventType {
|
|||||||
height: 200px;
|
height: 200px;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
}
|
}
|
||||||
|
#Config_JobPref_Expressions {
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
#Config_JobPref_Expressions #OnCreateExpression,
|
||||||
|
#Config_JobPref_Expressions #OnCloseExpression {
|
||||||
|
height: 16px;
|
||||||
|
min-height: 16px;
|
||||||
|
overflow: hidden;
|
||||||
|
font-family: Consolas, "Courier New", monospace;
|
||||||
|
}
|
||||||
#Config_JobQueues_Index i {
|
#Config_JobQueues_Index i {
|
||||||
width: 1.2857142857142858em;
|
width: 1.2857142857142858em;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
|||||||
@@ -1529,6 +1529,17 @@ div.logEventsViewport {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#Config_JobPref_Expressions {
|
||||||
|
margin-top: 10px;
|
||||||
|
|
||||||
|
#OnCreateExpression, #OnCloseExpression {
|
||||||
|
height: 16px;
|
||||||
|
min-height: 16px;
|
||||||
|
overflow: hidden;
|
||||||
|
font-family: @FontFamilyMono;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#Config_JobQueues_Index {
|
#Config_JobQueues_Index {
|
||||||
i {
|
i {
|
||||||
width: 1.2857142857142858em;
|
width: 1.2857142857142858em;
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
@@ -8,6 +8,7 @@ using Disco.Services.Jobs;
|
|||||||
using Disco.Services.Jobs.JobLists;
|
using Disco.Services.Jobs.JobLists;
|
||||||
using Disco.Services.Jobs.JobQueues;
|
using Disco.Services.Jobs.JobQueues;
|
||||||
using Disco.Services.Jobs.Statistics;
|
using Disco.Services.Jobs.Statistics;
|
||||||
|
using Disco.Services.Logging;
|
||||||
using Disco.Services.Plugins.Features.RepairProvider;
|
using Disco.Services.Plugins.Features.RepairProvider;
|
||||||
using Disco.Services.Plugins.Features.UIExtension;
|
using Disco.Services.Plugins.Features.UIExtension;
|
||||||
using Disco.Services.Plugins.Features.WarrantyProvider;
|
using Disco.Services.Plugins.Features.WarrantyProvider;
|
||||||
@@ -397,6 +398,8 @@ namespace Disco.Web.Controllers
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Database.Configuration.LazyLoadingEnabled = true;
|
||||||
|
|
||||||
// Create New Job
|
// Create New Job
|
||||||
var currentUser = Database.Users.Find(UserService.CurrentUserId);
|
var currentUser = Database.Users.Find(UserService.CurrentUserId);
|
||||||
|
|
||||||
@@ -424,7 +427,7 @@ namespace Disco.Web.Controllers
|
|||||||
// Set Opened Date in the past
|
// Set Opened Date in the past
|
||||||
j.OpenedDate = DateTime.Now.AddMinutes(-1 * m.QuickLogTaskTimeMinutes.Value);
|
j.OpenedDate = DateTime.Now.AddMinutes(-1 * m.QuickLogTaskTimeMinutes.Value);
|
||||||
// Close Job
|
// Close Job
|
||||||
j.OnCloseNormally(currentUser);
|
j.OnCloseNormally(Database, currentUser);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -432,10 +435,34 @@ namespace Disco.Web.Controllers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Database.SaveChanges();
|
||||||
|
|
||||||
|
// Evaluate OnCreate Expression
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var onCreateResult = j.EvaluateOnCreateExpression(Database);
|
||||||
|
if (!string.IsNullOrWhiteSpace(onCreateResult))
|
||||||
|
{
|
||||||
|
var jl = new JobLog()
|
||||||
|
{
|
||||||
|
Job = j,
|
||||||
|
TechUser = currentUser,
|
||||||
|
Timestamp = DateTime.Now,
|
||||||
|
Comments = onCreateResult
|
||||||
|
};
|
||||||
|
Database.JobLogs.Add(jl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
SystemLog.LogException("Job Expression - OnCreateExpression", ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Add Comments
|
// Add Comments
|
||||||
if (!string.IsNullOrWhiteSpace(m.Comments))
|
if (!string.IsNullOrWhiteSpace(m.Comments))
|
||||||
{
|
{
|
||||||
var jl = new Disco.Models.Repository.JobLog()
|
var jl = new JobLog()
|
||||||
{
|
{
|
||||||
Job = j,
|
Job = j,
|
||||||
TechUser = currentUser,
|
TechUser = currentUser,
|
||||||
|
|||||||
@@ -267,6 +267,11 @@
|
|||||||
<DesignTime>True</DesignTime>
|
<DesignTime>True</DesignTime>
|
||||||
<DependentUpon>Index.cshtml</DependentUpon>
|
<DependentUpon>Index.cshtml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Areas\Config\Views\JobPreferences\Parts\Expressions.generated.cs">
|
||||||
|
<DependentUpon>Expressions.cshtml</DependentUpon>
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DesignTime>True</DesignTime>
|
||||||
|
</Compile>
|
||||||
<Compile Include="Areas\Config\Views\JobPreferences\Parts\General.generated.cs">
|
<Compile Include="Areas\Config\Views\JobPreferences\Parts\General.generated.cs">
|
||||||
<AutoGen>True</AutoGen>
|
<AutoGen>True</AutoGen>
|
||||||
<DesignTime>True</DesignTime>
|
<DesignTime>True</DesignTime>
|
||||||
@@ -1190,6 +1195,10 @@
|
|||||||
<Generator>RazorGenerator</Generator>
|
<Generator>RazorGenerator</Generator>
|
||||||
<LastGenOutput>Index.generated.cs</LastGenOutput>
|
<LastGenOutput>Index.generated.cs</LastGenOutput>
|
||||||
</None>
|
</None>
|
||||||
|
<Content Include="Areas\Config\Views\JobPreferences\Parts\Expressions.cshtml">
|
||||||
|
<Generator>RazorGenerator</Generator>
|
||||||
|
<LastGenOutput>Expressions.generated.cs</LastGenOutput>
|
||||||
|
</Content>
|
||||||
<None Include="Areas\Config\Views\JobPreferences\Parts\General.cshtml">
|
<None Include="Areas\Config\Views\JobPreferences\Parts\General.cshtml">
|
||||||
<Generator>RazorGenerator</Generator>
|
<Generator>RazorGenerator</Generator>
|
||||||
<LastGenOutput>General.generated.cs</LastGenOutput>
|
<LastGenOutput>General.generated.cs</LastGenOutput>
|
||||||
|
|||||||
@@ -93,6 +93,18 @@ namespace Disco.Web.Areas.API.Controllers
|
|||||||
{
|
{
|
||||||
return new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.ImportLocationList);
|
return new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.ImportLocationList);
|
||||||
}
|
}
|
||||||
|
[NonAction]
|
||||||
|
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
|
||||||
|
public virtual System.Web.Mvc.ActionResult UpdateOnCreateExpression()
|
||||||
|
{
|
||||||
|
return new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.UpdateOnCreateExpression);
|
||||||
|
}
|
||||||
|
[NonAction]
|
||||||
|
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
|
||||||
|
public virtual System.Web.Mvc.ActionResult UpdateOnCloseExpression()
|
||||||
|
{
|
||||||
|
return new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.UpdateOnCloseExpression);
|
||||||
|
}
|
||||||
|
|
||||||
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
|
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
|
||||||
public JobPreferencesController Actions { get { return MVC.API.JobPreferences; } }
|
public JobPreferencesController Actions { get { return MVC.API.JobPreferences; } }
|
||||||
@@ -115,6 +127,8 @@ namespace Disco.Web.Areas.API.Controllers
|
|||||||
public readonly string UpdateLocationMode = "UpdateLocationMode";
|
public readonly string UpdateLocationMode = "UpdateLocationMode";
|
||||||
public readonly string UpdateLocationList = "UpdateLocationList";
|
public readonly string UpdateLocationList = "UpdateLocationList";
|
||||||
public readonly string ImportLocationList = "ImportLocationList";
|
public readonly string ImportLocationList = "ImportLocationList";
|
||||||
|
public readonly string UpdateOnCreateExpression = "UpdateOnCreateExpression";
|
||||||
|
public readonly string UpdateOnCloseExpression = "UpdateOnCloseExpression";
|
||||||
}
|
}
|
||||||
|
|
||||||
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
|
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
|
||||||
@@ -126,6 +140,8 @@ namespace Disco.Web.Areas.API.Controllers
|
|||||||
public const string UpdateLocationMode = "UpdateLocationMode";
|
public const string UpdateLocationMode = "UpdateLocationMode";
|
||||||
public const string UpdateLocationList = "UpdateLocationList";
|
public const string UpdateLocationList = "UpdateLocationList";
|
||||||
public const string ImportLocationList = "ImportLocationList";
|
public const string ImportLocationList = "ImportLocationList";
|
||||||
|
public const string UpdateOnCreateExpression = "UpdateOnCreateExpression";
|
||||||
|
public const string UpdateOnCloseExpression = "UpdateOnCloseExpression";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -185,6 +201,24 @@ namespace Disco.Web.Areas.API.Controllers
|
|||||||
public readonly string Override = "Override";
|
public readonly string Override = "Override";
|
||||||
public readonly string redirect = "redirect";
|
public readonly string redirect = "redirect";
|
||||||
}
|
}
|
||||||
|
static readonly ActionParamsClass_UpdateOnCreateExpression s_params_UpdateOnCreateExpression = new ActionParamsClass_UpdateOnCreateExpression();
|
||||||
|
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
|
||||||
|
public ActionParamsClass_UpdateOnCreateExpression UpdateOnCreateExpressionParams { get { return s_params_UpdateOnCreateExpression; } }
|
||||||
|
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
|
||||||
|
public class ActionParamsClass_UpdateOnCreateExpression
|
||||||
|
{
|
||||||
|
public readonly string OnCreateExpression = "OnCreateExpression";
|
||||||
|
public readonly string redirect = "redirect";
|
||||||
|
}
|
||||||
|
static readonly ActionParamsClass_UpdateOnCloseExpression s_params_UpdateOnCloseExpression = new ActionParamsClass_UpdateOnCloseExpression();
|
||||||
|
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
|
||||||
|
public ActionParamsClass_UpdateOnCloseExpression UpdateOnCloseExpressionParams { get { return s_params_UpdateOnCloseExpression; } }
|
||||||
|
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
|
||||||
|
public class ActionParamsClass_UpdateOnCloseExpression
|
||||||
|
{
|
||||||
|
public readonly string OnCloseExpression = "OnCloseExpression";
|
||||||
|
public readonly string redirect = "redirect";
|
||||||
|
}
|
||||||
static readonly ViewsClass s_views = new ViewsClass();
|
static readonly ViewsClass s_views = new ViewsClass();
|
||||||
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
|
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
|
||||||
public ViewsClass Views { get { return s_views; } }
|
public ViewsClass Views { get { return s_views; } }
|
||||||
@@ -284,6 +318,32 @@ namespace Disco.Web.Areas.API.Controllers
|
|||||||
return callInfo;
|
return callInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[NonAction]
|
||||||
|
partial void UpdateOnCreateExpressionOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, string OnCreateExpression, bool redirect);
|
||||||
|
|
||||||
|
[NonAction]
|
||||||
|
public override System.Web.Mvc.ActionResult UpdateOnCreateExpression(string OnCreateExpression, bool redirect)
|
||||||
|
{
|
||||||
|
var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.UpdateOnCreateExpression);
|
||||||
|
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "OnCreateExpression", OnCreateExpression);
|
||||||
|
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "redirect", redirect);
|
||||||
|
UpdateOnCreateExpressionOverride(callInfo, OnCreateExpression, redirect);
|
||||||
|
return callInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
[NonAction]
|
||||||
|
partial void UpdateOnCloseExpressionOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, string OnCloseExpression, bool redirect);
|
||||||
|
|
||||||
|
[NonAction]
|
||||||
|
public override System.Web.Mvc.ActionResult UpdateOnCloseExpression(string OnCloseExpression, bool redirect)
|
||||||
|
{
|
||||||
|
var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.UpdateOnCloseExpression);
|
||||||
|
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "OnCloseExpression", OnCloseExpression);
|
||||||
|
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "redirect", redirect);
|
||||||
|
UpdateOnCloseExpressionOverride(callInfo, OnCloseExpression, redirect);
|
||||||
|
return callInfo;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -105,10 +105,12 @@ namespace Disco.Web.Areas.Config.Controllers
|
|||||||
public _ViewNamesClass ViewNames { get { return s_ViewNames; } }
|
public _ViewNamesClass ViewNames { get { return s_ViewNames; } }
|
||||||
public class _ViewNamesClass
|
public class _ViewNamesClass
|
||||||
{
|
{
|
||||||
|
public readonly string Expressions = "Expressions";
|
||||||
public readonly string General = "General";
|
public readonly string General = "General";
|
||||||
public readonly string Locations = "Locations";
|
public readonly string Locations = "Locations";
|
||||||
public readonly string Reports = "Reports";
|
public readonly string Reports = "Reports";
|
||||||
}
|
}
|
||||||
|
public readonly string Expressions = "~/Areas/Config/Views/JobPreferences/Parts/Expressions.cshtml";
|
||||||
public readonly string General = "~/Areas/Config/Views/JobPreferences/Parts/General.cshtml";
|
public readonly string General = "~/Areas/Config/Views/JobPreferences/Parts/General.cshtml";
|
||||||
public readonly string Locations = "~/Areas/Config/Views/JobPreferences/Parts/Locations.cshtml";
|
public readonly string Locations = "~/Areas/Config/Views/JobPreferences/Parts/Locations.cshtml";
|
||||||
public readonly string Reports = "~/Areas/Config/Views/JobPreferences/Parts/Reports.cshtml";
|
public readonly string Reports = "~/Areas/Config/Views/JobPreferences/Parts/Reports.cshtml";
|
||||||
|
|||||||
Reference in New Issue
Block a user