/// <summary> /// Posts the PostLeadRequest object to the PulseLead service /// </summary> /// <param name="req"></param> /// <param name="import_trans_id"></param> /// <returns></returns> internal static ResponseHdr PostPulseLeadRequest(PostLeadRequest req, string import_trans_id) { try { // Post var svc = new PostLead(); ResponseHdr response_hdr = svc.Post(req); // save the credit score if (response_hdr.Successful && req.CreditScore > 0) { svc.SaveCreditScore(response_hdr._postArgs.ContactId, req.CreditScore); } // log the event if (response_hdr.Successful) { NLogger.Info(MethodBase.GetCurrentMethod().DeclaringType.FullName, MethodBase.GetCurrentMethod().Name, "Lead posted to Pulse. Zillow.ImporTransId = " + import_trans_id + ", ContactId = " + response_hdr._postArgs.ContactId.ToString()); } else { NLogger.Info(MethodBase.GetCurrentMethod().DeclaringType.FullName, MethodBase.GetCurrentMethod().Name, "Could not post lead to Pulse."); } return(response_hdr); } catch (Exception ex) { NLogger.Error(MethodBase.GetCurrentMethod().DeclaringType.FullName, MethodBase.GetCurrentMethod().Name, ex.Message, ex); throw; } }
/// <summary> /// Returns the PostLeadRequest object populated with Zillow XML data /// </summary> /// <param name="zcol"></param> /// <returns></returns> internal static PostLeadRequest GetPulseLeadRequest(ZillowAttributeCollection zcol) { try { PostLeadRequest req = MapZillowToPulseLeadRequest(zcol); NLogger.Info(MethodBase.GetCurrentMethod().DeclaringType.FullName, MethodBase.GetCurrentMethod().Name, "ZillowImport (" + zcol.ImportTransId.ToString() + ") completed."); return(req); } catch (Exception ex) { NLogger.Error(MethodBase.GetCurrentMethod().DeclaringType.FullName, MethodBase.GetCurrentMethod().Name, ex.Message, ex); throw; } }
//private const string EventLogName = "PulseLeadService-LT_PostLeads"; protected void Page_Load(object sender, EventArgs e) { #region for test if (Request.QueryString["test"] != null && Request.QueryString["test"].ToString() == "1") { return; } #endregion Response.Clear(); if (Request.InputStream.Length == 0) { Log("No XML data.", 0); WriteStatus(0, "No XML data."); return; } string token = string.Empty; try { string sqlCmd = "Select top 1 GlobalID from Company_General"; object obj = focusIT.DbHelperSQL.GetSingle(sqlCmd); token = (obj == null || obj == DBNull.Value) ? string.Empty : (string)obj; } catch (Exception ex) { } if (string.IsNullOrEmpty(token)) { token = System.Configuration.ConfigurationManager.AppSettings["SecurityToken"] == null ? "" : System.Configuration.ConfigurationManager.AppSettings["SecurityToken"].ToString(); if (string.IsNullOrEmpty(token)) { Log("SecurityToken is Empty!", 0); WriteStatus(0, "SecurityToken is Empty!"); return; } } PostLeadRequest req_lead = new PostLeadRequest(); req_lead.RequestHeader = new PostLeadWeb.LP2Service.Lead_ReqHdr(); req_lead.RequestHeader.SecurityToken = token; string err = string.Empty; bool checkDuplicates = false; #region mapping field try { var streamReader = new StreamReader(Request.InputStream); //string str = streamReader.ReadToEnd(); XDocument xmlDoc = XDocument.Load(streamReader); var leadApp = xmlDoc.Elements("LeadInformation").Elements("LeadApplication"); var applicantID = leadApp.Elements("ApplicantID").FirstOrDefault().Value; req_lead.LeadId = applicantID; if (ConfigurationManager.AppSettings["CheckDuplicates"] != null) { Boolean.TryParse(ConfigurationManager.AppSettings["CheckDuplicates"].ToString(), out checkDuplicates); } if (!string.IsNullOrEmpty(req_lead.LeadId)) { req_lead.CheckDuplicate = checkDuplicates; } PostLeadWeb.LP2Service.Address address = new PostLeadWeb.LP2Service.Address(); address.City = leadApp.Elements("City").FirstOrDefault().Value; address.State = leadApp.Elements("State").FirstOrDefault().Value; address.Zip = leadApp.Elements("Zip").FirstOrDefault().Value; address.Street = leadApp.Elements("Address1").FirstOrDefault().Value; req_lead.MailingAddress = address; req_lead.Email = leadApp.Elements("EmailAddress").FirstOrDefault().Value; req_lead.HomePhone = leadApp.Elements("HomePhone").FirstOrDefault().Value; req_lead.BusinessPhone = leadApp.Elements("WorkPhone").FirstOrDefault().Value; req_lead.BorrowerFirstName = leadApp.Elements("FirstName").FirstOrDefault().Value; req_lead.BorrowerLastName = leadApp.Elements("LastName").FirstOrDefault().Value; req_lead.BorrowerMiddleName = ""; req_lead.SSN = leadApp.Elements("SSN").FirstOrDefault().Value; req_lead.PreferredContactMethod = PreferredContactMethod.Email; //var oIncomeList = new List<OtherIncome>(); //if (!string.IsNullOrEmpty(leadApp.Elements("MonthlyIncome").FirstOrDefault().Value)) //{ // OtherIncome oIncome = new OtherIncome(); // oIncome.Amount = Convert.ToDecimal(leadApp.Elements("MonthlyIncome").FirstOrDefault().Value); // oIncomeList.Add(oIncome); //} //req_lead.OtherIncome = oIncomeList.ToArray(); // into loannotes #region CreditRating switch (leadApp.Elements("CreditRating").FirstOrDefault().Value.ToLower()) { case "good": req_lead.CreditRanking = PostLeadWeb.LP2Service.CreditRanking.Good; break; case "excellent": req_lead.CreditRanking = PostLeadWeb.LP2Service.CreditRanking.Excellent; break; case "fair": req_lead.CreditRanking = PostLeadWeb.LP2Service.CreditRanking.Fair; break; case "poor": req_lead.CreditRanking = PostLeadWeb.LP2Service.CreditRanking.Poor; break; case "verygood": req_lead.CreditRanking = PostLeadWeb.LP2Service.CreditRanking.VeryGood; break; default: req_lead.CreditRanking = PostLeadWeb.LP2Service.CreditRanking.Good; break; } #endregion //IsMilitary //TimeToContact //WorkingWithRealtor #region PropertyType switch (leadApp.Elements("PropertyType").FirstOrDefault().Value.ToLower()) { case "single-family": req_lead.PropertyType = "SFR"; break; case "town home": req_lead.PropertyType = "Townhome"; break; case "condominium": req_lead.PropertyType = "Condo"; break; case "Cooperative": req_lead.PropertyType = "Other"; break; case "multiple-family": req_lead.PropertyType = "TwotoFourUnit"; break; case "mobile home": req_lead.PropertyType = "Other"; break; default: req_lead.PropertyType = "Other"; break; } #endregion switch (leadApp.Elements("PropertyUse").FirstOrDefault().Value.ToLower()) { case "primary residence": req_lead.OccupancyType = PostLeadWeb.LP2Service.OccupancyType.PrimaryResidence; break; case "vacation property ": req_lead.OccupancyType = PostLeadWeb.LP2Service.OccupancyType.SecondHome; break; case "investment property": req_lead.OccupancyType = PostLeadWeb.LP2Service.OccupancyType.InvestmentProperty; break; } //PropertyCounty req_lead.Property_Zip = leadApp.Elements("PropertyZip").FirstOrDefault().Value; //PropertyMSA req_lead.Property_State = leadApp.Elements("PropertyState").FirstOrDefault().Value; //LoanType if (!string.IsNullOrEmpty(leadApp.Elements("LoansToBeFinanced").FirstOrDefault().Value)) { req_lead.Notes += "Loans to be financed=" + leadApp.Elements("LoansToBeFinanced").FirstOrDefault().Value; } //DownPayment req_lead.LoanAmount = string.IsNullOrEmpty(leadApp.Elements("LoanAmount").FirstOrDefault().Value) ? 0 : Convert.ToInt32(leadApp.Elements("LoanAmount").FirstOrDefault().Value); req_lead.PropertyValue = string.IsNullOrEmpty(leadApp.Elements("PropertyPrice").FirstOrDefault().Value) ? 0 : Convert.ToInt32(leadApp.Elements("PropertyPrice").FirstOrDefault().Value); //AddlCashOut if (!string.IsNullOrEmpty(leadApp.Elements("AddlCashOut").FirstOrDefault().Value)) { req_lead.Notes += "\r\n AdditionalCashout=" + leadApp.Elements("AddlCashOut").FirstOrDefault().Value; } //MortgageType if (!string.IsNullOrEmpty(leadApp.Elements("MortgageType").FirstOrDefault().Value)) { req_lead.Notes += "\r\n MortgageType=" + leadApp.Elements("MortgageType").FirstOrDefault().Value; } //TimeLine if (!string.IsNullOrEmpty(leadApp.Elements("TimeLine").FirstOrDefault().Value)) { req_lead.Notes += "\r\n TimeLine=" + leadApp.Elements("TimeLine").FirstOrDefault().Value; } //<AnnualIncome/> if (!string.IsNullOrEmpty(leadApp.Elements("AnnualIncome").FirstOrDefault().Value)) { req_lead.Notes += "\r\n AnnualIncome=" + leadApp.Elements("AnnualIncome").FirstOrDefault().Value; } //MonthlyPayment //req_lead.MonthlyPayment = string.IsNullOrEmpty(leadApp.Elements("MonthlyPayment").FirstOrDefault().Value) ? 0 : Convert.ToDecimal(leadApp.Elements("MonthlyPayment").FirstOrDefault().Value); //FirstMortgageMonthlyPayment = leadApp.Elements("FirstMortgageBalance").FirstOrDefault().Value; //FirstMortgageBalance if (!string.IsNullOrEmpty(leadApp.Elements("FirstMortgageBalance").FirstOrDefault().Value)) { req_lead.Notes += "\r\n FirstMortgageBalance=" + leadApp.Elements("FirstMortgageBalance").FirstOrDefault().Value; } //SecondMortgageBalance if (!string.IsNullOrEmpty(leadApp.Elements("SecondMortgageBalance").FirstOrDefault().Value)) { req_lead.Notes += "\r\n SecondMortgageBalance=" + leadApp.Elements("SecondMortgageBalance").FirstOrDefault().Value; } //AddlMortgagePayment if (!string.IsNullOrEmpty(leadApp.Elements("AddlMortgagePayment").FirstOrDefault().Value)) { req_lead.Notes += "\r\n AddlMortgagePayment=" + leadApp.Elements("AddlMortgagePayment").FirstOrDefault().Value; } //MonthlyObligations if (!string.IsNullOrEmpty(leadApp.Elements("MonthlyObligations").FirstOrDefault().Value)) { req_lead.Notes += "\r\n MonthlyObligations=" + leadApp.Elements("MonthlyObligations").FirstOrDefault().Value; } //Bankruptcy if (!string.IsNullOrEmpty(leadApp.Elements("Bankruptcy").FirstOrDefault().Value)) { req_lead.Notes += "\r\n Bankruptcy=" + leadApp.Elements("Bankruptcy").FirstOrDefault().Value; } #region LoanRequested switch (leadApp.Elements("LoanRequested").FirstOrDefault().Value.ToLower()) { case "purchase": req_lead.PurposeOfLoan = PostLeadWeb.LP2Service.PurposeOfLoan.Purchase; break; case "refinance": if (string.IsNullOrEmpty(leadApp.Elements("AddlCashOut").FirstOrDefault().Value)) { req_lead.PurposeOfLoan = PostLeadWeb.LP2Service.PurposeOfLoan.Refinance_Cashout; } else { req_lead.PurposeOfLoan = PostLeadWeb.LP2Service.PurposeOfLoan.Refinance_No_Cashout; } break; } #endregion //req_lead.LoanProgram = leadApp.Elements("LoanProgram").FirstOrDefault().Value; //MonthlyIncome-->LoanNotes if (!string.IsNullOrEmpty(leadApp.Elements("MonthlyIncome").FirstOrDefault().Value)) { req_lead.Notes += "\r\n MonthlyIncome=" + leadApp.Elements("MonthlyIncome").FirstOrDefault().Value; } //AnnualIncome-->LoanNotes if (!string.IsNullOrEmpty(leadApp.Elements("AnnualIncome").FirstOrDefault().Value)) { req_lead.Notes += "\r\n AnnualIncome=" + leadApp.Elements("AnnualIncome").FirstOrDefault().Value; } //IsMilitary-->LoanNotes if (!string.IsNullOrEmpty(leadApp.Elements("IsMilitary").FirstOrDefault().Value)) { req_lead.Notes += "\r\n IsMilitary=" + leadApp.Elements("IsMilitary").FirstOrDefault().Value; } //TimeToContact-->LoanNotes if (!string.IsNullOrEmpty(leadApp.Elements("IsMilitary").FirstOrDefault().Value)) { req_lead.Notes += "\r\n TimeToContact=" + leadApp.Elements("IsMilitary").FirstOrDefault().Value; } //WorkingWithRealtor-->LoanNotes if (!string.IsNullOrEmpty(leadApp.Elements("WorkingWithRealtor").FirstOrDefault().Value)) { req_lead.Notes += "\r\n WorkingWithRealtor=" + leadApp.Elements("WorkingWithRealtor").FirstOrDefault().Value; } //PropertyMSA-->LoanNotes if (!string.IsNullOrEmpty(leadApp.Elements("PropertyMSA").FirstOrDefault().Value)) { req_lead.Notes += "\r\n PropertyMSA=" + leadApp.Elements("PropertyMSA").FirstOrDefault().Value; } //PropertyCounty-->Loans.County if (!string.IsNullOrEmpty(leadApp.Elements("PropertyCounty").FirstOrDefault().Value)) { req_lead.County = leadApp.Elements("PropertyCounty").FirstOrDefault().Value; } //LoanType-->Loans.LoanType if (!string.IsNullOrEmpty(leadApp.Elements("LoanType").FirstOrDefault().Value)) { req_lead.LoanType = leadApp.Elements("LoanType").FirstOrDefault().Value; } //MortgageTerm-->Loans.Term int tempInt = 0; if (int.TryParse(leadApp.Elements("MortgageTerm").FirstOrDefault().Value, out tempInt)) { req_lead.Term = tempInt; } //CurrentLoanRate-->Loans.Rate decimal tempDecimal = 0; if (decimal.TryParse(leadApp.Elements("CurrentLoanRate").FirstOrDefault().Value, out tempDecimal)) { req_lead.Rate = tempDecimal; } //PartnerUID //NameOfPartner-->LoanNote if (!string.IsNullOrEmpty(leadApp.Elements("NameOfPartner").FirstOrDefault().Value)) { req_lead.Notes += "\r\n NameOfPartner=" + leadApp.Elements("NameOfPartner").FirstOrDefault().Value; } //TrackingNumber //DTI-->LoanNotes if (!string.IsNullOrEmpty(leadApp.Elements("DTI").FirstOrDefault().Value)) { req_lead.Notes += "\r\n DTI=" + leadApp.Elements("DTI").FirstOrDefault().Value; } //LTV-->Loans.LTV if (!string.IsNullOrEmpty(leadApp.Elements("LTV").FirstOrDefault().Value)) { req_lead.Notes += "\r\n LTV=" + leadApp.Elements("LTV").FirstOrDefault().Value; } //ApplicationDate //SourceID //FilterClass //FilterName //IsVerified //VerifiedHomePhone //PromotionalProgram-->LoanNotes if (!string.IsNullOrEmpty(leadApp.Elements("PromotionalProgram").FirstOrDefault().Value)) { req_lead.Notes += "\r\n PromotionalProgram=" + leadApp.Elements("PromotionalProgram").FirstOrDefault().Value; } string leadSource = ConfigurationManager.AppSettings["LeadSource"] == null ? string.Empty : ConfigurationManager.AppSettings["LeadSource"].ToString(); req_lead.LeadSource = string.IsNullOrEmpty(leadSource) ? "Lending Tree" : leadSource; //OtherLoanProgram //MatchFee //FilterRoutingID #endregion ServiceManager sm = new ServiceManager(); using (PostLeadWeb.LP2Service.LP2ServiceClient client = sm.StartServiceClient()) { err = string.Empty; RespHdr resp = client.PostLead(req_lead); if (resp == null) { WriteStatus(99, "Failed to Post Lead, Service returned no response."); return; } if (!resp.Successful) { //Log("Pulse Service Post Lead Result:" + err, 0); err = "Failed to Post Lead, Service error: " + resp.StatusInfo; WriteStatus(1, err); } else { WriteStatus(0, "Success"); } } } catch (Exception ex) { //Log(ex.Message, 0); WriteStatus(0, ex.ToString()); } }
internal static string FriendlyHtml(ZillowAttributeCollection zcol) { // Get Pulse Lead Request object from ZillowAttributeCollection PostLeadRequest pulse_lead_req = PulseLeadClient.GetPulseLeadRequest(zcol); // display results StringBuilder sb = new StringBuilder(); sb.AppendLine(@"<div class='col1'>Zillow Xml Attributes<br>"); sb.AppendLine("<table class='imagetable'>"); sb.AppendLine("<tr><th>GroupName</th><th>AttributeName</th><th>AttributeValue</th></tr>"); foreach (ZillowAttribute attrib in zcol.ZillowAttributes) { sb.AppendLine("<tr><td>" + attrib.GroupName + "</td>" + "<td>" + attrib.AttributeName + "</td>" + "<td>" + attrib.AttributeValue + "</td></tr>"); } sb.AppendLine("</table></div>"); sb.AppendLine(@"<div class='col2'>Pulse Lead Request<br>"); sb.AppendLine("<table class='imagetable'>"); sb.AppendLine("<tr><th>Name</th><th>Value</th></tr>"); foreach (FieldInfo f in pulse_lead_req.GetType().GetFields()) { if (f.Name.Equals("Employment", StringComparison.OrdinalIgnoreCase) && pulse_lead_req.Employment != null) { continue; } if (f.Name.Equals("OtherIncome", StringComparison.OrdinalIgnoreCase) && pulse_lead_req.OtherIncome != null) { continue; } if (f.Name.Equals("LiquidAssets", StringComparison.OrdinalIgnoreCase) && pulse_lead_req.LiquidAssets != null) { continue; } if (f.Name.Equals("RequestHeader", StringComparison.OrdinalIgnoreCase) && pulse_lead_req.RequestHeader != null) { continue; } sb.AppendLine("<tr><td>" + f.Name + "</td>" + "<td>" + f.GetValue(pulse_lead_req) + "</td></tr>"); } foreach (FieldInfo f in pulse_lead_req.GetType().GetFields()) { if (f.Name.Equals("RequestHeader", StringComparison.OrdinalIgnoreCase) && pulse_lead_req.RequestHeader != null) { sb.AppendLine("<tr><th colspan=2><strong>Request Header</strong></th></tr>"); foreach (FieldInfo f1 in pulse_lead_req.RequestHeader.GetType().GetFields()) { sb.AppendLine("<tr><td>" + f1.Name + "</td>" + "<td>" + f1.GetValue(pulse_lead_req.RequestHeader) + "</td></tr>"); } } else if (f.Name.Equals("Employment", StringComparison.OrdinalIgnoreCase) && pulse_lead_req.Employment != null) { sb.AppendLine("<tr><th colspan=2><strong>Employment</strong></th></tr>"); foreach (Employment employment in pulse_lead_req.Employment) { foreach (FieldInfo f1 in employment.GetType().GetFields()) { sb.AppendLine("<tr><td>" + f1.Name + "</td>" + "<td>" + f1.GetValue(employment) + "</td></tr>"); } } } else if (f.Name.Equals("OtherIncome", StringComparison.OrdinalIgnoreCase) && pulse_lead_req.OtherIncome != null) { sb.AppendLine("<tr><th colspan=2><strong>OtherIncome</strong></th></tr>"); foreach (OtherIncome other_income in pulse_lead_req.OtherIncome) { foreach (FieldInfo f1 in other_income.GetType().GetFields()) { sb.AppendLine("<tr><td>" + f1.Name + "</td>" + "<td>" + f1.GetValue(other_income) + "</td></tr>"); } } } else if (f.Name.Equals("LiquidAssets", StringComparison.OrdinalIgnoreCase) && pulse_lead_req.LiquidAssets != null) { sb.AppendLine("<tr><th colspan=2><strong>LiquidAssets</strong></th></tr>"); foreach (LiquidAssets liquid_assets in pulse_lead_req.LiquidAssets) { foreach (FieldInfo f1 in liquid_assets.GetType().GetFields()) { sb.AppendLine("<tr><td>" + f1.Name + "</td>" + "<td>" + f1.GetValue(liquid_assets) + "</td></tr>"); } } } } sb.AppendLine("</table></div>"); return(sb.ToString()); }
/// <summary> /// Populates PostLeadRequest with Zillow XML data /// </summary> /// <param name="zcol"></param> /// <returns></returns> private static PostLeadRequest MapZillowToPulseLeadRequest(ZillowAttributeCollection zcol) { // initialize request object PostLeadRequest req = new PostLeadRequest(); req.RequestHeader = new RequestHeader(); req.RequestHeader.SecurityToken = zcol.PulseSecurityToken; IEnumerable <ZillowAttribute> query = from p in zcol.ZillowAttributes where p.GroupName.Equals("ZillowMortgageContactList", StringComparison.OrdinalIgnoreCase) && p.AttributeName.Equals("version", StringComparison.OrdinalIgnoreCase) select p; req.LeadSource = CONST_LEADSOURCE + " v" + query.First().AttributeValue; //------------------------------------------------------------------ // CreditScore // Excellent = 1, 750-850 // VeryGood = 2, 700-749 // Good = 3, 650-699 // Fair = 4, 600-649 // Poor = 5, 300-599 query = from p in zcol.ZillowAttributes where p.GroupName.Equals("CreditScore", StringComparison.OrdinalIgnoreCase) && p.AttributeName.Equals("CreditScore_Text", StringComparison.OrdinalIgnoreCase) select p; if (query.Any()) { if (!string.IsNullOrEmpty(query.First().AttributeValue)) { int int_value; if (int.TryParse(query.First().AttributeValue, out int_value)) { req.CreditScore = int_value; if (int_value <= 599) { req.CreditRanking = CreditRanking.Poor; } else if (int_value <= 649) { req.CreditRanking = CreditRanking.Fair; } else if (int_value <= 699) { req.CreditRanking = CreditRanking.Good; } else if (int_value <= 749) { req.CreditRanking = CreditRanking.VeryGood; } else { req.CreditRanking = CreditRanking.Excellent; } } } } //------------------------------------------------------------------ //BaseMonthlyIncome query = from p in zcol.ZillowAttributes where p.GroupName.Equals("PrimaryBorrower", StringComparison.OrdinalIgnoreCase) && p.AttributeName.Equals("BaseMonthlyIncome", StringComparison.OrdinalIgnoreCase) select p; if (query.Any()) { if (!string.IsNullOrEmpty(query.First().AttributeValue)) { decimal d_value; if (decimal.TryParse(query.First().AttributeValue, out d_value)) { req.Employment = new Employment[] { new Employment() { MonthlySalary = d_value } }; } } } //------------------------------------------------------------------ //AdditionalMonthlyIncome query = from p in zcol.ZillowAttributes where p.GroupName.Equals("PrimaryBorrower", StringComparison.OrdinalIgnoreCase) && p.AttributeName.Equals("AdditionalMonthlyIncome", StringComparison.OrdinalIgnoreCase) select p; if (query.Any()) { if (!string.IsNullOrEmpty(query.First().AttributeValue)) { decimal d_value; if (decimal.TryParse(query.First().AttributeValue, out d_value)) { req.OtherIncome = new OtherIncome[] { new OtherIncome() { Amount = d_value } }; } } } //------------------------------------------------------------------ //PropertyUsage query = from p in zcol.ZillowAttributes where p.GroupName.Equals("PropertyDetails", StringComparison.OrdinalIgnoreCase) && p.AttributeName.Equals("PropertyUsage", StringComparison.OrdinalIgnoreCase) select p; if (query.Any()) { if (!string.IsNullOrEmpty(query.First().AttributeValue)) { if (query.First().AttributeValue.Equals("primaryResidence", StringComparison.OrdinalIgnoreCase)) { req.OccupancyType = OccupancyType.PrimaryResidence; } else if (query.First().AttributeValue.Equals("secondaryOrVacation", StringComparison.OrdinalIgnoreCase)) { req.OccupancyType = OccupancyType.SecondHome; } else if (query.First().AttributeValue.Equals("investmentOrRental", StringComparison.OrdinalIgnoreCase)) { req.OccupancyType = OccupancyType.InvestmentProperty; } } } //------------------------------------------------------------------ //LoanAmount query = from p in zcol.ZillowAttributes where p.GroupName.Equals("LoanDetails", StringComparison.OrdinalIgnoreCase) && p.AttributeName.Equals("LoanAmount", StringComparison.OrdinalIgnoreCase) select p; if (query.Any()) { if (!string.IsNullOrEmpty(query.First().AttributeValue)) { int int_value; if (int.TryParse(query.First().AttributeValue, out int_value)) { req.LoanAmount = int_value; } } } //------------------------------------------------------------------ //EstimatedPropertyValue query = from p in zcol.ZillowAttributes where p.GroupName.Equals("EstimatedPropertyValue", StringComparison.OrdinalIgnoreCase) && p.AttributeName.Equals("EstimatedPropertyValue_Text", StringComparison.OrdinalIgnoreCase) select p; if (query.Any()) { if (!string.IsNullOrEmpty(query.First().AttributeValue)) { int int_value; if (int.TryParse(query.First().AttributeValue, out int_value)) { req.PropertyValue = int_value; } } } //------------------------------------------------------------------ //Assets query = from p in zcol.ZillowAttributes where p.GroupName.Equals("Asset", StringComparison.OrdinalIgnoreCase) select p; if (query.Any()) { List <LiquidAssets> lassets = new List <LiquidAssets>(); string name_of_account = "Not provided"; foreach (ZillowAttribute item in query) { if (item.AttributeName.Equals("type", StringComparison.OrdinalIgnoreCase)) { name_of_account = item.AttributeValue; } else if (item.AttributeName.Equals("asset_text", StringComparison.OrdinalIgnoreCase)) { decimal d_value; if (decimal.TryParse(item.AttributeValue, out d_value)) { lassets.Add(new LiquidAssets { NameOfAccount = name_of_account, Amount = d_value, AccountNo = "" }); name_of_account = "Not provided"; } } } if (lassets.Any()) { req.LiquidAssets = lassets.ToArray(); } } //------------------------------------------------------------------ //LoanPurpose query = from p in zcol.ZillowAttributes where p.GroupName.Equals("LoanRequestCreated", StringComparison.OrdinalIgnoreCase) && p.AttributeName.Equals("LoanPurpose", StringComparison.OrdinalIgnoreCase) select p; if (query.Any()) { if (!string.IsNullOrEmpty(query.First().AttributeValue)) { if (query.First().AttributeValue.Equals("purchase", StringComparison.OrdinalIgnoreCase)) { req.PurposeOfLoan = PurposeOfLoan.Purchase; } else if (query.First().AttributeValue.Equals("refinance", StringComparison.OrdinalIgnoreCase)) { req.PurposeOfLoan = PurposeOfLoan.Refinance_No_Cashout; } else if (query.First().AttributeValue.Equals("homeEquity", StringComparison.OrdinalIgnoreCase)) { req.PurposeOfLoan = PurposeOfLoan.Refinance_Cashout; } } //<xsd:enumeration value="purchase"/> //<xsd:enumeration value="refinance"/> //<xsd:enumeration value="homeEquity"/> // req.PurposeOfLoan = PurposeOfLoan.Construction; // req.PurposeOfLoan = PurposeOfLoan.Other; // req.PurposeOfLoan = PurposeOfLoan.Purchase; // req.PurposeOfLoan = PurposeOfLoan.Refinance_Cashout; // req.PurposeOfLoan = PurposeOfLoan.Refinance_No_Cashout; } //------------------------------------------------------------------ //FirstName query = from p in zcol.ZillowAttributes where p.GroupName.Equals("WebContact", StringComparison.OrdinalIgnoreCase) && p.AttributeName.Equals("FirstName", StringComparison.OrdinalIgnoreCase) select p; if (query.Any()) { if (!string.IsNullOrEmpty(query.First().AttributeValue)) { req.BorrowerFirstName = Helpers.FormatSqlStringValue(query.First().AttributeValue, 50); } } //------------------------------------------------------------------ //LastName query = from p in zcol.ZillowAttributes where p.GroupName.Equals("WebContact", StringComparison.OrdinalIgnoreCase) && p.AttributeName.Equals("LastName", StringComparison.OrdinalIgnoreCase) select p; if (query.Any()) { if (!string.IsNullOrEmpty(query.First().AttributeValue)) { req.BorrowerLastName = Helpers.FormatSqlStringValue(query.First().AttributeValue, 50); } } //------------------------------------------------------------------ //EmailAddress query = from p in zcol.ZillowAttributes where p.GroupName.Equals("WebContact", StringComparison.OrdinalIgnoreCase) && p.AttributeName.Equals("EmailAddress", StringComparison.OrdinalIgnoreCase) select p; if (query.Any()) { if (!string.IsNullOrEmpty(query.First().AttributeValue)) { req.Email = Helpers.FormatSqlStringValue(query.First().AttributeValue, 255); } } //------------------------------------------------------------------ //PhoneNumber query = from p in zcol.ZillowAttributes where p.GroupName.Equals("WebContact", StringComparison.OrdinalIgnoreCase) && p.AttributeName.Equals("PhoneNumber", StringComparison.OrdinalIgnoreCase) select p; if (query.Any()) { if (!string.IsNullOrEmpty(query.First().AttributeValue)) { req.HomePhone = Helpers.FormatSqlStringValue(query.First().AttributeValue, 20); } } //------------------------------------------------------------------ //Message query = from p in zcol.ZillowAttributes where p.GroupName.Equals("WebContact", StringComparison.OrdinalIgnoreCase) && p.AttributeName.Equals("Message", StringComparison.OrdinalIgnoreCase) select p; if (query.Any()) { if (!string.IsNullOrEmpty(query.First().AttributeValue)) { req.Notes = Helpers.FormatSqlStringValue(query.First().AttributeValue, 4000); } } //------------------------------------------------------------------ //City query = from p in zcol.ZillowAttributes where p.GroupName.Equals("PropertyDetails", StringComparison.OrdinalIgnoreCase) && p.AttributeName.Equals("City", StringComparison.OrdinalIgnoreCase) select p; if (query.Any()) { if (!string.IsNullOrEmpty(query.First().AttributeValue)) { req.Property_City = Helpers.FormatSqlStringValue(query.First().AttributeValue, 50); } } //------------------------------------------------------------------ //State query = from p in zcol.ZillowAttributes where p.GroupName.Equals("PropertyDetails", StringComparison.OrdinalIgnoreCase) && p.AttributeName.Equals("State", StringComparison.OrdinalIgnoreCase) select p; if (query.Any()) { if (!string.IsNullOrEmpty(query.First().AttributeValue)) { req.Property_State = Helpers.ConvertStateNameToAbbrev(query.First().AttributeValue); } } //------------------------------------------------------------------ //StreetAddress query = from p in zcol.ZillowAttributes where p.GroupName.Equals("PropertyInfoType", StringComparison.OrdinalIgnoreCase) && p.AttributeName.Equals("StreetAddress", StringComparison.OrdinalIgnoreCase) select p; if (query.Any()) { if (!string.IsNullOrEmpty(query.First().AttributeValue)) { req.Property_Street = Helpers.FormatSqlStringValue(query.First().AttributeValue, 50); } } //------------------------------------------------------------------ //Zip query = from p in zcol.ZillowAttributes where p.GroupName.Equals("PropertyDetails", StringComparison.OrdinalIgnoreCase) && p.AttributeName.Equals("Zip", StringComparison.OrdinalIgnoreCase) select p; if (query.Any()) { if (!string.IsNullOrEmpty(query.First().AttributeValue)) { req.Property_Zip = Helpers.FormatSqlStringValue(query.First().AttributeValue, 10); } } //------------------------------------------------------------------ //PropertyType query = from p in zcol.ZillowAttributes where p.GroupName.Equals("PropertyDetails", StringComparison.OrdinalIgnoreCase) && p.AttributeName.Equals("PropertyType", StringComparison.OrdinalIgnoreCase) select p; if (query.Any()) { if (!string.IsNullOrEmpty(query.First().AttributeValue)) { req.PropertyType = Helpers.FormatSqlStringValue(query.First().AttributeValue, 255); } } //------------------------------------------------------------------ //CurrentLoanProgram query = from p in zcol.ZillowAttributes where p.GroupName.Equals("LoanDetails", StringComparison.OrdinalIgnoreCase) && p.AttributeName.Equals("CurrentLoanProgram", StringComparison.OrdinalIgnoreCase) select p; if (query.Any()) { if (!string.IsNullOrEmpty(query.First().AttributeValue)) { req.LoanProgram = Helpers.FormatSqlStringValue(query.First().AttributeValue, 255); } } return(req); }
static void MyTest(string[] args) { using (PulseLeadServiceClient.PulseLeadServiceClient client = new PulseLeadServiceClient.PulseLeadServiceClient()) { PostLeadRequest req = new PostLeadRequest(); req.BorrowerFirstName = "Peter"; req.BorrowerLastName = "FocusITestH"; req.HomePhone = "222-222-3333"; req.BusinessPhone = "233-333-4444"; req.CellPhone = "244-444-5555"; req.CreditRanking = CreditRanking.Good; req.Email = "*****@*****.**"; req.LoanProgram = "30-year fixed"; req.OccupancyType = OccupancyType.PrimaryResidence; req.LoanAmount = 200000; req.PurposeOfLoan = PurposeOfLoan.Refinance_Cashout; req.PreferredContactMethod = PreferredContactMethod.Email; //req.BranchName = "Atlanta"; //req.LoanOfficerFirstName = "Betty"; //req.LoanOfficerLastName = "Wilkinson"; req.MailingAddress = new Address() { City = "San Jose", State = "CA", Street = "123 Any Street", Zip = "95110" }; req.PropertyValue = 400000; req.Property_Street = "123 Any Street"; req.Property_City = "San Jose"; req.Property_State = "CA"; req.Property_Zip = "95110"; req.RequestHeader = new ReqHdr(); req.RequestHeader.SecurityToken = "90e588a7-df07-4abf-976c-ce655d6effa6"; RespHdr resp = null; resp = client.PostLead(req); if (resp.Successful) { Console.WriteLine("Successfully posted the lead to Pulse!"); } else { Console.WriteLine("Failed to post the lead to Pulse, reason:{0}.", resp.Error); } Console.ReadKey(); } using (PulseLeadServiceClient.PulseLeadServiceClient client = new PulseLeadServiceClient.PulseLeadServiceClient()) { PostLoanAppRequest req = new PostLoanAppRequest(); req.BorrowerFirstName = "PeterG"; req.BorrowerMiddleName = ""; req.BorrowerLastName = "TerrizziG"; //req.CoBorrowerFirstName //req.CoBorrowerMiddleName //req.CoBorrowerLastName //req.CoBorrowerType //req.CoBorrowerPhone //req.CoBorrowerCellPhone //req.CoBorrowerBusinessPhone //req.CoBorrowerEmail req.HomePhone = "203-221-3221"; req.BusinessPhone = "203-331-4441"; req.CellPhone = "203-441-5551"; //req.MailingAddress req.CreditRanking = CreditRanking.Good; req.Email = "*****@*****.**"; //req.HasDependents //req.DOB //req.BorrowerSSN //req.Employment //req.CoBorrowerEmployers //req.OtherIncome //req.CoBorrowerOtherIncome //req.LiquidAssets req.LoanProgram = "30-year fixed"; req.OccupancyType = OccupancyType.PrimaryResidence; req.LoanAmount = 300000; req.PurposeOfLoan = PurposeOfLoan.Purchase; req.PreferredContactMethod = PreferredContactMethod.Email; req.BranchName = "Atlanta"; //id=8 // "Branch1A1"; req.LoanOfficerFirstName = "Betty"; //"Frank" req.LoanOfficerLastName = "Wilkinson"; // "Smith"; req.PropertyValue = 300000; //req.PropertyType //req.HousingStatus //req.RentAmount //req.Property //req.InterestOnly //req.IncludeEscrows //req.Notes req.RequestHeader = new ReqHdr(); req.RequestHeader.SecurityToken = "ff5eaf4a-6c97-4a00-8252-9eec8bf2979b"; // "2934230595-324923804-2394923"; RespHdr resp = client.PostLoanApp(req); if (resp.Successful) { Console.WriteLine("Successfully posted the lead to Pulse!"); } else { Console.WriteLine("Failed to post the lead to Pulse, reason:{0}.", resp.Error); } Console.ReadKey(); } }