protected void Page_Load(object sender, EventArgs e) { // json示例 // {"ExecResult":"Success","ErrorMsg":""} // {"ExecResult":"Failed","ErrorMsg":"错误信息"} int iFileID = 0; int iUserID = 0; int iLoanRoleID = 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, "UserID", QueryStringType.ID); if (bIsValid == false) { this.Response.Write("{\"ExecResult\":\"Failed\",\"ErrorMsg\":\"Missing required query string.\"}"); this.Response.End(); } string sUserID = this.Request.QueryString["UserID"]; iUserID = Convert.ToInt32(sUserID); bIsValid = PageCommon.ValidateQueryString(this, "LoanRoleID", QueryStringType.ID); if (bIsValid == false) { this.Response.Write("{\"ExecResult\":\"Failed\",\"ErrorMsg\":\"Missing required query string.\"}"); this.Response.End(); } string sLoanRoleID = this.Request.QueryString["LoanRoleID"]; iLoanRoleID = Convert.ToInt32(sLoanRoleID); #endregion ServiceManager sm = new ServiceManager(); using (LP2ServiceClient service = sm.StartServiceClient()) { #region 调用ReassignProspect #region Build ReassignProspectRequest ReassignProspectRequest rpq = new ReassignProspectRequest(); rpq.hdr = new ReqHdr(); rpq.FileId = new int[1] { iFileID }; rpq.hdr.SecurityToken = "SecurityToken"; //todo:check dummy data rpq.hdr.UserId = iCurrrentUserID; rpq.FromUser = 0; rpq.ToUser = iUserID; rpq.ContactId = null; rpq.UserId = null; #endregion #region invoke ReassignProspect bool bSuccess = false; string sError = string.Empty; try { ReassignProspectResponse rpp = service.ReassignProspect(rpq); bSuccess = rpp.hdr.Successful; if (bSuccess == false) { sError = "Failed to invoke API ReassignProspect."; } } catch (System.ServiceModel.EndpointNotFoundException ex) { bSuccess = false; sError = "Exception happened: Point Manager is not running."; LPLog.LogMessage(ex.Message); } catch (Exception exception) { bSuccess = false; sError = "Exception happened when invoke API ReassignProspect."; LPLog.LogMessage(exception.Message); } finally { if (bSuccess == false) { this.Response.Write("{\"ExecResult\":\"Failed\",\"ErrorMsg\":\"" + sError + "\"}"); this.Response.End(); } } #endregion #endregion #region 调用ReassignLoan #region Build ReassignLoanRequest ReassignLoanRequest req = new ReassignLoanRequest(); req.hdr = new ReqHdr(); req.hdr.SecurityToken = "SecurityToken"; //todo:check dummy data req.hdr.UserId = iCurrrentUserID; List <ReassignUserInfo> UserList = new List <ReassignUserInfo>(); ReassignUserInfo UserInfo = new ReassignUserInfo(); UserInfo.FileId = iFileID; UserInfo.RoleId = iLoanRoleID; UserInfo.NewUserId = iUserID; UserList.Add(UserInfo); req.reassignUsers = UserList.ToArray(); #endregion #region invoke api bSuccess = false; sError = string.Empty; try { ReassignLoanResponse respone = service.ReassignLoan(req); bSuccess = respone.hdr.Successful; if (bSuccess == false) { sError = "Failed to invoke API ReassignLoan."; } } catch (System.ServiceModel.EndpointNotFoundException ex) { LPLog.LogMessage(ex.Message); bSuccess = false; sError = "Exception happened: Point Manager is not running."; } catch (Exception exception) { LPLog.LogMessage(exception.Message); bSuccess = false; sError = "Exception happened when invoke API ReassignLoan."; } finally { if (bSuccess == false) { this.Response.Write("{\"ExecResult\":\"Failed\",\"ErrorMsg\":\"" + sError + "\"}"); this.Response.End(); } } #endregion #endregion } #region Reassign Loan Team LPWeb.Model.LoanTeam lcModel = new LPWeb.Model.LoanTeam(); lcModel.FileId = iFileID; lcModel.RoleId = iLoanRoleID; lcModel.UserId = iUserID; LPWeb.Model.LoanTeam oldlcModel = new LPWeb.Model.LoanTeam(); oldlcModel.FileId = iFileID; oldlcModel.RoleId = 0; oldlcModel.UserId = 0; LPWeb.BLL.LoanTeam LoanTeam1 = new LPWeb.BLL.LoanTeam(); LoanTeam1.Reassign(oldlcModel, lcModel, iCurrrentUserID); #endregion this.Response.Write("{\"ExecResult\":\"Success\",\"ErrorMsg\":\"\"}"); this.Response.End(); }
public void BindData() { LPWeb.BLL.Loans bllLoans = new LPWeb.BLL.Loans(); LPWeb.BLL.LoanTeam bllLoanTeam = new LPWeb.BLL.LoanTeam(); LPWeb.BLL.Users bllUsers = new LPWeb.BLL.Users(); LPWeb.Model.Loans loanInfo = bllLoans.GetModel(LoanID); DataTable LoanInfo_datatable = bllLoans.GetLoanInfo(LoanID); decimal loanAmount = 0; LoanPointFields LoanPointFieldsMgr = new LoanPointFields(); //LPWeb.Model.LoanPointFields PointFieldInfo = LoanPointFieldsMgr.GetPointFieldInfo(LoanID, 21017); LPWeb.Model.LoanPointFields PointFieldInfo = LoanPointFieldsMgr.GetModel(LoanID, 21017); if (PointFieldInfo != null && !string.IsNullOrEmpty(PointFieldInfo.CurrentValue)) { decimal.TryParse(PointFieldInfo.CurrentValue, out loanAmount); } if (loanAmount <= 0 && LoanInfo_datatable != null && LoanInfo_datatable.Rows.Count > 0) { loanAmount = LoanInfo_datatable.Rows[0]["LoanAmount"] == DBNull.Value ? 0 : (decimal)LoanInfo_datatable.Rows[0]["LoanAmount"]; } this.labLoanamount.Text = loanAmount.ToString("n2"); var list = new List <ViewCompDetail>(); var Lo = new ViewCompDetail(); Lo.Type = "Loan Officer"; var LOUserId = bllLoanTeam.GetLoanOfficerID(LoanID); Lo.Name = bllLoanTeam.GetLoanOfficer(LoanID); Lo.Rate = GetUserCompRate(LOUserId); Lo.Amount = Lo.Rate * loanAmount / 100.00M; list.Add(Lo); loanInfo.BranchID = loanInfo.BranchID != null ? loanInfo.BranchID : 0; var branchM = new ViewCompDetail(); branchM.Type = "Branch Manager"; LPWeb.BLL.BranchManagers bllbranM = new LPWeb.BLL.BranchManagers(); var branchUserId = 0; var branchObj = bllbranM.GetModelList("BranchId =" + loanInfo.BranchID).FirstOrDefault(); if (branchObj != null) { branchUserId = branchObj.BranchMgrId; } LPWeb.Model.Users userBrM = bllUsers.GetModel(branchUserId); if (userBrM != null && userBrM.UserId == branchUserId) { branchM.Name = userBrM.LastName + "," + userBrM.FirstName; branchM.Rate = GetBranchMgrCompRate(LOUserId); branchM.Amount = branchM.Rate * loanAmount / 100.00M; } list.Add(branchM); loanInfo.DivisionID = loanInfo.DivisionID != null ? loanInfo.DivisionID : 0; var divisionM = new ViewCompDetail(); divisionM.Type = "Division Manager"; LPWeb.BLL.DivisionExecutives bllDivM = new LPWeb.BLL.DivisionExecutives(); var DivMUserId = 0; var divobj = bllDivM.GetModelList("DivisionId =" + loanInfo.DivisionID).FirstOrDefault(); if (divobj != null) { DivMUserId = divobj.ExecutiveId; } LPWeb.Model.Users userDivM = bllUsers.GetModel(DivMUserId); if (userDivM != null && userDivM.UserId == DivMUserId) { divisionM.Name = userDivM.LastName + "," + userDivM.FirstName; divisionM.Rate = GetDivisionMgrCompRate(LOUserId); divisionM.Amount = divisionM.Rate * loanAmount / 100.00M; } list.Add(divisionM); loanInfo.RegionID = loanInfo.RegionID != null ? loanInfo.RegionID : 0; var RegionM = new ViewCompDetail(); RegionM.Type = "Region Manager"; LPWeb.BLL.RegionExecutives bllRegionM = new LPWeb.BLL.RegionExecutives(); var RegionMUserId = 0; var regionObj = bllRegionM.GetModelList("RegionId =" + loanInfo.RegionID).FirstOrDefault(); if (regionObj != null) { RegionMUserId = regionObj.ExecutiveId; } LPWeb.Model.Users userRegionM = bllUsers.GetModel(RegionMUserId); if (userRegionM != null && userRegionM.UserId == RegionMUserId) { RegionM.Name = userRegionM.LastName + "," + userRegionM.FirstName; RegionM.Rate = GetRegionMgrCompRate(LOUserId); RegionM.Amount = RegionM.Rate * loanAmount / 100.00M; } list.Add(RegionM); gvCompDetail.DataSource = list; gvCompDetail.DataBind(); }