public void SetStateNotifier(IStateNotifier stateNotifier) { if (_stateNotifier is null) { _stateNotifier = stateNotifier; } }
override protected void EvalInner(IDSFDataObject dsfDataObject, IDev2Activity resource, int update) { var outerStateLogger = dsfDataObject.StateNotifier; IStateNotifier stateNotifier = null; try { dsfDataObject.Settings = new Dev2WorkflowSettingsTO { EnableDetailedLogging = Config.Server.EnableDetailedLogging, LoggerType = LoggerType.JSON, KeepLogsForDays = 2, CompressOldLogFiles = true }; if (dsfDataObject.Settings.EnableDetailedLogging) { stateNotifier = LogManager.CreateStateNotifier(dsfDataObject); dsfDataObject.StateNotifier = stateNotifier; } AddExecutionToExecutionManager(dsfDataObject, resource); WorkflowExecutionWatcher.HasAWorkflowBeenExecuted = true; Dev2Logger.Debug("Starting Execute", GlobalConstants.WarewolfDebug); stateNotifier?.LogPreExecuteState(resource); IDev2Activity next; IDev2Activity lastActivity; try { lastActivity = resource; next = resource.Execute(dsfDataObject, update); stateNotifier?.LogPostExecuteState(resource, next); } catch (Exception e) { stateNotifier?.LogExecuteException(e, resource); throw; } ExecuteNode(dsfDataObject, update, ref next, ref lastActivity); } finally { _executionManager?.CompleteExecution(); stateNotifier?.Dispose(); dsfDataObject.StateNotifier = outerStateLogger; } }
public string ResumeJob(IDSFDataObject dsfDataObject, string jobId, bool overrideVariables, string environment) { try { var monitoringApi = _jobStorage.GetMonitoringApi(); var jobDetails = monitoringApi.JobDetails(jobId); var currentState = jobDetails.History.OrderBy(s => s.CreatedAt).LastOrDefault(); if (currentState?.StateName != "Scheduled" && currentState?.StateName != "Failed") { return(GlobalConstants.Failed); } var values = jobDetails.Job.Args[0] as Dictionary <string, StringBuilder>; values.TryGetValue("environment", out StringBuilder persistedEnvironment); var decryptEnvironment = persistedEnvironment.ToString().CanBeDecrypted() ? DpapiWrapper.Decrypt(persistedEnvironment.ToString()) : persistedEnvironment.ToString(); if (overrideVariables) { if (values.ContainsKey("environment")) { values["environment"] = new StringBuilder(environment); } } else { values["environment"] = new StringBuilder(decryptEnvironment); } values.TryGetValue("currentuserprincipal", out StringBuilder currentUserPrincipal); var decryptCurrentUserPrincipal = currentUserPrincipal.ToString().CanBeDecrypted() ? DpapiWrapper.Decrypt(currentUserPrincipal.ToString()) : currentUserPrincipal.ToString(); if (values.ContainsKey("environment")) { values["currentuserprincipal"] = new StringBuilder(decryptCurrentUserPrincipal); } var workflowResume = new WorkflowResume(); var result = workflowResume.Execute(values, null); var serializer = new Dev2JsonSerializer(); var executeMessage = serializer.Deserialize <ExecuteMessage>(result); if (executeMessage.HasError) { var failedState = new FailedState(new Exception(executeMessage.Message?.ToString())); _client.ChangeState(jobId, failedState, ScheduledState.StateName); return(GlobalConstants.Failed); } values.TryGetValue("resourceID", out StringBuilder workflowId); values.TryGetValue("environment", out StringBuilder environments); values.TryGetValue("startActivityId", out StringBuilder startActivityId); values.TryGetValue("versionNumber", out StringBuilder versionNumber); values.TryGetValue("currentprincipal", out StringBuilder currentprincipal); _stateNotifier = dsfDataObject.StateNotifier; var audit = new Audit { WorkflowID = workflowId?.ToString(), Environment = environments?.ToString(), VersionNumber = versionNumber?.ToString(), NextActivityId = startActivityId?.ToString(), AuditDate = DateTime.Now, AuditType = "LogResumeExecutionState", LogLevel = LogLevel.Info, User = currentprincipal?.ToString() }; _stateNotifier?.LogAdditionalDetail(audit, nameof(ResumeJob)); var manuallyResumedState = new ManuallyResumedState(environments?.ToString()); _client.ChangeState(jobId, manuallyResumedState, currentState?.StateName); return(GlobalConstants.Success); } catch (Exception ex) { _stateNotifier?.LogExecuteException(ex, this); Dev2Logger.Error(nameof(ResumeJob), ex, GlobalConstants.WarewolfError); throw new Exception(ex.Message); } }
private static DsfDataObject BuildDataObject(IResourceModel workflow, IPrincipal principal, IStateNotifier stateNotifier, IExecutionEnvironment environment, bool stopOnError) { return(new DsfDataObject("", Guid.NewGuid()) { ResourceID = workflow.ID, ExecutionID = Guid.NewGuid(), ServiceName = workflow.DisplayName, ExecutingUser = principal, WorkspaceID = Guid.NewGuid(), IsDebug = false, StopExecution = stopOnError, RunWorkflowAsync = true, StateNotifier = stateNotifier, Environment = environment, Settings = new Dev2WorkflowSettingsTO { ExecutionLogLevel = LogLevel.DEBUG.ToString(), EnableDetailedLogging = true, LoggerType = LoggerType.JSON, KeepLogsForDays = 2, CompressOldLogFiles = true } }); }
public ManufactureForm(IStateNotifier notifier) { InitializeComponent(); notifier.AddStateChangeable(this); }
public Downloader(IStateNotifier stateNotifier) { stateNotifier.ThrowIfNull("stateNotifier"); _stateNotifier = stateNotifier; }
public OperatorForm(IStateNotifier notifier) { InitializeComponent(); notifier.AddStateChangeable(this); }