/// <summary> /// Handles a job item. /// </summary> /// <param name="ctx">The underlying item context.</param> protected virtual void HandleJobItem(IForAllItemExecutionContext <IJob, DateTimeOffset> ctx) { List <Exception> occuredErrors = new List <Exception>(); DateTimeOffset completedAt; JobExecutionContext execCtx = new JobExecutionContext(); try { execCtx.Job = ctx.Item; execCtx.ResultVars = new Dictionary <string, object>(EqualityComparerFactory.CreateCaseInsensitiveStringComparer(true, true)); execCtx.SyncRoot = new object(); execCtx.Time = ctx.State; execCtx.Job .Execute(execCtx); completedAt = AppTime.Now; } catch (Exception ex) { completedAt = AppTime.Now; AggregateException aggEx = ex as AggregateException; if (aggEx != null) { occuredErrors.AddRange(CollectionHelper.OfType <Exception>(aggEx.InnerExceptions)); } else { occuredErrors.Add(ex); } } JobExecutionResult result = new JobExecutionResult(); result.Context = execCtx; result.Errors = occuredErrors.ToArray(); result.Vars = new TMReadOnlyDictionary <string, object>(execCtx.ResultVars); result.Time = completedAt; this.RaiseEventHandler(this.Executed, new JobExecutionResultEventArgs(result)); }
/// <summary> /// Initializes the <see cref="TMApplication" /> class. /// </summary> static TMApplication() { _VARS = new SynchronizedDictionary <string, object>(EqualityComparerFactory.CreateCaseInsensitiveStringComparer(true, true)); }
/// <summary> /// Creates an empty collection for parameters. /// </summary> /// <returns>The created collection.</returns> protected virtual IDictionary <string, object> CreateEmptyParameterCollection() { return(new Dictionary <string, object>(EqualityComparerFactory.CreateCaseInsensitiveStringComparer(true, true))); }
// Protected Methods (2) /// <summary> /// Creates an empty storage for variables. /// </summary> /// <returns>The created storage.</returns> protected virtual IDictionary <string, object> CreateVarStorage() { return(new Dictionary <string, object>(EqualityComparerFactory.CreateCaseInsensitiveStringComparer(true, true))); }