/// <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)); } }
public bool CalculateDueDates(CalculateDueDatesRequest req, ref string err) { err = ""; bool logErr = false; try { WorkflowEvent e = new WorkflowEvent(WorkflowCmd.CalculateDueDates, req); m_ThreadContext.Post(new SendOrPostCallback(ProcessRequest), e); err = "Your request is being processed. It'll take a moment to finish."; return(true); } catch (Exception ex) { err = "CalculateDueDates, Exception:" + ex.Message; int Event_id = 7065; EventLog.WriteEntry(InfoHubEventLog.LogSource, err, EventLogEntryType.Warning, Event_id, Category); return(false); } finally { if (logErr) { int Event_id = 7066; EventLog.WriteEntry(InfoHubEventLog.LogSource, err, EventLogEntryType.Warning, Event_id, Category); } } }
private void CalcuateDueDates_Internal(CalculateDueDatesRequest req) { bool logErr = false; bool fatal = false; string err = ""; try { if ((req == null) || (req.hdr == null) || (req.UserId == null)) { err = "CalculateDueDatesRequest or its request header is null"; int Event_id = 7047; EventLog.WriteEntry(InfoHubEventLog.LogSource, err, EventLogEntryType.Warning, Event_id, Category); return; } if (req.UserId < 0) { err = "User Id in the CalculateDueDatesRequest is negative, userid=" + req.UserId; int Event_id = 7048; EventLog.WriteEntry(InfoHubEventLog.LogSource, err, EventLogEntryType.Warning, Event_id, Category); return; } if (req.FileId <= 0) { err = "FileId in CalculateDueDatesRequest is invalid, FileId=" + req.FileId; int Event_id = 7049; EventLog.WriteEntry(InfoHubEventLog.LogSource, err, EventLogEntryType.Warning, Event_id, Category); return; } if (m_da.Save_EstCloseDate(req.FileId, req.NewEstCloseDate, req.UserId, ref err) == false) { int Event_id = 7050; EventLog.WriteEntry(InfoHubEventLog.LogSource, err, EventLogEntryType.Warning, Event_id, Category); return; } if (m_da.CalculateDueDates(req.FileId, req.NewEstCloseDate, ref err) == false) { int Event_id = 7051; EventLog.WriteEntry(InfoHubEventLog.LogSource, err, EventLogEntryType.Warning, Event_id, Category); return; } } catch (Exception ex) { err = "CalculateDueDates, Exception:" + ex.Message; int Event_id = 7052; EventLog.WriteEntry(InfoHubEventLog.LogSource, err, EventLogEntryType.Warning, Event_id, Category); fatal = true; } finally { if (logErr) { int Event_id = 7053; EventLog.WriteEntry(InfoHubEventLog.LogSource, err, EventLogEntryType.Warning, Event_id, Category); } } }
public void ProcessRequest(object o) { string err = ""; bool logErr = false; bool fatal = false; try { if (o == null) { err = "Process Request, Workflow Event is null."; int Event_id = 7058; EventLog.WriteEntry(InfoHubEventLog.LogSource, err, EventLogEntryType.Warning, Event_id, Category); } WorkflowEvent e = o as WorkflowEvent; if (e == null) { err = "Process Request, Workflow Event is null."; int Event_id = 7059; EventLog.WriteEntry(InfoHubEventLog.LogSource, err, EventLogEntryType.Warning, Event_id, Category); return; } if (e.RequestMsg == null) { err = "Process Request, Workflow Request Message is null."; int Event_id = 7060; EventLog.WriteEntry(InfoHubEventLog.LogSource, err, EventLogEntryType.Warning, Event_id, Category); return; } switch (e.RequestType) { case WorkflowCmd.GenerateWorkflow: GenerateWorkflowRequest req = e.RequestMsg as GenerateWorkflowRequest; GenWorkflow_Internal(req); break; case WorkflowCmd.MonitorLoans: MonitorLoans(); break; case WorkflowCmd.CalculateDueDates: CalculateDueDatesRequest req1 = e.RequestMsg as CalculateDueDatesRequest; CalcuateDueDates_Internal(req1); break; case WorkflowCmd.UpdateEstCloseDate: UpdateEstCloseDateRequest req2 = e.RequestMsg as UpdateEstCloseDateRequest; UpdateEstCloseDate(req2); break; } } catch (Exception ex) { err = "ProcessRequest, Exception:" + ex.Message; int Event_id = 7061; EventLog.WriteEntry(InfoHubEventLog.LogSource, err, EventLogEntryType.Warning, Event_id, Category); } finally { if (logErr) { int Event_id = 7062; EventLog.WriteEntry(InfoHubEventLog.LogSource, err, EventLogEntryType.Warning, Event_id, Category); } } return; }
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(); }