/// <summary> /// 初始化设置 /// </summary> /// <param name="page">页面</param> /// <param name="domID">流程渲染控件DomID</param> /// <param name="onCreateListener">注册的事件</param> /// <param name="otherSetting">其他设置</param> public static void InitSetting(Page page, string domID, Action <WFClientSDK> onCreateListener, Dictionary <string, object> otherSetting = null) { WFClientSDK listener = new WFClientSDK(); listener.PageInstance = page; listener.DomID = domID; listener.OnCreateListener = onCreateListener; if (otherSetting != null && otherSetting.Count > 0) { var jsonOtherSetting = JsonConvert.SerializeObject(otherSetting); SDKHelper.RegisterScript(page, "init", "wanda_wf_client.initPostSetting(\"" + domID + "\"," + jsonOtherSetting + ");"); } else { SDKHelper.RegisterScript(page, "init", "wanda_wf_client.initPostSetting(\"" + domID + "\");"); } var str_op = HttpContext.Current.Request[AppSettingInfo.CONST_PostOperaionInfoKey]; if (!string.IsNullOrEmpty(str_op)) { listener.OnListen(); var param = InitExecuteParameter(str_op); listener.Execute(listener, param); } }
/// <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); }