protected void Page_Load(object sender, EventArgs e)
    {
        #region 接受参数

        bool bIsValid = PageCommon.ValidateQueryString(this, "ContactID", QueryStringType.ID);
        if (bIsValid == false)
        {
            bIsValid = PageCommon.ValidateQueryString(this, "LoanID", QueryStringType.ID);
            if (!bIsValid)
            {
                this.Response.Write("{\"ExecResult\":\"Failed\",\"ErrorMsg\":\"Missing required query string.\"}");
                this.Response.End();
            }
        }

        int iContactID = Convert.ToInt32(this.Request.QueryString["ContactID"]);
        int iLoanID    = Convert.ToInt32(this.Request.QueryString["LoanID"]);
        if (iContactID <= 0 && iLoanID <= 0)
        {
            this.Response.Write("{\"ExecResult\":\"Failed\",\"ErrorMsg\":\"Missing ContactId OR LoanId.\"}");
            this.Response.End();
        }

        if (iContactID <= 0 && iLoanID > 0)
        {
            object ob = LPWeb.DAL.DbHelperSQL.GetSingle(string.Format("Select dbo.lpfn_GetBorrowerContactId({0})", iLoanID));
            if (ob == null || ob == DBNull.Value)
            {
                this.Response.Write(string.Format("{\"ExecResult\":\"Failed\",\"ErrorMsg\":\"Cannot get BorrowerContactId for LoanId {0}.\"}", iLoanID));
                this.Response.End();
            }
            iContactID = (int)ob;
        }
        #endregion

        // json示例
        // {"ExecResult":"Success","ErrorMsg":""}
        // {"ExecResult":"Failed","ErrorMsg":"error message"}

        #region UpdateBorrowerRequest

        UpdateBorrowerResponse response = null;

        try
        {
            ServiceManager sm = new ServiceManager();
            using (LP2ServiceClient service = sm.StartServiceClient())
            {
                UpdateBorrowerRequest req = new UpdateBorrowerRequest();
                ReqHdr hdr = new ReqHdr();
                hdr.UserId    = this.CurrUser.iUserID;
                req.hdr       = hdr;
                req.ContactId = iContactID;

                response = service.UpdateBorrower(req);
            }
        }
        catch (System.ServiceModel.EndpointNotFoundException)
        {
            string sExMsg = string.Format("Exception happened when send UpdateBorrowerRequest to Point Manager (ContactID={0}): {1}", iContactID, "Point Manager is not running.");
            LPLog.LogMessage(LogType.Logerror, sExMsg);

            // update Contacts.UpdatePoint=1
            this.UpdatePoint(iContactID, true);

            this.Response.Write("{\"ExecResult\":\"Failed\",\"ErrorMsg\":\"" + sExMsg + "\"}");
            this.Response.End();
        }
        catch (Exception ex)
        {
            string sExMsg = string.Format("Exception happened when send UpdateBorrowerRequest to Point Manager (ContactID={0}): {1}", iContactID, ex.Message);
            LPLog.LogMessage(LogType.Logerror, sExMsg);

            // update Contacts.UpdatePoint=1
            this.UpdatePoint(iContactID, true);

            this.Response.Write("{\"ExecResult\":\"Failed\",\"ErrorMsg\":\"" + sExMsg + "\"}");
            this.Response.End();
        }

        if (response.hdr.Successful == false)
        {
            string sFailedMsg = "Failed to send UpdateBorrowerRequest to Point Manager: " + response.hdr.StatusInfo;
            LPLog.LogMessage(LogType.Logerror, sFailedMsg);

            // update Contacts.UpdatePoint=1
            this.UpdatePoint(iContactID, true);

            this.Response.Write("{\"ExecResult\":\"Failed\",\"ErrorMsg\":\"" + sFailedMsg + "\"}");
            this.Response.End();
        }
        else
        {
            // update Contacts.UpdatePoint=0
            this.UpdatePoint(iContactID, false);
        }

        #endregion

        System.Threading.Thread.Sleep(1000);

        this.Response.Write("{\"ExecResult\":\"Success\",\"ErrorMsg\":\"\"}");
        this.Response.End();
    }
Exemplo n.º 2
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        #region 获取用户输入

        string sLoanOfficerID = this.ddlLoanOfficer.SelectedValue;
        int    iLoanOfficerID = Convert.ToInt32(sLoanOfficerID);

        string sReferenceCode      = this.txtRefCode.Text.Trim();
        string sStatus             = this.ddlStatus.SelectedValue;
        string strCreditRanking    = this.ddlCreditRanking.SelectedValue;
        string strPreferredContact = this.ddlPreferredContact.SelectedValue;

        string sLeadSource = this.ddlLeadSource.SelectedValue;
        if (sLeadSource == "-- select --")
        {
            sLeadSource = string.Empty;
        }

        string sFirstName      = this.txtFirstName.Text.Trim();
        string sMiddleName     = this.txtMiddleName.Text.Trim();
        string sLastName       = this.txtLastName.Text.Trim();
        string sTitle          = this.ddlTitle.SelectedValue;
        string sGenerationCode = this.txtGenerationCode.Text.Trim();
        string sSSN            = this.txtSSN.Text.Trim();
        string sHomePhone      = this.txtHomePhone.Text.Trim();
        string sCellPhone      = this.txtCellPhone.Text.Trim();
        string sBizPhone       = this.txtBizPhone.Text.Trim();
        string sFax            = this.txtFax.Text.Trim();
        string sAddress        = this.txtAddress.Text.Trim();
        string sCity           = this.txtCity.Text.Trim();
        string sState          = this.ddlState.SelectedValue;
        string sZip            = this.txtZip.Text.Trim();
        string sEmail          = this.txtEmail.Text.Trim();
        string sDOB            = this.txtDOB.Text.Trim();
        int    iReferralID     = 0;
        if (!int.TryParse(this.hdnReferralID.Value, out iReferralID))
        {
            iReferralID = 0;
        }

        string sExperianScore = this.txtExperianScore.Text.Trim();
        if (sExperianScore == string.Empty)
        {
            sExperianScore = "0";
        }
        Int16 iExperianScore = Convert.ToInt16(sExperianScore);

        string sTransUnitScore = this.txtTransUnitScore.Text.Trim();
        if (sTransUnitScore == string.Empty)
        {
            sTransUnitScore = "0";
        }
        Int16 iTransUnitScore = Convert.ToInt16(sTransUnitScore);

        string sEquifaxScore = this.txtEquifaxScore.Text.Trim();
        if (sEquifaxScore == string.Empty)
        {
            sEquifaxScore = "0";
        }
        Int16 iEquifaxScore = Convert.ToInt16(sEquifaxScore);

        #endregion

        #region 检查LoanContacts

        string    sSql       = "select * from LoanContacts where ContactID=" + this.iProspectID;
        DataTable RefLoanIDs = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSql);
        if (RefLoanIDs.Rows.Count > 0)
        {
            #region UpdateBorrowerRequest

            UpdateBorrowerResponse response = null;

            try
            {
                ServiceManager sm = new ServiceManager();
                using (LP2ServiceClient service = sm.StartServiceClient())
                {
                    UpdateBorrowerRequest req = new UpdateBorrowerRequest();
                    ReqHdr hdr = new ReqHdr();
                    hdr.UserId    = this.CurrUser.iUserID;
                    req.hdr       = hdr;
                    req.ContactId = this.iProspectID;

                    response = service.UpdateBorrower(req);
                }
            }
            catch (System.ServiceModel.EndpointNotFoundException)
            {
                string sExMsg = string.Format("Exception happened when send UpdateBorrowerRequest to Point Manager (ContactID={0}): {1}", this.iProspectID, "Point Manager is not running.");
                LPLog.LogMessage(LogType.Logerror, sExMsg);

                // update Contacts.UpdatePoint=1
                this.UpdatePoint(this.iProspectID, true);

                PageCommon.WriteJsEnd(this, sExMsg, PageCommon.Js_RefreshSelf);
            }
            catch (Exception ex)
            {
                string sExMsg = string.Format("Exception happened when send UpdateBorrowerRequest to Point Manager (ContactID={0}): {1}", this.iProspectID, ex.Message);
                LPLog.LogMessage(LogType.Logerror, sExMsg);

                // update Contacts.UpdatePoint=1
                this.UpdatePoint(this.iProspectID, true);

                PageCommon.WriteJsEnd(this, sExMsg, PageCommon.Js_RefreshSelf);
            }

            if (response.hdr.Successful == false)
            {
                string sFailedMsg = "Failed to send UpdateBorrowerRequest to Point Manager: " + response.hdr.StatusInfo;
                LPLog.LogMessage(LogType.Logerror, sFailedMsg);

                // update Contacts.UpdatePoint=1
                this.UpdatePoint(this.iProspectID, true);

                PageCommon.WriteJsEnd(this, sFailedMsg, PageCommon.Js_RefreshSelf);
            }
            else
            {
                // update Contacts.UpdatePoint=0
                this.UpdatePoint(this.iProspectID, false);
            }

            #endregion
        }

        #endregion

        LoginUser CurrentUser     = new LoginUser();
        Prospect  ProspectManager = new Prospect();

        // Update prospect detail
        ProspectManager.UpdateProspectDetail(this.iProspectID, sLeadSource, sReferenceCode, CurrentUser.iUserID, iLoanOfficerID, sStatus, strCreditRanking, strPreferredContact, sFirstName, sMiddleName, sLastName, sTitle, sGenerationCode, sSSN, sHomePhone, sCellPhone, sBizPhone, sFax, sEmail, sDOB, iExperianScore, iTransUnitScore, iEquifaxScore, sAddress, sCity, sState, sZip, iReferralID);

        // build js
        StringBuilder sbJavaScript = new StringBuilder();
        sbJavaScript.AppendLine("$('#divContainer').hide();");
        sbJavaScript.AppendLine("alert('Save client detail successfully.');");

        #region Has associated Prospect Loan

        bool   bHasProspectLoan = this.HasProspectLoan(this.iProspectID);
        string sOldStatus       = this.hdnOldStatus.Value;
        string sNewStatus       = this.ddlStatus.SelectedValue;
        if (sNewStatus == "Suspended")
        {
            sNewStatus = "Suspend";
        }

        #endregion

        if (bHasProspectLoan == true && sOldStatus == "Active" &&
            (sStatus == "Bad" || sStatus == "Lost" || sStatus == "Suspended"))     // has prospect loan
        {
            sbJavaScript.AppendLine("var result = confirm('Do you want to also change the status of the associated leads to <" + sStatus + ">?')");

            sbJavaScript.AppendLine("if(result == false){" + this.sCloseDialogCodes + this.sRefreshCodes + "}else{ShowDialog_PointFolderSelection('" + this.iProspectID + "', '" + sNewStatus + "');}");
        }
        else
        {
            sbJavaScript.AppendLine(this.sCloseDialogCodes + this.sRefreshCodes);
        }
        btnUpdatePoint_Click(this, e);

        //Fixed BUG111, Refresh contact tab
        if (sRefreshTabCodes != string.Empty && sRefreshTabCodes != "")
        {
            sbJavaScript.AppendLine(sRefreshTabCodes);
        }

        // success
        this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Success", sbJavaScript.ToString(), true);
    }
Exemplo n.º 3
0
    protected void btnUpdatePoint_Click(object sender, EventArgs e)
    {
        #region send UpdateBorrowerRequest to point manager

        UpdateBorrowerResponse response = null;

        try
        {
            ServiceManager sm = new ServiceManager();
            using (LP2ServiceClient service = sm.StartServiceClient())
            {
                ReassignProspect(service);
                UpdateBorrowerRequest req = new UpdateBorrowerRequest();
                ReqHdr hdr = new ReqHdr();
                hdr.UserId    = this.CurrUser.iUserID;
                req.hdr       = hdr;
                req.ContactId = this.iProspectID;

                response = service.UpdateBorrower(req);
            }
        }
        catch (System.ServiceModel.EndpointNotFoundException)
        {
            string sExMsg = string.Format("Exception occurred while trying to send UpdateBorrowerRequest to Point Manager (ContactID={0}): {1}", this.iProspectID, "Point Manager is not running.");
            LPLog.LogMessage(LogType.Logerror, sExMsg);

            // update Contacts.UpdatePoint=1
            this.UpdatePoint(this.iProspectID, true);

            PageCommon.WriteJsEnd(this, sExMsg, PageCommon.Js_RefreshSelf);
        }
        catch (Exception ex)
        {
            string sExMsg = string.Format("Exception occured while trying to send UpdateBorrowerRequest to Point Manager (ContactID={0}): {1}", this.iProspectID, ex.Message);
            LPLog.LogMessage(LogType.Logerror, sExMsg);

            // update Contacts.UpdatePoint=1
            this.UpdatePoint(this.iProspectID, true);

            PageCommon.WriteJsEnd(this, sExMsg, PageCommon.Js_RefreshSelf);
        }

        #endregion

        if (response.hdr.Successful == true)
        {
            // update Contacts.UpdatePoint=0
            this.UpdatePoint(this.iProspectID, false);
            PageCommon.WriteJsEnd(this, "Updated Point successfully.", this.sRefreshCodes + this.sRefreshTabCodes + this.sCloseDialogCodes);
        }
        else
        {
            string sFailedMsg = response.hdr.StatusInfo;
            LPLog.LogMessage(LogType.Logerror, sFailedMsg);

            // update Contacts.UpdatePoint=1
            this.UpdatePoint(this.iProspectID, true);

            PageCommon.WriteJsEnd(this, sFailedMsg, PageCommon.Js_RefreshSelf);
        }
    }
Exemplo n.º 4
0
        /// <summary>
        /// Link button click event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnLink_Click(object sender, EventArgs e)
        {
            string sLoanIds  = this.hdLoanIds.Value;
            string sLinkType = this.hdLinkType.Value;
            int    iLinkType = 1;

            if (sLoanIds.Length < 1)
            {
                return;
            }

            try
            {
                LPWeb.BLL.ContactRoles contactRoles = new LPWeb.BLL.ContactRoles();
                DataSet dsRole = contactRoles.GetList("Name='" + sLinkType + "'");
                if (dsRole.Tables.Count > 0 && dsRole.Tables[0].Rows.Count > 0)
                {
                    iLinkType = Convert.ToInt32(dsRole.Tables[0].Rows[0]["ContactRoleId"].ToString());
                }
                LPWeb.BLL.LoanContacts loanContact = new LPWeb.BLL.LoanContacts();
                foreach (string sLoanID in sLoanIds.Split(','))
                {
                    if (sLoanID.Trim() == "")
                    {
                        continue;
                    }
                    int iLoanID       = 0;
                    int iOldContactID = 0;
                    if (sLoanID == "" || Int32.TryParse(sLoanID, out iLoanID) == false)
                    {
                        continue;
                    }
                    DataSet dsloancontact = loanContact.GetList("FileId=" + sLoanID + " AND ContactRoleId=" + iLinkType.ToString());
                    if (dsloancontact.Tables.Count > 0 && dsloancontact.Tables[0].Rows.Count > 0)
                    {
                        iOldContactID = Convert.ToInt32("0" + dsloancontact.Tables[0].Rows[0]["ContactId"].ToString());
                    }
                    LPWeb.Model.LoanContacts modelOld = loanContact.GetModel(iLoanID, iLinkType, iOldContactID);
                    if (modelOld == null)
                    {
                        modelOld           = new Model.LoanContacts();
                        modelOld.ContactId = 0;
                    }
                    LPWeb.Model.LoanContacts model = new LPWeb.Model.LoanContacts();
                    model.FileId        = iLoanID;
                    model.ContactRoleId = iLinkType;
                    model.ContactId     = this.iProspectID;
                    loanContact.Reassign(modelOld, model, 0);

                    ServiceManager sm = new ServiceManager();
                    using (LP2ServiceClient service = sm.StartServiceClient())
                    {
                        UpdateBorrowerRequest req = new UpdateBorrowerRequest();
                        req.hdr = new ReqHdr();
                        req.hdr.SecurityToken = "SecurityToken";
                        req.hdr.UserId        = this.CurrUser.iUserID;
                        req.ContactId         = model.ContactId;

                        UpdateBorrowerResponse respone = null;

                        try
                        {
                            respone = service.UpdateBorrower(req);
                        }
                        catch (System.ServiceModel.EndpointNotFoundException)
                        {
                            string sExMsg = string.Format("Exception happened when  Update loan (ContactId={0}): {1}", model.ContactId, "Point Manager is not running.");
                            LPLog.LogMessage(LogType.Logerror, sExMsg);
                        }
                        catch (Exception ex)
                        {
                            string sExMsg = string.Format("Exception happened when  Update loan (ContactId={0}): {1}", model.ContactId, ex.Message);
                            LPLog.LogMessage(LogType.Logerror, sExMsg);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LPLog.LogMessage(LogType.Logdebug, ex.ToString());
                PageCommon.WriteJsEnd(this, "Failed to link the selected loans.", this.sCloseDialogCodes + this.sRefreshCodes);
            }

            this.hdLoanIds.Value  = string.Empty;
            this.hdLinkType.Value = string.Empty;

            // success
            PageCommon.WriteJsEnd(this, "Link the selected loans successfully.", this.sCloseDialogCodes + this.sRefreshCodes);
        }