/// <summary> /// 执行流程动作(分步执行) /// </summary> /// <param name="methodName">操作命令</param> /// <param name="methodMode">方法类型(1:第一步提交,2:第二步提交)</param> /// <param name="bizContext">业务系统上下文</param> /// <returns></returns> public static WorkflowContext ExecuteMethod(string methodName, int methodMode, BizContext bizContext) { if (string.IsNullOrEmpty(methodName)) { throw new Exception("操作命令不能为空"); } string result = WFClientProcess.ExecuteMethod(methodName, methodMode, AppSettingInfo.CONST_WorkflowMethodVersion, bizContext); return(JsonConvert.DeserializeObject <WorkflowContext>(result)); }
/// <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); } }
/// <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); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text"; string bizContext = context.Request.Form["BizContext"]; string methodName = context.Request.Form["MethodName"]; string methodMode = context.Request.Form["MethodMode"]; string methodVersion = context.Request.Form["Version"]; string bizWFURL = context.Request.Form["BizWFURL"]; if (string.IsNullOrEmpty(bizContext)) { bizContext = context.Request.QueryString["BizContext"]; } if (string.IsNullOrEmpty(methodName)) { methodName = context.Request.QueryString["MethodName"]; } if (string.IsNullOrEmpty(methodMode)) { methodMode = context.Request.QueryString["MethodMode"]; } if (string.IsNullOrEmpty(methodVersion)) { methodVersion = context.Request.QueryString["Version"]; } if (string.IsNullOrEmpty(methodName)) { throw new Exception("参数MethodName为空"); } if (string.IsNullOrEmpty(bizContext)) { throw new Exception("参数BizContext为空"); } //反序列化得到BizContext BizContext bizContextObj = JsonConvert.DeserializeObject <BizContext>(bizContext); string result = WFClientProcess.ExecuteMethod(methodName, SDKHelper.ToInt(methodMode), methodVersion, bizContextObj, bizWFURL); context.Response.Write(result); }