Beispiel #1
0
        /// <summary>
        /// 执行
        /// </summary>
        /// <param name="host"></param>
        /// <param name="param"></param>
        internal void Execute(WFClientSDK host, WFExecuteParameter param)
        {
            string workflowContextPost = JsonConvert.SerializeObject(param.WorkflowContext);
            //TODO 执行流程操作
            WFExecuteArgs args = new WFExecuteArgs(param);

            if (args.ExecuteParameter.OperatorType == 7)
            {
                //如果执行的是撤回操作,则直接执行工作流方法,然后调用After。
                ExecuteMethodOnlyCallAfter(host, param);
                return;
            }

            bool result = true;

            if (BeforeExecute != null)
            {
                result = BeforeExecute(this, args);
            }
            if (result == false)
            {
                //如果Before出错则把POST回来的WorkflowContext再返回回去
                SDKHelper.ShowProcess(host.PageInstance, workflowContextPost);
                return;
            }
            string          workflowContext    = WFClientProcess.ExecuteMethod(args.ExecuteParameter, 1);
            WorkflowContext workflowContextOne = JsonConvert.DeserializeObject <WorkflowContext>(workflowContext);

            ProcessReturn(args, workflowContextOne);
            if (args.ExecuteParameter.WorkflowContext.StatusCode != 0)
            {
                SDKHelper.ShowProcess(host.PageInstance, JsonConvert.SerializeObject(args.ExecuteParameter.WorkflowContext));
                return;
            }
            if (SaveApplicationData != null)
            {
                result = SaveApplicationData(this, args);
            }
            if (result)
            {
                workflowContext = WFClientProcess.ExecuteMethod(args.ExecuteParameter, 2);
                args.ExecuteParameter.WorkflowContext = JsonConvert.DeserializeObject <WorkflowContext>(workflowContext);
                if (AfterExecute != null)
                {
                    AfterExecute(this, args);
                }
                SDKHelper.ShowProcess(host.PageInstance, workflowContext);
            }
            else
            {
                SDKHelper.ShowProcess(host.PageInstance, workflowContextPost);
            }
        }
Beispiel #2
0
        /// <summary>
        /// 执行工作流的方法(只调用After)
        /// </summary>
        /// <param name="host"></param>
        /// <param name="param"></param>
        private void ExecuteMethodOnlyCallAfter(WFClientSDK host, WFExecuteParameter param)
        {
            string workflowContextPost = JsonConvert.SerializeObject(param.WorkflowContext);
            //TODO 执行流程操作
            WFExecuteArgs args            = new WFExecuteArgs(param);
            string        workflowContext = WFClientProcess.ExecuteMethod(args.ExecuteParameter, 0);

            args.ExecuteParameter.WorkflowContext = JsonConvert.DeserializeObject <WorkflowContext>(workflowContext);
            if (AfterExecute != null)
            {
                AfterExecute(this, args);
            }
            SDKHelper.ShowProcess(host.PageInstance, workflowContext);
        }
Beispiel #3
0
 private void ProcessReturn(WFExecuteArgs args, WorkflowContext resultWorkflowContext)
 {
     if (resultWorkflowContext.StatusCode == 0 || resultWorkflowContext.StatusCode == 11 || resultWorkflowContext.StatusCode == 21)
     {
         //如果11和21的错误和成功,直接返回
         args.ExecuteParameter.WorkflowContext = resultWorkflowContext;
     }
     else
     {
         //其它错误,把错误代码赋给POST回来的WorkflowContext。然后返回
         args.ExecuteParameter.WorkflowContext.StatusCode    = resultWorkflowContext.StatusCode;
         args.ExecuteParameter.WorkflowContext.StatusMessage = resultWorkflowContext.StatusMessage;
         args.ExecuteParameter.WorkflowContext.LastException = resultWorkflowContext.LastException;
     }
 }