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 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 }