Exemplo n.º 1
0
        public static void SetWorkflowByStep(WF_WORKFLOW_INST row, StepConfig stepConfig)
        {
            DateTime now = DateTime.Now;

            SetWorkflowByStep(row, stepConfig.Name, stepConfig.DisplayName, now,
                              (int)stepConfig.StepType, (int)StepState.NotReceive, now);
        }
Exemplo n.º 2
0
 protected WorkflowException(StepConfig stepConfig, ErrorConfig errorConfig,
                             string message, Exception innerException)
     : base(message, innerException)
 {
     StepConfig  = stepConfig;
     ErrorConfig = errorConfig;
 }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        public void SetMainRowStatus(IUnitOfData context, StepConfig stepConfig)
        {
            WorkflowDbContext wfContent = context as WorkflowDbContext;
            string            sql       = "UPDATE {0} SET  " +
                                          " {1}_WF_STATUS = @WF_STATUS ,  " +
                                          " {1}_STEP_NAME = @STEP_NAME ,  " +
                                          " {1}_WF_TIME = @WF_TIME " +
                                          " WHERE FID = @FID";

            sql = string.Format(sql, MainTableName, Prefix);

            wfContent.RegisterSqlCommand(sql,
                                         new SqlParameter[] {
                new SqlParameter("@WF_STATUS", stepConfig.DisplayName)
                {
                    DbType = DbType.String
                },
                new SqlParameter("@STEP_NAME", stepConfig.Name)
                {
                    DbType = DbType.String
                },
                new SqlParameter("@WF_TIME", wfContent.Now)
                {
                    DbType = DbType.DateTime
                },
                new SqlParameter("@FID", FID)
                {
                    DbType = DbType.String
                },
            }
                                         );
        }
Exemplo n.º 5
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();
        }
Exemplo n.º 6
0
        //public static void FinishStep(Workflow workflow, WorkflowContent content, EndStepConfig config,
        //  IUnitOfData source, BaseProcessor processor)
        //{
        //    FinishType finishType = FinishType.Normal;
        //    if (config.EnableModify)
        //    {
        //        finishType = FinishType.ModifiedNormal;
        //    }
        //    FinishData result = FinishStep(workflow, finishType,
        //        workflow.WorkflowRow["WI_PROCESS_ID"], content);

        //    source.Submit();
        //}


        public static void SetWorkflowByStep(IUnitOfData source, WF_WORKFLOW_INST workflowRow,
                                             StepConfig nextStep)
        {
            workflowRow.WI_LAST_STEP      = workflowRow.WI_CURRENT_STEP;
            workflowRow.WI_LAST_STEP_NAME = workflowRow.WI_CURRENT_STEP_NAME;

            WorkflowInstUtil.SetWorkflowByStep(workflowRow, nextStep);
            nextStep.Prepare(workflowRow, source);
        }
Exemplo n.º 7
0
        protected static bool SendStep(Workflow workflow, StepConfig nextConfig)
        {
            Step step     = workflow.CurrentStep;
            bool result   = step.SendStep(nextConfig);
            Step nextStep = nextConfig.CreateStep(workflow);

            workflow.UpdateStep(nextStep);
            State nextState = nextStep.GetState(StepState.NotReceive);

            workflow.UpdateState(nextState);
            return(result);
        }
Exemplo n.º 8
0
 private Workflow(string workflowId, IUnitOfData workflowSource)
     : this(workflowSource)
 {
     //Source = workflowSource;
     WorkflowDbContext dbContext = workflowSource as WorkflowDbContext;
     WF_WORKFLOW_INST  row       = dbContext.WF_WORKFLOW_INST.FirstOrDefault(a => a.WI_ID == workflowId);
     AtawDebug.AssertNotNull(row, "该流程已处理或异常,请进历史页面查看", this);
     WorkflowId  = row.WI_ID;
     WorkflowRow = row;
     Config      = WorkflowConfig.GetByName(row.WI_WD_NAME, workflowSource);
     //WorkflowConfig.ConnString =
     StepConfig stepConfig = Config.Steps[row.WI_CURRENT_STEP];
     if (stepConfig != null)
     {
         CurrentStep  = stepConfig.CreateStep(this);
         CurrentState = CurrentStep.GetState(row.WI_STATUS.Value <StepState>());
     }
     else
     {
         throw new AtawException("不存在的步骤" + row.WI_CURRENT_STEP, this);
     }
 }
Exemplo n.º 9
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));
        }
Exemplo n.º 10
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);
        }
Exemplo n.º 11
0
 public RouteStep(Workflow workflow, StepConfig config)
     : base(workflow, config)
 {
 }
Exemplo n.º 12
0
        public override bool Execute(Workflow workflow)
        {
            StepConfig nextConfig = workflow.CurrentStep.Config.NextSteps.First();

            return(SendStep(workflow, nextConfig));
        }
Exemplo n.º 13
0
 public AutoStep(Workflow workflow, StepConfig config)
     : base(workflow, config)
 {
 }
Exemplo n.º 14
0
 protected WorkflowException(StepConfig stepConfig, ErrorConfig errorConfig)
 {
     StepConfig  = stepConfig;
     ErrorConfig = errorConfig;
 }
Exemplo n.º 15
0
 /// <summary>
 /// Initializes a new instance of the PlugInException class.
 /// </summary>
 public PlugInException(StepConfig stepConfig, ErrorConfig errorConfig, Exception innerException)
     : base(stepConfig, errorConfig, "插件计算错误", innerException)
 {
 }
Exemplo n.º 16
0
 public EndStep(Workflow workflow, StepConfig config)
     : base(workflow, config)
 {
 }
Exemplo n.º 17
0
 public void AddNextConfig(StepConfig config, int fromX, int fromY, int toX, int toY)
 {
     config.PrevStepName.Add(Name);
     NextStepNames.Add(new StepConnectionConfig(config.Name, fromX, fromY, toX, toY));
 }
Exemplo n.º 18
0
 public void AddNextConfig(StepConfig config)
 {
     AddNextConfig(config, 0, 0, 0, 0);
 }
Exemplo n.º 19
0
 protected Step(Workflow workflow, StepConfig config)
 {
     fWorkflow = workflow;
     Config    = config;
 }
Exemplo n.º 20
0
 public bool SendStep(StepConfig nextStep)
 {
     Send(nextStep);
     ClearDataSet();
     return(true);
 }
Exemplo n.º 21
0
 protected abstract void Send(StepConfig nextStep);
Exemplo n.º 22
0
 public MergeStep(Workflow workflow, StepConfig config)
     : base(workflow, config)
 {
 }
Exemplo n.º 23
0
 protected override void Send(StepConfig nextStep)
 {
     StepUtil.SendStep(Workflow, nextStep, Source);
 }
Exemplo n.º 24
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);
        }
Exemplo n.º 25
0
 public BeginStep(Workflow workflow, StepConfig config)
     : base(workflow, config)
 {
 }
Exemplo n.º 26
0
 public ManualStep(Workflow workflow, StepConfig config)
     : base(workflow, config)
 {
 }
Exemplo n.º 27
0
 /// <summary>
 /// Initializes a new instance of the NoActorException class.
 /// </summary>
 public NoActorException(StepConfig stepConfig, ErrorConfig errorConfig)
     : base(stepConfig, errorConfig)
 {
 }
Exemplo n.º 28
0
 protected override void Send(StepConfig nextStep)
 {
     AtawDebug.ThrowAtawException(string.Format(ObjectUtil.SysCulture,
                                                "工作流{1}的结束步骤{0}没有Send操作", Config.Parent.Name, Config.Name), this);
 }
Exemplo n.º 29
0
        private static WF_STEP_INST GetBackStep(Workflow workflow, StepConfig nextStep)
        {
            var context = workflow.Source as WorkflowDbContext;

            return(context.WF_STEP_INST.Where(m => m.SI_WI_ID == workflow.WorkflowRow.WI_ID).OrderBy(m => m.SI_INDEX).FirstOrDefault(m => m.SI_CURRENT_STEP == nextStep.Name));
        }
Exemplo n.º 30
0
 public NoActorException(StepConfig stepConfig, ErrorConfig errorConfig, Exception innerException)
     : base(stepConfig, errorConfig, "没有找到下一步骤的操作者", innerException)
 {
 }