private bool MoveFile(int nFileId, int nFolderId, out string err) { string strResultInfo = string.Empty; err = string.Empty; string sProspectStatus = LoansManager.GetProspectStatusInfo(nFileId); string sFileName = LoansManager.GetProspectFileNameInfo(nFileId); //bug 878 if (sFileName == "") { err = "The selected lead does not have a Point file."; return(false); } ServiceManager sm = new ServiceManager(); using (LP2ServiceClient client = sm.StartServiceClient()) { MoveFileRequest req = new MoveFileRequest(); req.FileId = nFileId; req.NewFolderId = nFolderId; req.hdr = new ReqHdr(); req.hdr.UserId = CurrUser.iUserID; MoveFileResponse response = client.MoveFile(req); if (response.hdr.Successful) { return(true); } // LPLog.LogMessage(LogType.Logerror, string.Format("Failed to move file:{0}", response.hdr.StatusInfo)); //PageCommon.WriteJsEnd(this, response.hdr.StatusInfo); err = response.hdr.StatusInfo; return(false); } }
private void ReassignProspect() { if (!AllowReassignProspect()) { return; } try { ServiceManager sm = new ServiceManager(); using (LP2ServiceClient service = sm.StartServiceClient()) { ReassignProspectRequest rpq = new ReassignProspectRequest(); rpq.hdr = new ReqHdr(); rpq.FileId = new int[1] { this.iFileID }; rpq.hdr.SecurityToken = "SecurityToken"; //todo:check dummy data rpq.hdr.UserId = CurrUser.iUserID; rpq.FromUser = int.Parse(hfLoanOfficer.Value); rpq.ToUser = int.Parse(ddlLoanOfficer.SelectedValue); rpq.ContactId = null; rpq.UserId = null; ReassignProspectResponse rpp = null; rpp = service.ReassignProspect(rpq); if (!rpp.hdr.Successful) { PageCommon.AlertMsg(this, rpp.hdr.StatusInfo); } } } catch (Exception ex) { LPLog.LogMessage(LogType.Logerror, ex.Message); } }
/// <summary> /// update Point file and move it to the closed loan/archived loan folder /// /// </summary> /// <param name="bComplete">true or false</param> /// <param name="sCompletedDate">if bComplete=true, sCompletedDate=DateTime.ToString() else string.Empty</param> /// <param name="iLoanID"></param> /// <param name="iLoginUserID"></param> /// <param name="sLoanStage"></param> /// <returns>error, if success, error=string.Empty</returns> public static string CloseLoan(int iLoanID, int iLoginUserID, int iFolderId) { string sError = string.Empty; try { ServiceManager sm = new ServiceManager(); using (LP2ServiceClient client = sm.StartServiceClient()) { DisposeLoanRequest req = new DisposeLoanRequest(); req.FileId = iLoanID; req.LoanStatus = "Closed"; req.NewFolderId = iFolderId; req.hdr = new ReqHdr(); req.hdr.UserId = iLoginUserID; req.StatusDate = DateTime.Now; DisposeLoanResponse response = client.DisposeLoan(req); if (response.hdr.Successful) { return("Moved the Point file to the selected folder successfully."); } else { return("Failed to move the Point file to the selected folder, reason:" + response.hdr.StatusInfo); } } } catch (System.ServiceModel.EndpointNotFoundException ee) { return("Failed to move the Point file, reason: Point Manager is not running."); } catch (Exception ex) { return("Failed to move the Point file, reason:" + ex.Message); } }
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 lbtnSuspend_Click(object sender, EventArgs e) { string err = "Failed to "; try { ServiceManager sm = new ServiceManager(); using (LP2ServiceClient service = sm.StartServiceClient()) { if (this.lbtnSuspend.Text.ToLower().IndexOf("suspend") >= 0) { err += "suspend "; StopPointImportRequest req = new StopPointImportRequest(); req.hdr = new ReqHdr(); req.hdr.SecurityToken = "SecurityToken"; //todo:check dummy data req.hdr.UserId = 5; //todo:check dummy data StopPointImportResponse respone = null; try { respone = service.StopPointImportService(req); if (respone.hdr.Successful) { this.lbtnSuspend.Text = "Resume Sync"; PageCommon.WriteJsEnd(this, "Suspend sync successfully.", PageCommon.Js_RefreshSelf); } else { PageCommon.WriteJsEnd(this, "Suspend sync failed, reason: " + respone.hdr.StatusInfo, PageCommon.Js_RefreshSelf); } } catch (System.ServiceModel.EndpointNotFoundException ee) { LPLog.LogMessage(ee.Message); PageCommon.AlertMsg(this, "Failed to Suspend sync, reason: Point Manager is not running."); } catch (Exception exception) { err = "Failed to suspend sync, reason: " + exception.Message; LPLog.LogMessage(err); PageCommon.WriteJsEnd(this, err, PageCommon.Js_RefreshSelf); } } else if (this.lbtnSuspend.Text.ToLower().IndexOf("resume") >= 0) { err += "resume "; StartPointImportRequest req = new StartPointImportRequest(); req.hdr = new ReqHdr(); req.hdr.SecurityToken = "SecurityToken"; //todo:check dummy data req.hdr.UserId = 5; //todo:check dummy data StartPointImportResponse respone = null; try { respone = service.StartPointImportService(req); if (respone.hdr.Successful) { this.lbtnSuspend.Text = "Suspend Sync"; PageCommon.WriteJsEnd(this, "Resume sync successfully.", PageCommon.Js_RefreshSelf); } else { PageCommon.WriteJsEnd(this, "Resume sync failed.", PageCommon.Js_RefreshSelf); } } catch (System.ServiceModel.EndpointNotFoundException ee) { err = "Failed to suspend sync, reason: " + ee.Message; LPLog.LogMessage(err); PageCommon.AlertMsg(this, "Failed to Resume sync, reason: Point Manager is not running."); } catch (Exception exception) { err = "Failed to suspend sync, reason: " + exception.Message; LPLog.LogMessage(err); PageCommon.WriteJsEnd(this, err, PageCommon.Js_RefreshSelf); } } } } catch (Exception ex) { err += "sync, reason: " + ex.Message; LPLog.LogMessage(LogType.Logerror, err); PageCommon.WriteJsEnd(this, err, PageCommon.Js_RefreshSelf); } }
protected int CreateContactAndProspect(string sFirstName, string sLastName, string sEmail, string sType, string sPhone, string sDOB, string sSSN, int iUserID, string Purpose) { #region create new contact LPWeb.Model.Contacts ContactsModel = new LPWeb.Model.Contacts(); ContactsModel.ContactId = 0; ContactsModel.FirstName = sFirstName; ContactsModel.LastName = sLastName; ContactsModel.Email = sEmail; if (sType == "Cell Phone") { ContactsModel.CellPhone = sPhone; ContactsModel.HomePhone = string.Empty; ContactsModel.BusinessPhone = string.Empty; } else if (sType == "Home Phone") { ContactsModel.CellPhone = string.Empty; ContactsModel.HomePhone = sPhone; ContactsModel.BusinessPhone = string.Empty; } else if (sType == "Work Phone") { ContactsModel.CellPhone = string.Empty; ContactsModel.HomePhone = string.Empty; ContactsModel.BusinessPhone = sPhone; } if (sDOB == string.Empty) { ContactsModel.DOB = null; } else { ContactsModel.DOB = Convert.ToDateTime(sDOB); } ContactsModel.SSN = sSSN; ContactsModel.MiddleName = string.Empty; ContactsModel.NickName = txtFirstName.Text.Trim(); ContactsModel.Title = string.Empty; ContactsModel.GenerationCode = string.Empty; ContactsModel.Fax = string.Empty; ContactsModel.MailingAddr = string.Empty; ContactsModel.MailingCity = string.Empty; ContactsModel.MailingState = string.Empty; ContactsModel.MailingZip = string.Empty; #endregion #region create new prospect LPWeb.Model.Prospect ProspectModel = new LPWeb.Model.Prospect(); ProspectModel.PreferredContact = sType; ProspectModel.Contactid = 0; ProspectModel.Created = DateTime.Now; ProspectModel.CreatedBy = iUserID; ProspectModel.LeadSource = ddlLeadSource.SelectedValue.ToString() == "0" ? "" : this.ddlLeadSource.SelectedItem.Text; string sLoanOfficerID = ddlLoanOfficer.SelectedValue; iLoanOfficerID = 0; if (sLoanOfficerID == "-1" || sLoanOfficerID == "-2") { //Nobody } else if (sLoanOfficerID == "0") { //Lead Routing Engine try { ServiceManager sm = new ServiceManager(); using (LP2ServiceClient client = sm.StartServiceClient()) { //invoke the WCF API GetNextLoanOfficer LR_GetNextLoanOfficerReq req = new LR_GetNextLoanOfficerReq(); req.LeadSource = ddlLeadSource.SelectedItem.Text; req.Purpose = Purpose; req.ReqHdr = new ReqHdr(); req.ReqHdr.UserId = CurrUser.iUserID; req.ReqHdr.SecurityToken = "SecurityToken"; LR_GetNextLoanOfficerResp response = client.LeadRouting_GetNextLoanofficer(req); if (response.RespHdr.Successful) { iLoanOfficerID = response.NextLoanOfficerID; } else { Company_Lead_Sources LeadSourceMgr = new Company_Lead_Sources(); DataTable SelLeadSourceList = LeadSourceMgr.GetList("LeadSourceID='" + ddlLeadSource.SelectedValue + "'").Tables[0]; if (SelLeadSourceList != null && SelLeadSourceList.Rows.Count > 0) { iLoanOfficerID = SelLeadSourceList.Rows[0]["DefaultUserId"] == DBNull.Value ? 0 : Convert.ToInt32(SelLeadSourceList.Rows[0]["DefaultUserId"]); } } } } catch (Exception ex) { Company_Lead_Sources LeadSourceMgr = new Company_Lead_Sources(); DataTable SelLeadSourceList = LeadSourceMgr.GetList("LeadSourceID='" + ddlLeadSource.SelectedValue + "'").Tables[0]; if (SelLeadSourceList != null && SelLeadSourceList.Rows.Count > 0) { iLoanOfficerID = SelLeadSourceList.Rows[0]["DefaultUserId"] == DBNull.Value ? 0 : Convert.ToInt32(SelLeadSourceList.Rows[0]["DefaultUserId"]); } } } else { iLoanOfficerID = Convert.ToInt32(sLoanOfficerID); } ProspectModel.Loanofficer = iLoanOfficerID; ProspectModel.ReferenceCode = string.Empty; ProspectModel.Status = "Active"; ProspectModel.CreditRanking = string.Empty; ProspectModel.Referral = null; Prospect ProspectManager = new Prospect(); int iContactId = ProspectManager.CreateContactAndProspect(ContactsModel, ProspectModel); #endregion return(iContactId); }
protected void btnSave_Click(object sender, EventArgs e) { if (this.CurrentFileId == 0) { return; } ServiceManager sm = new ServiceManager(); bool bSuccessful = false; using (LP2ServiceClient service = sm.StartServiceClient()) { ReassignLoanRequest req = new ReassignLoanRequest(); req.hdr = new ReqHdr(); req.hdr.SecurityToken = "SecurityToken"; //todo:check dummy data req.hdr.UserId = CurrentUser.iUserID; ReassignUserInfo uInfo = new ReassignUserInfo(); uInfo.FileId = this.CurrentFileId; uInfo.RoleId = int.Parse(ddlRole.SelectedValue); if (ddlUsers.SelectedValue != "") { uInfo.NewUserId = int.Parse(ddlUsers.SelectedValue); } else { uInfo.NewUserId = 0; } List <ReassignUserInfo> uList = new List <ReassignUserInfo>(); uList.Add(uInfo); req.reassignUsers = uList.ToArray(); ReassignLoanResponse respone = null; try { ReassignProspect(service); respone = service.ReassignLoan(req); if (respone.hdr.Successful) { LPWeb.Model.LoanTeam lcModel = new LPWeb.Model.LoanTeam(); lcModel.FileId = CurrentFileId; lcModel.RoleId = uInfo.RoleId; lcModel.UserId = uInfo.NewUserId; LPWeb.Model.LoanTeam oldlcModel = new LPWeb.Model.LoanTeam(); oldlcModel.FileId = CurrentFileId; oldlcModel.RoleId = oldRoleID; oldlcModel.UserId = oldUserID; LPWeb.BLL.LoanTeam lc = new LoanTeam(); //lc.Reassign(oldlcModel, lcModel, req.hdr.UserId, ddlRole.SelectedItem.Text, ddlUsers.SelectedItem.Text); lc.Reassign(oldlcModel, lcModel, req.hdr.UserId); bSuccessful = true; } else { bSuccessful = false; } if (bSuccessful) { PageCommon.WriteJsEnd(this, "Reassigned loan successfully", "window.parent.RefreshPage();" + this.hdnCloseDialogCodes.Value); } else { PageCommon.WriteJsEnd(this, string.Format("Failed to reassign loan, reason:{0}.", respone.hdr.StatusInfo), PageCommon.Js_RefreshSelf); } } catch (System.ServiceModel.EndpointNotFoundException ex) { LPLog.LogMessage(ex.Message); PageCommon.WriteJsEnd(this, "Failed to reassign loan, reason: Point Manager is not running.", PageCommon.Js_RefreshSelf); } catch (Exception exception) { LPLog.LogMessage(exception.Message); PageCommon.WriteJsEnd(this, string.Format("Failed to reassign loan, reason:{0}.", exception.Message), PageCommon.Js_RefreshSelf); } } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnDispose_Click(object sender, EventArgs e) { int nFileId = -1; if (!int.TryParse(this.hiSelectedLoan.Value, out nFileId)) { nFileId = -1; } if (nFileId == -1) { LPLog.LogMessage(LogType.Logerror, "Invalid file Id: " + this.hiSelectedLoan.Value); return; } int nFolderId = -1; if (!int.TryParse(this.hiSelectedFolderId.Value, out nFolderId)) { nFolderId = -1; } if (nFolderId == -1) { LPLog.LogMessage(LogType.Logerror, "Invalid folder Id: " + this.hiSelectedFolderId.Value); return; } try { ServiceManager sm = new ServiceManager(); using (LP2ServiceClient client = sm.StartServiceClient()) { DisposeLoanRequest req = new DisposeLoanRequest(); req.FileId = nFileId; req.LoanStatus = this.hiSelectedDisposal.Value; req.NewFolderId = nFolderId; req.hdr = new ReqHdr(); req.hdr.UserId = CurrUser.iUserID; req.StatusDate = DateTime.Now; DisposeLoanResponse response = client.DisposeLoan(req); if (response.hdr.Successful) { if (WorkflowManager.UpdateLoanStatus(nFileId, this.hiSelectedDisposal.Value, CurrUser.iUserID)) { BindLoanGrid(); LPLog.LogMessage(LogType.Loginfo, string.Format("Successfully update loan status, LoanId:{0}, to Status:{1}. ", nFileId, this.hiSelectedDisposal.Value)); } else { PageCommon.AlertMsg(this, "Failed to update loan status."); LPLog.LogMessage(LogType.Logerror, string.Format("Failed to update loan status, LoanId:{0}, to Status:{1}.", nFileId, this.hiSelectedDisposal.Value)); } } else { LPLog.LogMessage(LogType.Logerror, string.Format("Failed to move file:{0}", response.hdr.StatusInfo)); PageCommon.AlertMsg(this, response.hdr.StatusInfo); } } } catch (System.ServiceModel.EndpointNotFoundException ee) { LPLog.LogMessage(LogType.Logerror, string.Format("Faield to move file:{0}", ee.Message)); PageCommon.AlertMsg(this, "Failed to move the Point file, reason: Point Manager is not running."); } catch (Exception ex) { LPLog.LogMessage(LogType.Logerror, string.Format("Faield to move file:{0}", ex.Message)); PageCommon.AlertMsg(this, ex.Message); } }
protected void Page_Load(object sender, EventArgs e) { //string sError_Lost = "Lost required query string."; //if (this.Request.QueryString["TextBody"] == null) //{ // this.Response.Write("{\"ExecResult\":\"Failed\",\"ErrorMsg\":\"" + sError_Lost + "\"}"); // this.Response.End(); //} //string sHtmlBody = this.Request.QueryString["TextBody"]; //this.ltLSRBody.Text = sHtmlBody; // json示例 // {"ExecResult":"Success","ErrorMsg":""} // {"ExecResult":"Failed","ErrorMsg":"Failed to do sth."} #region 校验页面参数 string sErrorJs = "alert('Missing required query string.');window.close();"; if (this.Request.QueryString["FileId"] == null) { this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Missing3", sErrorJs, true); return; } string sFileId = this.Request.QueryString["FileId"]; if (PageCommon.IsID(sFileId) == false) { this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Missing1", sErrorJs, true); return; } int iFileId = Convert.ToInt32(sFileId); string sContactId = this.Request.QueryString["ContactId"]; string sUserId = this.Request.QueryString["UserId"]; if (PageCommon.IsID(sContactId) == false || PageCommon.IsID(sUserId) == false) { this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Missing1", sErrorJs, true); return; } int iContactId = 0; int iUserId = 0; string sLSRBody = "LSR content"; #endregion #region Invoke WCF string sErrorMsg = string.Empty; PreviewLSRRequest req = new PreviewLSRRequest(); PreviewLSRResponse resp = new PreviewLSRResponse(); //this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Waiting", "ShowWaitingDialog3(\"Preview report...\");", true); try { ServiceManager sm = new ServiceManager(); using (LP2ServiceClient service = sm.StartServiceClient()) { req.FileId = iFileId; req.hdr = new ReqHdr(); req.ContactId = (Int32.TryParse(sContactId, out iContactId) == true ? iContactId : 0); req.UserId = (Int32.TryParse(sUserId, out iUserId) == true ? iUserId : 0); resp = service.PreviewLSR(req); if (resp == null || resp.hdr == null) { PageCommon.WriteJsEnd(this, "", "CloseWaitingDialog3()"); this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_FailedGetHtml", "alert('Failed to preview report!');window.close();", true); return; } int iBranchID = 0; int first_check = 0; int icon_check = 1; string sSql = string.Format("select BranchID from Loans where FileId={0}", iFileId); iBranchID = (int)LPWeb.DAL.DbHelperSQL.GetSingle(sSql); sErrorMsg = resp.hdr.StatusInfo; if (resp.hdr.Successful == true) { sLSRBody = Encoding.UTF8.GetString(resp.ReportContent); String strPathAndQuery = HttpContext.Current.Request.Url.PathAndQuery; String strUrl = HttpContext.Current.Request.Url.AbsoluteUri.Replace(strPathAndQuery, "/"); int first = 0; string b_str = ""; string m_str = ""; int end = 0; string e_str = ""; string left_str = ""; first_check = sLSRBody.IndexOf("width:330px; height:64px"); if (first_check > 0) { first = sLSRBody.IndexOf("cid:"); b_str = sLSRBody.Substring(0, first - 12); m_str = "<img src=\"" + strUrl + "_layouts/LPWeb/Settings/GetPreviewBranchLogo.aspx?BranchID=" + iBranchID.ToString() + "&ss=" + DateTime.Now.Millisecond.ToString(); end = sLSRBody.IndexOf("width:330px; height:64px"); e_str = sLSRBody.Substring(end - 8, sLSRBody.Length - end + 8); sLSRBody = b_str + m_str + e_str; } first_check = sLSRBody.IndexOf("width:96px; height:13px"); if (first_check > 0) { first = sLSRBody.IndexOf("cid:"); b_str = sLSRBody.Substring(0, first - 12); end = sLSRBody.IndexOf("width:96px; height:13px"); e_str = sLSRBody.Substring(end - 8, sLSRBody.Length - end + 8); string p_str_buf = sLSRBody.Substring(first, sLSRBody.Length - first); int p_first = p_str_buf.IndexOf("data="); p_str_buf = p_str_buf.Substring(p_first + 6, p_str_buf.Length - p_first - 6); int p_end = p_str_buf.IndexOf("\""); string p_str = p_str_buf.Substring(0, p_end); int len8 = p_str.Length; m_str = "<img src=\"" + strUrl + string.Format("_layouts/LPWeb/Settings/GetLoanProgressPicture.aspx?Image={0}", p_str); sLSRBody = b_str + m_str + e_str; } first_check = sLSRBody.IndexOf("height:77px"); if (first_check > 0) { first = sLSRBody.IndexOf("cid:"); b_str = sLSRBody.Substring(0, first - 12); m_str = "<img src=\"" + strUrl + string.Format("_layouts/LPWeb/Settings/GetPreviewUserPicture.aspx?uid={0}&t={1}", this.CurrUser.iUserID.ToString(), DateTime.Now.Ticks); end = sLSRBody.IndexOf("height:77px"); e_str = sLSRBody.Substring(end - 20, sLSRBody.Length - end + 20); sLSRBody = b_str + m_str + e_str; } icon_check = sLSRBody.IndexOf("width:16px; height:16px"); while (icon_check > 0) { first = sLSRBody.IndexOf("cid:"); if (first > 0) { b_str = sLSRBody.Substring(0, first - 10); left_str = sLSRBody.Substring(first - 9, sLSRBody.Length - (first - 9)); end = left_str.IndexOf("width:16px; height:16px"); if (end > 0) { e_str = left_str.Substring(end - 8, left_str.Length - end + 8); string p_str_buf = sLSRBody.Substring(first, sLSRBody.Length - first); int p_first = p_str_buf.IndexOf("data="); p_str_buf = p_str_buf.Substring(p_first + 6, p_str_buf.Length - p_first - 6); int p_end = p_str_buf.IndexOf("\""); string p_str = p_str_buf.Substring(0, p_end); int len8 = p_str.Length; m_str = "<img src=\"" + strUrl + string.Format("_layouts/LPWeb/Settings/GetLoanProgressPicture.aspx?Image={0}", p_str); sLSRBody = b_str + m_str + e_str; } else { icon_check = -1; } } else { icon_check = -1; } } } else { this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_FailedGetHtml", "alert('Failed to preview report: " + resp.hdr.StatusInfo + "');window.close();", true); return; } } } catch (System.ServiceModel.EndpointNotFoundException ee) { PageCommon.AlertMsg(this, "Failed to preview report, Report Manager is not running, error: " + ee.ToString()); return; } catch (Exception ex) { //PageCommon.AlertMsg(this, "Failed to preview report, Report Manager is not running, error: " + ex.ToString()); return; } finally { this.ltLSRBody.Text = sLSRBody; } //this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Waiting", "CloseWaitingDialog3();",true); #endregion }
/// <summary> /// 完成 自定义task后 发送邮件 //gdc CR40 /// </summary> /// <param name="modelcmpAlerts"></param> /// <param name="taskID"></param> public void SaveOKAndSendEmail(LPWeb.Model.Company_Alerts modelcmpAlerts, int taskID) { LoginUser CurrentUser = new LoginUser(); int[] ToUserIDArray = null; int[] ToContactIDArray = null; string[] ToEmailAddrArray = null; int[] CCUserIDArray = null; int[] CCContactIDArray = null; string[] CCEmailAddrArray = null; #region use To and CC of email template #region 获取Email Template的Recipient(s) Template_Email EmailTemplateManager = new Template_Email(); DataTable RecipientList = EmailTemplateManager.GetRecipientList(modelcmpAlerts.CustomTaskEmailTemplId); #endregion #region 获取Loan Team string sSql = "select * from LoanTeam where FileId = " + this.iLoanID; DataTable LoanTeamList = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSql); #endregion #region 获取Contacts string sSql2 = "select * from LoanContacts where FileId = " + this.iLoanID; DataTable ContactList = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSql2); #endregion Collection <Int32> ToUserIDs = new Collection <int>(); Collection <Int32> ToContactIDs = new Collection <int>(); Collection <String> ToEmailList = new Collection <String>(); Collection <Int32> CCUserIDs = new Collection <int>(); Collection <Int32> CCContactIDs = new Collection <int>(); Collection <String> CCEmailList = new Collection <String>(); #region To DataRow[] ToRecipient = RecipientList.Select("RecipientType='To'"); if (ToRecipient.Length > 0) { string sEmailList_To = ToRecipient[0]["EmailAddr"].ToString(); string sContactList_To = ToRecipient[0]["ContactRoles"].ToString(); string sUserRoleList_To = ToRecipient[0]["UserRoles"].ToString(); string sTaskOwner = ToRecipient[0]["TaskOwner"].ToString(); #region Emails if (sEmailList_To != string.Empty) { string[] EmailArray_To = sEmailList_To.Split(';'); foreach (string sEmailTo in EmailArray_To) { ToEmailList.Add(sEmailTo); } } #endregion #region User IDs if (sUserRoleList_To != string.Empty) { string[] UserRoleArray_To = sUserRoleList_To.Split(';'); foreach (string sUserRoleIDTo in UserRoleArray_To) { int iUserRoleIDTo = Convert.ToInt32(sUserRoleIDTo); DataRow[] LoanTeamRows = LoanTeamList.Select("RoleId=" + iUserRoleIDTo); foreach (DataRow LoanTeamRow in LoanTeamRows) { int iUserID = Convert.ToInt32(LoanTeamRow["UserId"]); ToUserIDs.Add(iUserID); } } } #endregion #region Contact IDs if (sContactList_To != string.Empty) { string[] ContactArray_To = sContactList_To.Split(';'); foreach (string sContactIDTo in ContactArray_To) { int iContactRoleIDTo = Convert.ToInt32(sContactIDTo); DataRow[] ContactRows = ContactList.Select("ContactRoleId=" + iContactRoleIDTo); foreach (DataRow ContactRow in ContactRows) { int iContactID = Convert.ToInt32(ContactRow["ContactId"]); ToContactIDs.Add(iContactID); } } } #endregion #region TaskOwner if ((sTaskOwner != string.Empty) && (sTaskOwner != null)) { if (sTaskOwner == "True") { string sSql_LoanTasks = "select Owner from LoanTasks where LoanTaskId=" + taskID; DataTable LoanTasks_List = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSql_LoanTasks); string sOwnerId = LoanTasks_List.Rows[0]["Owner"].ToString(); if ((sTaskOwner != string.Empty) && (sTaskOwner != null)) { int iOwnerId = Convert.ToInt32(sOwnerId); string sSql_Users = "select EmailAddress, LastName, FirstName from Users where UserId=" + iOwnerId; DataTable Users_List = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSql_Users); string Owner_EmailAddress = Users_List.Rows[0]["EmailAddress"].ToString(); if ((Owner_EmailAddress != string.Empty) && (Owner_EmailAddress != null)) { ToUserIDs.Add(iOwnerId); ToEmailList.Add(Owner_EmailAddress); } } } } #endregion } #endregion #region CC DataRow[] CCRecipient = RecipientList.Select("RecipientType='CC'"); if (CCRecipient.Length > 0) { string sEmailList_CC = CCRecipient[0]["EmailAddr"].ToString(); string sContactList_CC = CCRecipient[0]["ContactRoles"].ToString(); string sUserRoleList_CC = CCRecipient[0]["UserRoles"].ToString(); #region Emails if (sEmailList_CC != string.Empty) { string[] EmailArray_CC = sEmailList_CC.Split(';'); foreach (string sEmailCC in EmailArray_CC) { CCEmailList.Add(sEmailCC); } } #endregion #region User IDs if (sUserRoleList_CC != string.Empty) { string[] UserRoleArray_CC = sUserRoleList_CC.Split(';'); foreach (string sUserRoleIDCC in UserRoleArray_CC) { int iUserRoleIDCC = Convert.ToInt32(sUserRoleIDCC); DataRow[] LoanTeamRows = LoanTeamList.Select("RoleId=" + iUserRoleIDCC); foreach (DataRow LoanTeamRow in LoanTeamRows) { int iUserID = Convert.ToInt32(LoanTeamRow["UserId"]); CCUserIDs.Add(iUserID); } } } #endregion #region Contact IDs if (sContactList_CC != string.Empty) { string[] ContactArray_CC = sContactList_CC.Split(';'); foreach (string sContactIDCC in ContactArray_CC) { int iContactRoleIDCC = Convert.ToInt32(sContactIDCC); DataRow[] ContactRows = ContactList.Select("ContactRoleId=" + iContactRoleIDCC); foreach (DataRow ContactRow in ContactRows) { int iContactID = Convert.ToInt32(ContactRow["ContactId"]); CCContactIDs.Add(iContactID); } } } #endregion } #endregion ToUserIDArray = new int[ToUserIDs.Count]; ToContactIDArray = new int[ToContactIDs.Count]; ToEmailAddrArray = new string[ToEmailList.Count]; CCUserIDArray = new int[CCUserIDs.Count]; CCContactIDArray = new int[CCContactIDs.Count]; CCEmailAddrArray = new string[CCEmailList.Count]; ToUserIDs.CopyTo(ToUserIDArray, 0); ToContactIDs.CopyTo(ToContactIDArray, 0); ToEmailList.CopyTo(ToEmailAddrArray, 0); CCUserIDs.CopyTo(CCUserIDArray, 0); CCContactIDs.CopyTo(CCContactIDArray, 0); CCEmailList.CopyTo(CCEmailAddrArray, 0); #endregion #region 调用API SendEmailResponse response = null; try { ServiceManager sm = new ServiceManager(); using (LP2ServiceClient service = sm.StartServiceClient()) { SendEmailRequest req = new SendEmailRequest(); req.EmailTemplId = modelcmpAlerts.CustomTaskEmailTemplId; req.FileId = this.iLoanID; req.UserId = CurrentUser.iUserID; req.ToEmails = ToEmailAddrArray; req.ToUserIds = ToUserIDArray; req.ToContactIds = ToContactIDArray; req.CCEmails = CCEmailAddrArray; req.CCUserIds = CCUserIDArray; req.CCContactIds = CCContactIDArray; req.hdr = new ReqHdr(); response = service.SendEmail(req); } } catch (System.ServiceModel.EndpointNotFoundException) { string sExMsg = string.Format("Failed to send the email, reason: Email Manager is not running."); LPLog.LogMessage(LogType.Logerror, sExMsg); //PageCommon.WriteJsEnd(this, sExMsg, "window.parent.CloseDialog_SendCompletionEmail();"); } catch (Exception ex) { string sExMsg = string.Format("Failed to send email, error: {0}", ex.Message); LPLog.LogMessage(LogType.Logerror, sExMsg); //PageCommon.WriteJsEnd(this, sExMsg, "window.parent.CloseDialog_SendCompletionEmail();"); } #endregion }
private bool SaveLoanNotes() { if (NoteSaved) { return(true); } string err = ""; string Note = Request.Form["tbxNote"].ToString().Trim(); bool cbExternalViewing = true; if (Request.Form["cbExternalViewing"] == null || string.IsNullOrEmpty(Request.Form["cbExternalViewing"].ToString())) { cbExternalViewing = false; } else { cbExternalViewing = Request.Form["cbExternalViewing"].ToString().ToUpper() == "ON" ? true : false; } try { if (Note == "") { //PageCommon.AlertMsg(this, "Please input the note!"); //ErrorMsg("Please input the note!"); return(true); //gdc CR43 为空时不添加Note ,需要在调用前综合判定 Note 和 Attachment } //if (Note.Length > 500) //{ // //PageCommon.AlertMsg(this, "The note length must be less than 500 characters!"); // ErrorMsg("The note length must be less than 500 characters!"); // return false; //} int fileId = iLoanID; var curUser = new LoginUser(); string senderName = curUser.sFirstName + " " + curUser.sLastName; DateTime dtNow = Convert.ToDateTime(sLocalTime); dtNow.AddMinutes(2); dtNow.AddSeconds(5); var req = new AddNoteRequest { FileId = fileId, Created = dtNow,//DateTime.Now, NoteTime = dtNow, Note = Note, Sender = senderName, hdr = new ReqHdr { UserId = curUser.iUserID } }; ServiceManager sm = new ServiceManager(); using (LP2ServiceClient client = sm.StartServiceClient()) { AddNoteResponse res = client.AddNote(req); bool exported = res.hdr.Successful; var model = new Model.LoanNotes { Note = Note, FileId = fileId, Created = dtNow,//DateTime.Now, Sender = senderName, Exported = exported, ExternalViewing = cbExternalViewing }; var bllLoanNotes = new LoanNotes(); bllLoanNotes.Add(model); NoteSaved = true; if (!exported) { //PageCommon.WriteJs(this, res.hdr.StatusInfo, "parent.ClosePopupWindow();"); ErrorMsg(res.hdr.StatusInfo); return(false); } else { //PageCommon.WriteJs(this, "Add note successfully.", "parent.ClosePopupWindow();"); //PageCommon.WriteJsEnd(this, "Add note Failed.", PageCommon.Js_RefreshSelf); return(true); } } } catch (System.ServiceModel.EndpointNotFoundException ee) { LPLog.LogMessage(ee.Message); //PageCommon.AlertMsg(this, "Failed to add note, reason: Point Manager is not running."); ErrorMsg("Failed to add note, reason: Point Manager is not running."); return(false); } catch (Exception exception) { err = "Failed to add note, reason:" + exception.Message + " LocalTime:" + sLocalTime; LPLog.LogMessage(err); // PageCommon.WriteJsEnd(this, err, PageCommon.Js_RefreshSelf); ErrorMsg(err); return(false); } }
/// <summary> /// Save user info /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { Model.Users newUser = null; if ("0" == Mode) { newUser = new Model.Users(); if (GetValue(ref newUser)) { //set the new user's default loans per page(50) newUser.LoansPerPage = 50; if (!CheckBeforeSave(newUser)) { return; } int?nSourceUID = null; int nTemp = 0; if (null != ViewState["SourceUID"]) { if (int.TryParse(ViewState["SourceUID"].ToString(), out nTemp)) { nSourceUID = nTemp; } } try { // save the new added user info, nSourceUID is null or not indicated to clone or not UserId = UsersManager.AddUserInfo(newUser, this.hiCurrLoanRep.Value, this.hiCurrGroup.Value, nSourceUID); Mode = "1"; this.btnDelete.Enabled = true; this.btnClone.Enabled = true; try { ServiceManager sm = new ServiceManager(); using (LP2ServiceClient service = sm.StartServiceClient()) { UpdateADUserRequest uReq = new UpdateADUserRequest(); ReqHdr hdr = new ReqHdr(); hdr.UserId = UserId.Value; uReq.hdr = hdr; uReq.AD_OU_Filter = this.lbPrefix.Text; uReq.AD_User = new LP_Service.User(); uReq.AD_User.Username = this.tbUserName.Text; uReq.AD_User.Firstname = this.tbFirstName.Text; uReq.AD_User.Lastname = this.tbLastName.Text; uReq.AD_User.Email = this.tbEmail.Text; uReq.AD_User.Enabled = this.ckbEnabled.Checked; if (!string.IsNullOrEmpty(this.tbPWD.Text.Trim())) { uReq.AD_User.Password = this.tbPWD.Text.Trim(); } else { uReq.AD_User.Password = string.Empty; } uReq.Command = UserMgrCommandType.CreateUser; UpdateADUserResponse uResponse; uResponse = service.UpdateADUser(uReq); if (!uResponse.hdr.Successful) { PageCommon.AlertMsg(this, "Failed to save user info in AD."); CallClientFn("closeBox(true);"); LPLog.LogMessage(LogType.Logerror, "Failed to save user info in AD. UserID: " + UserId.ToString() + ", Error: " + uResponse.hdr.StatusInfo); return; } } } catch (System.ServiceModel.EndpointNotFoundException ee) { LPLog.LogMessage(ee.Message); CallClientFn("closeBox(true);"); PageCommon.AlertMsg(this, "Failed to save user info in AD, reason: User Manager is not running."); return; } catch (Exception ex) { PageCommon.AlertMsg(this, "Failed to save user info in AD, reason:" + ex.Message); CallClientFn("closeBox(true);"); LPLog.LogMessage(LogType.Logerror, "Error occured when save user info in AD: " + ex.Message); return; } CallClientFn("ShowMsg('saveSuccss', '', true, true);"); } catch (Exception ex) { PageCommon.AlertMsg(this, "Failed to save user info, reason:" + ex.Message); LPLog.LogMessage(LogType.Logerror, "Error occured when save user info: " + ex.Message); return; } } else { CallClientFn("ShowMsg('invalidInput', '', false);"); } } else if ("1" == Mode) { newUser = UsersManager.GetModel(UserId.Value); bool changePwd = false; if ((newUser.Password != tbPWD.Text.Trim()) && !string.IsNullOrEmpty(tbPWD.Text.Trim())) { changePwd = true; } if (GetValue(ref newUser)) { if (!CheckBeforeSave(newUser)) { return; } try { // update current user info, without personalization info UsersManager.UpdateUserInfo(newUser, this.hiCurrLoanRep.Value, this.hiCurrGroup.Value); try { ServiceManager sm = new ServiceManager(); using (LP2ServiceClient service = sm.StartServiceClient()) { UpdateADUserRequest uReq = new UpdateADUserRequest(); ReqHdr hdr = new ReqHdr(); hdr.UserId = UserId.Value; uReq.hdr = hdr; uReq.AD_OU_Filter = this.lbPrefix.Text; uReq.AD_User = new LP_Service.User(); uReq.AD_User.Username = this.tbUserName.Text; uReq.AD_User.Firstname = this.tbFirstName.Text; uReq.AD_User.Lastname = this.tbLastName.Text; uReq.AD_User.Email = this.tbEmail.Text; uReq.AD_User.Enabled = this.ckbEnabled.Checked; if (changePwd) { uReq.AD_User.Password = this.tbPWD.Text; } else { uReq.AD_User.Password = string.Empty; } uReq.Command = UserMgrCommandType.UpdateUser; UpdateADUserResponse uResponse; uResponse = service.UpdateADUser(uReq); if (!uResponse.hdr.Successful) { PageCommon.AlertMsg(this, "Failed to update user info in AD, reason: " + uResponse.hdr.StatusInfo); CallClientFn("closeBox(true, false);"); LPLog.LogMessage(LogType.Logerror, "Failed to update user info to AD. UserID: " + UserId.ToString() + ", Error: " + uResponse.hdr.StatusInfo); return; } } } catch (System.ServiceModel.EndpointNotFoundException ee) { LPLog.LogMessage(ee.Message); CallClientFn("closeBox(true, false);"); PageCommon.AlertMsg(this, "Failed to update user info in AD, reason: User Manager is not running."); return; } catch (Exception ex) { PageCommon.AlertMsg(this, "Failed to update user info in AD, reason: " + ex.Message); CallClientFn("closeBox(true, false);"); LPLog.LogMessage(LogType.Logerror, "Error occured when update user info to AD: " + ex.Message); return; } CallClientFn("ShowMsg('saveSuccss', '', true, true, false);"); } catch (Exception ex) { PageCommon.AlertMsg(this, "Failed to save user info, reason: " + ex.Message); LPLog.LogMessage(LogType.Logerror, "Failed to save user info: " + ex.Message); return; } } else { CallClientFn("ShowMsg('invalidInput', '', false);"); } } }
/// <summary> /// Delete all user info when click "Delete" button /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnDelete_Click(object sender, EventArgs e) { bool bRessignSuccess = false; ServiceManager sm1 = new ServiceManager(); using (LP2ServiceClient service = sm1.StartServiceClient()) { ReassignLoanRequest req = new ReassignLoanRequest(); req.hdr = new ReqHdr(); req.hdr.SecurityToken = "SecurityToken"; //todo:check dummy data req.hdr.UserId = CurrUser.iUserID; // get all loans assigned to this user DataSet dsUserLoan = LoanTeamManager.GetUserLoan(UserId.Value); int nReassignUserId = 0; if (!int.TryParse(this.hiReassignUserId.Value, out nReassignUserId)) { nReassignUserId = 0; } if (null != dsUserLoan && dsUserLoan.Tables.Count > 0 && dsUserLoan.Tables[0].Rows.Count > 0) { List <ReassignUserInfo> uList = new List <ReassignUserInfo>(); Model.Users userToDelete = UsersManager.GetModel(UserId.Value); ReassignUserInfo uInfo = null; foreach (DataRow drUserLoan in dsUserLoan.Tables[0].Rows) { uInfo = new ReassignUserInfo(); uInfo.FileId = int.Parse(string.Format("{0}", drUserLoan["FileId"])); uInfo.RoleId = int.Parse(string.Format("{0}", drUserLoan["RoleId"])); uInfo.NewUserId = nReassignUserId; uList.Add(uInfo); } req.reassignUsers = uList.ToArray(); ReassignLoanResponse respone = null; try { respone = service.ReassignLoan(req); if (respone.hdr.Successful) { bool st = true; int fileId = 0; int newUserId = 0; int roleId = 0; int requester = req.hdr.UserId; foreach (ReassignUserInfo u in req.reassignUsers) { fileId = u.FileId; newUserId = u.NewUserId; roleId = u.RoleId; st = LPWeb.BLL.WorkflowManager.ReassignLoan(fileId, newUserId, UserId.Value, roleId, requester); } bRessignSuccess = true; } else { PageCommon.AlertMsg(this, "Failed to reassign loan, reason:" + respone.hdr.StatusInfo); CloseMe(true, true); return; } } catch (System.ServiceModel.EndpointNotFoundException ex) { LPLog.LogMessage(ex.Message); PageCommon.AlertMsg(this, "Failed to reassign loan, reason: User Manager is not running."); CloseMe(true, true); } catch (Exception exception) { LPLog.LogMessage(exception.Message); PageCommon.AlertMsg(this, string.Format("Failed to reassign loan, reason:{0}.", exception.Message)); CloseMe(true, true); } } else { bRessignSuccess = true; } if (bRessignSuccess) { UsersManager.DeleteUserInfo(UserId.Value, null, null, CurrUser.iUserID, nReassignUserId); LPLog.LogMessage(string.Format("User {0} deleted successfully.", this.tbUserName.Text)); CloseMe(true, true); try { ServiceManager sm = new ServiceManager(); using (LP2ServiceClient service2 = sm.StartServiceClient()) { UpdateADUserRequest uReq = new UpdateADUserRequest(); ReqHdr hdr = new ReqHdr(); hdr.UserId = UserId.Value; uReq.hdr = hdr; uReq.Command = UserMgrCommandType.DeleteUser; uReq.AD_OU_Filter = this.lbPrefix.Text; uReq.AD_User = new LP_Service.User(); uReq.AD_User.Username = this.tbUserName.Text; uReq.AD_User.Firstname = this.tbFirstName.Text; uReq.AD_User.Lastname = this.tbLastName.Text; uReq.AD_User.Email = this.tbEmail.Text; uReq.AD_User.Enabled = this.ckbEnabled.Checked; UpdateADUserResponse uResponse; uResponse = service2.UpdateADUser(uReq); if (!uResponse.hdr.Successful) { PageCommon.AlertMsg(this, "Failed to delete user in AD, reason:" + uResponse.hdr.StatusInfo); LPLog.LogMessage(LogType.Logerror, "Failed to delete user in AD. UserID: " + UserId.ToString()); } } } catch (System.ServiceModel.EndpointNotFoundException ee) { LPLog.LogMessage(ee.Message); PageCommon.AlertMsg(this, "Failed to delete user in AD, reason: User Manager is not running."); } catch (Exception ex) { PageCommon.AlertMsg(this, "Failed to delete user in AD, reason: " + ex.Message); LPLog.LogMessage(LogType.Logerror, "Error occured while trying to delete user in AD: " + ex.Message); } } } }
protected void btnSave_Click(object sender, EventArgs e) { Model.Users userInfo = UsersManager.GetModel(CurrUser.iUserID); try { if (null == userInfo) { LPLog.LogMessage(LogType.Logerror, string.Format("User Personalization - Settings: User with id {0} does not exist.", CurrUser.iUserID)); ClientFun("unknowerrmsg2", "alert('User does not exists, unknow error.');"); return; } if (!GetUserInfo(ref userInfo)) { ClientFun("invalidinputmsg", "alert('Invalid input!');"); return; } if (this.FileUpload1.HasFile) { string strMsg = ""; bool bIsValid = PageCommon.ValidateUpload(this, this.FileUpload1, 1024 * 1024 * 15, out strMsg, ".jpg", ".bmp", ".png", ".gif"); if (!bIsValid) { ClientFun("userPicInvalid", string.Format("alert('{0}');", strMsg)); return; } } string phone = this.txbPhone.Text.Trim(); userInfo.Phone = phone; userInfo.Fax = this.txbFax.Text.Trim(); userInfo.Cell = this.txbCell.Text.Trim(); userInfo.LicenseNumber = this.txbLicense.Text.Trim(); userInfo.NMLS = this.txbNMLS.Text.Trim(); userInfo.ExchangePassword = this.txbExchangPwd.Text.Trim(); if (userInfo.ExchangePassword == "" && !string.IsNullOrEmpty(this.tbPWD.Text)) { userInfo.ExchangePassword = this.tbPWD.Text.Trim(); } UsersManager.Update(userInfo); #region Save as UserLicense gdc CR43 if (!string.IsNullOrEmpty(hidLicenseNumberList.Value.Trim())) { try { List <Model.UserLicenses> ulList = new List <Model.UserLicenses>(); foreach (var item in hidLicenseNumberList.Value.Split(',')) { if (string.IsNullOrEmpty(item)) { continue; } Model.UserLicenses model = new Model.UserLicenses(); model.LicenseNumber = item; model.UserId = CurrUser.iUserID; ulList.Add(model); } BLL.UserLicenses ulBll = new BLL.UserLicenses(); ulBll.UpdatebatchByUserID(ulList); BindLicensesList(); } catch (Exception ex) { LPLog.LogMessage(ex.Message); PageCommon.AlertMsg(this, "Failed to Save User Licenses:" + ex.Message); return; } } #endregion if (!string.IsNullOrEmpty(this.tbPWD.Text)) { try { ServiceManager sm = new ServiceManager(); using (LP2ServiceClient service = sm.StartServiceClient()) { ReqHdr hdr; UpdateADUserRequest uReq = new UpdateADUserRequest(); hdr = new ReqHdr(); hdr.UserId = CurrUser.iUserID; uReq.hdr = hdr; uReq.Command = UserMgrCommandType.ChangePassword; uReq.AD_OU_Filter = this.hiPrefix.Value; uReq.AD_User = new LP_Service.User(); uReq.AD_User.Password = this.tbPWD.Text; uReq.AD_User.Username = this.hiUsername.Value; uReq.AD_User.Firstname = this.hiFirstName.Value; uReq.AD_User.Lastname = this.hiLastName.Value; uReq.AD_User.Email = this.lbEmail.Text; UpdateADUserResponse uResponse; uResponse = service.UpdateADUser(uReq); if (!uResponse.hdr.Successful) { PageCommon.AlertMsg(this, "Failed to update your password. Please make sure your new password meets the password policy requirements."); LPLog.LogMessage(LogType.Logerror, "Failed to change password in AD, username="******"Failed to change password in AD, reason: User Manager is not running."); return; } catch (Exception ex) { PageCommon.AlertMsg(this, "Failed to change password in AD, exception info: " + ex.Message); LPLog.LogMessage(LogType.Logerror, "Failed to change password in AD, username="******", Exception:" + ex.Message); return; } } ClientFun("sucsmsg", "alert('Saved!');"); } catch (Exception ex) { PageCommon.AlertMsg(this, "Failed to save user Personalization - Settings info, reason:" + ex.Message); LPLog.LogMessage(LogType.Logerror, "Failed to save user Personalization - Settings info: " + ex.Message); return; } }
protected void btnSave_Click(object sender, EventArgs e) { #region 获取用户输入 string sMandatoryPricePoint = this.txtMandatory_Points.Text.Trim(); string sBestEffortPricePoint = this.txtBestEffortPrice_Points.Text.Trim(); //string sCommissionTotal = this.txtCommissionTotal_Amount.Text.Trim(); //string sCommissionTotal_Points = this.txtCommissionTotal_Points.Text.Trim(); string sCommissionTotal = Request.Form["txtCommissionTotal_Amount"].Trim(); string sCommissionTotal_Points = Request.Form["txtCommissionTotal_Points"].Trim(); string sLenderCredit = Request.Form["txtLenderCredit_Amount"].Trim(); string sLenderCreditAmount = this.txtLenderCredit_Amount.Text.Trim(); string sLenderCreditPoint = this.txtLenderCredit_Points.Text.Trim(); string sLPMIPoint = Request.Form["txtLPMI_Points"].Trim(); string sBestEffortPriceToLOPoint = Request.Form["txtBestEffortPriceToLO_Points"].Trim(); string sHedgeCostPoint = Request.Form["txtHedgeCost_Points"].Trim(); string sCostOnSalePoint = Request.Form["txtCostOnSale_Points"].Trim(); string sOriginationPts = Request.Form["txtOriginationPts_Points"].Trim(); string sDiscountPts = Request.Form["txtDiscountPts_Points"].Trim(); string sExtension1Point = this.txtExtension1_Points.Text.Trim(); string sExtension2Point = this.txtExtension2_Points.Text.Trim(); string sCompensationPlan = this.ddlCompensationPlan.SelectedValue; string sLockOption = this.ddlLockOption.SelectedItem.Text; string sMIOption = this.ddlMIOption.SelectedItem.Text.Trim(); string sFirsTimeHomebuyer = this.ddlFirsTimeHomebuyer.SelectedValue; string sEscrowTaxes = this.ddlEscrowTaxes.SelectedValue; string sEscrowInsurance = this.ddlEscrowInsurance.SelectedValue; string sPrice = this.txtPrice.Text.Trim(); #endregion #region LoanProfit fields: Price, Lender Credit and Compensation Plan decimal tempDecimal = 0; LoanProfit LoanProfitMgr = new LoanProfit(); LPWeb.Model.LoanProfit loanProfitInfo = LoanProfitMgr.GetModel(this.iFileId); bool insert = false; if (loanProfitInfo == null) { loanProfitInfo = new LPWeb.Model.LoanProfit(); insert = true; } loanProfitInfo.FileId = this.iFileId; loanProfitInfo.CompensationPlan = sCompensationPlan; if (!string.IsNullOrEmpty(sLenderCredit)) { decimal.TryParse(sLenderCredit, out tempDecimal); } loanProfitInfo.LenderCredit = tempDecimal; tempDecimal = 0; if (!string.IsNullOrEmpty(sPrice)) { decimal.TryParse(sPrice, out tempDecimal); } loanProfitInfo.Price = tempDecimal; if (insert) { LoanProfitMgr.Add(loanProfitInfo); } else { LoanProfitMgr.Update(loanProfitInfo); } #endregion #region Mandatory/Final Price LoanPointFields LoanPointFieldsMgr = new LoanPointFields(); DataTable PointFieldInfo = LoanPointFieldsMgr.GetPointFieldInfo(this.iFileId, 11604); if (PointFieldInfo.Rows.Count > 0) { #region update LoanPointFieldsMgr.UpdatePointFieldValue(this.iFileId, 11604, sMandatoryPricePoint); #endregion } else { #region insert this.AddLoanPointField(this.iFileId, 11604, sMandatoryPricePoint); #endregion } #endregion #region Best Effort Price PointFieldInfo = LoanPointFieldsMgr.GetPointFieldInfo(this.iFileId, 12492); if (PointFieldInfo.Rows.Count > 0) { #region update LoanPointFieldsMgr.UpdatePointFieldValue(this.iFileId, 12492, sBestEffortPricePoint); #endregion } else { #region insert this.AddLoanPointField(this.iFileId, 12492, sBestEffortPricePoint); #endregion } #endregion #region Commission Total // 保存Commission Total %,不再保存Commission Total $ // LW 08/30/2013 Changed Commission Total % 14153 --> 6177 PointFieldInfo = LoanPointFieldsMgr.GetPointFieldInfo(this.iFileId, 6177); if (PointFieldInfo.Rows.Count > 0) { #region update LoanPointFieldsMgr.UpdatePointFieldValue(this.iFileId, 6177, sCommissionTotal_Points); #endregion } else { #region insert this.AddLoanPointField(this.iFileId, 6177, sCommissionTotal_Points); #endregion } #endregion #region Lender Credit // LW 08/30/2013 Changed Lender Credit 2284 --> 812 DataTable LenderCreditInfo = LoanPointFieldsMgr.GetPointFieldInfo(this.iFileId, 812); if (LenderCreditInfo.Rows.Count > 0) { #region update LoanPointFieldsMgr.UpdatePointFieldValue(this.iFileId, 812, sLenderCreditAmount); #endregion } else { #region insert this.AddLoanPointField(this.iFileId, 812, sLenderCreditAmount); #endregion } #endregion #region LPMI PointFieldInfo = LoanPointFieldsMgr.GetPointFieldInfo(this.iFileId, 12973); if (PointFieldInfo.Rows.Count > 0) { #region update LoanPointFieldsMgr.UpdatePointFieldValue(this.iFileId, 12973, sLPMIPoint); #endregion } else { #region insert this.AddLoanPointField(this.iFileId, 12973, sLPMIPoint); #endregion } #endregion #region Best Effort Price to LO // only update Best Effort Price to LO %, not Best Effort Price to LO $ PointFieldInfo = LoanPointFieldsMgr.GetPointFieldInfo(this.iFileId, 12495); if (PointFieldInfo.Rows.Count > 0) { #region update LoanPointFieldsMgr.UpdatePointFieldValue(this.iFileId, 12495, sBestEffortPriceToLOPoint); #endregion } else { #region insert this.AddLoanPointField(this.iFileId, 12495, sBestEffortPriceToLOPoint); #endregion } #endregion #region Hedge Cost PointFieldInfo = LoanPointFieldsMgr.GetPointFieldInfo(this.iFileId, 12974); if (PointFieldInfo.Rows.Count > 0) { #region update LoanPointFieldsMgr.UpdatePointFieldValue(this.iFileId, 12974, sHedgeCostPoint); #endregion } else { #region insert this.AddLoanPointField(this.iFileId, 12974, sHedgeCostPoint); #endregion } #endregion #region Cost on sale PointFieldInfo = LoanPointFieldsMgr.GetPointFieldInfo(this.iFileId, 12975); if (PointFieldInfo.Rows.Count > 0) { #region update LoanPointFieldsMgr.UpdatePointFieldValue(this.iFileId, 12975, sCostOnSalePoint); #endregion } else { #region insert this.AddLoanPointField(this.iFileId, 12975, sCostOnSalePoint); #endregion } #endregion #region Origination Pts PointFieldInfo = LoanPointFieldsMgr.GetPointFieldInfo(this.iFileId, 11243); if (PointFieldInfo.Rows.Count > 0) { #region update LoanPointFieldsMgr.UpdatePointFieldValue(this.iFileId, 11243, sOriginationPts); #endregion } else { #region insert this.AddLoanPointField(this.iFileId, 11243, sOriginationPts); #endregion } #endregion #region Discount Pts PointFieldInfo = LoanPointFieldsMgr.GetPointFieldInfo(this.iFileId, 11241); if (PointFieldInfo.Rows.Count > 0) { #region update LoanPointFieldsMgr.UpdatePointFieldValue(this.iFileId, 11241, sDiscountPts); #endregion } else { #region insert this.AddLoanPointField(this.iFileId, 11241, sDiscountPts); #endregion } #endregion #region Extension1 PointFieldInfo = LoanPointFieldsMgr.GetPointFieldInfo(this.iFileId, 12976); if (PointFieldInfo.Rows.Count > 0) { #region update LoanPointFieldsMgr.UpdatePointFieldValue(this.iFileId, 12976, sExtension1Point); #endregion } else { #region insert this.AddLoanPointField(this.iFileId, 12976, sExtension1Point); #endregion } #endregion #region Extension2 PointFieldInfo = LoanPointFieldsMgr.GetPointFieldInfo(this.iFileId, 12977); if (PointFieldInfo.Rows.Count > 0) { #region update LoanPointFieldsMgr.UpdatePointFieldValue(this.iFileId, 12977, sExtension2Point); #endregion } else { #region insert this.AddLoanPointField(this.iFileId, 12977, sExtension2Point); #endregion } #endregion #region Lock Option LoanLocks LoanLocksMgr = new LoanLocks(); if (this.LoanLocksInfo.Rows.Count > 0) { #region update LoanLocksMgr.UpdateLockOption(this.iFileId, sLockOption); #endregion } else { #region insert #region Build Model LPWeb.Model.LoanLocks LoanLocksModel = new LPWeb.Model.LoanLocks(); LoanLocksModel.FileId = this.iFileId; LoanLocksModel.LockOption = sLockOption; #endregion LoanLocksMgr.Add(LoanLocksModel); #endregion } // delete all the options first then add the one that's selected LoanPointFieldsMgr.DeletePointFields(this.iFileId, " PointFieldId in (6100, 6101, 11438, 12545)"); int iPointFieldId = 0; int.TryParse(ddlLockOption.SelectedValue, out iPointFieldId); if (iPointFieldId > 0) { this.AddLoanPointField(this.iFileId, iPointFieldId, "X"); } #endregion #region MI Option Loans LoansMgr = new Loans(); LoansMgr.UpdateMIOption(this.iFileId, sMIOption); //LoanPointFieldsMgr.DeletePointFields(this.iFileId, " PointFieldId=4018"); //this.AddLoanPointField(iFileId, 4018, sMIOption); LoanPointFieldsMgr.UpdatePointFieldValue(this.iFileId, 4018, sMIOption); #endregion #region Firs Time Homebuyer if (!string.IsNullOrEmpty(sFirsTimeHomebuyer)) { if (sFirsTimeHomebuyer.ToUpper().Contains("Y")) { LoansMgr.UpdateFirstTimeHomeBuyer(this.iFileId, true); } } else { LoansMgr.UpdateFirstTimeHomeBuyer(this.iFileId, false); } LoanPointFieldsMgr.DeletePointFields(this.iFileId, " PointFieldId=7505"); string s7505_FirstTimeHomeBuyer = "X"; this.AddLoanPointField(iFileId, 7505, s7505_FirstTimeHomeBuyer); #endregion #region Escrow Taxes PointFieldInfo = LoanPointFieldsMgr.GetPointFieldInfo(this.iFileId, 4003); LoanPointFieldsMgr.DeletePointFields(this.iFileId, " PointFieldId=4003"); if (sEscrowTaxes.Trim().ToUpper() == "Y") { this.AddLoanPointField(iFileId, 4003, "X"); } #endregion #region Escrow Insurance LoanPointFieldsMgr.DeletePointFields(this.iFileId, " PointFieldId=4004"); if (sEscrowInsurance.Trim().ToUpper() == "Y") { this.AddLoanPointField(iFileId, 4004, "X"); } #endregion #region Call WCF UpdateLockInfo ServiceManager sm = new ServiceManager(); using (LP2ServiceClient service = sm.StartServiceClient()) { UpdateLockInfoRequest req = new UpdateLockInfoRequest(); req.hdr = new ReqHdr(); req.hdr.SecurityToken = "SecurityToken"; //todo:check dummy data req.hdr.UserId = this.CurrUser.iUserID; req.FileId = this.iFileId; UpdateLockInfoResponse respone = null; try { respone = service.UpdateLockInfo(req); if (respone.hdr.Successful == false) { PageCommon.WriteJsEnd(this, "Save successfully, but failed to invoke UpdateLockInfo wcf service, reason:" + respone.hdr.StatusInfo, PageCommon.Js_RefreshSelf); } } catch (System.ServiceModel.EndpointNotFoundException) { string sExMsg = string.Format("Save successfully, but exception happened when Sync Point File (FileID={0}): {1}", this.iFileId, "Point Manager is not running."); LPLog.LogMessage(LogType.Logerror, sExMsg); PageCommon.WriteJsEnd(this, sExMsg, PageCommon.Js_RefreshSelf); } catch (Exception ex) { string sExMsg = string.Format("Save successfully, but exception happened when Sync Point File (FileID={0}): {1}", this.iFileId, ex.Message); LPLog.LogMessage(LogType.Logerror, sExMsg); PageCommon.WriteJsEnd(this, sExMsg, PageCommon.Js_RefreshSelf); } } #endregion // success PageCommon.WriteJsEnd(this, "Save successfully.", PageCommon.Js_RefreshSelf); }
/// <summary> /// 加载card信息 /// </summary> public void LoadInfo() { try { ServiceManager sm = new ServiceManager(); using (LP2ServiceClient client = sm.StartServiceClient()) { #region No use //var creditCardInfo = new LP_Service.GetCreditCardRequest(); //creditCardInfo.hdr = new LP_Service.ReqHdr(); //creditCardInfo.hdr.UserId = loginUser.iUserID; //var rsp = client.GetCreditCard(ref creditCardInfo); //if (rsp.hdr.Successful) //{ // hfCardID.Value = creditCardInfo.Card_ID; // txbCardNumber.Text = creditCardInfo.Card_Number; // txbNameonCard.Text = creditCardInfo.Card_First_Name + " " + creditCardInfo.Card_Last_Name; // txbCardExpiration.Text = creditCardInfo.Card_Exp_Month.ToString() + "/" + creditCardInfo.Card_Exp_Year; // if (creditCardInfo.Card_SIC != "***") // { // txbCardCSCcode.Text = creditCardInfo.Card_SIC; // } // else //{ // txbCardCSCcode.Text = ""; //} //ddlCardType.SelectedValue = creditCardInfo.Card_Type.ToString(); //switch (creditCardInfo.Card_Type) //{ // case CreditCardType.VISA: // ddlCardType.SelectedValue = "0"; // break; // case CreditCardType.MasterCard: // ddlCardType.SelectedValue = "1"; // break; // case CreditCardType.Amex: // ddlCardType.SelectedValue = "2"; // break; // case CreditCardType.Discover: // ddlCardType.SelectedValue = "3"; // break; // default: ddlCardType.SelectedValue = ""; // break; //} #endregion txbCardCSCcode.Text = ""; btnAddBalance.Enabled = true; var reqBalance = new LP_Service.GetUserAccountBalanceRequest(); reqBalance.hdr = new LP_Service.ReqHdr(); reqBalance.hdr.UserId = loginUser.iUserID; var rspBalance = client.GetUserAccountBalance(reqBalance); if (rspBalance.hdr.Successful) { txbBalance.Text = rspBalance.Balance.ToString("N2"); } #region No use //} //else //{ // btnAddBalance.Enabled = false; //} #endregion } } catch (Exception ex) { PageCommon.AlertMsg(this, "Load error:" + ex.Message); } }
private string SendLSREmail(int ContactID, string ContactEmail, string ContactName, int UserID, string UserEmail, string UserName, bool External, Dictionary <string, byte[]> Attachments) { string ReturnMessage = string.Empty; ServiceManager sm = new ServiceManager(); LPWeb.BLL.Loans _bLoan = new LPWeb.BLL.Loans(); using (LP2ServiceClient service = sm.StartServiceClient()) { SendLSRRequest req = new SendLSRRequest(); req.hdr = new ReqHdr(); req.hdr.SecurityToken = "SecurityToken"; //todo:check dummy data req.hdr.UserId = this.CurrUser.iUserID; req.FileId = iLoanID; req.TemplReportId = GetTemplReportId(); req.External = External; req.Attachments = Attachments; if (ContactID > 0) { req.ToContactId = ContactID; req.ToContactEmail = ContactEmail; req.ToContactUserName = ContactName; } if (UserID > 0) { req.ToUserId = UserID; req.ToUserEmail = UserEmail; req.ToUserUserName = UserName; } req.LoanAutoEmailid = SaveLoanAutoEmailid(req.FileId, req.TemplReportId, req.ToContactId, req.ToUserId, req.External); SendLSRResponse respone = null; try { respone = service.SendLSR(req); if (respone.hdr.Successful) { ReturnMessage = string.Empty; } else { ReturnMessage = respone.hdr.StatusInfo; } } catch (System.ServiceModel.EndpointNotFoundException) { string sExMsg = string.Format("Failed to send email, reason: Email Manager is not running."); LPLog.LogMessage(LogType.Logerror, sExMsg); ReturnMessage = sExMsg; } catch (Exception ex) { string sExMsg = string.Format("Failed to send email, error: {0}", ex.Message); LPLog.LogMessage(LogType.Logerror, sExMsg); ReturnMessage = sExMsg; } return(ReturnMessage); } }
protected void btnSave_Click(object sender, EventArgs e) { string err = ""; try { if (tbxNote.Text.Trim() == "") { PageCommon.AlertMsg(this, "Please input the note!"); return; } //if (tbxNote.Text.Trim().Length > 500) //{ // PageCommon.AlertMsg(this, "The note length must be less than 500 characters!"); // return; //} int contactId = int.Parse(hfdContactId.Value); var curUser = new LoginUser(); string senderName = curUser.sFirstName + " " + curUser.sLastName; var req = new AddNoteRequest { FileId = contactId, Created = DateTime.Now, Note = tbxNote.Text.Trim(), Sender = senderName, hdr = new ReqHdr { UserId = curUser.iUserID } }; ServiceManager sm = new ServiceManager(); using (LP2ServiceClient client = sm.StartServiceClient()) { //AddNoteResponse res = client.AddNote(req); //bool exported = !res.hdr.Successful ? false : true; bool exported = true; var model = new Model.ProspectNotes { Note = tbxNote.Text, ContactId = contactId, Created = DateTime.Now, Sender = senderName, Exported = exported }; var bllProspectNotes = new ProspectNotes(); bllProspectNotes.Add(model); //if (!exported) //{ // PageCommon.WriteJs(this, res.hdr.StatusInfo, "parent.ClosePopupWindow();"); //} //else //{ PageCommon.WriteJs(this, "Add note successfully.", "parent.ClosePopupWindow();"); //PageCommon.WriteJsEnd(this, "Add note Failed.", PageCommon.Js_RefreshSelf); //} } } catch (System.ServiceModel.EndpointNotFoundException ee) { LPLog.LogMessage(ee.Message); PageCommon.AlertMsg(this, "Failed to add note, reason: Point Manager is not running."); } catch (Exception exception) { err = "Failed to add note, reason:" + exception.Message; LPLog.LogMessage(err); PageCommon.WriteJsEnd(this, err, PageCommon.Js_RefreshSelf); } }
private string ImportLoansAndSubmitLoan(int iLoanID, string sProgram, string sType) { string ReturnMessage = string.Empty; ServiceManager sm = new ServiceManager(); int[] FileIDs = new int[1]; FileIDs.SetValue(iLoanID, 0); using (LP2ServiceClient service = sm.StartServiceClient()) { ImportLoansRequest req = new ImportLoansRequest(); req.hdr = new ReqHdr(); req.hdr.SecurityToken = "SecurityToken"; //todo:check dummy data req.hdr.UserId = this.CurrUser.iUserID; req.FileIds = FileIDs; ImportLoansResponse respone = null; try { respone = service.ImportLoans(req); if (respone.hdr.Successful) { ReturnMessage = string.Empty; } else { ReturnMessage = respone.hdr.StatusInfo; } } catch (System.ServiceModel.EndpointNotFoundException) { string sExMsg = string.Format("Failed to ImportLoans, reason: ImportLoans Manager is not running."); LPLog.LogMessage(LogType.Logerror, sExMsg); return(ReturnMessage); } catch (Exception ex) { string sExMsg = string.Format("Failed toImportLoans, error: {0}", ex.Message); LPLog.LogMessage(LogType.Logerror, sExMsg); return(ReturnMessage); } DT_SubmitLoanRequest reqDT = new DT_SubmitLoanRequest(); reqDT.hdr = new ReqHdr(); reqDT.hdr.SecurityToken = "SecurityToken"; //todo:check dummy data reqDT.hdr.UserId = this.CurrUser.iUserID; reqDT.FileId = iLoanID; reqDT.Loan_Program = sProgram; reqDT.Originator_Type = sType; DT_SubmitLoanResponse responeDT = null; try { responeDT = service.DTSubmitLoan(reqDT); if (responeDT.hdr.Successful) { ReturnMessage = string.Empty; } else { ReturnMessage = responeDT.hdr.StatusInfo; } } catch (System.ServiceModel.EndpointNotFoundException) { string sExMsg = string.Format("Failed to ImportLoans, reason: ImportLoans Manager is not running."); LPLog.LogMessage(LogType.Logerror, sExMsg); return(ReturnMessage); } catch (Exception ex) { string sExMsg = string.Format("Failed to ImportLoans, error: {0}", ex.Message); LPLog.LogMessage(LogType.Logerror, sExMsg); return(ReturnMessage); } try { LoanActivities _bLoanActivities = new LoanActivities(); Model.LoanActivities _mLoanActivities = new Model.LoanActivities(); _mLoanActivities.FileId = iLoanID; _mLoanActivities.UserId = this.CurrUser.iUserID; _mLoanActivities.ActivityName = "The loan has been submitted to DataTrac by " + this.CurrUser.sFullName; _mLoanActivities.ActivityTime = DateTime.Now; int iNew = _bLoanActivities.Add(_mLoanActivities); } catch (Exception ex) { string sExMsg = string.Format("Failed to Update LoanActivities, error: {0}", ex.Message); LPLog.LogMessage(LogType.Logerror, sExMsg); return(ReturnMessage); } return(ReturnMessage); } }
/// <summary> /// 发送邮件(旧发送方式) /// </summary> public void SendEmailOld() { LoginUser CurrentUser = new LoginUser(); string Token = Request.QueryString["Token"] != null ? Request.QueryString["Token"].ToString() : ""; LPWeb.BLL.Email_AttachmentsTemp bllEmailAttachTemp = new Email_AttachmentsTemp(); var errMsg = string.Empty; //遍历所有模板 发送邮件 foreach (var iEmailTemplateID in iEmailTemplateIDList) { string sEmailTemplateName = string.Empty; int[] ToUserIDArray = null; int[] ToContactIDArray = null; string[] ToEmailAddrArray = null; int[] CCUserIDArray = null; int[] CCContactIDArray = null; string[] CCEmailAddrArray = null; Dictionary <string, byte[]> Attachments = new Dictionary <string, byte[]>(); #region Attachments var ds = bllEmailAttachTemp.GetListWithFileImage(iEmailTemplateID, Token); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { foreach (DataRow item in ds.Tables[0].Rows) { try { Attachments.Add(item["Name"].ToString() + "." + item["FileType"].ToString(), (byte[])item["FileImage"]); } catch { } } } #endregion #region use To and CC of email template #region 获取Email Template的Recipient(s) Template_Email EmailTemplateManager = new Template_Email(); DataTable RecipientList = EmailTemplateManager.GetRecipientList(iEmailTemplateID); var emailTemplatemodel = EmailTemplateManager.GetModel(iEmailTemplateID); if (emailTemplatemodel != null) { sEmailTemplateName = emailTemplatemodel.Name; } #endregion #region 获取Loan Team string sSql = "select * from LoanTeam where FileId = " + this.iLoanID; DataTable LoanTeamList = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSql); #endregion #region 获取Contacts string sSql2 = "select * from LoanContacts where FileId = " + this.iLoanID; DataTable ContactList = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSql2); #endregion Collection <Int32> ToUserIDs = new Collection <int>(); Collection <Int32> ToContactIDs = new Collection <int>(); Collection <String> ToEmailList = new Collection <String>(); Collection <Int32> CCUserIDs = new Collection <int>(); Collection <Int32> CCContactIDs = new Collection <int>(); Collection <String> CCEmailList = new Collection <String>(); #region To DataRow[] ToRecipient = RecipientList.Select("RecipientType='To'"); if (ToRecipient.Length > 0) { string sEmailList_To = ToRecipient[0]["EmailAddr"].ToString(); string sContactList_To = ToRecipient[0]["ContactRoles"].ToString(); string sUserRoleList_To = ToRecipient[0]["UserRoles"].ToString(); string sTaskOwner = ToRecipient[0]["TaskOwner"].ToString(); #region Emails if (sEmailList_To != string.Empty) { string[] EmailArray_To = sEmailList_To.Split(';'); foreach (string sEmailTo in EmailArray_To) { ToEmailList.Add(sEmailTo); } } #endregion #region User IDs if (sUserRoleList_To != string.Empty) { string[] UserRoleArray_To = sUserRoleList_To.Split(';'); foreach (string sUserRoleIDTo in UserRoleArray_To) { int iUserRoleIDTo = Convert.ToInt32(sUserRoleIDTo); DataRow[] LoanTeamRows = LoanTeamList.Select("RoleId=" + iUserRoleIDTo); foreach (DataRow LoanTeamRow in LoanTeamRows) { int iUserID = Convert.ToInt32(LoanTeamRow["UserId"]); ToUserIDs.Add(iUserID); } } } #endregion #region Contact IDs if (sContactList_To != string.Empty) { string[] ContactArray_To = sContactList_To.Split(';'); foreach (string sContactIDTo in ContactArray_To) { int iContactRoleIDTo = Convert.ToInt32(sContactIDTo); DataRow[] ContactRows = ContactList.Select("ContactRoleId=" + iContactRoleIDTo); foreach (DataRow ContactRow in ContactRows) { int iContactID = Convert.ToInt32(ContactRow["ContactId"]); ToContactIDs.Add(iContactID); } } } #endregion #region TaskOwner if ((sTaskOwner != string.Empty) && (sTaskOwner != null)) { if (sTaskOwner == "True") { string sSql_LoanTasks = "select Owner from LoanTasks where LoanTaskId=" + this.iTaskID; DataTable LoanTasks_List = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSql_LoanTasks); string sOwnerId = LoanTasks_List.Rows[0]["Owner"].ToString(); if ((sOwnerId != string.Empty) && (sOwnerId != null)) { int iOwnerId = Convert.ToInt32(sOwnerId); string sSql_Users = "select EmailAddress, LastName, FirstName from Users where UserId=" + iOwnerId; DataTable Users_List = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSql_Users); string Owner_EmailAddress = Users_List.Rows[0]["EmailAddress"].ToString(); if ((Owner_EmailAddress != string.Empty) && (Owner_EmailAddress != null)) { ToUserIDs.Add(iOwnerId); ToEmailList.Add(Owner_EmailAddress); } } } } #endregion } #endregion #region CC DataRow[] CCRecipient = RecipientList.Select("RecipientType='CC'"); if (CCRecipient.Length > 0) { string sEmailList_CC = CCRecipient[0]["EmailAddr"].ToString(); string sContactList_CC = CCRecipient[0]["ContactRoles"].ToString(); string sUserRoleList_CC = CCRecipient[0]["UserRoles"].ToString(); #region Emails if (sEmailList_CC != string.Empty) { string[] EmailArray_CC = sEmailList_CC.Split(';'); foreach (string sEmailCC in EmailArray_CC) { CCEmailList.Add(sEmailCC); } } #endregion #region User IDs if (sUserRoleList_CC != string.Empty) { string[] UserRoleArray_CC = sUserRoleList_CC.Split(';'); foreach (string sUserRoleIDCC in UserRoleArray_CC) { int iUserRoleIDCC = Convert.ToInt32(sUserRoleIDCC); DataRow[] LoanTeamRows = LoanTeamList.Select("RoleId=" + iUserRoleIDCC); foreach (DataRow LoanTeamRow in LoanTeamRows) { int iUserID = Convert.ToInt32(LoanTeamRow["UserId"]); CCUserIDs.Add(iUserID); } } } #endregion #region Contact IDs if (sContactList_CC != string.Empty) { string[] ContactArray_CC = sContactList_CC.Split(';'); foreach (string sContactIDCC in ContactArray_CC) { int iContactRoleIDCC = Convert.ToInt32(sContactIDCC); DataRow[] ContactRows = ContactList.Select("ContactRoleId=" + iContactRoleIDCC); foreach (DataRow ContactRow in ContactRows) { int iContactID = Convert.ToInt32(ContactRow["ContactId"]); CCContactIDs.Add(iContactID); } } } #endregion } #endregion if (ToUserIDs.Count == 0 && ToEmailList.Count == 0 && ToContactIDs.Count == 0 && CCUserIDs.Count == 0 && CCContactIDs.Count == 0 && CCEmailList.Count == 0) { errMsg = "No email recipient ! email template: " + sEmailTemplateName; break; } ToUserIDArray = new int[ToUserIDs.Count]; ToContactIDArray = new int[ToContactIDs.Count]; ToEmailAddrArray = new string[ToEmailList.Count]; CCUserIDArray = new int[CCUserIDs.Count]; CCContactIDArray = new int[CCContactIDs.Count]; CCEmailAddrArray = new string[CCEmailList.Count]; ToUserIDs.CopyTo(ToUserIDArray, 0); ToContactIDs.CopyTo(ToContactIDArray, 0); ToEmailList.CopyTo(ToEmailAddrArray, 0); CCUserIDs.CopyTo(CCUserIDArray, 0); CCContactIDs.CopyTo(CCContactIDArray, 0); CCEmailList.CopyTo(CCEmailAddrArray, 0); #endregion #region 调用API SendEmailResponse response = null; try { ServiceManager sm = new ServiceManager(); using (LP2ServiceClient service = sm.StartServiceClient()) { SendEmailRequest req = new SendEmailRequest(); req.EmailTemplId = iEmailTemplateID; req.FileId = this.iLoanID; //req.UserId = CurrentUser.iUserID; req.UserId = 0; req.ToEmails = ToEmailAddrArray; req.ToUserIds = ToUserIDArray; req.ToContactIds = ToContactIDArray; req.CCEmails = CCEmailAddrArray; req.CCUserIds = CCUserIDArray; req.CCContactIds = CCContactIDArray; req.hdr = new ReqHdr(); #region add Attachments req.Attachments = Attachments; #endregion response = service.SendEmail(req); } } catch (System.ServiceModel.EndpointNotFoundException) { string sExMsg = string.Format("Failed to send the email, reason: Email Manager is not running."); LPLog.LogMessage(LogType.Logerror, sExMsg); //PageCommon.WriteJsEnd(this, sExMsg, "window.parent.CloseDialog_SendCompletionEmail();"); response = new SendEmailResponse() { resp = new RespHdr() { Successful = false, StatusInfo = sExMsg } }; } catch (Exception ex) { string sExMsg = string.Format("Failed to send email, error: {0}", ex.Message); LPLog.LogMessage(LogType.Logerror, sExMsg); //PageCommon.WriteJsEnd(this, sExMsg, "window.parent.CloseDialog_SendCompletionEmail();"); response = new SendEmailResponse() { resp = new RespHdr() { Successful = false, StatusInfo = sExMsg } }; } #endregion if (response.resp.Successful != true) { //PageCommon.WriteJsEnd(this, "Failed to send completion email: " + response.resp.StatusInfo.Replace("'", "\'"), "window.parent.CloseDialog_SendCompletionEmail();"); errMsg = response.resp.StatusInfo.Replace("'", "\'"); break; } //有一个邮件发送错误都报发送错误并退出发送 } if (string.IsNullOrEmpty(errMsg)) { try { bllEmailAttachTemp.DeleteByToken(Token); } catch { } this.Response.Write("{\"ExecResult\":\"Success\",\"ErrorMsg\":\"\"}"); return; } else { this.Response.Write("{\"ExecResult\":\"Failed\",\"ErrorMsg\":\"" + errMsg + "\"}"); return; } }
protected void btnSave_Click(object sender, EventArgs e) { Model.Users userInfo = UsersManager.GetModel(CurrUser.iUserID); Model.UserPipelineColumns userPipelineCols = UserPipelineColsManager.GetModel(CurrUser.iUserID); Model.UserProspectColumns userProspectCols = UserProspectColsManager.GetModel(CurrUser.iUserID); Model.UserHomePref userHomePref = UserHomePrefManager.GetModel(CurrUser.iUserID); try { if (null == userInfo) { LPLog.LogMessage(LogType.Logerror, string.Format("User Personalization: User with id {0} does not exist.", CurrUser.iUserID)); ClientFun("unknowerrmsg2", "ShowMsg('unknowerror');"); return; } if (!GetUserInfo(ref userInfo)) { ClientFun("invalidinputmsg", "ShowMsg('invalidInput');"); return; } UsersManager.Update(userInfo); if (null == userPipelineCols) { userPipelineCols = new Model.UserPipelineColumns(); userPipelineCols.UserId = CurrUser.iUserID; GetUserPipelineColumnsInfo(ref userPipelineCols); UserPipelineColsManager.Add(userPipelineCols); } else { GetUserPipelineColumnsInfo(ref userPipelineCols); UserPipelineColsManager.Update(userPipelineCols); } if (null == userProspectCols) { userProspectCols = new Model.UserProspectColumns(); userProspectCols.UserId = CurrUser.iUserID; GetUserProspectColumnsInfo(ref userProspectCols); UserProspectColsManager.Add(userProspectCols); } else { GetUserProspectColumnsInfo(ref userProspectCols); UserProspectColsManager.Update(userProspectCols); } if (null == userHomePref) { userHomePref = new Model.UserHomePref(); userHomePref.UserId = CurrUser.iUserID; GetUserHomePrefInfo(ref userHomePref); UserHomePrefManager.Add(userHomePref); } else { GetUserHomePrefInfo(ref userHomePref); UserHomePrefManager.Update(userHomePref); } if (!string.IsNullOrEmpty(this.tbPWD.Text)) { try { ServiceManager sm = new ServiceManager(); using (LP2ServiceClient service = sm.StartServiceClient()) { ReqHdr hdr; UpdateADUserRequest uReq = new UpdateADUserRequest(); hdr = new ReqHdr(); hdr.UserId = CurrUser.iUserID; uReq.hdr = hdr; uReq.Command = UserMgrCommandType.ChangePassword; uReq.AD_OU_Filter = this.hiPrefix.Value; uReq.AD_User = new LP_Service.User(); uReq.AD_User.Password = this.tbPWD.Text; uReq.AD_User.Username = this.hiUsername.Value; uReq.AD_User.Firstname = this.hiFirstName.Value; uReq.AD_User.Lastname = this.hiLastName.Value; uReq.AD_User.Email = this.lbEmail.Text; UpdateADUserResponse uResponse; uResponse = service.UpdateADUser(uReq); if (!uResponse.hdr.Successful) { PageCommon.AlertMsg(this, "Failed to change password in AD, error info: " + uResponse.hdr.StatusInfo); LPLog.LogMessage(LogType.Logerror, "Failed to change password in AD, username="******"Failed to change password in AD, reason: User Manager is not running."); return; } catch (Exception ex) { PageCommon.AlertMsg(this, "Failed to change password in AD, exception info: " + ex.Message); LPLog.LogMessage(LogType.Logerror, "Failed to change password in AD, username="******", Exception:" + ex.Message); return; } } ClientFun("sucsmsg", "ShowMsg('savesuccess');"); } catch (Exception ex) { PageCommon.AlertMsg(this, "Failed to save user personalization info, reason:" + ex.Message); LPLog.LogMessage(LogType.Logerror, "Failed to save user personalization info: " + ex.Message); return; } }
protected void Page_Load(object sender, EventArgs e) { // json示例 // {"ExecResult":"Success","ErrorMsg":""} // {"ExecResult":"Failed","ErrorMsg":"错误信息"} int iFileID = 0; int iContactID = 0; int iContactRoleID = 0; int iCurrrentUserID = this.CurrUser.iUserID; #region 校验页面参数 bool bIsValid = PageCommon.ValidateQueryString(this, "FileID", QueryStringType.ID); if (bIsValid == false) { this.Response.Write("{\"ExecResult\":\"Failed\",\"ErrorMsg\":\"Missing required query string.\"}"); this.Response.End(); } string sFileID = this.Request.QueryString["FileID"]; iFileID = Convert.ToInt32(sFileID); bIsValid = PageCommon.ValidateQueryString(this, "ContactID", QueryStringType.ID); if (bIsValid == false) { this.Response.Write("{\"ExecResult\":\"Failed\",\"ErrorMsg\":\"Missing required query string.\"}"); this.Response.End(); } string sContactID = this.Request.QueryString["ContactID"]; iContactID = Convert.ToInt32(sContactID); bIsValid = PageCommon.ValidateQueryString(this, "ContactRoleID", QueryStringType.ID); if (bIsValid == false) { this.Response.Write("{\"ExecResult\":\"Failed\",\"ErrorMsg\":\"Missing required query string.\"}"); this.Response.End(); } string sContactRoleID = this.Request.QueryString["ContactRoleID"]; iContactRoleID = Convert.ToInt32(sContactRoleID); #endregion #region 调用ReassignContact ServiceManager sm = new ServiceManager(); using (LP2ServiceClient service = sm.StartServiceClient()) { #region Build ReassignContactRequest ReassignContactRequest req = new ReassignContactRequest(); req.hdr = new ReqHdr(); req.hdr.SecurityToken = "SecurityToken"; //todo:check dummy data req.hdr.UserId = this.CurrUser.iUserID; List <ReassignContactInfo> ContactList = new List <ReassignContactInfo>(); ReassignContactInfo ContactInfo = new ReassignContactInfo(); ContactInfo.FileId = iFileID; ContactInfo.ContactRoleId = iContactRoleID; ContactInfo.NewContactId = iContactID; ContactList.Add(ContactInfo); req.reassignContacts = ContactList.ToArray(); #endregion #region invoke ReassignContact bool bSuccess = false; string sError = string.Empty; try { ReassignContactResponse respone = service.ReassignContact(req); bSuccess = respone.hdr.Successful; if (bSuccess == false) { sError = "Failed to assign contact, reason:" + respone.hdr.StatusInfo; } } catch (System.ServiceModel.EndpointNotFoundException ex) { bSuccess = false; sError = "Failed to assign contact: Point Manager is not running."; LPLog.LogMessage(ex.Message); } catch (Exception exception) { bSuccess = false; sError = "Failed to assign contact. Exception: " + exception.Message; LPLog.LogMessage(exception.Message); } finally { if (bSuccess == false) { this.Response.Write("{\"ExecResult\":\"Failed\",\"ErrorMsg\":\"" + sError + "\"}"); this.Response.End(); } } #endregion } #endregion #region Reassign Loan Contact LPWeb.Model.LoanContacts lcModel = new LPWeb.Model.LoanContacts(); lcModel.FileId = iFileID; lcModel.ContactRoleId = iContactRoleID; lcModel.ContactId = iContactID; LPWeb.Model.LoanContacts oldlcModel = new LPWeb.Model.LoanContacts(); oldlcModel.FileId = iFileID; oldlcModel.ContactRoleId = 0; oldlcModel.ContactId = 0; LPWeb.BLL.LoanContacts LoanContacts1 = new LPWeb.BLL.LoanContacts(); LoanContacts1.Reassign(oldlcModel, lcModel, iCurrrentUserID); #endregion this.Response.Write("{\"ExecResult\":\"Success\",\"ErrorMsg\":\"\"}"); this.Response.End(); }
protected int CreateLoan(int iContactId, decimal LoanAmount, string Purpose) { int iFolderId = 0; LPWeb.Model.LoanDetails LoanDetailsModel = new LPWeb.Model.LoanDetails(); LoanDetailsModel.FileId = 0; LoanDetailsModel.FolderId = iFolderId; LoanDetailsModel.Status = "Prospect"; LoanDetailsModel.ProspectLoanStatus = "Active"; LoanDetailsModel.BoID = iContactId; LoanDetailsModel.CoBoID = 0; LoanDetailsModel.Created = DateTime.Now; LoanDetailsModel.CreatedBy = CurrUser.iUserID; LoanDetailsModel.Modifed = DateTime.Now; LoanDetailsModel.ModifiedBy = CurrUser.iUserID; LoanDetailsModel.LoanAmount = LoanAmount; LoanDetailsModel.EstCloseDate = null; LoanDetailsModel.Ranking = string.Empty; LoanDetailsModel.UserId = CurrUser.iUserID; string sLoanOfficerID = ddlLoanOfficer.SelectedValue; iLoanOfficerID = 0; if (sLoanOfficerID == "-1" || sLoanOfficerID == "-2") { //Nobody } else if (sLoanOfficerID == "0") { //Lead Routing Engine try { ServiceManager sm = new ServiceManager(); using (LP2ServiceClient client = sm.StartServiceClient()) { //invoke the WCF API GetNextLoanOfficer LR_GetNextLoanOfficerReq req = new LR_GetNextLoanOfficerReq(); req.LeadSource = ddlLeadSource.SelectedItem.Text; req.Purpose = Purpose; req.ReqHdr = new ReqHdr(); req.ReqHdr.UserId = CurrUser.iUserID; req.ReqHdr.SecurityToken = "SecurityToken"; LR_GetNextLoanOfficerResp response = client.LeadRouting_GetNextLoanofficer(req); if (response.RespHdr.Successful) { iLoanOfficerID = response.NextLoanOfficerID; } else { Company_Lead_Sources LeadSourceMgr = new Company_Lead_Sources(); DataTable SelLeadSourceList = LeadSourceMgr.GetList("LeadSourceID='" + ddlLeadSource.SelectedValue + "'").Tables[0]; if (SelLeadSourceList != null && SelLeadSourceList.Rows.Count > 0) { iLoanOfficerID = SelLeadSourceList.Rows[0]["DefaultUserId"] == DBNull.Value ? 0 : Convert.ToInt32(SelLeadSourceList.Rows[0]["DefaultUserId"]); } } } } catch (Exception ex) { Company_Lead_Sources LeadSourceMgr = new Company_Lead_Sources(); DataTable SelLeadSourceList = LeadSourceMgr.GetList("LeadSourceID='" + ddlLeadSource.SelectedValue + "'").Tables[0]; if (SelLeadSourceList != null && SelLeadSourceList.Rows.Count > 0) { iLoanOfficerID = SelLeadSourceList.Rows[0]["DefaultUserId"] == DBNull.Value ? 0 : Convert.ToInt32(SelLeadSourceList.Rows[0]["DefaultUserId"]); } } } else { iLoanOfficerID = Convert.ToInt32(sLoanOfficerID); } LoanDetailsModel.LoanOfficerId = iLoanOfficerID; LoanDetailsModel.Rate = null; LoanDetailsModel.Program = string.Empty; LoanDetailsModel.Purpose = Purpose; LoanDetailsModel.Lien = string.Empty; LoanDetailsModel.PropertyAddr = string.Empty; LoanDetailsModel.PropertyCity = string.Empty; LoanDetailsModel.PropertyState = string.Empty; LoanDetailsModel.PropertyZip = string.Empty; LoanDetailsModel.FileName = string.Empty; LoanDetailsModel.PropertyType = string.Empty; LoanDetailsModel.HousingStatus = string.Empty; LoanDetailsModel.IncludeEscrows = false; LoanDetailsModel.InterestOnly = false; LoanDetailsModel.RentAmount = 0; LoanDetailsModel.CoborrowerType = string.Empty; Loans LoansMgr = new Loans(); int iFileID = LoansMgr.LoanDetailSaveFileId(LoanDetailsModel); return(iFileID); }
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; #region 调用LP2Service try { // workflow api ServiceManager sm = new ServiceManager(); using (LP2ServiceClient service = sm.StartServiceClient()) { UpdateEstCloseDateRequest req = new UpdateEstCloseDateRequest(); req.FileId = Convert.ToInt32(sLoanID); req.NewDate = Convert.ToDateTime(sNewDate); req.hdr = new ReqHdr(); req.hdr.UserId = Convert.ToInt32(sLoginUserID); UpdateEstCloseDateResponse respone = service.UpdateEstCloseDate(req); if (respone.hdr.Successful == true) { sExecResult = "Success"; sErrorMsg = ""; } else { sExecResult = "Failed"; sErrorMsg = "Failed to change est. close date: " + respone.hdr.StatusInfo + "."; } } } catch (System.ServiceModel.EndpointNotFoundException ee) { sExecResult = "Failed"; sErrorMsg = "Failed to change est. close date."; PageCommon.AlertMsg(this, "Failed to change est. close date, reason: Point Manager is not running."); } catch (Exception ex) { sExecResult = "Failed"; sErrorMsg = "Failed to change est. close date."; } #endregion System.Threading.Thread.Sleep(1000); sErrorMsg = sErrorMsg.Replace(@"\", @"\\"); this.Response.Write("{\"ExecResult\":\"" + sExecResult + "\",\"ErrorMsg\":\"" + sErrorMsg + "\"}"); this.Response.End(); }
private bool Save() { #region get user input string sFirstName = this.txtFirstName.Text.Trim(); string sLastName = this.txtLastName.Text.Trim(); string sEmail = this.txtEmail.Text.Trim(); string sPhone = this.txtPhone.Text.Trim(); string sType = this.ddlType.SelectedValue; string sDOB = this.txtBirthday.Text.Trim(); if (!string.IsNullOrEmpty(sDOB)) { DateTime DOB; if (DateTime.TryParse(sDOB, out DOB) == false) { //PageCommon.AlertMsg(this, "Date of Birth is not a invalid date format."); PageCommon.WriteJsEnd(this, "Date of Birth is not a invalid date format.", PageCommon.Js_RefreshSelf); return(false); } } string sSSN = this.txtSSN.Text.Trim(); string sWorkflow = this.ddlWorkflow.SelectedValue; int iWflTempID = 0; int.TryParse(sWorkflow, out iWflTempID); string sMarketing = this.ddlMarketing.SelectedValue; // MailChimpList ID // Task Name string sTaskName = string.Empty; if (this.radTaskList.Checked == true) { if (this.ddlTaskList.SelectedValue == "-- select --") { sTaskName = string.Empty; } else { sTaskName = this.ddlTaskList.SelectedValue; } } else { sTaskName = this.txtTaskName.Text.Trim(); } // Due Date string sDueDate = this.txtDueDate.Text.Trim(); DateTime DueDate; if (sDueDate != string.Empty) { if (DateTime.TryParse(sDueDate, out DueDate) == false) { //PageCommon.AlertMsg(this, "Due Date is not a invalid date format."); PageCommon.WriteJsEnd(this, "Due Date is not a invalid date format.", PageCommon.Js_RefreshSelf); return(false); } DueDate = DateTime.Parse(sDueDate); } // Due Time string sDueTime = ddlDueTime_hour.Text + ":" + ddlDueTime_min.Text; //this.txtDueTime.Text.Trim(); DateTime DTN = DateTime.Now; string sDueTime_Span = null; TimeSpan DueTime = new TimeSpan(); if (sDueTime != string.Empty) { if (DateTime.TryParse(sDueTime, out DTN) == true) { sDueTime_Span = DTN.ToString("HH:mm"); if (TimeSpan.TryParse(sDueTime_Span, out DueTime) == false) { //PageCommon.AlertMsg(this, "Invalid Due Time format."); PageCommon.WriteJsEnd(this, "Invalid Due Time format.", PageCommon.Js_RefreshSelf); return(false); } } else { //PageCommon.AlertMsg(this, "Invalid Due Time format."); PageCommon.WriteJsEnd(this, "Invalid Due Time format.", PageCommon.Js_RefreshSelf); return(false); } } string sReminderUser = string.Empty; string sReminderUserID = string.Empty; int iReminderUserID = 0; string sReminderInterval = string.Empty; if (this.chkReminder.Checked == true) { sReminderUser = this.txtReminderUser.Text.Trim(); sReminderUserID = this.hdnReminderUserID.Value; iReminderUserID = Convert.ToInt32(sReminderUserID); sReminderInterval = this.ddlReminderInterval.SelectedValue; } //CR53 decimal loanAmount = string.IsNullOrEmpty(txtLoanAmount.Text) ? 0M : Convert.ToDecimal(txtLoanAmount.Text.Trim()); string purpose = ddlPurpose.Text.Trim() == "- select -" ? "" : ddlPurpose.Text; #endregion #region create contact/prospect and loan int iContactId = 0; try { iContactId = this.CreateContactAndProspect(sFirstName, sLastName, sEmail, sType, sPhone, sDOB, sSSN, this.CurrUser.iUserID, purpose); } catch (Exception ex) { //PageCommon.AlertMsg(this, "Failed to save contact and prospect."); PageCommon.WriteJsEnd(this, "Failed to save contact and prospect." + ex.Message, PageCommon.Js_RefreshSelf); return(false); } #endregion #region create loan //int iFileID = 0; try { iFileID = this.CreateLoan(iContactId, loanAmount, purpose); } catch (Exception ex) { //PageCommon.AlertMsg(this, "Failed to save loan info."); PageCommon.WriteJsEnd(this, "Failed to save loan info.", PageCommon.Js_RefreshSelf); return(false); } #endregion #region Apply LoanWflTempl if (iWflTempID > 0) { try { this.ApplyLoanWflTempl(iFileID, iWflTempID, this.CurrUser.iUserID); } catch (Exception ex) { //PageCommon.AlertMsg(this, "Failed to apply workflow template to loan."); PageCommon.WriteJsEnd(this, "Failed to apply workflow template to loan.", PageCommon.Js_RefreshSelf); return(false); } } #endregion #region GenerateWorkflow and get iCurrentLoanStageId int iCurrentLoanStageId = 0; if (iWflTempID > 0) { string sError; bool bResult = this.GenerateWorkflow(iFileID, iWflTempID, this.CurrUser.iUserID, out sError); if (bResult == false) { //PageCommon.AlertMsg(this, "Failed to generate workflow template: " + sError); PageCommon.WriteJsEnd(this, "Failed to generate workflow template: " + sError, PageCommon.Js_RefreshSelf); return(false); } System.Threading.Thread.Sleep(2000); // get current loan stage id iCurrentLoanStageId = LPWeb.BLL.WorkflowManager.GetCurrentLoanStageId(iFileID); } else if (!string.IsNullOrEmpty(sTaskName)) { iWflTempID = LPWeb.BLL.WorkflowManager.GetDefaultWorkflowTemplate("Prospect"); if (iWflTempID < 1) { iCurrentLoanStageId = LPWeb.BLL.WorkflowManager.GenerateDefaultLoanStages(iFileID, "Prospect"); } } #endregion #region Create Task and Reminder if (!string.IsNullOrEmpty(sTaskName)) { #region create task if (iCurrentLoanStageId < 0) { //PageCommon.AlertMsg(this, "There is no loan stage available."); PageCommon.WriteJsEnd(this, "There is no loan stage available.", PageCommon.Js_RefreshSelf); return(false); } int iLoanTaskId = 0; try { iLoanTaskId = this.CreateLoanTask(iFileID, sTaskName, this.CurrUser.iUserID, sDueDate, sDueTime, iCurrentLoanStageId); } catch (Exception ex) { } #endregion #region reminder if (this.chkReminder.Checked == true) { string sReminderDueTime = string.Empty; if (sDueTime != string.Empty) { TimeSpan Interval = new TimeSpan(); if (sReminderInterval.Contains("minutes") == true) { string sMinutes = sReminderInterval.Replace(" minutes", ""); int iMinutes = Convert.ToInt32(sMinutes); Interval = new TimeSpan(0, iMinutes, 0); } else if (sReminderInterval.Contains("hours") == true) { string sHours = sReminderInterval.Replace(" hours", ""); int iHours = Convert.ToInt32(sHours); Interval = new TimeSpan(iHours, 0, 0); } TimeSpan ReminderDueTime = DueTime.Add(Interval); sReminderDueTime = ReminderDueTime.ToString(); } string sReminderTaskName = sTaskName + " - Quick Lead Form - Reminder"; if (iReminderUserID == this.CurrUser.iUserID && sDueDate == DateTime.Now.ToString("MM/dd/yyyy")) { this.CurrUser.InitTaskListDueToday(); } } #endregion } #endregion #region API MailChimp_Subscribe if (sMarketing != string.Empty) { string sError2 = string.Empty; bool bResult2 = this.MailChimp_Subscribe(iContactId, sMarketing, out sError2); if (bResult2 == false) { //PageCommon.AlertMsg(this, "Failed to invoke API MailChimp_Subscribe: " + sError2); PageCommon.WriteJsEnd(this, "Failed to invoke API MailChimp_Subscribe: " + sError2, PageCommon.Js_RefreshSelf); return(false); } } #endregion if (ddlLoanOfficer.SelectedValue == "0") //Lead Routing Engine { #region invoke the WCF API LeadRouting_AssignLoanOfficer try { ServiceManager sm = new ServiceManager(); using (LP2ServiceClient client = sm.StartServiceClient()) { LR_AssignLoanOfficerReq req = new LR_AssignLoanOfficerReq(); req.LoanId = iFileID; req.LoanOfficerId = iLoanOfficerID; req.BorrowerContactId = iContactId; req.CoBorrowerContactId = 0; req.ReqHdr = new ReqHdr(); req.ReqHdr.UserId = CurrUser.iUserID; req.ReqHdr.SecurityToken = "SecurityToken"; RespHdr resp = client.LeadRouting_AssignLoanOfficer(req); } } catch (Exception ex) { PageCommon.WriteJsEnd(this, "Pulse Lead Manager is not running. Please select a Loan Officer from the list and save the lead.", PageCommon.Js_RefreshSelf); return(false); } #endregion } return(true); }
protected void btnSend_Click(object sender, EventArgs e) { LoginUser CurrentUser = new LoginUser(); int[] ToUserIDArray = null; int[] ToContactIDArray = null; string[] ToEmailAddrArray = null; int[] CCUserIDArray = null; int[] CCContactIDArray = null; string[] CCEmailAddrArray = null; #region use To and CC of email template #region 获取Email Template的Recipient(s) Template_Email EmailTemplateManager = new Template_Email(); DataTable RecipientList = EmailTemplateManager.GetRecipientList(this.iEmailTemplateID); #endregion #region 获取Loan Team string sSql = "select * from LoanTeam where FileId = " + this.iLoanID; DataTable LoanTeamList = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSql); #endregion #region 获取Contacts string sSql2 = "select * from LoanContacts where FileId = " + this.iLoanID; DataTable ContactList = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSql2); #endregion #region 获取Prospect Loan Officer string sSql3 = "SELECT dbo.Users.* FROM dbo.Prospect INNER JOIN dbo.ProspectTasks ON dbo.Prospect.Contactid = dbo.ProspectTasks.ContactId INNER JOIN dbo.Users ON dbo.Prospect.Loanofficer = dbo.Users.UserId WHERE dbo.ProspectTasks.ProspectTaskId =" + this.iProspectID; DataTable LoanOfficerList = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSql3); #endregion Collection <Int32> ToUserIDs = new Collection <int>(); Collection <Int32> ToContactIDs = new Collection <int>(); Collection <String> ToEmailList = new Collection <String>(); Collection <Int32> CCUserIDs = new Collection <int>(); Collection <Int32> CCContactIDs = new Collection <int>(); Collection <String> CCEmailList = new Collection <String>(); #region To DataRow[] ToRecipient = RecipientList.Select("RecipientType='To'"); if (ToRecipient.Length > 0) { string sEmailList_To = ToRecipient[0]["EmailAddr"].ToString(); string sContactList_To = ToRecipient[0]["ContactRoles"].ToString(); string sUserRoleList_To = ToRecipient[0]["UserRoles"].ToString(); string sTaskOwner = ToRecipient[0]["TaskOwner"].ToString(); #region Emails if (sEmailList_To != string.Empty) { string[] EmailArray_To = sEmailList_To.Split(';'); foreach (string sEmailTo in EmailArray_To) { ToEmailList.Add(sEmailTo); } } #endregion #region User IDs if (sUserRoleList_To != string.Empty) { string[] UserRoleArray_To = sUserRoleList_To.Split(';'); foreach (string sUserRoleIDTo in UserRoleArray_To) { int iUserRoleIDTo = Convert.ToInt32(sUserRoleIDTo); DataRow[] LoanTeamRows = LoanTeamList.Select("RoleId=" + iUserRoleIDTo); foreach (DataRow LoanTeamRow in LoanTeamRows) { int iUserID = Convert.ToInt32(LoanTeamRow["UserId"]); ToUserIDs.Add(iUserID); } } } #endregion #region Contact IDs if (sContactList_To != string.Empty) { string[] ContactArray_To = sContactList_To.Split(';'); foreach (string sContactIDTo in ContactArray_To) { int iContactRoleIDTo = Convert.ToInt32(sContactIDTo); DataRow[] ContactRows = ContactList.Select("ContactRoleId=" + iContactRoleIDTo); foreach (DataRow ContactRow in ContactRows) { int iContactID = Convert.ToInt32(ContactRow["ContactId"]); ToContactIDs.Add(iContactID); } } } #endregion #region Loan Officer User IDs if (sUserRoleList_To != string.Empty) { foreach (DataRow LoanOfficerRow in LoanOfficerList.Rows) { int iLOUserID = Convert.ToInt32(LoanOfficerRow["UserId"]); ToUserIDs.Add(iLOUserID); } } #endregion #region TaskOwner if ((sTaskOwner != string.Empty) && (sTaskOwner != null)) { if (sTaskOwner == "True") { string sSql_LoanTasks = "select Owner from LoanTasks where LoanTaskId=" + this.iProspectID; DataTable LoanTasks_List = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSql_LoanTasks); string sOwnerId = LoanTasks_List.Rows[0]["Owner"].ToString(); if ((sTaskOwner != string.Empty) && (sTaskOwner != null)) { int iOwnerId = Convert.ToInt32(sOwnerId); string sSql_Users = "select EmailAddress, LastName, FirstName from Users where UserId=" + iOwnerId; DataTable Users_List = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSql_Users); string Owner_EmailAddress = Users_List.Rows[0]["EmailAddress"].ToString(); if ((Owner_EmailAddress != string.Empty) && (Owner_EmailAddress != null)) { ToUserIDs.Add(iOwnerId); ToEmailList.Add(Owner_EmailAddress); } } } } #endregion } #endregion #region CC DataRow[] CCRecipient = RecipientList.Select("RecipientType='CC'"); if (CCRecipient.Length > 0) { string sEmailList_CC = CCRecipient[0]["EmailAddr"].ToString(); string sContactList_CC = CCRecipient[0]["ContactRoles"].ToString(); string sUserRoleList_CC = CCRecipient[0]["UserRoles"].ToString(); #region Emails if (sEmailList_CC != string.Empty) { string[] EmailArray_CC = sEmailList_CC.Split(';'); foreach (string sEmailCC in EmailArray_CC) { CCEmailList.Add(sEmailCC); } } #endregion #region User IDs if (sUserRoleList_CC != string.Empty) { string[] UserRoleArray_CC = sUserRoleList_CC.Split(';'); foreach (string sUserRoleIDCC in UserRoleArray_CC) { int iUserRoleIDCC = Convert.ToInt32(sUserRoleIDCC); DataRow[] LoanTeamRows = LoanTeamList.Select("RoleId=" + iUserRoleIDCC); foreach (DataRow LoanTeamRow in LoanTeamRows) { int iUserID = Convert.ToInt32(LoanTeamRow["UserId"]); CCUserIDs.Add(iUserID); } } } #endregion #region Contact IDs if (sContactList_CC != string.Empty) { string[] ContactArray_CC = sContactList_CC.Split(';'); foreach (string sContactIDCC in ContactArray_CC) { int iContactRoleIDCC = Convert.ToInt32(sContactIDCC); DataRow[] ContactRows = ContactList.Select("ContactRoleId=" + iContactRoleIDCC); foreach (DataRow ContactRow in ContactRows) { int iContactID = Convert.ToInt32(ContactRow["ContactId"]); CCContactIDs.Add(iContactID); } } } #endregion } #endregion ToUserIDArray = new int[ToUserIDs.Count]; ToContactIDArray = new int[ToContactIDs.Count]; ToEmailAddrArray = new string[ToEmailList.Count]; CCUserIDArray = new int[CCUserIDs.Count]; CCContactIDArray = new int[CCContactIDs.Count]; CCEmailAddrArray = new string[CCEmailList.Count]; ToUserIDs.CopyTo(ToUserIDArray, 0); ToContactIDs.CopyTo(ToContactIDArray, 0); ToEmailList.CopyTo(ToEmailAddrArray, 0); CCUserIDs.CopyTo(CCUserIDArray, 0); CCContactIDs.CopyTo(CCContactIDArray, 0); CCEmailList.CopyTo(CCEmailAddrArray, 0); #endregion #region 调用API bool successful_status = true; try { ServiceManager sm = new ServiceManager(); using (LP2ServiceClient service = sm.StartServiceClient()) { SendEmailRequest req = new SendEmailRequest(); req.EmailTemplId = this.iEmailTemplateID; req.FileId = this.iProspectID; req.UserId = CurrentUser.iUserID; req.ToEmails = ToEmailAddrArray; req.ToUserIds = ToUserIDArray; req.ToContactIds = ToContactIDArray; req.CCEmails = CCEmailAddrArray; req.CCUserIds = CCUserIDArray; req.CCContactIds = CCContactIDArray; req.hdr = new ReqHdr(); SendEmailResponse response = service.SendEmail(req); if (response.resp.Successful == false) { this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_FailedSend5", "alert('Failed to send completion email.');window.parent.CloseDialog_SendCompletionEmail()();", true); return; } } } catch (System.ServiceModel.EndpointNotFoundException ee) { successful_status = false; PageCommon.AlertMsg(this, "Failed to send completion email, reason: Email Manager is not running."); } #endregion if (successful_status == true) { PageCommon.WriteJs(this, "Send completion email successfully.", "window.parent.CloseDialog_SendCompletionEmail();"); } }
/// <summary> /// load dropdown list data /// </summary> private void DoInitData() { try { int? intRegionID = null; int? intDivisionID = null; string sRegionID = "0"; if (this.Request.QueryString["Region"] != null) { sRegionID = this.Request.QueryString["Region"].ToString(); intRegionID = Convert.ToInt32(sRegionID); } string sDivisionID = "0"; if (this.Request.QueryString["Division"] != null) { sDivisionID = this.Request.QueryString["Division"].ToString(); intDivisionID = Convert.ToInt32(sDivisionID); } DataSet dsFilter = PageCommon.GetOrgStructureDataSourceByLoginUser(intRegionID, intDivisionID, true); this.ddlRegion.DataSource = dsFilter.Tables[0]; this.ddlRegion.DataValueField = "RegionId"; this.ddlRegion.DataTextField = "Name"; this.ddlRegion.DataBind(); this.ddlRegion.Attributes.Add("onchange", "send_request('Region')"); //this.ddlDivision.DataSource = this.GetDivisionData(sRegionID); this.ddlDivision.DataSource = dsFilter.Tables[1]; this.ddlDivision.DataValueField = "DivisionId"; this.ddlDivision.DataTextField = "Name"; this.ddlDivision.DataBind(); this.ddlDivision.Attributes.Add("onchange", "send_request('Division')"); //this.ddlBranch.DataSource = this.GetBranchData(sRegionID, sDivisionID); this.ddlBranch.DataSource = dsFilter.Tables[2]; this.ddlBranch.DataValueField = "BranchId"; this.ddlBranch.DataTextField = "Name"; this.ddlBranch.DataBind(); this.ddlRegion.SelectedIndex = 0; this.ddlDivision.SelectedIndex = 0; this.ddlBranch.SelectedIndex = 0; #region set suspend text try { ServiceManager sm = new ServiceManager(); using (LP2ServiceClient service = sm.StartServiceClient()) { GetPointMgrStatusRequest req = new GetPointMgrStatusRequest(); req.hdr = new ReqHdr(); req.hdr.SecurityToken = "SecurityToken"; //todo:check dummy data req.hdr.UserId = 5; //todo:check dummy data GetPointMgrStatusResponse respone = null; respone = service.GetPointManagerStatus(req); if (respone.Running) { this.lbtnSuspend.Text = "Suspend Sync"; } else { this.lbtnSuspend.Text = "Resume Sync"; } } } catch (System.ServiceModel.EndpointNotFoundException ee) { LPLog.LogMessage(ee.Message); PageCommon.AlertMsg(this, "Failed reason: Point Manager is not running."); return; } catch (Exception exception) { LPLog.LogMessage(exception.Message); return; //PageCommon.WriteJsEnd(this, "Import Point Folders Failed.", PageCommon.Js_RefreshSelf); } #endregion } catch (Exception ex) { throw ex; } }
protected void btnSave_Click(object sender, EventArgs e) { if (this.CurrentFileId == 0) { return; } int ContactID = 0; LPWeb.Model.Contacts model = new LPWeb.Model.Contacts(); try { ContactID = int.Parse(hfdContactID.Value); Contacts contact = new Contacts(); model = contact.GetModel(ContactID); } catch { } ServiceManager sm = new ServiceManager(); using (LP2ServiceClient service = sm.StartServiceClient()) { ReassignContactRequest req = new ReassignContactRequest(); req.hdr = new ReqHdr(); req.hdr.SecurityToken = "SecurityToken"; //todo:check dummy data req.hdr.UserId = CurrentUser.iUserID; ReassignContactInfo cInfo = new ReassignContactInfo(); List <ReassignContactInfo> cList = new List <ReassignContactInfo>(); cInfo.FileId = this.CurrentFileId;//todo:check dummy data cInfo.ContactRoleId = int.Parse(ddlContactRole.SelectedValue); cInfo.NewContactId = ContactID; cList.Add(cInfo); req.reassignContacts = cList.ToArray(); ReassignContactResponse respone = null; try { respone = service.ReassignContact(req); if (respone.hdr.Successful) { LPWeb.Model.LoanContacts lcModel = new LPWeb.Model.LoanContacts(); lcModel.FileId = CurrentFileId; lcModel.ContactRoleId = cInfo.ContactRoleId; lcModel.ContactId = ContactID; LPWeb.Model.LoanContacts oldlcModel = new LPWeb.Model.LoanContacts(); oldlcModel.FileId = CurrentFileId; oldlcModel.ContactRoleId = oldRoleID; oldlcModel.ContactId = oldContactID; LPWeb.BLL.LoanContacts lc = new LoanContacts(); lc.Reassign(oldlcModel, lcModel, req.hdr.UserId); try { PageCommon.WriteJsEnd(this, "Reassigned contact successfully", PageCommon.Js_RefreshParent); } catch { } } else { try { PageCommon.WriteJsEnd(this, String.Format("Failed to reassign contact: reason: {0}.", respone.hdr.StatusInfo), PageCommon.Js_RefreshSelf); } catch { } } } catch (System.ServiceModel.EndpointNotFoundException ex) { LPLog.LogMessage(ex.Message); PageCommon.WriteJsEnd(this, "Failed to reassign contact: reason, Point Manager is not running. ", PageCommon.Js_RefreshSelf); } catch (Exception exception) { LPLog.LogMessage(exception.Message); PageCommon.WriteJsEnd(this, String.Format("Failed to reassign contact, reason: {0}", exception.Message), PageCommon.Js_RefreshSelf); } } }
protected void btnSend_Click(object sender, EventArgs e) { #region 准备接口数据 string sEmailTemplateID = this.ddlEmailTemplateList.SelectedValue; string sToIDs = this.hdnToIDs.Value; LoginUser CurrentUser = this.CurrUser; string Token = hidToken.Value; Dictionary <string, byte[]> Attachments = new Dictionary <string, byte[]>(); #region Attachments //LPWeb.BLL.Template_Email_Attachments bllTempEmailattach = new Template_Email_Attachments(); //var ds = bllTempEmailattach.GetList(" [Enabled] =1 AND TemplEmailId = " + sEmailTemplateID); LPWeb.BLL.Email_AttachmentsTemp bllEmailAttachTemp = new Email_AttachmentsTemp(); var ds = bllEmailAttachTemp.GetListWithFileImage(Convert.ToInt32(sEmailTemplateID), Token); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { foreach (DataRow item in ds.Tables[0].Rows) { try { Attachments.Add(item["Name"].ToString() + "." + item["FileType"].ToString(), (byte[])item["FileImage"]); } catch { } } } #endregion int[] ToUserIDArray = null; int[] ToContactIDArray = null; string[] ToEmailAddrArray = null; int EmailIndex = 0; int[] CCUserIDArray = null; int[] CCContactIDArray = null; string[] CCEmailAddrArray = null; if (sToIDs == string.Empty) // 如果未添加收件人,则以email template的To和CC为准发邮件 { #region use To and CC of email template #region 获取Email Template的Recipient(s) Template_Email EmailTemplateManager = new Template_Email(); DataTable RecipientList = EmailTemplateManager.GetRecipientList(Convert.ToInt32(sEmailTemplateID)); #endregion #region 获取Loan Team string sSql = "select * from LoanTeam where FileId = " + this.iLoanID; DataTable LoanTeamList = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSql); #endregion #region 获取Contacts string sSql2 = "select * from LoanContacts where FileId = " + this.iLoanID; DataTable ContactList = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSql2); #endregion Collection <Int32> ToUserIDs = new Collection <int>(); Collection <Int32> ToContactIDs = new Collection <int>(); Collection <String> ToEmailList = new Collection <String>(); Collection <Int32> CCUserIDs = new Collection <int>(); Collection <Int32> CCContactIDs = new Collection <int>(); Collection <String> CCEmailList = new Collection <String>(); #region To DataRow[] ToRecipient = RecipientList.Select("RecipientType='To'"); if (ToRecipient.Length > 0) { string sEmailList_To = ToRecipient[0]["EmailAddr"].ToString(); string sContactList_To = ToRecipient[0]["ContactRoles"].ToString(); string sUserRoleList_To = ToRecipient[0]["UserRoles"].ToString(); #region Emails if (sEmailList_To != string.Empty) { string[] EmailArray_To = sEmailList_To.Split(';'); foreach (string sEmailTo in EmailArray_To) { ToEmailList.Add(sEmailTo); } } #endregion #region User IDs if (sUserRoleList_To != string.Empty) { string[] UserRoleArray_To = sUserRoleList_To.Split(';'); foreach (string sUserRoleIDTo in UserRoleArray_To) { int iUserRoleIDTo = Convert.ToInt32(sUserRoleIDTo); DataRow[] LoanTeamRows = LoanTeamList.Select("RoleId=" + iUserRoleIDTo); foreach (DataRow LoanTeamRow in LoanTeamRows) { int iUserID = Convert.ToInt32(LoanTeamRow["UserId"]); ToUserIDs.Add(iUserID); } } } #endregion #region Contact IDs if (sContactList_To != string.Empty) { string[] ContactArray_To = sContactList_To.Split(';'); foreach (string sContactIDTo in ContactArray_To) { int iContactRoleIDTo = Convert.ToInt32(sContactIDTo); DataRow[] ContactRows = ContactList.Select("ContactRoleId=" + iContactRoleIDTo); foreach (DataRow ContactRow in ContactRows) { int iContactID = Convert.ToInt32(ContactRow["ContactId"]); ToContactIDs.Add(iContactID); } } } #endregion } #endregion #region CC DataRow[] CCRecipient = RecipientList.Select("RecipientType='CC'"); if (CCRecipient.Length > 0) { string sEmailList_CC = CCRecipient[0]["EmailAddr"].ToString(); string sContactList_CC = CCRecipient[0]["ContactRoles"].ToString(); string sUserRoleList_CC = CCRecipient[0]["UserRoles"].ToString(); #region Emails if (sEmailList_CC != string.Empty) { string[] EmailArray_CC = sEmailList_CC.Split(';'); foreach (string sEmailCC in EmailArray_CC) { CCEmailList.Add(sEmailCC); } } #endregion #region User IDs if (sUserRoleList_CC != string.Empty) { string[] UserRoleArray_CC = sUserRoleList_CC.Split(';'); foreach (string sUserRoleIDCC in UserRoleArray_CC) { int iUserRoleIDCC = Convert.ToInt32(sUserRoleIDCC); DataRow[] LoanTeamRows = LoanTeamList.Select("RoleId=" + iUserRoleIDCC); foreach (DataRow LoanTeamRow in LoanTeamRows) { int iUserID = Convert.ToInt32(LoanTeamRow["UserId"]); CCUserIDs.Add(iUserID); } } } #endregion #region Contact IDs if (sContactList_CC != string.Empty) { string[] ContactArray_CC = sContactList_CC.Split(';'); foreach (string sContactIDCC in ContactArray_CC) { int iContactRoleIDCC = Convert.ToInt32(sContactIDCC); DataRow[] ContactRows = ContactList.Select("ContactRoleId=" + iContactRoleIDCC); foreach (DataRow ContactRow in ContactRows) { int iContactID = Convert.ToInt32(ContactRow["ContactId"]); CCContactIDs.Add(iContactID); } } } #endregion } // if check me, add user's email to CC list if (this.chkCCMe.Checked == true && CurrentUser.sEmail != string.Empty) { CCEmailList.Add(CurrentUser.sEmail); } #endregion ToUserIDArray = new int[ToUserIDs.Count]; ToContactIDArray = new int[ToContactIDs.Count]; ToEmailAddrArray = new string[ToEmailList.Count]; CCUserIDArray = new int[CCUserIDs.Count]; CCContactIDArray = new int[CCContactIDs.Count]; CCEmailAddrArray = new string[CCEmailList.Count]; ToUserIDs.CopyTo(ToUserIDArray, 0); ToContactIDs.CopyTo(ToContactIDArray, 0); ToEmailList.CopyTo(ToEmailAddrArray, 0); CCUserIDs.CopyTo(CCUserIDArray, 0); CCContactIDs.CopyTo(CCContactIDArray, 0); CCEmailList.CopyTo(CCEmailAddrArray, 0); #endregion } else // 如果添加收件人,则覆盖email template的To和CC { #region build ToUserIDArray and ToContactIDArray Collection <Int32> ToUserIDs = new Collection <int>(); Collection <Int32> ToContactIDs = new Collection <int>(); string EmailAddress = ""; string UserSql = ""; string ContactSql = ""; DataTable UserTable = null; DataTable ContactTable = null; string[] ToIDArray = sToIDs.Split('$'); ToEmailAddrArray = new string[ToIDArray.Length]; foreach (string ToID in ToIDArray) { if (ToID.Contains("User") == true) { int iToUserID = Convert.ToInt32(ToID.Replace("User", "")); ToUserIDs.Add(iToUserID); UserSql = "select EmailAddress from Users where UserId = " + iToUserID; UserTable = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(UserSql); foreach (DataRow dr in UserTable.Rows) { if (dr["EmailAddress"] == DBNull.Value) { EmailAddress = ""; } else { EmailAddress = dr["EmailAddress"].ToString().Trim(); } } ToEmailAddrArray[EmailIndex] = EmailAddress; EmailIndex = EmailIndex + 1; } else { int iToContactID = Convert.ToInt32(ToID.Replace("Contact", "")); ToContactIDs.Add(iToContactID); ContactSql = "select Email from Contacts where ContactId = " + iToContactID; ContactTable = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(ContactSql); foreach (DataRow dr in ContactTable.Rows) { if (dr["Email"] == DBNull.Value) { EmailAddress = ""; } else { EmailAddress = dr["Email"].ToString().Trim(); } } ToEmailAddrArray[EmailIndex] = EmailAddress; EmailIndex = EmailIndex + 1; } } ToUserIDArray = new int[ToUserIDs.Count]; ToContactIDArray = new int[ToContactIDs.Count]; if (ToUserIDs.Count > 0) { ToUserIDs.CopyTo(ToUserIDArray, 0); } if (ToContactIDs.Count > 0) { ToContactIDs.CopyTo(ToContactIDArray, 0); } #endregion CCUserIDArray = new int[0]; CCContactIDArray = new int[0]; if (this.chkCCMe.Checked == true && CurrentUser.sEmail != string.Empty) { CCEmailAddrArray = new string[1]; CCEmailAddrArray.SetValue(CurrentUser.sEmail, 0); } else { CCEmailAddrArray = new string[0]; } } #endregion #region 调用API string sCloseDialogCodes = this.GetCloseDialogJs(); SendEmailResponse response = null; try { ServiceManager sm = new ServiceManager(); using (LP2ServiceClient service = sm.StartServiceClient()) { #region SendEmailRequest SendEmailRequest req = new SendEmailRequest(); if (this.chkUserEmailTemplate.Checked == true) { req.EmailTemplId = Convert.ToInt32(sEmailTemplateID); req.EmailSubject = string.Empty; req.EmailBody = null; req.AppendPictureSignature = false; } else { req.EmailTemplId = 0; req.EmailSubject = this.txtSubject.Text.Trim(); req.EmailBody = Encoding.UTF8.GetBytes(this.txtBody.Text.Trim()); req.AppendPictureSignature = this.chkAppendMyPic.Checked; } if (this.Request.QueryString["LoanID"] != null) { req.FileId = this.iLoanID; } else if (this.Request.QueryString["ProspectID"] != null) { req.ProspectId = this.iProspectID; } else if (this.Request.QueryString["ProspectAlertID"] != null) { req.PropsectTaskId = this.iProspectAlertID; } if ((this.Request.QueryString["LoanID"] == null) && (this.Request.QueryString["ProspectID"] != null)) { string sSql = "select * from LoanContacts where ContactId=" + req.ProspectId + " and (ContactRoleId=dbo.lpfn_GetBorrowerRoleId() or ContactRoleId=dbo.lpfn_GetCoBorrowerRoleId())"; DataTable LoanList = null; try { LoanList = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSql); foreach (DataRow LoanListRow in LoanList.Rows) { req.FileId = (int)LoanListRow["FileId"]; } } catch { } if (LoanList == null || LoanList.Rows.Count == 0) { } } req.UserId = CurrentUser.iUserID; req.ToEmails = ToEmailAddrArray; req.ToUserIds = ToUserIDArray; req.ToContactIds = ToContactIDArray; req.CCEmails = CCEmailAddrArray; req.CCUserIds = CCUserIDArray; req.CCContactIds = CCContactIDArray; req.hdr = new ReqHdr(); #region add Attachments req.Attachments = Attachments; #endregion #endregion response = service.SendEmail(req); } } catch (System.ServiceModel.EndpointNotFoundException) { string sExMsg = string.Format("Failed to send email, reason: Email Manager is not running."); LPLog.LogMessage(LogType.Logerror, sExMsg); PageCommon.WriteJsEnd(this, sExMsg, sCloseDialogCodes); } catch (Exception ex) { string sExMsg = string.Format("Failed to send email, error: {0}", ex.Message); LPLog.LogMessage(LogType.Logerror, sExMsg); PageCommon.WriteJsEnd(this, sExMsg, sCloseDialogCodes); } #endregion // 提示调用结果 if (response.resp.Successful == true) { try { bllEmailAttachTemp.DeleteByToken(Token); } catch { } string RefreshParent = "window.parent.location.href=window.parent.location.href;"; PageCommon.WriteJsEnd(this, "Sent email successfully.", RefreshParent + sCloseDialogCodes); } else { PageCommon.WriteJsEnd(this, "Failed to send email: " + response.resp.StatusInfo.Replace("'", "\'"), sCloseDialogCodes); } }
/// <summary> /// 更新 card信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnUpdateCard_Click(object sender, EventArgs e) { #region 检查 if (ddlCardType.SelectedValue == "") { PageCommon.RegisterJsMsg(this, "please select Card Type", ""); return; } if (string.IsNullOrEmpty(txbCardNumber.Text)) { PageCommon.RegisterJsMsg(this, "please input Card Number", ""); return; } if (string.IsNullOrEmpty(txbCardExpiration.Text)) { PageCommon.RegisterJsMsg(this, "please input Card Expiration", ""); return; } if (txbCardExpiration.Text.Trim().IndexOf('/') == -1) { PageCommon.RegisterJsMsg(this, "the expiration in the format of mm/yy", ""); return; } if (string.IsNullOrEmpty(txbCardCSCcode.Text)) { PageCommon.RegisterJsMsg(this, "please input Card CSC code", ""); return; } if (string.IsNullOrEmpty(txbNameonCard.Text)) { PageCommon.RegisterJsMsg(this, "please input Name on Card", ""); return; } #endregion try { var creditCard = new LP_Service.UpdateCreditCardRequest(); var exp = txbCardExpiration.Text.Trim().Split('/'); int mm = Convert.ToInt32(exp[0]); if (mm >= 1 && mm <= 12) { creditCard.Card_Exp_Month = exp[0]; } else { PageCommon.RegisterJsMsg(this, "Card Expiration (mm/yy): mm should be a number between 1 and 12", ""); return; } if (Convert.ToInt32(DateTime.Now.Year.ToString().Substring(0, 2) + exp[1]) >= DateTime.Now.Year) { creditCard.Card_Exp_Year = exp[1]; } else { PageCommon.RegisterJsMsg(this, "Card Expiration (mm/yy): yy Should be more than equal to the current year", ""); return; } var name = txbNameonCard.Text.Split(' ').ToList(); if (name.Count < 2) { } creditCard.Card_First_Name = name.FirstOrDefault(); creditCard.Card_Last_Name = name.LastOrDefault(); creditCard.Card_IsDefault = "True"; creditCard.Card_Number = txbCardNumber.Text.Trim(); creditCard.Card_SIC = txbCardCSCcode.Text.Trim(); creditCard.Card_Type = (LP_Service.CreditCardType)Convert.ToInt32(ddlCardType.SelectedValue.Trim()); //creditCard.ExtensionData = creditCard.Card_ID = hfCardID.Value.Trim(); ServiceManager sm = new ServiceManager(); using (LP2ServiceClient client = sm.StartServiceClient()) { creditCard.hdr = new LP_Service.ReqHdr(); creditCard.hdr.UserId = loginUser.iUserID; var rq = client.UpdateCreditCard(creditCard); if (rq.hdr.Successful) { //PageCommon.RegisterJsMsg(this, "", PageCommon.Js_RefreshSelf); PageCommon.RegisterJsMsg(this, "Update Credit Card Successfully.", ""); } else { PageCommon.RegisterJsMsg(this, rq.hdr.StatusInfo, ""); } } } catch (Exception ex) { PageCommon.AlertMsg(this, "Error:" + ex.Message); } }