protected int GetTaskStageID(int iFileId) { //LPWeb.BLL.WorkflowManager wm = new LPWeb.BLL.WorkflowManager(); int iCurrentLoanStageId = LPWeb.BLL.WorkflowManager.GetCurrentLoanStageId(iFileId); if (iCurrentLoanStageId > 0) { return(iCurrentLoanStageId); } int iDefaultWorkflowTempl = LPWeb.BLL.WorkflowManager.GetDefaultWorkflowTemplate("Prospect"); if (iDefaultWorkflowTempl > 0) { ServiceManager sm = new ServiceManager(); using (LP2ServiceClient service = sm.StartServiceClient()) { GenerateWorkflowRequest req = new GenerateWorkflowRequest(); req.hdr = new ReqHdr(); req.hdr.SecurityToken = string.Empty; req.hdr.UserId = CurrUser.iUserID; req.FileId = iFileId; req.WorkflowTemplId = iDefaultWorkflowTempl; GenerateWorkflowResponse resp = service.GenerateWorkflow(req); if ((resp == null) || (!resp.hdr.Successful)) { return(iCurrentLoanStageId); } iCurrentLoanStageId = LPWeb.BLL.WorkflowManager.GetCurrentLoanStageId(iFileId); return(iCurrentLoanStageId); } return(iCurrentLoanStageId); } iCurrentLoanStageId = LPWeb.BLL.WorkflowManager.GenerateDefaultLoanStages(iFileId, "Prospect"); return(iCurrentLoanStageId); }
protected void btnApplyWfl_Click(object sender, EventArgs e) { int iWorkflowTemplID = Convert.ToInt32(this.ddlWfTemps.SelectedValue); //string sJsCodes = "window.parent.document.getElementById('ifrLoanInfo').contentWindow.location.reload();window.location.href=window.location.href;"; string sJsCodes = "window.location.href=window.location.href;"; var request = new GenerateWorkflowRequest { FileId = CurrentFileId, WorkflowTemplId = iWorkflowTemplID, hdr = new ReqHdr { UserId = new LoginUser().iUserID } }; GenerateWorkflowResponse response = null; try { ServiceManager sm = new ServiceManager(); using (LP2ServiceClient client = sm.StartServiceClient()) { response = client.GenerateWorkflow(request); } } catch (System.ServiceModel.EndpointNotFoundException) { string sExMsg = string.Format("Failed to apply workflow template: {0}", "Workflow Manager is not running.", iWorkflowTemplID); LPLog.LogMessage(LogType.Logerror, sExMsg); PageCommon.WriteJsEnd(this, sExMsg, sJsCodes); } catch (Exception ex) { string sExMsg = string.Format("Failed to apply workflow template: {0}, error detail:", ex.Message); LPLog.LogMessage(LogType.Logerror, sExMsg); PageCommon.WriteJsEnd(this, sExMsg, sJsCodes); } if (response.hdr.Successful == false) { PageCommon.WriteJsEnd(this, "Failed to apply workflow template: " + response.hdr.StatusInfo, sJsCodes); } System.Threading.Thread.Sleep(2000); var CurrentUserId = this.CurrUser.iUserID; LPWeb.Model.LoanWflTempl lWflTempModel = new LPWeb.Model.LoanWflTempl(); lWflTempModel.FileId = CurrentFileId; lWflTempModel.ApplyBy = CurrentUserId; lWflTempModel.ApplyDate = DateTime.Now; lWflTempModel.WflTemplId = iWorkflowTemplID; LPWeb.BLL.LoanWflTempl bLoanWflTempl = new LoanWflTempl(); bLoanWflTempl.Apply(lWflTempModel); // success PageCommon.WriteJsEnd(this, "Applied workflow template successfully.", sJsCodes); }
protected bool GenerateWorkflow(int iFileID, int iWflTempID, int iUserID, out string sError) { #region API GenerateWorkflow sError = string.Empty; var request = new GenerateWorkflowRequest { FileId = iFileID, WorkflowTemplId = iWflTempID, hdr = new ReqHdr { UserId = iUserID } }; GenerateWorkflowResponse response = null; try { ServiceManager sm = new ServiceManager(); using (LP2ServiceClient client = sm.StartServiceClient()) { response = client.GenerateWorkflow(request); } } catch (System.ServiceModel.EndpointNotFoundException) { string sExMsg = string.Format("Failed to apply workflow template: {0}", "Workflow Manager is not running.", iWflTempID); LPLog.LogMessage(LogType.Logerror, sExMsg); sError = sExMsg; return(false); } catch (Exception ex) { string sExMsg = string.Format("Failed to apply workflow template: {0}, error detail:", ex.Message); LPLog.LogMessage(LogType.Logerror, sExMsg); sError = sExMsg; return(false); } if (response.hdr.Successful == false) { sError = "Failed to apply workflow template: " + response.hdr.StatusInfo; return(false); } #endregion return(true); }
protected void btnApply_Click(object sender, EventArgs e) { string sTargetWorkflowTemplateID = this.hdnTargetWorkflowTemplateID.Value; int iTargetWorkflowTemplateID = Convert.ToInt32(sTargetWorkflowTemplateID); #region Generate Workflow try { // workflow api ServiceManager sm = new ServiceManager(); using (LP2ServiceClient service = sm.StartServiceClient()) { GenerateWorkflowRequest req = new GenerateWorkflowRequest(); req.FileId = this.iLoanID; req.WorkflowTemplId = iTargetWorkflowTemplateID; req.hdr = new ReqHdr(); req.hdr.UserId = CurrUser.iUserID; GenerateWorkflowResponse response = service.GenerateWorkflow(req); if (response.hdr.Successful) { PageCommon.WriteJsEnd(this, "Generate workflow successfully.", "window.parent.location.href=window.parent.location.href;"); } else { string sFailedMsg = "Failed to generate workflow: " + response.hdr.StatusInfo; LPLog.LogMessage(LogType.Logerror, sFailedMsg); PageCommon.WriteJsEnd(this, sFailedMsg, PageCommon.Js_RefreshSelf); } } } catch (System.ServiceModel.EndpointNotFoundException) { string sExMsg = string.Format("Exception happened when send GenerateWorkflowRequest to Point Manager (FileID={0}): {1}", this.iLoanID, "Point Manager is not running."); LPLog.LogMessage(LogType.Logerror, sExMsg); PageCommon.WriteJsEnd(this, sExMsg, PageCommon.Js_RefreshSelf); } catch (Exception ex) { string sExMsg = string.Format("Exception happened when send GenerateWorkflowRequest to Point Manager (FileID={0}): {1}", this.iLoanID, ex.Message); LPLog.LogMessage(LogType.Logerror, sExMsg); PageCommon.WriteJsEnd(this, sExMsg, PageCommon.Js_RefreshSelf); } #endregion }
protected void Page_Load(object sender, EventArgs e) { // json示例 // {"ExecResult":"Success"} // {"ExecResult":"Failed","ErrorMsg":"unknown errors."} #region 接收参数 // WorkflowTemplateID bool bIsValid = PageCommon.ValidateQueryString(this, "WorkflowTemplateID", QueryStringType.ID); if (bIsValid == false) { this.Response.Write("{\"ExecResult\":\"Failed\",\"ErrorMsg\":\"Lose required query string.\"}"); this.Response.End(); } string sWorkflowTemplateID = this.Request.QueryString["WorkflowTemplateID"]; int iWorkflowTemplateID = Convert.ToInt32(sWorkflowTemplateID); #endregion #region 加载Workflow Template信息 LPWeb.BLL.Template_Workflow WorkflowTemplateManager = new LPWeb.BLL.Template_Workflow(); DataTable WorkflowTemplateInfo = WorkflowTemplateManager.GetWorkflowTemplateInfo(iWorkflowTemplateID); if (WorkflowTemplateInfo.Rows.Count == 0) { this.Response.Write("{\"ExecResult\":\"Failed\",\"ErrorMsg\":\"Invalid workflow template id.\"}"); this.Response.End(); } string sWorkflowType = WorkflowTemplateInfo.Rows[0]["WorkflowType"].ToString(); #endregion #region 加载Loan List string sSql = "select * from LoanWflTempl a inner join Loans b on a.FileId=b.FileId WHERE a.WflTemplId=" + sWorkflowTemplateID + " and b.Status='" + sWorkflowType + "'"; DataTable LoanList = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSql); #endregion bool bAllSuccess = true; try { foreach (DataRow LoanRow in LoanList.Rows) { int iFileID = Convert.ToInt32(LoanRow["FileId"]); // workflow api ServiceManager sm = new ServiceManager(); using (LP2ServiceClient service = sm.StartServiceClient()) { GenerateWorkflowRequest req = new GenerateWorkflowRequest(); req.FileId = iFileID; req.WorkflowTemplId = iWorkflowTemplateID; req.hdr = new ReqHdr(); req.hdr.SecurityToken = "SecurityToken"; //todo:check dummy data req.hdr.UserId = this.CurrUser.iUserID; GenerateWorkflowResponse respone = service.GenerateWorkflow(req); if (respone.hdr.Successful == false) { bAllSuccess = false; break; } } } } catch (System.ServiceModel.EndpointNotFoundException) { this.Response.Write("{\"ExecResult\":\"Failed\",\"ErrorMsg\":\"Exception happened when regenerate workflows: Point Manager is not running.\"}"); this.Response.End(); } catch (Exception) { this.Response.Write("{\"ExecResult\":\"Failed\",\"ErrorMsg\":\"Unknown exception happened when regenerate workflows.\"}"); this.Response.End(); } if (bAllSuccess == true) { this.Response.Write("{\"ExecResult\":\"Success\"}"); } else { this.Response.Write("{\"ExecResult\":\"Failed\",\"ErrorMsg\":\"Failed to regenerate workflows.\"}"); } }
protected void Page_Load(object sender, EventArgs e) { #region 接收参数 // LoanID bool bIsValid = PageCommon.ValidateQueryString(this, "LoanID", QueryStringType.ID); if (bIsValid == false) { this.Response.Write("{\"ExecResult\":\"Failed\",\"ErrorMsg\":\"Missing required query string.\"}"); this.Response.End(); } string sLoanID = this.Request.QueryString["LoanID"].ToString(); // WorkflowTemplateID bIsValid = PageCommon.ValidateQueryString(this, "WorkflowTemplateID", QueryStringType.ID); if (bIsValid == false) { this.Response.Write("{\"ExecResult\":\"Failed\",\"ErrorMsg\":\"Missing required query string.\"}"); this.Response.End(); } string sWorkflowTemplateID = this.Request.QueryString["WorkflowTemplateID"].ToString(); #endregion // json示例 // {"ExecResult":"Success","ErrorMsg":""} // {"ExecResult":"Failed","ErrorMsg":"执行数据库脚本时发生错误。"} string sExecResult = string.Empty; string sErrorMsg = string.Empty; try { // workflow api ServiceManager sm = new ServiceManager(); using (LP2ServiceClient service = sm.StartServiceClient()) { GenerateWorkflowRequest req = new GenerateWorkflowRequest(); req.FileId = int.Parse(sLoanID); req.WorkflowTemplId = Convert.ToInt32(sWorkflowTemplateID); req.hdr = new ReqHdr(); req.hdr.SecurityToken = "SecurityToken"; //todo:check dummy data req.hdr.UserId = this.CurrUser.iUserID; GenerateWorkflowResponse respone = service.GenerateWorkflow(req); if (respone.hdr.Successful) { sExecResult = "Success"; sErrorMsg = "Success to completed selected task(s)"; } else { sExecResult = "Failed"; sErrorMsg = "Failed to completed selected task(s)"; } } } catch (System.ServiceModel.EndpointNotFoundException) { sExecResult = "Failed"; sErrorMsg = "Failed to regenerate task(s), reason: Point Manager is not running."; } catch (Exception) { sExecResult = "Failed"; sErrorMsg = "Failed to regenerate task(s)"; } System.Threading.Thread.Sleep(1000); this.Response.Write("{\"ExecResult\":\"" + sExecResult + "\",\"ErrorMsg\":\"" + sErrorMsg + "\"}"); this.Response.End(); }