public StepStatuses GetStatus(string elementid) { StepStatuses ret = StepStatuses.NotRun; XmlElement[] nodes = ChildNodes; for (int x = 0; x < Math.Min(nodes.Length, _lastStep); x++) { if (nodes[x].Attributes[_ELEMENT_ID].Value == elementid) { ret = (StepStatuses)Enum.Parse(typeof(StepStatuses), nodes[x].Attributes[_STEP_STATUS].Value); } } return(ret); }
public async Task <CommandResult> Handle(AppendStepLogCommand request, CancellationToken cancellationToken) { var stopwatch = new Stopwatch(); stopwatch.Start(); var step = await _entitiesRepository.GetFirstOrDefaultAsync <Step>(e => e.Id == request.StepId); if (StepStatuses.IsCompleteStatus(step.Status)) { throw new InvalidStepStatusException("Cannot append log to step, step status is complete with " + step.Status); } step.UpdateJournal(new Domain.Entities.JournalEntries.JournalEntry() { CreatedBy = request.CreatedBy, CreatedOn = DateTime.UtcNow, Updates = new List <Domain.ValueObjects.Update>() { new Update() { Type = UpdateType.Append, FieldName = "logs", Value = new StepLog() { CreatedOn = DateTime.UtcNow, Message = request.Log }, } } }); //await _entitiesRepository.UpdateStep(step); var createdWorkflowTemplateId = await _node.Handle(new AddShardWriteOperation() { Data = step, WaitForSafeWrite = true, Operation = ConsensusCore.Domain.Enums.ShardOperationOptions.Update }); return(new CommandResult() { ElapsedMs = stopwatch.ElapsedMilliseconds, ObjectRefId = step.Id.ToString(), Type = CommandResultTypes.Update }); }
private Image _RenderEdge(Edge edge, StepStatuses status, Definition definition) { Bitmap ret = new Bitmap((int)edge.Rectangle.Width, (int)edge.Rectangle.Height); Graphics gp = Graphics.FromImage(ret); gp.TranslateTransform(0 - edge.Rectangle.X, 0 - edge.Rectangle.Y); gp.DrawLines(edge.ConstructPen(_GetBrush(status), definition), edge.Points); edge.AppendEnds(gp, _GetBrush(status), definition); if (edge.Label != null) { IElement elem = definition.LocateElement(edge.bpmnElement); if (elem != null) { SizeF sf = gp.MeasureString(elem.ToString(), Constants.FONT, new SizeF(edge.Label.Bounds.Rectangle.Width, edge.Label.Bounds.Rectangle.Height), Constants.STRING_FORMAT); gp.DrawString(elem.ToString(), Constants.FONT, _GetBrush(status), new RectangleF(edge.Label.Bounds.Rectangle.X, edge.Label.Bounds.Rectangle.Y, Math.Max(edge.Label.Bounds.Rectangle.Width, sf.Width), Math.Max(edge.Label.Bounds.Rectangle.Height, sf.Height)), Constants.STRING_FORMAT); } } return(ret); }
private string _GetImageStreamName(StepStatuses status) { string ret = "Org.Reddragonit.BpmEngine.symbols.Black.png"; switch (status) { case StepStatuses.Failed: ret = "Org.Reddragonit.BpmEngine.symbols.Red.png"; break; case StepStatuses.Succeeded: ret = "Org.Reddragonit.BpmEngine.symbols.Green.png"; break; case StepStatuses.Waiting: ret = "Org.Reddragonit.BpmEngine.symbols.Blue.png"; break; } return(ret); }
private Brush _GetBrush(StepStatuses status) { Brush ret = Brushes.Black; switch (status) { case StepStatuses.Failed: ret = Brushes.Red; break; case StepStatuses.Succeeded: ret = Brushes.Green; break; case StepStatuses.Waiting: ret = Brushes.Blue; break; } return(ret); }
private Color _GetColor(StepStatuses status) { Color ret = Color.Black; switch (status) { case StepStatuses.Failed: ret = Color.Red; break; case StepStatuses.Succeeded: ret = Color.Green; break; case StepStatuses.Waiting: ret = Color.Blue; break; } return(ret); }
public async Task <IActionResult> Create(CreateStepCommand command, bool?wait_for_completion, string timeout = "30s") { var stopwatch = new Stopwatch(); stopwatch.Start(); try { command.CreatedBy = ClaimsUtility.GetId(User); var result = await Mediator.Send(command); Step step = (await Mediator.Send(new GetEntityQuery <Step>() { Expression = s => s.Id == new Guid(result.ObjectRefId), Exclude = (s) => s.Journal })).Result; if (wait_for_completion.HasValue && wait_for_completion.Value) { var ms = DateTimeMathsUtility.GetMs(timeout); while (!StepStatuses.IsCompleteStatus(step.Status) && stopwatch.ElapsedMilliseconds < ms) { step = (await Mediator.Send(new GetEntityQuery <Step>() { Expression = s => s.Id == new Guid(result.ObjectRefId) })).Result; } } return(Ok(new HttpCommandResult <Step>("step", result, step))); } catch (BaseException e) { Logger.LogError(e.Message); stopwatch.Stop(); return(BadRequest(e.ToExceptionResult(stopwatch.ElapsedMilliseconds))); } }
private void _addPathEntry(string elementID, string incomingID, string[] outgoingID, StepStatuses status, DateTime start, DateTime?end, string completedBy) { XmlElement elem = _ProduceElement(_PATH_ENTRY_ELEMENT); _SetAttribute(elem, _ELEMENT_ID, elementID); _SetAttribute(elem, _STEP_STATUS, status.ToString()); _SetAttribute(elem, _START_TIME, start.ToString(Constants.DATETIME_FORMAT)); if (incomingID != null) { _SetAttribute(elem, _INCOMING_ID, incomingID); } if (end.HasValue) { _SetAttribute(elem, _END_TIME, end.Value.ToString(Constants.DATETIME_FORMAT)); } if (completedBy != null) { _SetAttribute(elem, _COMPLETED_BY, completedBy); } if (outgoingID != null) { if (outgoingID.Length == 1) { _SetAttribute(elem, _OUTGOING_ID, outgoingID[0]); } else { foreach (string str in outgoingID) { elem.AppendChild(_ProduceElement(_OUTGOING_ELEM)); elem.ChildNodes[elem.ChildNodes.Count - 1].InnerText = str; } } } Console.WriteLine(string.Format("Adding Path Entry for {0}-{1}", elementID, status)); _AppendElement(elem); _stateChanged(); }
private void _addPathEntry(string elementID, string incomingID, string outgoingID, StepStatuses status, DateTime start, DateTime end) { _addPathEntry(elementID, incomingID, new string[] { outgoingID }, status, start, end, null); }
private void _addPathEntry(string elementID, string incomingID, StepStatuses status, DateTime start) { _addPathEntry(elementID, incomingID, null, status, start, null, null); }
private Image _Render(ProcessPath path, Definition definition, string elemid) { Size sz = Size; Bitmap bmp = new Bitmap(sz.Width, sz.Height); int minX = 0; int maxX = 0; int minY = 0; int maxY = 0; foreach (IElement elem in Children) { _RecurGetDimensions(elem, ref minX, ref maxX, ref minY, ref maxY); } Graphics gp = Graphics.FromImage(bmp); gp.TranslateTransform(Math.Abs(minX), Math.Abs(minY)); foreach (Shape shape in _Shapes) { if (shape.bpmnElement == (elemid == null ? shape.bpmnElement : elemid)) { StepStatuses status = path.GetStatus(shape.bpmnElement); BPMIcons? icon = shape.GetIcon(definition); IElement elem = definition.LocateElement(shape.bpmnElement); if (icon.HasValue) { Image img = Bitmap.FromStream(Utility.LocateEmbededResource(_GetImageStreamName(status))); Rectangle rect = new Rectangle(0, 0, 0, 0); switch (icon.Value) { case BPMIcons.Task: case BPMIcons.SendTask: case BPMIcons.ReceiveTask: case BPMIcons.UserTask: case BPMIcons.ManualTask: case BPMIcons.ServiceTask: case BPMIcons.ScriptTask: case BPMIcons.BusinessRuleTask: Pen p = new Pen(_GetBrush(status), Constants.PEN_WIDTH); gp.DrawEllipse(p, new RectangleF(shape.Rectangle.X, shape.Rectangle.Y, 11, 11)); gp.DrawEllipse(p, new RectangleF(shape.Rectangle.X, shape.Rectangle.Y + shape.Rectangle.Height - 11, 11, 11)); gp.DrawEllipse(p, new RectangleF(shape.Rectangle.X + shape.Rectangle.Width - 11, shape.Rectangle.Y, 11, 11)); gp.DrawEllipse(p, new RectangleF(shape.Rectangle.X + shape.Rectangle.Width - 11, shape.Rectangle.Y + shape.Rectangle.Height - 11, 11, 11)); gp.FillPolygon(Brushes.White, new PointF[] { new PointF(shape.Rectangle.X, shape.Rectangle.Y + 5), new PointF(shape.Rectangle.X + 5, shape.Rectangle.Y + 5), new PointF(shape.Rectangle.X + 5, shape.Rectangle.Y), new PointF(shape.Rectangle.X + shape.Rectangle.Width - 5, shape.Rectangle.Y), new PointF(shape.Rectangle.X + shape.Rectangle.Width - 5, shape.Rectangle.Y + 5), new PointF(shape.Rectangle.X + shape.Rectangle.Width, shape.Rectangle.Y + 5), new PointF(shape.Rectangle.X + shape.Rectangle.Width, shape.Rectangle.Y + shape.Rectangle.Height - 5), new PointF(shape.Rectangle.X + shape.Rectangle.Width - 5, shape.Rectangle.Y + shape.Rectangle.Height - 5), new PointF(shape.Rectangle.X + shape.Rectangle.Width - 5, shape.Rectangle.Y + shape.Rectangle.Height), new PointF(shape.Rectangle.X + 5, shape.Rectangle.Y + shape.Rectangle.Height), new PointF(shape.Rectangle.X + 5, shape.Rectangle.Y + shape.Rectangle.Height - 5), new PointF(shape.Rectangle.X, shape.Rectangle.Y + shape.Rectangle.Height - 5), new PointF(shape.Rectangle.X, shape.Rectangle.Y + 5) }); gp.DrawLine(p, new PointF(shape.Rectangle.X + 5, shape.Rectangle.Y), new PointF(shape.Rectangle.X + shape.Rectangle.Width - 5, shape.Rectangle.Y)); gp.DrawLine(p, new PointF(shape.Rectangle.X + shape.Rectangle.Width, shape.Rectangle.Y + 5), new PointF(shape.Rectangle.X + shape.Rectangle.Width, shape.Rectangle.Y + shape.Rectangle.Height - 5)); gp.DrawLine(p, new PointF(shape.Rectangle.X + 5, shape.Rectangle.Y + shape.Rectangle.Height), new PointF(shape.Rectangle.X + shape.Rectangle.Width - 5, shape.Rectangle.Y + shape.Rectangle.Height)); gp.DrawLine(p, new PointF(shape.Rectangle.X, shape.Rectangle.Y + 5), new PointF(shape.Rectangle.X, shape.Rectangle.Y + shape.Rectangle.Height - 5)); switch (icon.Value) { case BPMIcons.Task: rect = new Rectangle(0, 0, 1, 1); break; case BPMIcons.SendTask: rect = new Rectangle(278, 10, 46, 30); break; case BPMIcons.ReceiveTask: rect = new Rectangle(330, 10, 46, 30); break; case BPMIcons.UserTask: rect = new Rectangle(274, 52, 40, 47); break; case BPMIcons.ManualTask: rect = new Rectangle(327, 53, 55, 36); break; case BPMIcons.ServiceTask: rect = new Rectangle(335, 100, 48, 45); break; case BPMIcons.ScriptTask: rect = new Rectangle(385, 8, 33, 37); break; case BPMIcons.BusinessRuleTask: rect = new Rectangle(272, 111, 49, 30); break; } gp.DrawImage(img, new RectangleF(shape.Rectangle.X + 5, shape.Rectangle.Y + 5, 15, 15), rect, GraphicsUnit.Pixel); break; default: switch (icon.Value) { case BPMIcons.StartEvent: rect = new Rectangle(7, 5, 46, 46); break; case BPMIcons.MessageStartEvent: rect = new Rectangle(62, 5, 46, 46); break; case BPMIcons.TimerStartEvent: rect = new Rectangle(115, 5, 46, 46); break; case BPMIcons.ConditionalStartEvent: rect = new Rectangle(168, 5, 46, 46); break; case BPMIcons.SignalStartEvent: rect = new Rectangle(220, 5, 46, 46); break; case BPMIcons.MessageIntermediateThrowEvent: rect = new Rectangle(8, 56, 46, 46); break; case BPMIcons.EscalationIntermediateThrowEvent: rect = new Rectangle(62, 56, 46, 46); break; case BPMIcons.LinkIntermediateThrowEvent: rect = new Rectangle(116, 56, 46, 46); break; case BPMIcons.CompensationIntermediateThrowEvent: rect = new Rectangle(169, 56, 46, 46); break; case BPMIcons.SignalIntermediateThrowEvent: rect = new Rectangle(221, 56, 46, 46); break; case BPMIcons.MessageIntermediateCatchEvent: rect = new Rectangle(8, 107, 46, 46); break; case BPMIcons.TimerIntermediateCatchEvent: rect = new Rectangle(62, 107, 46, 46); break; case BPMIcons.ConditionalIntermediateCatchEvent: rect = new Rectangle(116, 107, 46, 46); break; case BPMIcons.LinkIntermediateCatchEvent: rect = new Rectangle(169, 107, 46, 46); break; case BPMIcons.SignalIntermediateCatchEvent: rect = new Rectangle(221, 107, 46, 46); break; case BPMIcons.EndEvent: rect = new Rectangle(6, 160, 48, 48); break; case BPMIcons.MessageEndEvent: rect = new Rectangle(61, 160, 48, 48); break; case BPMIcons.EscalationEndEvent: rect = new Rectangle(114, 160, 48, 48); break; case BPMIcons.ErrorEndEvent: rect = new Rectangle(167, 160, 48, 48); break; case BPMIcons.CompensationEndEvent: rect = new Rectangle(220, 160, 48, 48); break; case BPMIcons.SignalEndEvent: rect = new Rectangle(274, 160, 48, 48); break; case BPMIcons.TerminateEndEvent: rect = new Rectangle(332, 160, 48, 48); break; case BPMIcons.ExclusiveGateway: rect = new Rectangle(8, 214, 63, 63); break; case BPMIcons.ParallelGateway: rect = new Rectangle(77, 214, 63, 63); break; case BPMIcons.InclusiveGateway: rect = new Rectangle(149, 214, 63, 63); break; case BPMIcons.ComplexGateway: rect = new Rectangle(222, 214, 63, 63); break; case BPMIcons.EventBasedGateway: rect = new Rectangle(292, 214, 63, 63); break; } gp.DrawImage(img, shape.Rectangle, rect, GraphicsUnit.Pixel); break; } } if (elem != null) { if (elem is TextAnnotation) { gp.DrawLines(new Pen(_GetBrush(status), Constants.PEN_WIDTH), new PointF[] { new PointF(shape.Rectangle.X + 20, shape.Rectangle.Y), new PointF(shape.Rectangle.X, shape.Rectangle.Y), new PointF(shape.Rectangle.X, shape.Rectangle.Y + shape.Rectangle.Height), new PointF(shape.Rectangle.X + 20, shape.Rectangle.Y + shape.Rectangle.Height) }); } else if (elem is Lane || elem is Participant) { gp.DrawRectangle(new Pen(_GetBrush(status), Constants.PEN_WIDTH), Rectangle.Round(shape.Rectangle)); } else if (elem is SubProcess) { gp.DrawPath(new Pen(_GetBrush(status), Constants.PEN_WIDTH), _GenerateRoundedRectangle(shape.Rectangle.X, shape.Rectangle.Y, shape.Rectangle.Width, shape.Rectangle.Height)); } if (elem.ToString() != "") { if (shape.Label != null) { SizeF sf = gp.MeasureString(elem.ToString(), Constants.FONT, new SizeF(shape.Label.Bounds.Rectangle.Width, float.MaxValue), Constants.STRING_FORMAT); gp.DrawString(elem.ToString(), Constants.FONT, _GetBrush(status), new RectangleF(shape.Label.Bounds.Rectangle.X, shape.Label.Bounds.Rectangle.Y, Math.Max(shape.Label.Bounds.Rectangle.Width, sf.Width), Math.Max(shape.Label.Bounds.Rectangle.Height, sf.Height)), Constants.STRING_FORMAT); } else { SizeF size = gp.MeasureString(elem.ToString(), Constants.FONT); if (size.Height != 0 || size.Width != 0) { if (elem is Lane || elem is LaneSet || elem is Participant) { Bitmap tbmp = new Bitmap((int)size.Height * 2, (int)size.Width); Graphics g = Graphics.FromImage(tbmp); g.TranslateTransform(tbmp.Width / 2, tbmp.Height); g.RotateTransform(-90); g.TranslateTransform(0, 0); g.DrawString(elem.ToString(), Constants.FONT, _GetBrush(status), 0, 0); g.Save(); gp.DrawImage(tbmp, new PointF(shape.Rectangle.X - 7, shape.Rectangle.Y + ((shape.Rectangle.Height - tbmp.Height) / 2))); } else { gp.DrawString(elem.ToString(), Constants.FONT, _GetBrush(status), new RectangleF(shape.Rectangle.X + 0.5f, shape.Rectangle.Y + 15, shape.Rectangle.Width - 1, shape.Rectangle.Height - 15.5f), Constants.STRING_FORMAT); } } } } } } } foreach (Edge edge in _Edges) { if (edge.bpmnElement == (elemid == null ? edge.bpmnElement : elemid)) { StepStatuses status = path.GetStatus(edge.bpmnElement); gp.DrawLines(edge.ConstructPen(_GetBrush(status), definition), edge.Points); edge.AppendEnds(gp, _GetBrush(status), definition); if (edge.Label != null) { IElement elem = definition.LocateElement(edge.bpmnElement); if (elem != null) { SizeF sf = gp.MeasureString(elem.ToString(), Constants.FONT, new SizeF(edge.Label.Bounds.Rectangle.Width, edge.Label.Bounds.Rectangle.Height), Constants.STRING_FORMAT); gp.DrawString(elem.ToString(), Constants.FONT, _GetBrush(status), new RectangleF(edge.Label.Bounds.Rectangle.X, edge.Label.Bounds.Rectangle.Y, Math.Max(edge.Label.Bounds.Rectangle.Width, sf.Width), Math.Max(edge.Label.Bounds.Rectangle.Height, sf.Height)), Constants.STRING_FORMAT); } } } } return(bmp); }
public async Task <CommandResult> Handle(ScanWorkflowCommand request, CancellationToken cancellationToken) { var stopwatch = new Stopwatch(); stopwatch.Start(); List <string> messages = new List <string>(); bool workflowStillRunning = false; var workflow = await _entitiesRepository.GetFirstOrDefaultAsync <Workflow>(w => w.Id == request.WorkflowId); if (workflow == null) { throw new MissingWorkflowException("Failed to find workflow " + request.WorkflowId + " as workflow does not exist."); } //Get the workflow template var workflowTemplate = await _entitiesRepository.GetFirstOrDefaultAsync <WorkflowTemplate>(wt => wt.ReferenceId == workflow.WorkflowTemplateId); if (workflowTemplate == null) { throw new WorkflowTemplateNotFoundException("Failed to scan workflow " + request.WorkflowId + " workflow template " + workflow.WorkflowTemplateId + "."); } //Get all the steps related to this task var workflowSteps = (await _entitiesRepository.GetAsync <Step>(s => s.WorkflowId == request.WorkflowId)).ToList(); foreach (var workflowStep in workflowSteps) { workflowStep.Outputs = DynamicDataUtility.DecryptDynamicData((await _entitiesRepository.GetFirstOrDefaultAsync <StepTemplate>(st => st.ReferenceId == workflowStep.StepTemplateId)).OutputDefinitions, workflowStep.Outputs, EncryptionProtocol.AES256, ClusterStateService.GetEncryptionKey()); if (!workflowStep.IsComplete()) { messages.Add("Workflow step " + workflowStep.Id + " (" + workflowStep.Name + ")" + " is running."); workflowStillRunning = true; } } bool stepCreated = false; if (!workflowStillRunning) { if (workflow.CompletedLogicBlocks == null) { workflow.CompletedLogicBlocks = new List <string>(); } //Evaluate all logic blocks that have not been completed var logicBlocks = workflowTemplate.LogicBlocks.Where(lb => !workflow.CompletedLogicBlocks.Contains(lb.Key)).ToList(); foreach (var logicBlock in logicBlocks) { var lockId = Guid.NewGuid(); bool lockObtained = false; while (!lockObtained) { while (_clusterStateService.IsLogicBlockLocked(request.WorkflowId, logicBlock.Key)) { Console.WriteLine("Found " + ("workflow:" + request.WorkflowId + ">logicBlock:" + logicBlock) + " Lock"); await Task.Delay(1000); } int entryNumber = await _clusterStateService.LockLogicBlock(lockId, request.WorkflowId, logicBlock.Key); //Check whether you got the lock lockObtained = _clusterStateService.WasLockObtained(lockId, request.WorkflowId, logicBlock.Key); } //When the logic block is released, recheck whether this logic block has been evaluated workflow = await _entitiesRepository.GetFirstOrDefaultAsync <Workflow>(w => w.Id == request.WorkflowId); workflow.Inputs = DynamicDataUtility.DecryptDynamicData(workflowTemplate.InputDefinitions, workflow.Inputs, EncryptionProtocol.AES256, ClusterStateService.GetEncryptionKey()); if (workflow.CompletedLogicBlocks == null) { workflow.CompletedLogicBlocks = new List <string>(); } //If the logic block is ready to be processed, submit the steps if (logicBlock.Value.Dependencies.Evaluate(workflowSteps) && !workflow.CompletedLogicBlocks.Contains(logicBlock.Key)) { foreach (var substep in logicBlock.Value.SubsequentSteps) { if (workflowSteps.Where(s => s.Name == substep.Key).Count() == 0) { var verifiedInputs = new Dictionary <string, object>(); foreach (var mapping in substep.Value.Mappings) { //find the mapping with the highest priority var highestPriorityReference = WorkflowTemplateUtility.GetHighestPriorityReference(mapping.Value.OutputReferences, workflowSteps.ToArray()); //if the highest priority reference is null, there are no mappings if (highestPriorityReference == null && mapping.Value.DefaultValue == null) { } // If default value is higher priority else if (mapping.Value.DefaultValue != null && (highestPriorityReference == null || highestPriorityReference.Priority < mapping.Value.DefaultValue.Priority)) { verifiedInputs.Add(mapping.Key, mapping.Value.DefaultValue.Value); } // If the step ref is not -1 it is a step in the array but the workflow else if (highestPriorityReference.StepName != ReservedValues.WorkflowStartStepName) { var parentStep = workflowSteps.Where(ss => ss.Name == highestPriorityReference.StepName).FirstOrDefault(); //If there is a AND and there is no parent step, throw a error if (parentStep == null) { throw new InvalidWorkflowProcessingException("Missing source for mapping " + mapping.Key + " from step " + highestPriorityReference.StepName); } else { if (parentStep != null) { try { // Get the output value based on the pre-requisite id var outPutValue = DynamicDataUtility.GetData(parentStep.Outputs, highestPriorityReference.OutputId); // Validate it is in the definition verifiedInputs.Add(mapping.Key, outPutValue.Value); } catch (Exception e) { //TO DO Move this to logger Console.WriteLine("Found error at mapping " + mapping.Key + " for step " + substep.Key); throw e; } } } } //Get the value from the workflow ref else { // Validate it is in the definition verifiedInputs.Add(mapping.Key, DynamicDataUtility.GetData(workflow.Inputs, highestPriorityReference.OutputId).Value); } } stepCreated = true; //Add the step TODO, add step priority await _mediator.Send(new CreateStepCommand() { StepTemplateId = substep.Value.StepTemplateId, CreatedBy = SystemUsers.QUEUE_MANAGER, Inputs = verifiedInputs, WorkflowId = workflow.Id, Name = substep.Key //create the step with the right subsequent step }); messages.Add("Started workflow step " + substep.Key); } } //Mark it as evaluated workflow.UpdateJournal( new JournalEntry() { CreatedBy = request.CreatedBy, CreatedOn = DateTime.UtcNow, Updates = new List <Update>() { new Update() { FieldName = "completedlogicblocks", Type = UpdateType.Append, Value = logicBlock.Key } } }); //await _workflowsRepository.UpdateWorkflow(workflow); await _node.Handle(new AddShardWriteOperation() { Data = workflow, WaitForSafeWrite = true, Operation = ConsensusCore.Domain.Enums.ShardOperationOptions.Update }); } await _clusterStateService.UnlockLogicBlock(lockId, request.WorkflowId, logicBlock.Key); } //Check if there are no longer any steps that are unassigned or assigned var workflowStatus = workflow.Status; workflowSteps = (await _entitiesRepository.GetAsync <Step>(s => s.WorkflowId == request.WorkflowId)).ToList(); var highestStatus = StepStatuses.GetHighestPriority(workflowSteps.Select(s => s.Status).ToArray()); var newWorkflowStatus = stepCreated ? WorkflowStatuses.ConvertStepStatusToWorkflowStatus(StepStatuses.Unassigned) : WorkflowStatuses.ConvertStepStatusToWorkflowStatus(highestStatus); if (newWorkflowStatus != workflow.Status) { workflow.UpdateJournal( new JournalEntry() { CreatedBy = request.CreatedBy, CreatedOn = DateTime.UtcNow, Updates = new List <Update>() { new Update() { FieldName = "status", Type = UpdateType.Override, Value = newWorkflowStatus } } }); //await _workflowsRepository.UpdateWorkflow(workflow); await _node.Handle(new AddShardWriteOperation() { Data = workflow, WaitForSafeWrite = true, Operation = ConsensusCore.Domain.Enums.ShardOperationOptions.Update }); messages.Add("Updated workflow status " + newWorkflowStatus + "."); } } return(new CommandResult() { ObjectRefId = request.WorkflowId.ToString(), ElapsedMs = stopwatch.ElapsedMilliseconds, Type = CommandResultTypes.Update, IsSuccessful = true, Messages = messages.ToArray() }); }
private Brush _GetBrush(StepStatuses status) { return(new SolidBrush(_GetColor(status))); }
private Image _RenderShape(Shape shape, StepStatuses status, BPMIcons?icon, IElement elem) { Bitmap ret = new Bitmap((int)Math.Ceiling(shape.Rectangle.Width), (int)Math.Ceiling(shape.Rectangle.Height)); Graphics gp = Graphics.FromImage(ret); gp.TranslateTransform(0 - shape.Rectangle.X, 0 - shape.Rectangle.Y); if (icon.HasValue) { Rectangle rect = new Rectangle(0, 0, 0, 0); switch (icon.Value) { case BPMIcons.Task: case BPMIcons.SendTask: case BPMIcons.ReceiveTask: case BPMIcons.UserTask: case BPMIcons.ManualTask: case BPMIcons.ServiceTask: case BPMIcons.ScriptTask: case BPMIcons.BusinessRuleTask: Pen p = new Pen(_GetBrush(status), Constants.PEN_WIDTH); gp.DrawPath(p, _GenerateRoundedRectangle(shape.Rectangle.X, shape.Rectangle.Y, shape.Rectangle.Width, shape.Rectangle.Height)); IconGraphic.AppendIcon(new RectangleF(shape.Rectangle.X + 5, shape.Rectangle.Y + 5, 15, 15), icon.Value, gp, _GetColor(status)); break; default: IconGraphic.AppendIcon(shape.Rectangle, icon.Value, gp, _GetColor(status)); break; } } if (elem != null) { if (elem is TextAnnotation) { gp.DrawLines(new Pen(_GetBrush(status), Constants.PEN_WIDTH), new PointF[] { new PointF(shape.Rectangle.X + 20, shape.Rectangle.Y), new PointF(shape.Rectangle.X, shape.Rectangle.Y), new PointF(shape.Rectangle.X, shape.Rectangle.Y + shape.Rectangle.Height), new PointF(shape.Rectangle.X + 20, shape.Rectangle.Y + shape.Rectangle.Height) }); } else if (elem is Lane || elem is Participant) { gp.DrawRectangle(new Pen(_GetBrush(status), Constants.PEN_WIDTH), Rectangle.Round(shape.Rectangle)); } else if (elem is SubProcess) { gp.DrawPath(new Pen(_GetBrush(status), Constants.PEN_WIDTH), _GenerateRoundedRectangle(shape.Rectangle.X, shape.Rectangle.Y, shape.Rectangle.Width, shape.Rectangle.Height)); } if (elem.ToString() != "") { if (shape.Label != null) { SizeF sf = gp.MeasureString(elem.ToString(), Constants.FONT, new SizeF(shape.Label.Bounds.Rectangle.Width, float.MaxValue), Constants.STRING_FORMAT); gp.DrawString(elem.ToString(), Constants.FONT, _GetBrush(status), new RectangleF(shape.Label.Bounds.Rectangle.X, shape.Label.Bounds.Rectangle.Y, Math.Max(shape.Label.Bounds.Rectangle.Width, sf.Width), Math.Max(shape.Label.Bounds.Rectangle.Height, sf.Height)), Constants.STRING_FORMAT); } else { SizeF size = gp.MeasureString(elem.ToString(), Constants.FONT); if (size.Height != 0 || size.Width != 0) { if (elem is Lane || elem is LaneSet || elem is Participant) { Bitmap tbmp = new Bitmap((int)size.Height * 2, (int)size.Width); Graphics g = Graphics.FromImage(tbmp); g.TranslateTransform(tbmp.Width / 2, tbmp.Height); g.RotateTransform(-90); g.TranslateTransform(0, 0); g.DrawString(elem.ToString(), Constants.FONT, _GetBrush(status), 0, 0); g.Save(); gp.DrawImage(tbmp, new PointF(shape.Rectangle.X - 7, shape.Rectangle.Y + ((shape.Rectangle.Height - tbmp.Height) / 2))); } else { gp.DrawString(elem.ToString(), Constants.FONT, _GetBrush(status), new RectangleF(shape.Rectangle.X + 0.5f, shape.Rectangle.Y + 15, shape.Rectangle.Width - 1, shape.Rectangle.Height - 15.5f), Constants.STRING_FORMAT); } } } } } return(ret); }