Example #1
0
        public static void SendStep(Workflow workflow, StepConfig nextStep, IUnitOfData source)
        {
            DateTime now = DateTime.Now;
            //  = AtawIocContext.Current.FetchInstance<IUnitOfData>();
            WorkflowDbContext dbContext   = source as WorkflowDbContext;
            WF_WORKFLOW_INST  workflowRow = workflow.WorkflowRow;
            WorkflowContent   content     = WorkflowInstUtil.CreateContent(workflowRow);

            using (dbContext)
            {
                //拷贝新步骤
                WF_STEP_INST stepRow = new WF_STEP_INST();
                (source as WorkflowDbContext).WF_STEP_INST.Add(stepRow);
                CopyWorkflowToStep(dbContext, workflowRow, stepRow, FlowAction.Flow);
                //人工步骤的处理
                bool isManual = workflow.CurrentStep.Config.StepType == StepType.Manual;
                if (isManual)
                {
                    CopyManualInfo(workflow.WorkflowRow, stepRow);
                }
                //更新工作流实例
                workflowRow.WI_INDEX = workflowRow.WI_INDEX.Value <int>() + 1;
                if (isManual)
                {
                    workflowRow.WI_LAST_MANUAL      = workflowRow.WI_CURRENT_STEP;
                    workflowRow.WI_LAST_MANUAL_NAME = workflowRow.WI_CURRENT_STEP_NAME;
                    //更新参与人列表
                    string      refIds    = workflowRow.WI_REF_LIST;
                    QuoteIdList ulRef     = QuoteIdList.LoadFromString(refIds);
                    string      receiveId = workflowRow.WI_RECEIVE_ID;
                    string      sendId    = workflowRow.WI_SEND_ID;
                    string      processId = workflowRow.WI_PROCESS_ID;
                    ulRef.Add(receiveId);
                    ulRef.Add(sendId);
                    ulRef.Add(processId);
                    int outInt;
                    workflowRow.WI_REF_LIST = ulRef.ToString(out outInt);
                    //接收人  处理人  重新置为空
                    workflowRow.WI_RECEIVE_ID      = "";
                    workflowRow.WI_LAST_PROCESS_ID = workflowRow.WI_PROCESS_ID;
                    workflowRow.WI_PROCESS_ID      = "";
                    workflowRow.WI_RECEIVE_LIST    = "";
                    //清空超时和提醒标识
                    if (workflowRow.WI_IS_TIMEOUT.Value <bool>() == true)
                    {
                        workflowRow.WI_IS_TIMEOUT = false;
                    }
                    //清空错误处理信息 WI_ERROR_TYPE WI_MAX_RETRY_TIMES WI_RETRY_TIMES  WI_NEXT_EXE_DATE
                    WorkflowInstUtil.ClearError(workflowRow);
                }
                //更新主表信息
                SetWorkflowByStep(source, workflowRow, nextStep);
                content.SetMainRowStatus(source, nextStep);
                dbContext.Submit();
            }
            // IUnitOfData dbContext = AtawIocContext.Current.FetchInstance<IUnitOfData>();
            //ATAW_WORKFLOWContext context = dbContext as ATAW_WORKFLOWContext;
            //拷贝新步骤
            //WF_STEP_INST stepRow = new WF_STEP_INST();
        }
Example #2
0
        protected override bool Execute()
        {
            AutoStepConfig config = Config as AutoStepConfig;

            WorkflowContent content = WorkflowInstUtil.CreateContent(WorkflowRow);

            try
            {
                AutoProcessor processor = AtawIocContext.Current.FetchInstance <AutoProcessor>(config.PlugRegName);
                processor.Config  = config;
                processor.Source  = Source;
                processor.Content = content;
                processor.Execute(WorkflowRow);
            }
            catch (Exception ex)
            {
                throw new PlugInException(config, config.Error, ex);
            }

            //    WorkflowRow.BeginEdit();
            WorkflowRow.WI_STATUS = (int)StepState.ProcessNotSend;
            WorkflowInstUtil.ClearError(WorkflowRow);
            int result = Source.Submit();

            return(true);
        }
Example #3
0
        public static bool BackStep(Workflow workflow, StepConfig backStep)
        {
            var workflowRow = workflow.WorkflowRow;
            var source      = workflow.Source as WorkflowDbContext;

            var stepInst = GetBackStep(workflow, backStep);

            var newStepInst = new WF_STEP_INST();

            source.WF_STEP_INST.Add(newStepInst);
            CopyWorkflowToStep(source, workflow.WorkflowRow, newStepInst, FlowAction.Back);
            CopyManualInfo(workflow.WorkflowRow, newStepInst);
            //回退步骤 修改接收人列表 和 接收人个数
            //从步骤实例表中查询上次接收的人


            workflowRow.WI_INDEX         = stepInst.SI_INDEX;
            workflowRow.WI_RECEIVE_ID    = stepInst.SI_RECEIVE_ID;//上次接收的人
            workflowRow.WI_RECEIVE_LIST  = QuoteIdList.GetQuoteId(stepInst.SI_RECEIVE_ID);
            workflowRow.WI_RECEIVE_COUNT = 1;
            workflowRow.WI_SEND_ID       = GlobalVariable.UserId.ToString();
            workflowRow.WI_SEND_DATE     = source.Now;

            workflowRow.WI_LAST_MANUAL         = stepInst.SI_LAST_MANUAL;
            workflowRow.WI_LAST_MANUAL_NAME    = stepInst.SI_LAST_MANUAL_NAME;
            workflowRow.WI_LAST_STEP           = stepInst.SI_LAST_STEP;
            workflowRow.WI_LAST_STEP_NAME      = stepInst.SI_LAST_STEP_NAME;
            workflowRow.WI_CURRENT_CREATE_DATE = DateTime.Now;
            // stepInst.SI_VALID_FLAG = 1;
            WorkflowInstUtil.ClearError(workflowRow);
            WorkflowInstUtil.SetWorkflowByStep(workflowRow, backStep);
            WorkflowContent workflowContent = WorkflowInstUtil.CreateContent(workflow.WorkflowRow);

            workflowContent.SetMainRowStatus(source, backStep);
            backStep.Prepare(workflowRow, source);
            source.Submit();
            return(true);
        }