/// <summary> /// Handles the Click event of the btnSave control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void btnSave_Click(object sender, EventArgs e) { /*Save: When clicked, if the Target Close Date is changed, an UpdateEstCloseDateRequest message will be sent to the Point Manager. * If the Point Manager returns an error, it will display the error and will not save the change; * otherwise, it will send a CalculateDueDates message to the Workflow Manager. * If the Workflow Manager returns an error, it will display the error and abort the operation. */ DateTime dtClose = DateTime.MinValue; DateTime.TryParse(tbxTargetCloseDate.Text, out dtClose); if (dtClose == DateTime.MinValue) { PageCommon.AlertMsg(this, "Please enter the Target Close Date"); return; } try { ServiceManager sm = new ServiceManager(); using (LP2ServiceClient client = sm.StartServiceClient()) { var req = new UpdateEstCloseDateRequest(); req.FileId = CurrentFileId; req.NewDate = dtClose; req.hdr = new ReqHdr(); req.hdr.UserId = new LoginUser().iUserID; var response = client.UpdateEstCloseDate(req); if (!response.hdr.Successful) { PageCommon.AlertMsg(this, response.hdr.StatusInfo); return; } var req1 = new CalculateDueDatesRequest(); req1.FileId = CurrentFileId; req1.NewEstCloseDate = dtClose; req1.hdr = new ReqHdr(); req1.hdr.UserId = new LoginUser().iUserID; var response1 = client.CalculateDueDates(req1); if (!response1.hdr.Successful) { PageCommon.AlertMsg(this, response1.hdr.StatusInfo); } else { PageCommon.AlertMsg(this, "Save Successfuly!"); BindPage(); } } } catch (System.ServiceModel.EndpointNotFoundException ex) { PageCommon.AlertMsg(this, "Failed to save the Target Close Date, reason: Workflow Manager Service not running."); } catch (Exception ee) { PageCommon.AlertMsg(this, String.Format("Failed to save the Target Close Date, reason: {0}", ee.Message)); } }
protected void Page_Load(object sender, EventArgs e) { #region 接收参数 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(); bIsValid = PageCommon.ValidateQueryString(this, "NewDate", QueryStringType.Date); if (bIsValid == false) { this.Response.Write("{\"ExecResult\":\"Failed\",\"ErrorMsg\":\"Missing required query string.\"}"); this.Response.End(); } string sNewDate = this.Request.QueryString["NewDate"].ToString(); bIsValid = PageCommon.ValidateQueryString(this, "LoginUserID", QueryStringType.ID); if (bIsValid == false) { this.Response.Write("{\"ExecResult\":\"Failed\",\"ErrorMsg\":\"Missing required query string.\"}"); this.Response.End(); } string sLoginUserID = this.Request.QueryString["LoginUserID"].ToString(); #endregion // json示例 // {"ExecResult":"Success","ErrorMsg":""} // {"ExecResult":"Failed","ErrorMsg":"执行数据库脚本时发生错误。"} string sExecResult = string.Empty; string sErrorMsg = string.Empty; try { // workflow api // workflow api ServiceManager sm = new ServiceManager(); using (LP2ServiceClient service = sm.StartServiceClient()) { CalculateDueDatesRequest req = new CalculateDueDatesRequest(); req.FileId = Convert.ToInt32(sLoanID); req.NewEstCloseDate = Convert.ToDateTime(sNewDate); req.hdr = new ReqHdr(); CalculateDueDatesResponse respone = service.CalculateDueDates(req); if (respone.hdr.Successful == true) { sExecResult = "Success"; sErrorMsg = ""; } else { sExecResult = "Failed"; sErrorMsg = "Failed to calculate due dates of all the pending tasks: " + respone.hdr.StatusInfo + "."; } } sExecResult = "Success"; sErrorMsg = ""; } catch (System.ServiceModel.EndpointNotFoundException ee) { sExecResult = "Failed"; sErrorMsg = "Failed to calculate due dates of all the pending tasks."; PageCommon.AlertMsg(this, "Failed to calculate due dates, reason: Point Manager is not running."); } catch (Exception ex) { sExecResult = "Failed"; sErrorMsg = "Failed to calculate due dates of all the pending tasks."; } System.Threading.Thread.Sleep(1000); this.Response.Write("{\"ExecResult\":\"" + sExecResult + "\",\"ErrorMsg\":\"" + sErrorMsg + "\"}"); this.Response.End(); }