/// <inheritdoc/> public ServiceState GetInitialServiceState(string org, string app) { // Read the workflow template string workflowData = File.ReadAllText(_settings.GetWorkflowPath(org, app, null) + _settings.WorkflowFileName, Encoding.UTF8); return(WorkflowHelper.GetInitialWorkflowState(workflowData)); }
/// <inheritdoc/> public ServiceState GetInitialServiceState(string org, string app) { string developer = AuthenticationHelper.GetDeveloperUserName(_httpContextAccessor.HttpContext); string workflowFullFilePath = _settings.GetWorkflowPath(org, app, developer) + _settings.WorkflowFileName; string workflowData = File.ReadAllText(workflowFullFilePath, Encoding.UTF8); return(WorkflowHelper.GetInitialWorkflowState(workflowData)); }
/// <inheritdoc/> public Stream GetProcessDefinition(string org, string app) { string developer = AuthenticationHelper.GetDeveloperUserName(httpContextAccessor.HttpContext); string bpmnFilePath = repositorySettings.GetWorkflowPath(org, app, developer) + repositorySettings.WorkflowFileName; return(File.OpenRead(bpmnFilePath.AsFileName())); }
public ServiceState InitializeServiceState(string org, string service, string developer, int partyId, Guid instanceId) { string workflowFullFilePath = _settings.GetWorkflowPath(org, service, developer) + _settings.WorkflowFileName; string workflowData = System.IO.File.ReadAllText(workflowFullFilePath, Encoding.UTF8); Definitions workflowModel = null; XmlSerializer serializer = new XmlSerializer(typeof(Definitions)); using (TextReader tr = new StringReader(workflowData)) { workflowModel = (Definitions)serializer.Deserialize(tr); } string nextStepName = string.Empty; SequenceFlow currentSequenceFlow = workflowModel.Process.SequenceFlow.Find(seq => seq.Id == workflowModel.Process.StartEvent.Outgoing); if (currentSequenceFlow != null) { Task nextStepObj = workflowModel.Process.Task.Find(task => task.Id == currentSequenceFlow.TargetRef); if (nextStepObj != null) { nextStepName = nextStepObj.Name; } } JObject stateJson = JObject.FromObject(new { state = nextStepName, }); if (string.IsNullOrEmpty(nextStepName)) { _logger.LogError("Unable to read workflowfile, unable to find next step name from start event"); } string stateFilePath = $"{_settings.GetTestdataForPartyPath(org, service, developer)}{partyId}/{instanceId}/{instanceId}.state.json"; System.IO.File.WriteAllText(stateFilePath, stateJson.ToString(), Encoding.UTF8); return(new ServiceState() { State = string.IsNullOrEmpty(nextStepName) ? WorkflowStep.Unknown : (WorkflowStep)Enum.Parse(typeof(WorkflowStep), nextStepName, true), }); }
/// <summary> /// Method that adds the workflow file to the repository if its not there, or replaces it if its an old version of the workflow file. /// </summary> /// <param name="owner">The owner of the service.</param> /// <param name="service">The name of the service.</param> /// <param name="developer">The developer of the service.</param> private void CheckAndUpdateWorkflowFile(string owner, string service, string developer) { string workflowFullFilePath = _settings.GetWorkflowPath(owner, service, AuthenticationHelper.GetDeveloperUserName(_httpContextAccessor.HttpContext)) + _settings.WorkflowFileName; string templateWorkflowData = File.ReadAllText(_generalSettings.WorkflowTemplate, Encoding.UTF8); if (!File.Exists(workflowFullFilePath)) { // Create the workflow folder Directory.CreateDirectory(_settings.GetWorkflowPath(owner, service, AuthenticationHelper.GetDeveloperUserName(_httpContextAccessor.HttpContext))); File.WriteAllText(workflowFullFilePath, templateWorkflowData, Encoding.UTF8); } else { if (ShouldUpdateFile(workflowFullFilePath, templateWorkflowData)) { // Overwrite existing file File.WriteAllText(workflowFullFilePath, templateWorkflowData, Encoding.UTF8); } } }
/// <inheritdoc/> public Stream GetProcessDefinition(string org, string app) { string bpmnFilePath = repositorySettings.GetWorkflowPath(org, app, null) + repositorySettings.WorkflowFileName; return(File.OpenRead(bpmnFilePath.AsFileName())); }