public ResultCodeModel SaveSelfReported(LoanCanonicalType SelfReported) { _log.Info("InvokeSelfReportedService.SaveSelfReported() starting ..."); LoanManagementClient client = null; Dictionary <string, string> paramList = null; ResponseMessageList messageList = new ResponseMessageList(); //try/catch here, and handle results/errors appropriately... ResultCodeModel result = new ResultCodeModel(); try { client = new LoanManagementClient(); result.ResultCode = client.SaveLoanSelfReportedEntry(paramList, ref SelfReported, out messageList); } catch (TimeoutException timeout) { ErrorModel error = new ErrorModel("There was a timeout problem calling the SelfReported Management Service", "InvokeSelfReportedMangementService"); result.ErrorList.Add(error); result.ResultCode = 2;//FAIL; ProxyHelper.HandleServiceException(client); _log.Error("InvokeSelfReportedService.SaveSelfReported() Timeout Exception:" + timeout.Message); } catch (CommunicationException comm) { ErrorModel error = new ErrorModel("There was a communication problem calling the SelfReported Management Service", "InvokeSelfReportedMangementService"); result.ErrorList.Add(error); result.ResultCode = 2;//FAIL; ProxyHelper.HandleServiceException(client); _log.Error("InvokeSelfReportedService.SaveSelfReported() Communication Exception:" + comm.Message); } catch (Exception e) { ErrorModel error = new ErrorModel("There was an exception thrown calling the SelfReported Management Service", "InvokeSelfReportedMangementService"); result.ErrorList.Add(error); result.ResultCode = 2;//FAIL; _log.Error("InvokeSelfReportedService.SaveSelfReported() Exception:" + e.Message); } finally { if (client != null && client.State != CommunicationState.Closed) { ProxyHelper.CloseChannel(client); } } _log.Info("InvokeSelfReportedService.SaveSelfReported() ending ..."); return(result); }
public GetLoanResponse GetLoan(GetLoanRequest getRequest) { _log.Debug("InvokeLoanManagementService.GetLoan() starting ..."); LoanManagementClient client = null; GetLoanResponse response = null; try { client = new LoanManagementClient(); _log.Debug("client created successfully"); ILoanManagement lm = (ILoanManagement)client; response = lm.GetLoan(getRequest); _log.Debug("response was received from ODS LoanManagement service"); } catch (TimeoutException timeout) { _log.Error("InvokeLoanManagementService.GetLoan() Timeout Exception:" + timeout.Message); ProxyHelper.HandleServiceException(client); } catch (CommunicationException comm) { _log.Error("InvokeLoanManagementService.GetLoan() Communication Exception:" + comm.Message); ProxyHelper.HandleServiceException(client); } catch (Exception e) { _log.Error("InvokeLoanManagementService.GetLoan() Exception:" + e.Message); } finally { if (client != null && client.State != CommunicationState.Closed) { ProxyHelper.CloseChannel(client); } } _log.Debug("InvokeLoanManagementService.GetLoan() ending ..."); return(response); }
public GetLoanSelfReportedEntryResponse GetSelfReported(GetLoanSelfReportedEntryRequest getRequest) { _log.Info("InvokeSelfReportedService.GetSelfReported() starting ..."); LoanManagementClient client = null; GetLoanSelfReportedEntryResponse response = null; try { client = new LoanManagementClient(); ILoanManagement lm = (ILoanManagement)client; response = lm.GetLoanSelfReportedEntry(getRequest); } catch (TimeoutException timeout) { _log.Error("InvokeSelfReportedService.GetSelfReported() Timeout Exception:" + timeout.Message); ProxyHelper.HandleServiceException(client); } catch (CommunicationException comm) { _log.Error("InvokeSelfReportedService.GetSelfReported() Communication Exception:" + comm.Message); ProxyHelper.HandleServiceException(client); } catch (Exception e) { _log.Error("InvokeSelfReportedService.GetSelfReported() Exception:" + e.Message); } finally { if (client != null && client.State != CommunicationState.Closed) { ProxyHelper.CloseChannel(client); } } _log.Info("InvokeSelfReportedService.GetSelfReported() ending ..."); return(response); }
public static KeyValuePair<string, string> CreateLoan( string leadID, string clientID, string branchID, string userID, string SSN, string ZIP) { if (String.IsNullOrWhiteSpace(leadID)) { return new KeyValuePair<string, string>("Error", "Lead is not selected."); } if (String.IsNullOrWhiteSpace(clientID)) { return new KeyValuePair<string, string>("Error", "Client is not selected."); } if (String.IsNullOrWhiteSpace(userID)) { return new KeyValuePair<string, string>("Error", "User is not selected."); } if (String.IsNullOrWhiteSpace(SSN) || !Regex.IsMatch(SSN, @"\d{3}-\d{2}-\d{4}")) { return new KeyValuePair<string, string>("Error", "SSN is not filled."); } if (String.IsNullOrWhiteSpace(ZIP) || !Regex.IsMatch(ZIP, @"\d{5}(-\d{4})?")) { return new KeyValuePair<string, string>("Error", "Lead is not filled."); } SSN = SSN.Replace("-", ""); var iLeadID = -1; var iClientID = -1; var iBranchID = -1; if (!int.TryParse(leadID, out iLeadID) && iLeadID < 0) { return new KeyValuePair<string, string>("Error", "Lead is incorrect."); } if (!int.TryParse(clientID, out iClientID) && iClientID < 0) { return new KeyValuePair<string, string>("Error", "Client is incorrect."); } if (!String.IsNullOrWhiteSpace(branchID) && !int.TryParse(branchID, out iBranchID) && iBranchID < 0) { return new KeyValuePair<string, string>("Error", "Branch is incorrect."); } DataManager.LeadModified(iLeadID); try { var lead = DataManager.GetLeadById(iLeadID); TestHost.Initialize(); SecurityContext.Initialize(); Host.Current.ApplicationName = "LOS"; SecurityContext currSecContext = SecurityContext.Current; SecurityContext.Current.User.UserName = "******"; SecurityContext.SetUser("devClientAdmin"); SecurityContext.Current.Data["clientID"] = UserManager.GetUser(SecurityContext.Current.User.UserName).ClientId.Value; using (var serviceClient = new LoanManagementClient()) { int? nBranchID = null; if (iBranchID != -1) { nBranchID = iBranchID; } string homeStreetAddress = null; string homeZip = null; string homeState = null; string homeCity = null; if (lead.HomeAddress != null) { homeStreetAddress = lead.HomeAddress.ToString(); if (!Regex.IsMatch(lead.HomeAddress.ZipCode, @"\d{5}-?(\d{4})?")) { homeZip = lead.HomeAddress.ZipCode; } homeState = lead.HomeAddress.State; homeCity = lead.HomeAddress.City; } string workStreetAddress = null; string workZip = null; string workState = null; string workCity = null; if (lead.WorkAddress != null) { workStreetAddress = lead.WorkAddress.ToString(); if (!Regex.IsMatch(lead.WorkAddress.ZipCode, @"\d{5}-?(\d{4})?")) { workZip = lead.WorkAddress.ZipCode; } workState = lead.WorkAddress.State; workCity = lead.WorkAddress.City; } string subjectPropertyStreetAddress = null; string subjectPropertyZip = null; string subjectPropertyState = null; string subjectPropertyCity = null; if (lead.SubjectPropertyAddress != null) { var serverZIP = lead.SubjectPropertyAddress.ZipCode.Replace("-", ""); var clientZIP = ZIP.Replace("-", ""); if (serverZIP.Equals(clientID)) { subjectPropertyStreetAddress = lead.SubjectPropertyAddress.ToString(); if (!Regex.IsMatch(lead.SubjectPropertyAddress.ZipCode, @"\d{5}-?(\d{4})?")) { subjectPropertyZip = lead.SubjectPropertyAddress.ZipCode; } subjectPropertyState = lead.SubjectPropertyAddress.State; subjectPropertyCity = lead.SubjectPropertyAddress.City; } else { subjectPropertyZip = ZIP; } } else { subjectPropertyZip = ZIP; } string source = null; if (lead.LeadSource != null) { source = lead.LeadSource.Where; } serviceClient.CreateLoan( iClientID, nBranchID, userID, lead.FirstName, lead.LastName, SSN, lead.HomePhone ?? "", homeStreetAddress, homeZip, homeState, homeCity, lead.Email, lead.CompanyName, lead.JobTitle, workStreetAddress, workZip, workState, workCity, lead.BusinessPhone ?? "", subjectPropertyStreetAddress, subjectPropertyZip, subjectPropertyState, subjectPropertyCity, source ); } var success = String.Concat("New loan ", lead.FullName, " was successfully created!"); return new KeyValuePair<string, string>("Success", success); } catch (ApplicationException) { return new KeyValuePair<string, string>("Error", "This lead does not exist."); } catch (Exception) { return new KeyValuePair<string, string>("Error", "Loan is not created."); } }