/// <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; } }
public bool SaveCreditScore(int contact_id, int credit_score) { try { //int contactId = IsBorrower ? postArgs.ContactId : postArgs.CoBorrowerContactId; if (contact_id <= 0) { return(false); } string sqlCommand = @"UPDATE [dbo].[Contacts] SET Experian = @Experian WHERE ContactId = @ContactId"; SqlParameter[] parameters = { new SqlParameter("@ContactId", SqlDbType.Int, 4) , new SqlParameter("@Experian", SqlDbType.Int) }; parameters[0].Value = contact_id; parameters[1].Value = credit_score; focusIT.DbHelperSQL.ExecuteSql(sqlCommand, parameters); } catch (Exception ex) { NLogger.Error(MethodBase.GetCurrentMethod().DeclaringType.FullName, MethodBase.GetCurrentMethod().Name, ex.Message, ex); return(false); } return(true); }
public ResponseHdr Post(PostLeadRequest req_lead) { string err = string.Empty; ResponseHdr respHdr = new ResponseHdr(); bool status = false; try { status = CheckData(ref req_lead, ref err); if (status == false) { NLogger.Error(MethodBase.GetCurrentMethod().DeclaringType.FullName, MethodBase.GetCurrentMethod().Name, "CheckData error: " + err); return(respHdr); } InternalLeadReq req = new InternalLeadReq(); req.req = req_lead; status = ImportLead(ref req, ref err); respHdr._postArgs = req._postArgs; return(respHdr); } catch (Exception exception) { err = exception.ToString(); NLogger.Error(MethodBase.GetCurrentMethod().DeclaringType.FullName, MethodBase.GetCurrentMethod().Name, exception.Message, exception); return(respHdr); } finally { respHdr.Successful = status; respHdr.Error = err; } }
/// <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; } }
/// <summary> /// Parses the Zillow XML into the ZillowAttributeCollection /// </summary> /// <param name="ds"></param> /// <returns></returns> internal static ZillowAttributeCollection ImportLeadFromZillowv5(DataSet ds) { try { // Initialize objects and import N/V pairs ZillowAttributeCollection collection = new ZillowAttributeCollection(); foreach (DataTable dt in ds.Tables) { foreach (DataRow dr in dt.Rows) { foreach (DataColumn dc in dt.Columns) { collection.ZillowAttributes.Add(new ZillowAttribute() { GroupName = dt.TableName, AttributeName = dc.ColumnName, AttributeValue = dr[dc].ToString() }); } } } // Validate only Version 5 is supported IEnumerable <ZillowAttribute> query = from p in collection.ZillowAttributes where p.GroupName.Equals("ZillowMortgageContactList", StringComparison.OrdinalIgnoreCase) && p.AttributeName.Equals("version", StringComparison.OrdinalIgnoreCase) select p; if (query.Any()) { if (!string.IsNullOrEmpty(query.First().AttributeValue)) { if (!query.First().AttributeValue.Equals("5")) { ApplicationException appex = new ApplicationException("Application Error: only ZillowMortgageContactList version 5 is supported."); NLogger.Error(MethodBase.GetCurrentMethod().DeclaringType.FullName, MethodBase.GetCurrentMethod().Name, appex.Message, appex); throw appex; } } else { ApplicationException appex = new ApplicationException("Application Error: unable to locate version in ZillowMortgageContactList."); NLogger.Error(MethodBase.GetCurrentMethod().DeclaringType.FullName, MethodBase.GetCurrentMethod().Name, appex.Message, appex); throw appex; } } else { ApplicationException appex = new ApplicationException("Application Error: unable to parse the Zillow XML."); NLogger.Error(MethodBase.GetCurrentMethod().DeclaringType.FullName, MethodBase.GetCurrentMethod().Name, appex.Message, appex); throw appex; } // update the collection's xml version collection.XmlVersion = query.First().AttributeValue; return(collection); } catch (Exception ex) { NLogger.Error(MethodBase.GetCurrentMethod().DeclaringType.FullName, MethodBase.GetCurrentMethod().Name, ex.Message, ex); throw; } }