private async Task PopulateWorkflowStatuses(string workflowInstanceId) { if (HyperStore == null) { return; } if (string.IsNullOrWhiteSpace(workflowInstanceId)) { return; } try { var args = new RetrieveHyperWorkflowsStatusesArgs() { WorkflowInstancesIds = new string[] { workflowInstanceId } }; WorkflowStatuses = await HyperStore.ExecuteAsyncThrows(args); } catch (Exception ex) { Console.WriteLine(ex.Message); } // Pull all working statuses. }
private async Task <string[]> GetWorkflowInstanceIdsAsync( bool activeOnly) { if (_request == null || string.IsNullOrWhiteSpace(_request.MissionId)) { return new string[] { } } ; var args = new FindHyperDocumentsArgs(true); args.SetDocumentType(typeof(HyperWorkflowInstance)); args.DescriptorConditions.AddCondition("MissionId", _request.MissionId); var instances = await FindHyperDocumentsArgs.FindAsync <HyperWorkflowInstance>(_netStore, args); if (!activeOnly) { return(instances.Select(it => it.Id).ToArray()); } var statsArgs = new RetrieveHyperWorkflowsStatusesArgs { MissionIds = new[] { _request.MissionId } }; var statuses = await _netStore.ExecuteAsync(statsArgs); if (statuses == null || !statuses.Any()) { return new string[] { } } ; var data = new List <HyperWorkflowInstance>(); foreach (var status in statuses) { var activeInstance = instances.FirstOrDefault(it => it.Id == status.WorkflowInstanceId); if (activeInstance == null) { continue; } data.Add(activeInstance); } return(data.Select(it => it.Id).ToArray()); }
public async Task <WorkflowViewModel> GetWorkflowAsync(string workflowId) { if (string.IsNullOrEmpty(workflowId)) { throw new ArgumentException(nameof(workflowId)); } // Find all data sources stored on this node (and visible by the current user). var findArgs = new FindHyperDocumentsArgs(); findArgs.SetDocumentType(typeof(HyperWorkflow)); var workflows = await _netStore.ExecuteAsync(findArgs); // Pull all working statuses. var statsArgs = new RetrieveHyperWorkflowsStatusesArgs(); var workflowStatuses = await _netStore.ExecuteAsync(statsArgs); var workflowsData = new List <WorkflowViewModel>(); var model = new WorkflowViewModel(); foreach (var document in workflows) { var configuration = document.GetPayload <HyperWorkflow>(); if (configuration == null) { continue; } if (workflowId != configuration.Id) { continue; } model.WorkflowId = configuration.Id; model.Name = configuration.Name; model.Document = document; model.Source = configuration; model.WorkflowStatuses = workflowStatuses.Where(it => it.Configuration.Id == configuration.Id).ToArray(); return(model); } throw new ApplicationException("Missing workflow"); }
public async Task <List <FlowDesignNodeStatus> > LoadWorkflowStatuses() { var result = new List <FlowDesignNodeStatus>(); if (HyperStore == null || string.IsNullOrWhiteSpace(WorkflowId) || string.IsNullOrWhiteSpace(WorkflowInstanceId)) { return(result); } var args = new RetrieveHyperWorkflowsStatusesArgs(); var statsArgs = new RetrieveHyperWorkflowsStatusesArgs { WorkflowConfigurationIds = new string[] { WorkflowId }, WorkflowInstancesIds = new string[] { WorkflowInstanceId } }; var statuses = await HyperStore.ExecuteAsync(statsArgs); if (statuses != null && statuses.Any()) { var workflowStatuses = statuses.OrderBy(it => it.PrintTitle).ToList(); foreach (var wfStatus in workflowStatuses) { foreach (var status in wfStatus.NodeStatuses) { var state = status.OperationalState == Common.UniOperationalStates.Operational ? "OK" : status.OperationalState.ToString(); var designNodeStatus = new FlowDesignNodeStatus() { NodeId = status.NodeId, StatusMessage = status.StatusMessage, SystemStatusMessage = status.SystemStatusMessage, DefaultStatusMessage = status.GenerateDefaultStatusMessage(), LoggerStatusMessage = status.GenerateLoggerStatusMessage(), IsActive = status.IsActive, State = state }; result.Add(designNodeStatus); } } } return(result); }
private async Task PopulateWorkflows() { Items.Clear(); IsLoadedData = false; var findArgs = new FindHyperDocumentsArgs(); findArgs.SetDocumentType(typeof(HyperWorkflow)); var workflows = await HyperStore.ExecuteAsync(findArgs); if (workflows == null || !workflows.Any()) { return; } var statsArgs = new RetrieveHyperWorkflowsStatusesArgs(); var statuses = await HyperStore.ExecuteAsync(statsArgs); if (statuses == null) { statuses = new HyperWorkflowStatus[] { }; } foreach (var workflow in workflows) { var configuration = workflow.GetPayload <HyperWorkflow>(); if (configuration == null) { Console.WriteLine($"Failed to load workflow from document: {workflow.Id}"); continue; } var wfVm = new WorkflowConfigurationVm { Source = configuration, WorkflowStatuses = statuses.Where(it => it.Configuration.Id == configuration.Id).ToArray() }; Items.Add(wfVm); } IsLoadedData = true; }
private async Task UpdateMissionCollections() { Missions.Clear(); var workflowStatuses = new List <HyperWorkflowStatus>(); foreach (var node in _nodes) { var retrieveWorkflowsArgs = new RetrieveHyperWorkflowsStatusesArgs(); var statuses = await HyperStore.ExecuteAsync(retrieveWorkflowsArgs); var missions = new List <HyperWorkflowStatus>(); if (statuses != null) { foreach (var status in statuses) { var isMaster = status.SlaveWorkflowStatuses != null && status.SlaveWorkflowStatuses.Any(); var isSlave = status.ParentWorkflowInstanceId != null; if (!isMaster && !isSlave) { var hasTasks = status.ActiveTaskPhases != null && status.ActiveTaskPhases.Length > 0 && status.ActiveTaskPhases.Sum(x => x.PendingTasksCount) > 0; if (hasTasks) { missions.Add(status); } } else if (isSlave) { if (!status.IsCompleted) { missions.Add(status); } } } } missions = missions.Where(m => !string.IsNullOrEmpty(m.MissionId)).ToList(); missions.ForEach(m => Missions.Add(m)); } }
private async Task PopulateData() { Items.Clear(); IsLoadedData = false; if (HyperStore == null || string.IsNullOrWhiteSpace(WorkflowId)) { return; } //var documentId = HyperDocumentId.Create<HyperWorkflow>(WorkflowId); //var wfArgs = new RetrieveHyperDocumentArgs(documentId); //var wfDoc = await HyperStore.ExecuteAsync(wfArgs); //if (wfArgs.ExecutionResult.IsNotSuccess) // return; //var workflow = wfDoc?.GetPayload<HyperWorkflow>(); var statsArgs = new RetrieveHyperWorkflowsStatusesArgs { WorkflowConfigurationIds = new string[] { WorkflowId } }; //var statsArgs = new RetrieveHyperWorkflowsStatusesArgs(); var statuses = await HyperStore.ExecuteAsync(statsArgs); if (statuses != null && statuses.Any()) { var workflowStatuses = statuses.OrderBy(it => it.PrintTitle).ToList(); foreach (var st in workflowStatuses) { var wfInstVm = new WorkflowInstanceVm() { Source = st, HyperStore = HyperStore }; Items.Add(wfInstVm); } } IsLoadedData = true; }
protected async Task DoRefreshAsync() { if (HyperStore == null || this.Source == null || string.IsNullOrEmpty(this.Source.WorkflowInstanceId)) { return; } this.Source.NodeStatuses = new HyperWorkflowNodeStatus[] { }; // Clear all the statuses. var args = new RetrieveHyperWorkflowsStatusesArgs() { WorkflowInstancesIds = new string[] { this.Source.WorkflowInstanceId } }; HyperWorkflowStatus[] statuses = await HyperStore.ExecuteAsync(args); if (statuses != null && statuses.Length > 0) { Source = statuses.FirstOrDefault(it => it.WorkflowInstanceId == WorkflowInstanceId); } }