public void BeginStepExecute(StepConfig stepConfig, int priority, string workflowName, WorkflowContent content, IUnitOfData context)
        {
            StringBuilder sb = new StringBuilder();

            content.SaveStringBuilder(sb);
            // throw new System.NotImplementedException();

            WorkflowDbContext wfContent = context as WorkflowDbContext;

            //ATAW_WORKFLOWContext wfContent = context as ATAW_WORKFLOWContext;
            WF_WORKFLOW_INST inst = new WF_WORKFLOW_INST();

            inst.WI_ID          = wfContent.GetUniId();
            inst.WI_CONTENT_XML = sb.ToString();
            inst.WI_NAME        = workflowName;
            wfContent.WF_WORKFLOW_INST.Add(inst);

            //步骤基本信息
            StepUtil.SetWorkflowByStep(inst, stepConfig.Name, stepConfig.DisplayName, wfContent.Now,
                                       (int)stepConfig.StepType, (int)StepState.ProcessNotSend);
            inst.WI_INDEX    = 1;
            inst.WI_PRIORITY = priority;
            //扩展信息
            //父子流程
            //主表控制
            content.SetAllMainRow(wfContent, stepConfig, inst.WI_ID);
        }
Example #2
0
        public void Run()
        {
            bool continueRun;

            do
            {
                try
                {
                    if (!IsFinish)
                    {
                        continueRun = CurrentState.Execute(this);
                    }
                    else
                    {
                        continueRun = false;
                    }
                }
                catch (WorkflowException ex)
                {
                    SaveError(ex);
                    continueRun = SetWorkflowException(ex);
                    throw new AtawException("工作流异常", ex, this);
                }
                catch (Exception ex)
                {
                    string mesg = string.Format(ObjectUtil.SysCulture,
                                                "程序出现异常,异常信息是:{0}{1}{0}堆栈信息是:{0}{2}",
                                                Environment.NewLine, ex.Message, ex.StackTrace);
                    AtawTrace.WriteFile(LogType.WorkFlowError, mesg);;
                    // throw ex;

                    //SaveError(ex);
                    continueRun = false;
                    IsFinish    = true;
                    StepUtil.ErrorAbort(Source, WorkflowRow);
                    //StepUtil.ErrorAbort(this, FinishType.Error);
                    //  throw new AtawException("工作流异常", ex, this);
                    throw ex;
                }
            } while (continueRun);
        }
Example #3
0
        public bool Back(string backStepName)
        {
            ManualStepConfig manualConfig = Config as ManualStepConfig;

            // var backStepName = string.Empty;
            if (manualConfig.HaveBack)
            {
                if (backStepName.IsAkEmpty())
                {
                    // 否则退到上一人工步骤,如果没有则报错
                    backStepName = WorkflowRow.WI_LAST_MANUAL;
                }
                AtawDebug.AssertNotNullOrEmpty(backStepName, string.Format(ObjectUtil.SysCulture,
                                                                           "人工步骤{0}没有可以回退的上一个人工步骤", manualConfig.Name), this);
            }

            StepConfig backStep = Config.Parent.Steps[backStepName];

            AtawDebug.AssertArgumentNull(backStep, string.Format(ObjectUtil.SysCulture,
                                                                 "指定的人工步骤{0} 不存在", backStepName), this);
            return(StepUtil.BackStep(Workflow, backStep));
        }
Example #4
0
        protected override bool Execute()
        {
            BeginStepConfig stepConfig = Config as BeginStepConfig;
            Creator         creator    = AtawIocContext.Current.FetchInstance <Creator>(stepConfig.CreatorRegName);

            creator.Parameter = Parameter;
            creator.Workflow  = Workflow;

            WorkflowContent content = creator.CreateContent(Source);
            StringBuilder   sb      = new StringBuilder();

            content.SaveStringBuilder(sb);
            // throw new System.NotImplementedException();
            WorkflowDbContext wfContent = Source as WorkflowDbContext;

            //ATAW_WORKFLOWContext wfContent = context as ATAW_WORKFLOWContext;

            WorkflowRow.WI_CONTENT_XML = sb.ToString();
            creator.CreateWorkflowName(Source);
            WorkflowRow.WI_NAME = creator.WorkflowName;
            creator.UpdateWorkflowRow(Source);
            wfContent.WF_WORKFLOW_INST.Add(WorkflowRow);

            //步骤基本信息
            StepUtil.SetWorkflowByStep(WorkflowRow, stepConfig.Name, stepConfig.DisplayName, wfContent.Now,
                                       (int)stepConfig.StepType, (int)StepState.ProcessNotSend);
            WorkflowRow.WI_INDEX    = 1;
            WorkflowRow.WI_PRIORITY = (int)creator.Priority;
            //扩展信息
            //父子流程
            //主表控制
            content.SetAllMainRow(wfContent, stepConfig, WorkflowRow.WI_ID);

            Source.Submit();

            return(true);
        }
Example #5
0
        public static void Abort(IUnitOfData source, WF_WORKFLOW_INST WorkflowRow, FinishType finishType = FinishType.Abort)
        {
            WorkflowDbContext    dbContext = source as WorkflowDbContext;
            WorkflowContent      content   = WorkflowInstUtil.CreateContent(WorkflowRow);
            WF_WORKFLOW_INST_HIS wfi_His   = new WF_WORKFLOW_INST_HIS();

            //copy
            wfi_His.WI_ID              = WorkflowRow.WI_ID;
            wfi_His.WI_WD_NAME         = WorkflowRow.WI_WD_NAME;
            wfi_His.WI_CONTENT_XML     = WorkflowRow.WI_CONTENT_XML;
            wfi_His.WI_NAME            = WorkflowRow.WI_NAME;
            wfi_His.WI_CREATE_DATE     = WorkflowRow.WI_CREATE_DATE;
            wfi_His.WI_CREATE_USER     = WorkflowRow.WI_CREATE_USER;
            wfi_His.WI_REF_LIST        = WorkflowRow.WI_REF_LIST;
            wfi_His.WI_IS_TIMEOUT      = WorkflowRow.WI_IS_TIMEOUT;
            wfi_His.WI_TIMEOUT_DATE    = WorkflowRow.WI_TIMEOUT_DATE;
            wfi_His.WI_NEXT_EXE_DATE   = WorkflowRow.WI_NEXT_EXE_DATE;
            wfi_His.WI_PRIORITY        = WorkflowRow.WI_PRIORITY;
            wfi_His.WI_STATUS          = WorkflowRow.WI_STATUS;
            wfi_His.WI_ERROR_TYPE      = WorkflowRow.WI_ERROR_TYPE;
            wfi_His.WI_RETRY_TIMES     = WorkflowRow.WI_RETRY_TIMES;
            wfi_His.WI_MAX_RETRY_TIMES = WorkflowRow.WI_MAX_RETRY_TIMES;
            wfi_His.WI_WE_ID           = WorkflowRow.WI_WE_ID;
            wfi_His.WI_PARENT_ID       = WorkflowRow.WI_PARENT_ID;
            wfi_His.WI_PC_FLAG         = WorkflowRow.WI_PC_FLAG;
            //赋值
            wfi_His.WI_END_DATE  = dbContext.Now;
            wfi_His.WI_END_STATE = (int)finishType;
            if (!string.IsNullOrEmpty(WorkflowRow.WI_PROCESS_ID))
            {
                wfi_His.WI_END_USER = WorkflowRow.WI_PROCESS_ID;
            }
            else
            {
                wfi_His.WI_END_USER = GlobalVariable.UserId.ToString();
            }
            //附加
            dbContext.WF_WORKFLOW_INST_HIS.Add(wfi_His);
            ////copy步骤历史
            string wiId = WorkflowRow.WI_ID;
            List <WF_STEP_INST>     stepList    = dbContext.WF_STEP_INST.Where(a => a.SI_WI_ID == wiId).ToList();
            List <WF_STEP_INST_HIS> stepListHis = new List <WF_STEP_INST_HIS>();

            foreach (var step in stepList)
            {
                //------------
                WF_STEP_INST_HIS his = new WF_STEP_INST_HIS();
                his.SI_WI_ID             = step.SI_WI_ID;
                his.SI_CURRENT_STEP      = step.SI_CURRENT_STEP;
                his.SI_CURRENT_STEP_NAME = step.SI_CURRENT_STEP_NAME;
                his.SI_END_DATE          = step.SI_END_DATE;

                his.SI_FLOW_TYPE        = step.SI_FLOW_TYPE;
                his.SI_ID               = step.SI_ID;
                his.SI_INDEX            = step.SI_INDEX;
                his.SI_IS_TIMEOUT       = step.SI_IS_TIMEOUT;
                his.SI_LAST_MANUAL      = step.SI_LAST_MANUAL;
                his.SI_LAST_MANUAL_NAME = step.SI_LAST_MANUAL_NAME;
                his.SI_LAST_STEP        = step.SI_LAST_STEP;
                his.SI_LAST_STEP_NAME   = step.SI_LAST_STEP_NAME;
                his.SI_NOTE             = step.SI_NOTE;
                his.SI_PRIORITY         = step.SI_PRIORITY;
                his.SI_PROCESS_DATE     = step.SI_PROCESS_DATE;
                his.SI_PROCESS_ID       = step.SI_PROCESS_ID;
                his.SI_RECEIVE_DATE     = step.SI_RECEIVE_DATE;
                his.SI_RECEIVE_ID       = step.SI_RECEIVE_ID;
                his.SI_SEND_DATE        = step.SI_SEND_DATE;
                his.SI_SEND_ID          = step.SI_SEND_ID;
                his.SI_START_DATE       = step.SI_START_DATE;
                his.SI_STATUS           = step.SI_STATUS;
                his.SI_STEP_TYPE        = step.SI_STEP_TYPE;
                his.SI_TIME_SPAN        = step.SI_TIME_SPAN;
                his.SI_TIMEOUT_DATE     = step.SI_TIMEOUT_DATE;

                dbContext.WF_STEP_INST.Remove(step);
                dbContext.WF_STEP_INST_HIS.Add(his);
            }
            //新增最后一个步骤到历史
            WF_STEP_INST_HIS his_step = new WF_STEP_INST_HIS();

            // dbContext.WF_STEP_INST_HIS.Add(his_step);
            StepUtil.CopyWorkflowToStepHis(dbContext, WorkflowRow, his_step, FlowAction.Flow);
            dbContext.WF_STEP_INST_HIS.Add(his_step);
            ////更新主表信息
            //删除视力表

            content.EndMainRowStatus(dbContext, finishType);
            ////主表转移先不做
            ////--提交
            dbContext.WF_WORKFLOW_INST.Remove(WorkflowRow);
            dbContext.Submit();
        }
Example #6
0
 protected override void Send(StepConfig nextStep)
 {
     StepUtil.SendStep(Workflow, nextStep, Source);
 }
Example #7
0
        //private void SaveWorkflowInst()
        //{
        //    WorkflowResolver.SetCommands(AdapterCommand.Update);
        //    UpdateUtil.UpdateTableResolvers(Source.Context, null, WorkflowResolver);
        //}

        //public bool IsTimeout
        //{
        //    get
        //    {
        //        ManualStepConfig manualConfig = Config as ManualStepConfig;
        //        bool isTimeout = TimeLimitConfig.IsTimeOut(manualConfig.TimeLimiter,
        //            Source.Context, WorkflowRow, "WI_CURRENT_CREATE_DATE");
        //        if (!isTimeout)
        //            isTimeout = TimeLimitConfig.IsTimeOut(Workflow.Config.TimeLimiter,
        //                Source.Context, WorkflowRow, "WI_CREATE_DATE");
        //        return isTimeout;
        //    }
        //}

        protected override void Send(StepConfig nextStep)
        {
            //if (IsTimeout)
            //    WorkflowRow["WI_IS_TIMEOUT"] = true;
            StepUtil.SendStep(Workflow, nextStep, Source);
        }
Example #8
0
        protected override bool Execute()
        {
            WorkflowDbContext dbContext = Source as WorkflowDbContext;
            EndStepConfig     config    = Config as EndStepConfig;
            AutoProcessor     processor = null;
            WorkflowContent   content   = WorkflowInstUtil.CreateContent(WorkflowRow);

            if (!string.IsNullOrEmpty(config.PlugRegName))
            {
                try
                {
                    processor         = AtawIocContext.Current.FetchInstance <AutoProcessor>(config.PlugRegName);
                    processor.Config  = config;
                    processor.Source  = Source;
                    processor.Content = content;
                    processor.Execute(WorkflowRow);
                }
                catch (Exception ex)
                {
                    string mesg = string.Format(ObjectUtil.SysCulture,
                                                "程序出现异常,异常信息是:{0}{1}{0}堆栈信息是:{0}{2}",
                                                Environment.NewLine, ex.Message, ex.StackTrace);
                    AtawTrace.WriteFile(LogType.WorkFlowError, mesg);;

                    // AtawTrace.WriteFile();
                    throw new PlugInException(config, config.Error, ex);
                }
            }
            FinishType finishType = FinishType.Normal;

            if (config.EnableModify)
            {
                finishType = FinishType.ModifiedNormal;
            }
            //-----
            ////新增实例历史
            // "WI_ID",
            //"WI_WD_NAME", "WI_CONTENT_XML", "WI_NAME", "WI_CREATE_DATE", "WI_CREATE_USER",
            //"WI_REF_LIST", "WI_IS_TIMEOUT","WI_TIMEOUT_DATE", "WI_NEXT_EXE_DATE", "WI_PRIORITY" ,
            //"WI_STATUS", "WI_ERROR_TYPE","WI_RETRY_TIMES","WI_MAX_RETRY_TIMES","WI_WE_ID",
            //"WI_PARENT_ID","WI_PC_FLAG"
            WF_WORKFLOW_INST_HIS wfi_His = new WF_WORKFLOW_INST_HIS();

            //copy
            wfi_His.WI_ID              = WorkflowRow.WI_ID;
            wfi_His.WI_WD_NAME         = WorkflowRow.WI_WD_NAME;
            wfi_His.WI_CONTENT_XML     = WorkflowRow.WI_CONTENT_XML;
            wfi_His.WI_NAME            = WorkflowRow.WI_NAME;
            wfi_His.WI_CREATE_DATE     = WorkflowRow.WI_CREATE_DATE;
            wfi_His.WI_CREATE_USER     = WorkflowRow.WI_CREATE_USER;
            wfi_His.WI_REF_LIST        = WorkflowRow.WI_REF_LIST;
            wfi_His.WI_IS_TIMEOUT      = WorkflowRow.WI_IS_TIMEOUT;
            wfi_His.WI_TIMEOUT_DATE    = WorkflowRow.WI_TIMEOUT_DATE;
            wfi_His.WI_NEXT_EXE_DATE   = WorkflowRow.WI_NEXT_EXE_DATE;
            wfi_His.WI_PRIORITY        = WorkflowRow.WI_PRIORITY;
            wfi_His.WI_STATUS          = WorkflowRow.WI_STATUS;
            wfi_His.WI_ERROR_TYPE      = WorkflowRow.WI_ERROR_TYPE;
            wfi_His.WI_RETRY_TIMES     = WorkflowRow.WI_RETRY_TIMES;
            wfi_His.WI_MAX_RETRY_TIMES = WorkflowRow.WI_MAX_RETRY_TIMES;
            wfi_His.WI_WE_ID           = WorkflowRow.WI_WE_ID;
            wfi_His.WI_PARENT_ID       = WorkflowRow.WI_PARENT_ID;
            wfi_His.WI_PC_FLAG         = WorkflowRow.WI_PC_FLAG;
            //赋值
            wfi_His.WI_END_DATE  = dbContext.Now;
            wfi_His.WI_END_STATE = (int)finishType;
            if (!string.IsNullOrEmpty(WorkflowRow.WI_PROCESS_ID))
            {
                wfi_His.WI_END_USER = WorkflowRow.WI_PROCESS_ID;
            }
            else
            {
                wfi_His.WI_END_USER = GlobalVariable.UserId.ToString();
            }
            //附加
            dbContext.WF_WORKFLOW_INST_HIS.Add(wfi_His);
            ////copy步骤历史
            string wiId = WorkflowRow.WI_ID;
            List <WF_STEP_INST>     stepList    = dbContext.WF_STEP_INST.Where(a => a.SI_WI_ID == wiId).ToList();
            List <WF_STEP_INST_HIS> stepListHis = new List <WF_STEP_INST_HIS>();

            foreach (var step in stepList)
            {
                //------------
                WF_STEP_INST_HIS his = new WF_STEP_INST_HIS();
                his.SI_WI_ID             = step.SI_WI_ID;
                his.SI_CURRENT_STEP      = step.SI_CURRENT_STEP;
                his.SI_CURRENT_STEP_NAME = step.SI_CURRENT_STEP_NAME;
                his.SI_END_DATE          = step.SI_END_DATE;

                his.SI_FLOW_TYPE        = step.SI_FLOW_TYPE;
                his.SI_ID               = step.SI_ID;
                his.SI_INDEX            = step.SI_INDEX;
                his.SI_IS_TIMEOUT       = step.SI_IS_TIMEOUT;
                his.SI_LAST_MANUAL      = step.SI_LAST_MANUAL;
                his.SI_LAST_MANUAL_NAME = step.SI_LAST_MANUAL_NAME;
                his.SI_LAST_STEP        = step.SI_LAST_STEP;
                his.SI_LAST_STEP_NAME   = step.SI_LAST_STEP_NAME;
                his.SI_NOTE             = step.SI_NOTE;
                his.SI_PRIORITY         = step.SI_PRIORITY;
                his.SI_PROCESS_DATE     = step.SI_PROCESS_DATE;
                his.SI_PROCESS_ID       = step.SI_PROCESS_ID;
                his.SI_RECEIVE_DATE     = step.SI_RECEIVE_DATE;
                his.SI_RECEIVE_ID       = step.SI_RECEIVE_ID;
                his.SI_SEND_DATE        = step.SI_SEND_DATE;
                his.SI_SEND_ID          = step.SI_SEND_ID;
                his.SI_START_DATE       = step.SI_START_DATE;
                his.SI_STATUS           = step.SI_STATUS;
                his.SI_STEP_TYPE        = step.SI_STEP_TYPE;
                his.SI_TIME_SPAN        = step.SI_TIME_SPAN;
                his.SI_TIMEOUT_DATE     = step.SI_TIMEOUT_DATE;

                dbContext.WF_STEP_INST.Remove(step);
                dbContext.WF_STEP_INST_HIS.Add(his);
            }
            //新增最后一个步骤到历史
            WF_STEP_INST_HIS his_step = new WF_STEP_INST_HIS();

            // dbContext.WF_STEP_INST_HIS.Add(his_step);
            StepUtil.CopyWorkflowToStepHis(dbContext, WorkflowRow, his_step, FlowAction.Flow);
            dbContext.WF_STEP_INST_HIS.Add(his_step);
            ////更新主表信息
            //删除视力表

            content.EndMainRowStatus(Source as WorkflowDbContext, finishType);
            ////主表转移先不做
            ////--提交
            dbContext.WF_WORKFLOW_INST.Remove(WorkflowRow);
            Source.Submit();
            return(false);
        }
Example #9
0
 public void Abort()
 {
     StepUtil.Abort(Source, WorkflowRow);
 }