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();
    }
Exemplo n.º 2
0
    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);
            }
        }
    }
Exemplo n.º 3
0
    protected void btnSelect_Click(object sender, EventArgs e)
    {
        int iNewContactID = Convert.ToInt32(this.hdnSelContactID.Value);

        #region 加载LoanContacts

        string    sSql       = "select * from LoanContacts where ContactID=" + this.iDelContactID;
        DataTable RefLoanIDs = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSql);

        #endregion

        #region 调用PointManager.ReassignContactRequest

        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>();
            foreach (DataRow RefLoanRow in RefLoanIDs.Rows)
            {
                int iFileID        = Convert.ToInt32(RefLoanRow["FileId"]);
                int iContactRoleID = Convert.ToInt32(RefLoanRow["ContactRoleId"]);

                ReassignContactInfo ContactInfo = new ReassignContactInfo();
                ContactInfo.FileId        = iFileID;
                ContactInfo.ContactRoleId = iContactRoleID;
                ContactInfo.NewContactId  = iNewContactID;
                ContactList.Add(ContactInfo);
            }
            req.reassignContacts = ContactList.ToArray();

            #endregion

            ReassignContactResponse respone = null;
            try
            {
                respone = service.ReassignContact(req);

                if (respone.hdr.Successful)
                {
                    foreach (DataRow RefLoanRow in RefLoanIDs.Rows)
                    {
                        int iFileID        = Convert.ToInt32(RefLoanRow["FileId"]);
                        int iContactRoleID = Convert.ToInt32(RefLoanRow["ContactRoleId"]);

                        #region Reassign Loan Contact

                        LPWeb.Model.LoanContacts lcModel = new LPWeb.Model.LoanContacts();
                        lcModel.FileId        = iFileID;
                        lcModel.ContactRoleId = iContactRoleID;
                        lcModel.ContactId     = iNewContactID;

                        LPWeb.Model.LoanContacts oldlcModel = new LPWeb.Model.LoanContacts();
                        oldlcModel.FileId        = iFileID;
                        oldlcModel.ContactRoleId = iContactRoleID;
                        oldlcModel.ContactId     = this.iDelContactID;

                        LPWeb.BLL.LoanContacts lc = new LoanContacts();
                        lc.Reassign(oldlcModel, lcModel, req.hdr.UserId);

                        #endregion

                        #region delete contact

                        Contacts bllContact = new Contacts();
                        int      iUserType  = 0;
                        if (this.CurrUser.bIsCompanyExecutive)
                        {
                            iUserType = 0;
                        }
                        else if (this.CurrUser.bIsBranchManager)
                        {
                            iUserType = 1;
                        }
                        else
                        {
                            iUserType = 2;
                        }
                        bllContact.PartnerContactsDelete(this.iDelContactID, CurrUser.iUserID, iUserType);

                        #endregion
                    }

                    PageCommon.WriteJsEnd(this, "Deleted contact successfully", PageCommon.Js_RefreshParent);
                }
                else
                {
                    PageCommon.WriteJsEnd(this, String.Format("Failed to reassign contact: reason: {0}.", respone.hdr.StatusInfo), PageCommon.Js_RefreshSelf);
                }
            }
            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);
            }
        }

        #endregion
    }