/// <summary> /// 请求WebService返回结果 /// </summary> /// <typeparam name="T">返回的结果类型</typeparam> /// <param name="dicParamWebService">WebService返回结果</param> /// <returns></returns> private static T PostWebServiceGetResult <T>(Dictionary <string, object> dicParamWebService) { string result = SDKHelper.QueryPostWebService(dicParamWebService); ResultBaseContext baseContext = JsonConvert.DeserializeObject <ResultBaseContext>(result); if (baseContext.StatusCode == ClientConstDefine.WORKFLOW_SERVICE_ERRORCODE_NOERROR) { return(JsonConvert.DeserializeObject <T>((string)baseContext.Data)); } else { throw new Exception(baseContext.StatusMessage, baseContext.LastException); } }
/// <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); }
/// <summary> /// 获取流程WorkflowContext对象(加载已有流程信息) /// </summary> /// <param name="page">页面对象</param> /// <param name="businessID">业务ID</param> /// <param name="userInfo">用户信息</param> /// <returns>流程信息</returns> public static WorkflowContext GetProcess(Page page, string businessID, UserInfo userInfo) { BizContext bizContext = new BizContext(); bizContext.BusinessID = businessID; if (userInfo == null) { bizContext.CurrentUser = new UserInfo() { UserLoginID = SDKHelper.GetUserName(HttpContext.Current) }; } else { bizContext.CurrentUser = userInfo; } return(WFClientProcess.GetProcess(page, bizContext)); }
/// <summary> /// 检查是否发起过流程 /// </summary> /// <param name="businessID">业务ID</param> /// <returns></returns> internal static bool Exist(string businessID) { var dicParamWebService = SDKHelper.BuildParamWebService(AppSettingInfo.CONST_Action_ProcessOperator, AppSettingInfo.CONST_OtherMethod_ExistProcess, Guid.NewGuid().ToString(), Newtonsoft.Json.JsonConvert.SerializeObject(new { BusinessID = businessID, })); string result = SDKHelper.QueryPostWebService(dicParamWebService); ResultBaseContext baseContext = JsonConvert.DeserializeObject <ResultBaseContext>(result); if (baseContext.StatusCode == ClientConstDefine.WORKFLOW_SERVICE_ERRORCODE_NOERROR) { return((string)baseContext.Data == Boolean.TrueString); } else { throw new Exception(baseContext.StatusMessage, baseContext.LastException); } }
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); }
/// <summary> /// 完善BizContext信息 /// </summary> /// <param name="context"></param> /// <returns></returns> internal static BizContext RepaireBizContext(BizContext context) { if (string.IsNullOrEmpty(context.AppCode)) { context.AppCode = AppSettingInfo.ApplicationCode; } if (context.BusinessID == null) { context.BusinessID = ""; } if (context.CurrentUser == null) { context.CurrentUser = new UserInfo() { UserLoginID = SDKHelper.GetUserName(HttpContext.Current) }; } if (string.IsNullOrEmpty(context.WFToken)) { context.WFToken = Guid.NewGuid().ToString(); } return(context); }
public override Dictionary <string, object> BuildParamWebService(string action, string method, string token, string callBackUrl, Dictionary <string, string> dicParam, HttpContext context) { string version = "1.0"; if (dicParam.ContainsKey("Version")) { version = dicParam["Version"]; } string paramStr = string.Empty; if (dicParam.ContainsKey("Param")) { paramStr = dicParam["Param"]; } //将appCode,action,method,param(序列化后的dicParam)添加到dicParamWebService中调用WebService return(SDKHelper.BuildParamWebService(action, method, token, Newtonsoft.Json.JsonConvert.SerializeObject( new { Version = version, Param = paramStr, CurrentUserLoginID = SDKHelper.GetUserName(context), BizAppCode = AppSettingInfo.ApplicationCode }), callBackUrl)); }
public override Dictionary <string, object> BuildParamWebService(string action, string method, string token, string callBackUrl, Dictionary <string, string> dicParam, HttpContext context) { return(SDKHelper.BuildParamWebService(action, method, token, Newtonsoft.Json.JsonConvert.SerializeObject(dicParam), callBackUrl)); }
/// <summary> /// 显示流程 /// </summary> /// <param name="page"></param> /// <param name="workflowContext"></param> public static void ShowProcess(Page page, string workflowContext) { SDKHelper.RegisterScript(page, AppSettingInfo.CONST_WorkflowContextJsonVarName, SDKHelper.FormateVarScript(AppSettingInfo.CONST_WorkflowContextJsonVarName, workflowContext)); SDKHelper.RegisterScript(page, "showProcess", "wanda_wf_client.showProcess();"); }
/// <summary> /// 调用WebService请求(调用地址为Web.Config中配置的地址) /// </summary> /// <param name="Pars"></param> /// <returns></returns> public static string QueryPostWebService(Dictionary <string, object> Pars) { string workFlowServerFullURL = SDKHelper.GetWorkflowServerUrlFullPath(AppSettingInfo.WorkflowServerUrl); return(QueryPostWebService(workFlowServerFullURL, AppSettingInfo.CONST_WorkflowServiceMethodName, Pars)); }