public OUTPUT Invoke <INPUT, OUTPUT>(INPUT input, Func <INPUT, OUTPUT> func) where INPUT : class where OUTPUT : class { _unitOfWork.Initialize(); try { var output = InsideBehavior.Invoke(input, func); Result = InsideBehavior.Result; _unitOfWork.Commit(); return(output); } catch { _unitOfWork.Rollback(); throw; } finally { _unitOfWork.Dispose(); } }
public override bool Invoke(DictionaryParameters parameters, IInvocationResult jobResult) { var result = IsActive; var description = string.Format("ActivityId '{0}'.", System.Diagnostics.Trace.CorrelationManager.ActivityId.ToString()); jobResult.Description = description; jobResult.Succeeded = result; if(!result) { var message = "Plugin not active"; Logger.Warn("{0} {1}. Nothing to do.", description, message); jobResult.Code = Constants.InvocationResultCodes.ERROR_SERVICE_NOT_ACTIVE; jobResult.Message = message; } else { var message = "Plugin active"; jobResult.Code = Constants.InvocationResultCodes.ERROR_INVALID_FUNCTION; jobResult.Message = message; } return result; }
public TOutput Invoke <TInput, TOutput>(TInput input, Func <TInput, TOutput> func) where TInput : class where TOutput : class { _unitOfWork.Initialize(); try { var output = InsideBehavior.Invoke(input, func); Result = InsideBehavior.Result; _unitOfWork.Commit(); return(output); } catch { _unitOfWork.Rollback(); throw; } finally { _unitOfWork.Dispose(); } }
public override bool Invoke(DictionaryParameters parameters, IInvocationResult jobResult) { var result = base.Invoke(parameters, jobResult); if(!result) { return result; } var message = new StringBuilder(); message.AppendLine("[{0}] DefaultPlugin.Invoke ..."); message.AppendLine(); foreach(KeyValuePair<string, object> item in parameters) { message.AppendFormat("{0}: '{1}'", item.Key, item.Value ?? item.Value.ToString()); message.AppendLine(); } message.AppendLine("DefaultPlugin.Invoke() COMPLETED."); message.AppendLine(); Logger.WriteLine("[{0}] {1}", System.Diagnostics.Trace.CorrelationManager.ActivityId, message.ToString()); result = true; jobResult.Succeeded = result; jobResult.Code = 1; jobResult.Message = "DefaultPlugin.Invoke COMPLETED and logged the intended operation to a tracing facility."; jobResult.Description = message.ToString(); jobResult.InnerJobResult = null; return result; }
public override bool Invoke(DictionaryParameters parameters, IInvocationResult jobResult) { if(!IsActive) { return false; } jobResult = null; return true; }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////// private static void ReadInvocationResult( EmberReader reader, IDictionary <int, IInvocationResult> pendingInvocations) { var success = true; IInvocationResult result = null; while (reader.Read() && (reader.InnerNumber != InnerNumber.EndContainer)) { switch (reader.GetContextSpecificOuterNumber()) { case GlowInvocationResult.InvocationId.OuterNumber: var invocationId = reader.AssertAndReadContentsAsInt32(); pendingInvocations.TryGetValue(invocationId, out result); pendingInvocations.Remove(invocationId); break; case GlowInvocationResult.Success.OuterNumber: success = reader.ReadContentsAsBoolean(); break; case GlowInvocationResult.Result.OuterNumber: if (result != null) { result.Read(reader); } else { reader.Skip(); } break; default: reader.Skip(); break; } } result?.Publish(success); }
public override bool Invoke(DictionaryParameters parameters, IInvocationResult jobResult) { var fReturn = false; if(!IsActive) { jobResult.Succeeded = fReturn; jobResult.Code = 1; jobResult.Message = "Plugin inactive"; } var invocationParameters = parameters.Convert<ProgrammePluginInvokeParameters>(); try { var result = biz.dfch.CS.Utilities.Process.StartProcess( invocationParameters.CommandLine, invocationParameters.WorkingDirectory, invocationParameters.Credential); fReturn = true; jobResult.Succeeded = fReturn; jobResult.Code = 0; jobResult.Message = invocationParameters.CommandLine; } catch(Exception ex) { jobResult.Succeeded = fReturn; jobResult.Code = ex.HResult; jobResult.Message = ex.Message; jobResult.Description = ex.StackTrace; } return jobResult.Succeeded; }
public override bool Invoke(DictionaryParameters parameters, IInvocationResult jobResult) { var activityId = Trace.CorrelationManager.ActivityId; var result = base.Invoke(parameters, jobResult); if(!result) { return result; } try { var invocationParameters = parameters.Convert<ActivitiPluginInvokeParameters>(); var workflowInputParameters = new DictionaryParameters(invocationParameters.Parameters); Logger.Info("JobId: '{0}'. ActivityId '{1}'. {2}({3}).", invocationParameters.JobId, activityId, invocationParameters.Id, string.Join(", ", workflowInputParameters.Keys)); var message = string.Format("JobId: '{0}'", invocationParameters.JobId); var description = string.Format("ExternalWorkflow: ActivityId '{0}'.", activityId); var definitionId = client.GetDefinitionId(invocationParameters.Id); var responseData = client.InvokeWorkflowInstance(definitionId, new Hashtable(workflowInputParameters)); var responseDataMessage = string.Format ( "id '{0}'. processDefinitionId '{1}'. Suspended '{2}'. Completed '{3}'. Ended '{4}'. [JobId '{5}'. ActivityId '{6}]", responseData.id, responseData.processDefinitionId, responseData.suspended, responseData.completed, responseData.ended, invocationParameters.JobId, activityId ); Logger.Info(responseDataMessage); result = true; if (result) { jobResult.Code = biz.dfch.CS.Appclusive.Scheduler.Public.Constants.InvocationResultCodes.ERROR_SUCCESS; } else { jobResult.Code = biz.dfch.CS.Appclusive.Scheduler.Public.Constants.InvocationResultCodes.ERROR_INVALID_FUNCTION; } jobResult.Succeeded = result; jobResult.Description = description; jobResult.Message = message; } catch(Exception ex) { jobResult.Succeeded = result; jobResult.Code = ex.HResult; jobResult.Message = ex.Message; jobResult.Description = ex.StackTrace; throw; } return jobResult.Succeeded; }
public override bool Invoke(DictionaryParameters parameters, IInvocationResult invocationResult) { Contract.Requires("2" == invocationResult.Version, "This plugin only supports non-serialisable invocation results."); var fReturn = false; var result = base.Invoke(parameters, invocationResult); if(!result) { return result; } var message = new StringBuilder(); message.AppendLine("PowerShellScriptPlugin.Invoke ..."); message.AppendLine(); Logger.WriteLine(message.ToString()); message.Clear(); Contract.Assert(parameters.ContainsKey(SCRIPT_NAME_KEY)); var scriptPathAndName = parameters.GetOrDefault(SCRIPT_NAME_KEY, "") as string; parameters.Remove(SCRIPT_NAME_KEY); Contract.Assert(!parameters.ContainsKey(SCRIPT_NAME_KEY)); var scriptParameters = (Dictionary<string, object>) parameters; Contract.Assert(null != scriptParameters); var activityId = Trace.CorrelationManager.ActivityId; foreach(var item in scriptParameters) { message.AppendFormat("{0} - {1}", item.Key, item.Value); message.AppendLine(); } Logger.WriteLine(message.ToString()); message.Clear(); var data = new ThreadPoolUserWorkItemParameters() { ActivityId = activityId , Logger = Logger , ScriptParameters = scriptParameters , ScriptPathAndName = scriptPathAndName }; ThreadPool.QueueUserWorkItem(new WaitCallback(ThreadPoolUserWorkItem.ThreadProc), data); message.AppendLine("PowerShellScriptPlugin.Invoke DISPATCHED."); message.AppendLine(); Logger.WriteLine(message.ToString()); fReturn = true; invocationResult.Succeeded = fReturn; invocationResult.Code = 1; invocationResult.Message = "PowerShellScriptPlugin.Invoke COMPLETED and logged the intended operation to a tracing facility."; invocationResult.Description = message.ToString(); invocationResult.InnerJobResult = null; return fReturn; }