Exemple #1
0
        public static void openFlowChart(object sender)
        {
            flowChartIndx = ((KryptonButton)sender).Name.Substring(12);
            FlowForm ff = new FlowForm();

            ff.ShowDialog();
        }
        public override async Task <FlowSheet> CreateSheet(FlowInstance instance, FlowForm flowForm)
        {
            var flowSheet = await base.CreateSheet(instance, flowForm);

            //数据处理
            var formObj     = Newtonsoft.Json.JsonConvert.DeserializeObject <JObject>(flowSheet.FlowInstance.FormData);
            var sheetData   = formObj["sheetData"];
            var sheetHeader = sheetData["header"];

            flowSheet.SheetDate = sheetHeader["sheetDate"].ToObjectWithDefault <DateTime>();
            flowSheet.Remarks   = sheetHeader["remarks"].ToObjectWithDefault <string>();
            flowSheet.SetPropertyValue("StoreName", sheetHeader["storeName"].ToObjectWithDefault <string>());
            flowSheet.OrderStatus = "待审核";
            return(flowSheet);
        }
        private void BuildDefaultForm()
        {
            //读取程序集中内置的表单
            var files = Common.Fun.GetFilesInAsm(typeof(MasterCoreModule).GetAssembly(), "Master.Forms");

            foreach (var file in files)
            {
                var fileName = System.IO.Path.GetFileNameWithoutExtension(file.Name);
                var form     = new FlowForm()
                {
                    FormKey     = fileName.Split('-')[1],
                    FormName    = fileName.Split('-')[0],
                    FormType    = WorkFlow.FormType.Html,
                    IsActive    = true,
                    FormContent = Common.Fun.ReadEmbedString(file)
                };
                Configuration.Modules.Core().DefaultForms.Add(form);
            }
            //Configuration.Modules.WorkFlow().
        }
Exemple #4
0
 public abstract Task Handle(FlowInstance instance, FlowForm flowForm);
Exemple #5
0
        /// <summary>
        /// 创建一个实例
        /// </summary>
        /// <returns></returns>
        public virtual async Task CreateInstance(FlowInstanceCreateDto flowInstanceCreateDto)
        {
            var manager = Manager as FlowInstanceManager;
            var user    = await GetCurrentUserAsync();

            var flowInstance = flowInstanceCreateDto.MapTo <FlowInstance>();

            flowInstance.Code = Common.Fun.ConvertToTimeStamp(DateTime.Now).ToString();
            FlowForm form = null;

            //1.如果流程提交数据没有FlowSchemeId,表示此流程直接由表单创建,提交即代表完成
            if (flowInstanceCreateDto.FlowSchemeId == null || flowInstanceCreateDto.FlowSchemeId.Value == 0)
            {
                if (flowInstanceCreateDto.FlowFormId == null || flowInstanceCreateDto.FlowFormId.Value == 0)
                {
                    throw new UserFriendlyException(L("参数错误,必须提供FlowFormId参数"));
                }
                form = await FlowFormManager.GetByIdFromCacheAsync(flowInstanceCreateDto.FlowFormId.Value);

                //如果表单没有内容,默认从内置表单中获取
                if (string.IsNullOrWhiteSpace(form.FormContent))
                {
                    form.FormContent = Configuration.Modules.WorkFlow().DefaultForms.SingleOrDefault(o => o.FormKey == form.FormKey)?.FormContent;
                }
                flowInstance.FlowSchemeId   = null;
                flowInstance.FormContent    = form.FormContent;
                flowInstance.FormType       = form.FormType;
                flowInstance.InstanceName   = form.FormName;
                flowInstance.InstanceStatus = InstanceStatus.Finish;//直接为完成状态

                await manager.InsertAsync(flowInstance);

                await CurrentUnitOfWork.SaveChangesAsync();

                await manager.FinishInstance(flowInstance);//调用流程结束事件

                return;
            }

            //2.从流程定义中复制表单id及流程内容
            var flowScheme = await FlowSchemeManager.GetAll().Include(o => o.FlowForm).Where(o => o.Id == flowInstanceCreateDto.FlowSchemeId).SingleAsync();

            form = await FlowFormManager.GetByIdFromCacheAsync(flowScheme.FlowFormId);

            flowInstance.FlowFormId    = flowScheme.FlowFormId;
            flowInstance.FormContent   = form.FormContent;
            flowInstance.FormType      = flowScheme.FlowForm.FormType;
            flowInstance.SchemeContent = flowScheme.SchemeContent;
            flowInstance.InstanceName  = flowScheme.SchemeName;

            //创建运行实例
            var wfruntime = new FlowRuntime(flowInstance);

            #region 根据运行实例改变当前节点状态

            flowInstance.ActivityId     = wfruntime.nextNodeId;
            flowInstance.ActivityType   = wfruntime.GetNextNodeType();
            flowInstance.ActivityName   = wfruntime.nextNode.name;
            flowInstance.PreviousId     = wfruntime.currentNodeId;
            flowInstance.MakerList      = (wfruntime.GetNextNodeType() != 4 ? GetNextMakers(wfruntime) : "");
            flowInstance.InstanceStatus = (wfruntime.GetNextNodeType() == 4 ? InstanceStatus.Finish : InstanceStatus.Processing);

            await manager.InsertAsync(flowInstance);

            await CurrentUnitOfWork.SaveChangesAsync();

            if (flowInstance.InstanceStatus == InstanceStatus.Finish)
            {
                await manager.FinishInstance(flowInstance);//调用流程结束事件
            }
            wfruntime.flowInstanceId = flowInstance.Id;

            #endregion 根据运行实例改变当前节点状态

            #region 流程操作记录

            FlowInstanceOperationHistory processOperationHistoryEntity = new FlowInstanceOperationHistory
            {
                FlowInstanceId = flowInstance.Id,
                Content        = "【创建】"
                                 + user.Name
                                 + "创建了一个流程进程【"
                                 + flowInstance.Code + "/"
                                 + flowInstance.InstanceName + "】"
            };
            await FlowInstanceOperationHistoryRepository.InsertAsync(processOperationHistoryEntity);

            #endregion 流程操作记录

            await AddTransHistory(wfruntime);
        }