コード例 #1
0
    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();
    }
コード例 #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        #region 校验页面参数

        if (this.Request.QueryString["CloseDialogCodes"] == null)
        {
            PageCommon.WriteJsEnd(this, "Missing required query string.", "try{window.parent.location.href=window.parent.location.href}catch{}");
        }

        string sCloseDialogCodes = this.Request.QueryString["CloseDialogCodes"].ToString() + ";";

        bool bIsValid = PageCommon.ValidateQueryString(this, "FileID", QueryStringType.ID);

        if (bIsValid == false)
        {
            PageCommon.WriteJsEnd(this, "Missing required query string.", sCloseDialogCodes);
        }

        string sFileID = this.Request.QueryString["FileID"].ToString();
        this.iFileID = Convert.ToInt32(sFileID);

        #endregion

        #region 获取Borrower和Property信息

        #region Property

        LPWeb.BLL.Loans LoanManager = new LPWeb.BLL.Loans();
        DataTable       LoanInfo    = LoanManager.GetLoanInfo(this.iFileID);
        if (LoanInfo.Rows.Count == 0)
        {
            PageCommon.WriteJsEnd(this, "Invalid query string.", sCloseDialogCodes);
        }
        string sPropertyAddress = LoanInfo.Rows[0]["PropertyAddr"].ToString();
        string sPropertyCity    = LoanInfo.Rows[0]["PropertyCity"].ToString();
        string sPropertyState   = LoanInfo.Rows[0]["PropertyState"].ToString();
        string sPropertyZip     = LoanInfo.Rows[0]["PropertyZip"].ToString();

        string sProperty = sPropertyAddress + ", " + sPropertyCity + ", " + sPropertyState + " " + sPropertyZip;

        #endregion

        #region Borrower

        DataTable BorrowerInfo = LoanManager.GetBorrowerInfo(this.iFileID);
        if (BorrowerInfo.Rows.Count == 0)
        {
            PageCommon.WriteJsEnd(this, "There is no Borrower in this loan.", sCloseDialogCodes);
        }
        string sFirstName  = BorrowerInfo.Rows[0]["FirstName"].ToString();
        string sMiddleName = BorrowerInfo.Rows[0]["MiddleName"].ToString();
        string sLastName   = BorrowerInfo.Rows[0]["LastName"].ToString();

        string sBorrower = sLastName + ",  " + sFirstName;
        if (sMiddleName != string.Empty)
        {
            sBorrower += " " + sMiddleName;
        }

        this.lbBorrower.Text = sBorrower;
        this.lbProperty.Text = sProperty;

        #endregion

        #endregion

        #region 查询条件

        string sWhere = string.Empty;

        if (this.Request.QueryString["search"] == null)    // 未设置查询条件
        {
            sWhere = " (1=0)";
        }
        else
        {
            //sWhere = " (FileId <> " + this.iFileID + ")";
            sWhere = " (1=1) ";
            // Service Type
            if (this.Request.QueryString["ServiceType"] != null)
            {
                string sServiceType = this.Request.QueryString["ServiceType"];

                sWhere += "  and ServiceTypes='" + sServiceType + "'";
            }

            // Company
            if (this.Request.QueryString["Company"] != null)
            {
                string sCompany = this.Request.QueryString["Company"];

                sWhere += " and CompanyName like '" + sCompany + "%'";
            }

            // Zip
            if (this.Request.QueryString["Zip"] != null)
            {
                string sZip = this.Request.QueryString["Zip"];

                sWhere += " and MailingZip like '" + sZip + "%'";
            }
        }

        #endregion

        #region 排序

        string sOrderByField = "ContactsName";
        if (this.Request.QueryString["OrderByField"] != null)
        {
            sOrderByField = this.Request.QueryString["OrderByField"];
        }

        int iOrderByType = 0;  // default asc
        if (this.Request.QueryString["OrderByType"] != null)
        {
            string sOrderByType = this.Request.QueryString["OrderByType"];
            if (sOrderByType != "0")
            {
                sOrderByType = "1";
            }

            iOrderByType = Convert.ToInt32(sOrderByType);
        }

        #endregion

        if (this.IsPostBack == false)
        {
            #region 加载Service Type Filter

            string    sSql2           = "select * from ServiceTypes where Enabled=1 order by Name";
            DataTable ServiceTypeList = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSql2);

            DataRow AllRow = ServiceTypeList.NewRow();
            AllRow["ServiceTypeId"] = 0;
            AllRow["Name"]          = "All";
            AllRow["Enabled"]       = true;

            ServiceTypeList.Rows.InsertAt(AllRow, 0);

            this.ddlServiceType.DataSource = ServiceTypeList;
            this.ddlServiceType.DataBind();

            #endregion

            #region 加载Contact Role Filter

            string    sSql3           = "select * from ContactRoles where Enabled=1 and Name <> 'Borrower' and Name <> 'CoBorrower' order by Name";
            DataTable ContactRoleList = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSql3);

            DataRow EmptyRow = ContactRoleList.NewRow();
            EmptyRow["ContactRoleId"] = 0;
            EmptyRow["Name"]          = "-- select --";
            EmptyRow["Enabled"]       = true;

            ContactRoleList.Rows.InsertAt(EmptyRow, 0);

            this.ddlContactRole.DataSource = ContactRoleList;
            this.ddlContactRole.DataBind();

            #endregion

            #region 加载Contact List

            int iPageSize  = this.AspNetPager1.PageSize;
            int iPageIndex = 1;
            if (this.Request.QueryString["PageIndex"] != null)
            {
                iPageIndex = Convert.ToInt32(this.Request.QueryString["PageIndex"]);
            }

            int iRowCount = 0;

            LPWeb.BLL.LoanContacts contacts = new LPWeb.BLL.LoanContacts();
            DataSet ds = contacts.GetDistinctLoanContactsForReassign(iPageSize, iPageIndex, sWhere, out iRowCount, sOrderByField, iOrderByType);

            this.AspNetPager1.RecordCount = iRowCount;

            #region set EmptyDataText

            if (this.Request.QueryString["search"] == null)
            {
                this.gridLoanContactList.EmptyDataText = "Please enter conditions and click Display.";
            }
            else
            {
                if (iRowCount == 0)
                {
                    this.gridLoanContactList.EmptyDataText = "There is no loan contact by the conditions.";
                }
            }

            #endregion

            this.gridLoanContactList.DataSource = ds;
            this.gridLoanContactList.DataBind();



            #endregion
        }
    }
コード例 #3
0
ファイル: LoanDetails.aspx.cs プロジェクト: PulseCRM/Pulse
    protected void Page_Load(object sender, EventArgs e)
    {
        #region 校验页面参数

        string sReturnUrl = "../Pipeline/ProcessingPipelineSummary.aspx";
        string sErrorMsg  = "Failed to load this page: missing required query string.";
        string sBackJs    = "window.location.href='" + sReturnUrl + "'";
        string sFileID    = string.Empty;
        string sFileIDs   = string.Empty;
        string sPageFrom  = string.Empty;

        // contactid
        bool bIsValid = PageCommon.ValidateQueryString(this, "ContactID", QueryStringType.ID);
        if (bIsValid)
        {
            try
            {
                int ContactID = int.Parse(this.Request.QueryString["ContactID"]);
                LPWeb.BLL.LoanContacts blllc = new LPWeb.BLL.LoanContacts();
                DataSet ds = blllc.GetContactLoans(ContactID);
                if (ds == null || ds.Tables.Count < 1 || ds.Tables[0].Rows.Count < 1)
                {
                    PageCommon.WriteJsEnd(this, sErrorMsg, sBackJs);
                }
                else
                {
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        if (i == 0)
                        {
                            sFileID = ds.Tables[0].Rows[0][0].ToString();
                        }
                        sFileIDs = ds.Tables[0].Rows[0][0].ToString() + ",";
                    }

                    sFileIDs = sFileIDs.TrimEnd(",".ToCharArray());
                }
            }
            catch
            {
                PageCommon.WriteJsEnd(this, sErrorMsg, sBackJs);
            }
        }
        else
        {
            // fieldid
            bIsValid = PageCommon.ValidateQueryString(this, "fieldid", QueryStringType.ID);
            if (bIsValid == false)
            {
                PageCommon.WriteJsEnd(this, sErrorMsg, sBackJs);
            }
            sFileID = this.Request.QueryString["fieldid"];

            // fieldids
            bIsValid = PageCommon.ValidateQueryString(this, "fieldids", QueryStringType.IDs);
            if (bIsValid == false)
            {
                PageCommon.WriteJsEnd(this, sErrorMsg, sBackJs);
            }
            sFileIDs = this.Request.QueryString["fieldids"];
        }

        // FromPage
        bIsValid = PageCommon.ValidateQueryString(this, "FromPage", QueryStringType.String);
        if (bIsValid == false)
        {
            PageCommon.WriteJsEnd(this, sErrorMsg, sBackJs);
        }
        sPageFrom = this.Request.QueryString["FromPage"];
        if (sPageFrom == string.Empty)
        {
            sPageFrom = sReturnUrl;
        }
        #endregion

        this.hfID.Value       = sFileID;
        this.hfIDs.Value      = sFileIDs;
        this.hfPageFrom.Value = sPageFrom;

        // insert the UserRecentItems
        LPWeb.BLL.UserRecentItems _bUserRecentItems = new LPWeb.BLL.UserRecentItems();
        _bUserRecentItems.InsertUserRecentItems(Convert.ToInt32(sFileID), CurrUser.iUserID);
    }
コード例 #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);
        }