private void WorkFlowPerformButtonClick(object sender, EventArgs e) { if (vm.wfStepList.Count > 0) { var wfStepLsit = vm.wfStepList; WorkFlowStep wfStep = wfStepLsit.FirstOrDefault(); wfStepLsit.Remove(wfStep); if (wfStep != null) { switch (wfStep.workFlowStepName) { case "BloodPressure": Navigation.PushAsync(new Views.AddNewBloodPressurePage(myPatient, wfStepLsit, myUser)); break; case "Body temperature": Navigation.PushAsync(new Views.AddNewBodyTempPage(myPatient, wfStepLsit, myUser)); break; case "SpO2": Navigation.PushAsync(new Views.AddNewSPOPage(myPatient, wfStepLsit, myUser)); break; } } } }
public void SubWorkFlow() { var workFlowBuilder = new WorkFlowStep(); Instance.AddWorkFlow(workFlowBuilder).Execute(); Assert.IsTrue(workFlowBuilder.ExecutedStep); }
/// <summary> /// 添加 流程步骤 /// </summary> /// <param name="doc"></param> /// <param name="dto"></param> /// <param name="flow"></param> private void AddSteps(XmlDocument doc, FlowDesignerDto dto, ref WorkFlowDesign flow) { XmlNodeList steps = doc.DocumentElement.GetElementsByTagName("WorkFlowStep"); flow.Steps.Clear(); for (int i = 0; i < steps.Count; i++) { XmlElement step = (XmlElement)steps.Item(i); WorkFlowStep flowStep = new WorkFlowStep(); var id = step.GetAttribute("Id"); if (string.IsNullOrWhiteSpace(id)) { step.SetAttribute("Id", CombHelper.NewComb().ToString()); } flowStep.Id = Guid.Parse(step.GetAttribute("Id")); flowStep.FlowDesignId = dto.Id; flowStep.StepId = Int16.Parse(step.GetAttribute("id")); flowStep.StepName = step.GetAttribute("StepName"); flowStep.StepType = Int16.Parse(step.GetAttribute("StepType")); flowStep.CountersignType = step.GetAttribute("CountersignType") != "" ? Int16.Parse(step.GetAttribute("CountersignType")) : Int16.Parse("0"); flowStep.CountersignStrategy = step.GetAttribute("CountersignStrategy") != "" ? Int16.Parse(step.GetAttribute("CountersignStrategy")) : Int16.Parse("0"); flowStep.CountersignPer = step.GetAttribute("CountersignPer") != "" ? Int16.Parse(step.GetAttribute("CountersignPer")) : Int16.Parse("100"); flowStep.BackType = step.GetAttribute("BackType") != "" ? Int16.Parse(step.GetAttribute("BackType")) : Int16.Parse("0"); flowStep.SpecifiedBackStep = step.GetAttribute("SpecifiedBackStep"); flowStep.SpecifiedDay = step.GetAttribute("SpecifiedDay") != "" ? Int16.Parse(step.GetAttribute("SpecifiedDay")) : Int16.Parse("0"); flowStep.IsArchives = step.GetAttribute("IsArchives") != "" ? int.Parse(step.GetAttribute("IsArchives")) == 1 : false; flowStep.StepDescription = step.GetAttribute("StepDescription"); flow.Steps.Add(flowStep); } }
public IActionResult AddWorkFlowStepToWorkFlow(int workFlowID, string wfStepName) { WorkFlowStep wfStep = new WorkFlowStep(); wfStep.WorkFlowStepName = wfStepName; int wfStepID = _patientInfoRepository.AddWorkFowStepToWorkFlow(workFlowID, wfStep); return(Ok(wfStepID)); }
private void RulesBindingSource_AddingNew(object sender, AddingNewEventArgs e) { WorkFlowStepRules r = new WorkFlowStepRules(); WorkFlowStep s = (WorkFlowStep)datastepsBindingSource.Current; //if (s.Rules == null) //{ // s.Rules = new List<WorkFlowStepRules>(); //} e.NewObject = r; }
private void InTableParametersBindingSource_AddingNew(object sender, AddingNewEventArgs e) { WorkFlowStep s = (WorkFlowStep)datastepsBindingSource.Current; PassedArgs x = new PassedArgs(); //if (s.InParameters == null) //{ // s.InParameters = new List<PassedArgs>(); //} //s.InParameters.Add(x); e.NewObject = x; }
private void DatastepsBindingSource_AddingNew(object sender, AddingNewEventArgs e) { IDataWorkFlow w = (IDataWorkFlow)workFlowsBindingSource.Current; WorkFlowStep ws = new WorkFlowStep(); ws.ID = Guid.NewGuid().ToString(); //if (w.Datasteps == null) //{ // w.Datasteps = new List<WorkFlowStep>(); //} //w.Datasteps.Add(ws); e.NewObject = ws; }
/// <summary> /// 添加下一步处理流程 /// </summary> /// <param name="workFlow"></param> /// <param name="workFlowNodes"></param> public void AddNextStep(Domain.WorkFlow.WorkFlow workFlow, IEnumerable <WorkFlowNode> workFlowNodes, string nowNodeId, string domainName, string domainId, Entity <string> domain) { IList <WorkFlowNode> nextNodes = workFlowNodes.Where(s => s.PreviousNodeList.Contains(nowNodeId)).ToList(); if (nextNodes.Count > 1) { IList <WorkFlowNode> conditionNodes = nextNodes.Where(s => s.Type == WorkFlowNodeType.判断).ToList(); if (conditionNodes.Count == 1) { throw new WorkFlowException("只获取到一个判断节点"); } if (conditionNodes.Count > 0)//后续节点是否有判断节点,如果有则处理判断逻辑 { foreach (var item in conditionNodes) { Assembly assembly = Assembly.Load(""); string nodeProperty = item.NodeProperty; string[] arr = nodeProperty.Split("="); string[] arr1 = arr[0].Split('.'); string className = arr1[0]; bool flag = JudgeFlowStep(domainName, arr1, className); if (flag == Convert.ToBoolean(arr[1])) { WorkFlowStep workFlowStep = new WorkFlowStep(); workFlowStep.DomainName = domainName; workFlowStep.DomainId = domainId; workFlowStep.WorkFlowNodeId = item.Id; workFlowStep.StepName = item.NodeName; _workFlowStepRepository.Insert(workFlowStep); break; } } } else//多个后续节点且没有判断节点 { IList <WorkFlowStep> workFlowSteps = new List <WorkFlowStep>(); foreach (var item in nextNodes) { WorkFlowStep workFlowStep = GetNextStep(domainName, domainId, domain, item); workFlowSteps.Add(workFlowStep); } _workFlowStepRepository.BatchInsert(workFlowSteps); } } else if (nextNodes.Count == 1) { WorkFlowStep workFlowStep = GetNextStep(domainName, domainId, domain, nextNodes[0]); _workFlowStepRepository.Insert(workFlowStep); } }
private void ExamSavetClick(object sender, EventArgs e) { if (wfSteps == null) { if (vm.SaveExamination()) { Navigation.PushAsync(new Views.PatientDeatilPage(_patient)); } else { //popup } } else { vm.SaveExamination(); if (wfSteps.Count == 0) { Navigation.PushAsync(new Views.WorkFlow(_patient, myUser)); } else { var wfStepLsit = wfSteps; WorkFlowStep wfStep = wfStepLsit.FirstOrDefault(); wfStepLsit.Remove(wfStep); if (wfStep != null) { switch (wfStep.workFlowStepName) { case "BloodPressure": Navigation.PushAsync(new Views.AddNewBloodPressurePage(_patient, wfStepLsit, myUser)); break; case "Body temperature": Navigation.PushAsync(new Views.AddNewBodyTempPage(_patient, wfStepLsit, myUser)); break; case "SpO2": Navigation.PushAsync(new Views.AddNewSPOPage(_patient, wfStepLsit, myUser)); break; } } else { Navigation.PushAsync(new Views.WorkFlow(_patient, myUser)); } } } }
public void StartProcess(string domainName, string id, Func <string, Entity <string> > getDomain, Action onProcessStart = null) { Domain.WorkFlow.WorkFlow workFlow = _workFlowRepository.SelectSingle(s => s.DomainName == domainName, s => s.Version); IEnumerable <WorkFlowNode> workFlowNodes = _workFlowNodeRepository.Select(s => s.WorkFlowId == workFlow.Id); WorkFlowNode workFlowNode = workFlowNodes.FirstOrDefault(s => s.Type == WorkFlowNodeType.开始); WorkFlowStep workFlowStep = new WorkFlowStep(); workFlowStep.DomainName = domainName; workFlowStep.DomainId = id; workFlowStep.WorkFlowNodeId = workFlowNode.Id; workFlowStep.StepName = workFlowNode.NodeName; _workFlowStepRepository.Insert(workFlowStep); onProcessStart.Invoke(); Entity <string> domain = getDomain(id); }
public bool Create(WorkFlowStep entity) { var result = true; using (UnitOfWork.Build(_workFlowStepRepository.DbContext)) { result = _workFlowStepRepository.Create(entity); //依赖于表单 if (!entity.FormId.Equals(Guid.Empty)) { _dependencyService.Create(WorkFlowDefaults.ModuleName, entity.WorkFlowId, FormDefaults.ModuleName, entity.FormId); } } return(result); }
public bool Update(WorkFlowStep entity) { var original = _workFlowStepRepository.FindById(entity.WorkFlowStepId); if (original == null) { return(false); } var result = true; using (UnitOfWork.Build(_workFlowStepRepository.DbContext)) { result = _workFlowStepRepository.Update(entity); if (!original.FormId.Equals(Guid.Empty)) { //依赖于表单 _dependencyService.Update(WorkFlowDefaults.ModuleName, entity.WorkFlowId, FormDefaults.ModuleName, entity.FormId); } } return(result); }
/// <summary> /// 获取下一步处理人数据 /// </summary> /// <param name="domainName"></param> /// <param name="domainId"></param> /// <param name="domain"></param> /// <param name="item"></param> /// <returns></returns> private WorkFlowStep GetNextStep(string domainName, string domainId, Entity <string> domain, WorkFlowNode item) { bool resolve = true; string nodeProperty = item.NodeProperty; int actor = 0; resolve = int.TryParse(nodeProperty, out actor); if (nodeProperty.Contains("domain")) { string[] arr = nodeProperty.Split('.'); PropertyInfo property = domain.GetType().GetProperties().FirstOrDefault(s => s.Name == arr[1]); var value = property.GetType().GetProperty(arr[1]).GetValue(property); resolve = int.TryParse(value.ToString(), out actor); } else { PropertyInfo property = domain.GetType().GetProperties().FirstOrDefault(s => s.Name == "Id"); var value = property.GetType().GetProperty("Id").GetValue(property); string[] arr = nodeProperty.Split('.'); MethodInfo method; object obj; GetInstance(arr[1], arr[0], out method, out obj); var returnValue = method.Invoke(obj, new object[] { value }); resolve = int.TryParse(value.ToString(), out actor); } if (!resolve) { throw new WorkFlowException("节点" + item.Id + "获取流程处理人失败"); } WorkFlowStep workFlowStep = new WorkFlowStep(); workFlowStep.DomainName = domainName; workFlowStep.DomainId = domainId; workFlowStep.WorkFlowNodeId = item.Id; workFlowStep.StepName = item.NodeName; workFlowStep.Actor = actor.ToString(); return(workFlowStep); }
/// <summary> /// 添加 流程步骤 /// </summary> /// <param name="doc"></param> /// <param name="dto"></param> /// <param name="flow"></param> private void AddSteps(XmlDocument doc, FlowDesignerDto dto,ref WorkFlowDesign flow) { XmlNodeList steps = doc.DocumentElement.GetElementsByTagName("WorkFlowStep"); flow.Steps.Clear(); for (int i = 0; i < steps.Count; i++) { XmlElement step = (XmlElement)steps.Item(i); WorkFlowStep flowStep = new WorkFlowStep(); var id = step.GetAttribute("Id"); if (string.IsNullOrWhiteSpace(id)) step.SetAttribute("Id", CombHelper.NewComb().ToString()); flowStep.Id = Guid.Parse(step.GetAttribute("Id")); flowStep.FlowDesignId = dto.Id; flowStep.StepId = Int16.Parse(step.GetAttribute("id")); flowStep.StepName = step.GetAttribute("StepName"); flowStep.StepType = Int16.Parse(step.GetAttribute("StepType")); flowStep.CountersignType = step.GetAttribute("CountersignType") != "" ? Int16.Parse(step.GetAttribute("CountersignType")) : Int16.Parse("0"); flowStep.CountersignStrategy = step.GetAttribute("CountersignStrategy") != "" ? Int16.Parse(step.GetAttribute("CountersignStrategy")) : Int16.Parse("0"); flowStep.CountersignPer = step.GetAttribute("CountersignPer") != "" ? Int16.Parse(step.GetAttribute("CountersignPer")) : Int16.Parse("100"); flowStep.BackType = step.GetAttribute("BackType") != "" ? Int16.Parse(step.GetAttribute("BackType")) : Int16.Parse("0"); flowStep.SpecifiedBackStep = step.GetAttribute("SpecifiedBackStep"); flowStep.SpecifiedDay = step.GetAttribute("SpecifiedDay") != "" ? Int16.Parse(step.GetAttribute("SpecifiedDay")) : Int16.Parse("0"); flowStep.IsArchives = step.GetAttribute("IsArchives") != "" ? int.Parse(step.GetAttribute("IsArchives")) == 1 : false; flowStep.StepDescription = step.GetAttribute("StepDescription"); flow.Steps.Add(flowStep); } }
/// <summary> /// 启动工作流 /// </summary> /// <param name="context"></param> /// <returns></returns> public async Task <WorkFlowExecutionResult> StartAsync(WorkFlowStartUpContext context) { var result = new WorkFlowExecutionResult(); result.IsSuccess = true; if (_WorkFlowInstanceService.Find(n => n.EntityId == context.WorkFlowMetaData.EntityId && n.ObjectId == context.ObjectId && n.StateCode == WorkFlowProcessState.Processing) != null) { result.IsSuccess = false; result.Message = _loc["workflow_processing_notallowcancel"]; } if (result.IsSuccess) { var workFlowSteps = _workFlowStepService.Query(n => n .Where(f => f.WorkFlowId == context.WorkFlowMetaData.WorkFlowId) .Sort(s => s.SortAscending(f => f.StepOrder))); //生成审批任务 var InstanceInfo = new WorkFlowInstance() { ApplicantId = context.ApplicantId , CreatedOn = DateTime.Now , Description = context.Description , EntityId = context.WorkFlowMetaData.EntityId , ObjectId = context.ObjectId , WorkFlowId = context.WorkFlowMetaData.WorkFlowId , StateCode = WorkFlowProcessState.Processing , Attachments = context.Attachments , WorkFlowInstanceId = Guid.NewGuid() }; //生成审批唯一码 var randomService = new Randoms(); //生成审批处理步骤 var wfpList = new List <WorkFlowProcess>(); //开始节点 var startNode = workFlowSteps.Find(n => n.NodeType == 0); bool hasNext = true; WorkFlowStep nextStep = startNode; WorkFlowProcess prevStep = null; int stepOrder = 1; while (hasNext) { //生成当前节点处理记录 if (nextStep.NodeType > 1) { var handlerIds = _workFlowHandlerFinder.GetCurrentHandlerId(InstanceInfo, prevStep, nextStep.HandlerIdType, nextStep.Handlers); if (handlerIds.IsEmpty()) { result.IsSuccess = false; result.Message = _loc["workflow_step_nonehandler"].FormatWith(nextStep.Name); break; } foreach (var hid in handlerIds) { var wfp = new WorkFlowProcess() { Name = nextStep.Name , StateCode = WorkFlowProcessState.Waiting , StepOrder = stepOrder , UniqueCode = randomService.CreateRandomValue(6, true) , AuthAttributes = nextStep.AuthAttributes , FormId = nextStep.FormId , AllowAssign = nextStep.AllowAssign , AllowCancel = nextStep.AllowCancel , HandlerIdType = nextStep.HandlerIdType , Handlers = nextStep.Handlers , HandlerId = hid , ReturnType = nextStep.ReturnType , ReturnTo = nextStep.ReturnTo , AttachmentRequired = nextStep.AttachmentRequired , AttachmentExts = nextStep.AttachmentExts , //Conditions = step.Conditions //, NodeName = nextStep.NodeName , WorkFlowInstanceId = InstanceInfo.WorkFlowInstanceId , WorkFlowProcessId = Guid.NewGuid() }; if (stepOrder == 1) { wfp.StartTime = DateTime.Now; wfp.StateCode = WorkFlowProcessState.Processing; result.NextHandlerId = handlerIds; } wfpList.Add(wfp); } prevStep = wfpList.Find(n => n.StepOrder == stepOrder); stepOrder++; } //获取下一节点 if (nextStep.Conditions.IsNotEmpty()) { var stepConditions = new List <WorkFlowStepCondition>().DeserializeFromJson(nextStep.Conditions); nextStep = null;//重设下一节点 //判断流转条件 foreach (var scnd in stepConditions) { var flag = true; if (scnd.Conditions.NotEmpty()) { foreach (var cnd in scnd.Conditions) { if (cnd.CompareAttributeName.IsNotEmpty()) { cnd.Values.Add(context.ObjectData.GetStringValue(cnd.CompareAttributeName)); } var attr = _attributeFinder.Find(context.EntityMetaData.EntityId, cnd.AttributeName); flag = cnd.IsTrue(attr, context.ObjectData.GetStringValue(cnd.AttributeName)); if (scnd.LogicalOperator == LogicalOperator.Or && flag) { break; } if (scnd.LogicalOperator == LogicalOperator.And && !flag) { break; } } } if (flag) { if (!scnd.NextStepId.Equals(Guid.Empty)) { nextStep = workFlowSteps.Find(n => n.WorkFlowStepId == scnd.NextStepId); hasNext = nextStep != null; } break; } else { continue; } } hasNext = nextStep != null; } else { nextStep = null; hasNext = false; } //结束节点 if (hasNext && nextStep.NodeType == 1) { nextStep = null; hasNext = false; break; } } if (wfpList.IsEmpty()) { result.IsSuccess = false; result.Message = _loc["workflow_start_failure"]; } result.Instance = InstanceInfo; result.Instance.Steps = wfpList; } OnStarting(context, result); _eventPublisher.Publish(new WorkFlowStartingEvent { Context = context, Result = result }); if (result.IsSuccess) { try { _WorkFlowInstanceService.BeginTransaction(); _WorkFlowInstanceService.Create(result.Instance); _workFlowProcessService.CreateMany(result.Instance.Steps); //更新记录流程状态 //_workFlowProcessUpdater.UpdateObjectProcessState(context.EntityMetaData, context.ObjectId, WorkFlowProcessState.Processing); //上传附件 await _attachmentCreater.CreateManyAsync(context.EntityMetaData.EntityId, result.Instance.WorkFlowInstanceId, context.AttachmentFiles).ConfigureAwait(false); _WorkFlowInstanceService.CompleteTransaction(); result.IsSuccess = true; } catch (Exception e) { _WorkFlowInstanceService.RollBackTransaction(); result.IsSuccess = false; result.Message = "error:" + e.Message; _logService.Error(e); } } OnStarted(context, result); _eventPublisher.Publish(new WorkFlowStartedEvent { Context = context, Result = result }); return(result); }
public int AddWorkFowStepToWorkFlow(int workFlowId, WorkFlowStep workFlowStep) { _context.Workflows.Where(x => x.WorkFlowId == workFlowId).FirstOrDefault().WorkFlowSteps.Add(workFlowStep); _context.SaveChanges(); return(workFlowStep.WorkFlowStepId); }
// public Task<string> CreateNewWorkflowAsync(WorkFlow workFlow, CancellationToken stoppingToken = default) // { // throw new NotImplementedException(); // } // // public Task PersisWorkflowAsync(string workFlowId, WorkFlow wf, StepExecutionContext context, ExecutionResult executionResult, // long swElapsedMilliseconds, CancellationToken stoppingToken = default) // { // throw new NotImplementedException(); // } // // public Task PersisWorkflowStepAsync(string workFlowId, WorkFlowStep step, Dictionary<string, object> inComeData, Dictionary<string, object> outComeData, // ExecutionResult executionResult, CancellationToken stoppingToken = default) // { // throw new NotImplementedException(); // } // // public Task<IEnumerable<string>> GetRunnableInstancesAsync(DateTime asAt, CancellationToken stoppingToken = default) // { // throw new NotImplementedException(); // } // // public Task<WorkFlow> GetWorkflowInstanceAsync(string id, CancellationToken stoppingToken = default) // { // throw new NotImplementedException(); // } // // public Task<IEnumerable<WorkFlow>> GetWorkflowInstancesAsync(IEnumerable<string> ids, CancellationToken stoppingToken = default) // { // throw new NotImplementedException(); // } // // public Task<IEnumerable<WorkFlow>> GetWorkflowInstancesAsync(WorkFlowStatus? status, string type, DateTime? createdFrom, DateTime? createdTo, // int skip, int take, CancellationToken stoppingToken = default) // { // throw new NotImplementedException(); // } public Task PersistWorkflowStepAsync(string wfiId, string workflowId, WorkFlowStep workFlowStep, Dictionary <string, object> inComeData, Dictionary <string, object> outComeData, ExecutionResult executionResult, CancellationToken stoppingToken) { _logger.LogInformation($"{workFlowStep.Id} 执行结果:{executionResult.Proceed}"); return(Task.CompletedTask); }