protected void UpdateLeadCityStateIP(XVerifyManager xvm, CbrLead lead, string ipAddress) { //Update state/city/ip if (string.IsNullOrWhiteSpace(lead.City) || string.IsNullOrWhiteSpace(lead.State)) { //used cached xverify info if available if (xvm.IpInfo?.ipdata != null) { lead.City = xvm.IpInfo.ipdata.city; lead.State = xvm.IpInfo.ipdata.region; } else { var ipInfo = xvm.GetIpVerification(ipAddress); lead.City = ipInfo.ipdata.city; lead.State = ipInfo.ipdata.region; } _db.SaveChanges(); } if (lead.Ip != ipAddress) { lead.Ip = ipAddress; _db.SaveChanges(); } }
private string GetCountryId(string ipAddress) { XVerifyManager xm = new XVerifyManager(); string countryId = "US"; if (!string.IsNullOrWhiteSpace(ipAddress)) { countryId = xm.GetCountryFromIP(ipAddress); if (string.IsNullOrWhiteSpace(countryId)) { countryId = "US"; } } return(countryId); }
public CoregPostResponse SubmitLead(EngageIqRequest request, string ipAddress) { // use this to flag leads as not qualified // due to wrong answers on custom questions bool postLead = true; var lead = _db.CbrLeads.FirstOrDefault(c => c.CbrLeadId == request.CbrLeadId); if (lead == null) { return(new CoregPostResponse() { Success = false, Other = $"LeadId {request.CbrLeadId} not found." }); } var xverifyManager = new XVerifyManager(); var zipResponse = xverifyManager.VerifyZipAndIpAddress(ipAddress, request.Zip, request.email); if (zipResponse.IpIsIrReputable) { return(new CoregPostResponse() { Success = false, ipIsIrReputable = true }); } if (zipResponse.NoMatch || zipResponse.ZipCodeInvalid) { return(new CoregPostResponse() { Success = false, zipIpVerificationFailed = true, InvalidZip = zipResponse.ZipCodeInvalid }); } UpdateLeadCityStateIP(xverifyManager, lead, ipAddress); string leadtimestamp = DateTime.Now.ToString("yyyyMMddHHmmss"); //20170719123212 string postdate_YMD = DateTime.Now.ToString("yyyy-MM-dd"); //1971-01-03 string gender = GenderGetSingleCharacter(lead); string dob_YMD_dash = null; string dob_YMD_slash = null; if (lead.BirthDate.HasValue) { dob_YMD_dash = lead.BirthDate.Value.ToString("yyyy-MM-dd"); //1971-01-03 dob_YMD_slash = lead.BirthDate.Value.ToString("yyyy/MM/dd"); //1971/01/03 } SwapSpacesForPlusSign(request, lead); string postData = null; //EngageIQ_Taxotere &s1=rev1&eiq_campaign_id=251&[email protected]&first_name=Romnick&last_name=Sars&phone=4026804444&ip=192.168.1.1&q1=Yes&q2=No //Rail road cancer &s1=rev1&eiq_campaign_id=632&[email protected]&first_name=Romnick&last_name=Sars&phone=3048806079&ip=192.168.1.1&q1=Yes //Hernia Mesh &s1=rev1&eiq_campaign_id=548&[email protected]&first_name=Romnick&last_name=Sars&phone=3048806079&ip=192.168.1.1&state=AL&q1=Yes&q2=2004+or+later&q3=Yes&q4=0 //Xarelto &s1=rev1&eiq_campaign_id=514&[email protected]&first_name=Romnick&last_name=Sars&phone=2056532345&zip=35126&state=AL&q1=Yes&q2=No //back brace &s1=rev1&eiq_campaign_id=341&[email protected] &first_name=Romnick&last_name=Sars&phone=4026804444&address=125+Broadway&zip=10016&city=New York&state=NY&ip=192.168.1.2 //medical alert &s1=rev1&eiq_campaign_id=561&[email protected]&first_name=Romnick&last_name=Sars&phone=3048806079&address=5911+Marches&zip=35126&city=Pinson &state=AL&dob=1971-01-03&gender=M&datetime=2017-7-19&leadid=20170719123212 //pain gel &s1=rev1&eiq_campaign_id=401&[email protected]&first_name=Romnick&last_name=Sars&phone=2126532345&address=125+Broadway&zip=10016&city=New York&state=NY&ip=104.173.123.246&dob=06/11/1943&gender=M& //toluna &s1=rev1&eiq_campaign_id=1& [email protected]&first_name=Romnick&last_name=Sars&zip=01516&gender=M&birth_date=1960-05-16 //motorveh accid &s1=rev1&eiq_campaign_id=204&[email protected]&first_name=Romnick&last_name=Sars&phone=2056532345&address=5911+Marchester+circle&zip=35126&city=Pinson&state=AL&ip=104.173.123.246&lr=new&program_name=National+Injury+Bureau+MVA(1170)&program_id=1170&q1=Auto&q2=2015&q4=no&q5=Fred Panopio&q6=no&comments=I+was+hit+from+behind+by+a+truck&s1=yourSudID1&terms=Yes //my survey &s1=rev1&eiq_campaign_id=2& [email protected]&first_name=Romnick&last_name=Sars //GlobalTestmarket &s1=rev1&eiq_campaign_id=4&p_value=CD1&[email protected]&first_name=Romnick&last_name=Sars var r = request; var l = lead; switch (request.CampaignCodeId) { case CoregCampaignType.EngageIQ_Taxotere: postLead = (r.Q1 == "Yes" && r.Q2 == "No"); postData = $"&s1={r.SubIdTag}&eiq_campaign_id={r.CampaignCode}&eiq_email={l.EmailAddress}&first_name={l.Firstname}&last_name={l.Lastname}&phone={l.Phone}&ip={ipAddress}&q1={r.Q1}&q2={r.Q2}"; break; case CoregCampaignType.EngageIQ_RailroadCancer: postLead = (r.Q1 == "Yes"); postData = $"&s1={r.SubIdTag}&eiq_campaign_id={r.CampaignCode}&eiq_email={l.EmailAddress}&first_name={l.Firstname}&last_name={l.Lastname}&phone={l.Phone}&ip={ipAddress}&q1={r.Q1}"; break; case CoregCampaignType.EngageIQ_HernaMesh: postLead = r.Q1 == "Yes" && IsGreaterThan(r.Q2, 2003) && r.Q3 == "Yes" && r.Q4 == "0"; postData = $"&s1={r.SubIdTag}&eiq_campaign_id={r.CampaignCode}&eiq_email={l.EmailAddress}&first_name={l.Firstname}&last_name={l.Lastname}&phone={l.Phone}&state={l.State}&ip={ipAddress}&q1={r.Q1}&q2={r.Q2}"; break; case CoregCampaignType.EngageIQ_Xarelto: postLead = (r.Q1 == "Yes" && r.Q2 == "No"); postData = $"&s1={r.SubIdTag}&eiq_campaign_id={r.CampaignCode}&eiq_email={l.EmailAddress}&first_name={l.Firstname}&last_name={l.Lastname}&phone={l.Phone}&zip={l.Zip}&state={l.State}&q1={r.Q1}&q2={r.Q2}"; break; case CoregCampaignType.EngageIQ_BackBrace: postData = $"&s1={r.SubIdTag}&eiq_campaign_id={r.CampaignCode}&eiq_email={l.EmailAddress}&first_name={l.Firstname}&last_name={l.Lastname}&phone={l.Phone}&zip={l.Zip}&address={l.Address}&city={l.City}&state={l.State}&ip={ipAddress}"; break; case CoregCampaignType.EngageIQ_MedicalAlert: postData = $"&s1={r.SubIdTag}&eiq_campaign_id={r.CampaignCode}&eiq_email={l.EmailAddress}&first_name={l.Firstname}&last_name={l.Lastname}&phone={l.Phone}&zip={l.Zip}&address={l.Address}&city={l.City}&state={l.State}&ip={ipAddress}&dob={dob_YMD_dash}&gender={gender}&datetime={postdate_YMD}&leadid={leadtimestamp}"; break; case CoregCampaignType.EngageIQ_PainGel: postLead = (r.Q1 == "Yes"); postData = $"&s1={r.SubIdTag}&eiq_campaign_id={r.CampaignCode}&eiq_email={l.EmailAddress}&first_name={l.Firstname}&last_name={l.Lastname}&phone={l.Phone}&zip={l.Zip}&address={l.Address}&city={l.City}&state={l.State}&ip={ipAddress}&dob={dob_YMD_slash}&gender={gender}"; break; case CoregCampaignType.EngageIQ_Toluna: //needs pre ping postLead = CheckPrePing(l.EmailAddress); postData = $"&s1={r.SubIdTag}&eiq_campaign_id={r.CampaignCode}&eiq_email={l.EmailAddress}&first_name={l.Firstname}&last_name={l.Lastname}&zip={l.Zip}&gender={gender}&birth_date={dob_YMD_dash}"; break; case CoregCampaignType.EngageIQ_MotorVehicleAccident: postLead = IsGreaterThan(r.Q2, 2014) && r.Q6 == "No" && ZipIsAllowed(l.Zip, @"~\OfferValidation\EngageIQ\zips_mva.txt"); postData = $"&s1={r.SubIdTag}&eiq_campaign_id={r.CampaignCode}&eiq_email={l.EmailAddress}&first_name={l.Firstname}&last_name={l.Lastname}&phone={l.Phone}&zip={l.Zip}&address={l.Address}&city={l.City}&state={l.State}&ip={ipAddress}&lr=new&program_name=National+Injury+Bureau+MVA(1170)&program_id=1170&q1={r.Q1}&q2={r.Q2}&q3={r.Q3}&q4={r.Q4}&q5={r.Q5}&q6={r.Q6}&comments={r.Comments1}&terms=Yes"; break; case CoregCampaignType.EngageIQ_MySurvey: //needs pre ping postLead = CheckPrePing(l.EmailAddress); postData = $"&s1={r.SubIdTag}&eiq_campaign_id={r.CampaignCode}&eiq_email={l.EmailAddress}&first_name={l.Firstname}&last_name={l.Lastname}"; break; case CoregCampaignType.EngageIQ_GlobalTestMarket: //needs pre ping postLead = CheckPrePing(l.EmailAddress); postData = $"&s1={r.SubIdTag}&eiq_campaign_id={r.CampaignCode}&eiq_email={l.EmailAddress}&first_name={l.Firstname}&last_name={l.Lastname}&p_value=CD295"; break; default: throw new ArgumentOutOfRangeException(); } postData = basePostData + postData; if (postLead) { string finalUrl = baseurl + postData; string response = Get(finalUrl); if (!string.IsNullOrWhiteSpace(response)) { //dynamic dyn = JsonConvert.DeserializeObject(response); if (response.ToLower().Contains("success")) { UpdateLeadAccepted(r, l); return(new CoregPostResponse() { Success = true }); } WriteCoregError("EngageIQ", postData, finalUrl, response); return(new CoregPostResponse() { Success = true }); } return(new CoregPostResponse() { Success = false, Other = "No response." }); } //lead was not posted due to wrong answers on custom questions WriteCoregError("EngageIQ", postData, baseurl, "No response."); return(new CoregPostResponse() { Success = true }); }
public MobileSignupResponse SignUpUser(string email, string ipAddress) { var db = new GloshareContext(); if (string.IsNullOrWhiteSpace(email)) { return(new MobileSignupResponse() { Message = "Email is blank." }); } try { var xv = new XVerifyManager(); if (xv.GetEmailVerification(email)) { string countryId = GetCountryId(ipAddress); var response = new MobileSignupResponse(); response.ValidEmail = true; MobilelLead existingLead = db.MobilelLeads.FirstOrDefault(m => m.EmailAddress.ToLower() == email); if (existingLead == null) { email = email.Trim().ToLower(); existingLead = new MobilelLead() { EmailAddress = email, Ip = ipAddress, CountryId = countryId }; db.MobilelLeads.Add(existingLead); db.SaveChanges(); var oils = db.OptInLeads.Where(o => o.EmailAddress == email); if (!oils.Any()) { var oil = new OptInLead(); oil.EmailAddress = email; oil.Ip = ipAddress; oil.OfferId = "51011"; db.OptInLeads.Add(oil); db.SaveChanges(); } } return(new MobileSignupResponse() { UserId = existingLead.UserId, IsRegistered = existingLead.IsRegistered, DisplayName = string.IsNullOrWhiteSpace(existingLead.Firstname) ? null : $"{existingLead.Firstname} {existingLead.Lastname}", ValidEmail = true, Message = "Success", DashUrl = $"{ConfigurationManager.AppSettings["BaseWebUrl"]}dash?ug={existingLead.UserId}", RegisterUrl = $"{ConfigurationManager.AppSettings["BaseWebUrl"]}register?ug={existingLead.UserId}", DailySurveysUrl = $"{ConfigurationManager.AppSettings["BaseWebUrl"]}mysurveys?mu={existingLead.UserId}", EarningsUrl = $"{ConfigurationManager.AppSettings["BaseWebUrl"]}earnings?ug={existingLead.UserId}" }); } return(new MobileSignupResponse() { ValidEmail = false, Message = "Email Invalid." }); } catch (Exception e) { return(new MobileSignupResponse() { Message = $"Error: {e.Message}" }); } }
public CoregPostResponse SubmitLead(CoregPostRequestBase request, string ipAddress, bool isTest) { var lead = _db.CbrLeads.FirstOrDefault(c => c.CbrLeadId == request.CbrLeadId); if (lead == null) { return(new CoregPostResponse() { Success = false, Other = $"LeadId {request.CbrLeadId} not found." }); } var xverifyManager = new XVerifyManager(); var zipResponse = xverifyManager.VerifyZipAndIpAddress(ipAddress, request.Zip, request.email); if (zipResponse.IpIsIrReputable) { return(new CoregPostResponse() { Success = false, ipIsIrReputable = true }); } if (zipResponse.NoMatch || zipResponse.ZipCodeInvalid) { return(new CoregPostResponse() { Success = false, zipIpVerificationFailed = true, InvalidZip = zipResponse.ZipCodeInvalid }); } UpdateLeadCityStateIP(xverifyManager, lead, ipAddress); string leadtimestamp = DateTime.Now.ToString("M/d/yyyy"); //m/d/yyyy h:mm:ss string postData = null; var r = request; var l = lead; Dictionary <string, object> postParameters = new Dictionary <string, object>(); postParameters.Add("subid", request.SubIdTag); postParameters.Add("first_name", lead.Firstname); postParameters.Add("last_name", lead.Lastname); postParameters.Add("email_address", request.email); postParameters.Add("contact_phone", lead.Phone); postParameters.Add("ip_address", ipAddress); switch (request.CampaignCodeId) { case CoregCampaignType.Centerfield_Sprint: //postData = // $"&offer_id={request.CampaignCode}&subid={r.SubIdTag}&email_address={l.EmailAddress}&first_name={l.Firstname}&last_name={l.Lastname}&contact_phone={l.Phone}&ip_address={ipAddress}×tamp={leadtimestamp}"; postParameters.Add("offer_id", request.CampaignCode); break; default: throw new ArgumentOutOfRangeException(); } if (isTest) { postParameters.Add("is_test", true); // postData += "&is_test=true"; } string response = PostForm(postParameters, baseurl); if (!string.IsNullOrWhiteSpace(response)) { if (response.ToLower().Contains("success")) { UpdateLeadAccepted(r, l); return(new CoregPostResponse() { Success = true }); } WriteCoregError("Centerfield", postData, baseurl, response); return(new CoregPostResponse() { Success = true }); } WriteCoregError("Centerfield", postData, baseurl, "No response."); return(new CoregPostResponse() { Success = false, Other = "No response." }); }
public CoregPostResponse SubmitLead(ProvideMediaRequest request, string ipAddress, bool isTest) { var lead = _db.CbrLeads.FirstOrDefault(l => l.CbrLeadId == request.CbrLeadId); if (lead == null) { return(new CoregPostResponse() { Success = false, Other = $"LeadId {request.CbrLeadId} not found." }); } //XVerifyManager xvm = new XVerifyManager(); //var xverifyZipResult = xvm.VerifyZipCode(lead.EmailAddress, ipAddress, lead.Address, lead.Zip); //if (!xverifyZipResult.IsValid) //{ // if (xverifyZipResult.NoMatch) // { // return new ProvideMediaResponse() { Success = false, Other = "Failed zip/ip verifiction." }; // } // return new ProvideMediaResponse() // { // Success = false, // InvalidAddress = xverifyZipResult.AddressInvalid, // InvalidZip = xverifyZipResult.ZipCodeInvalid, // Message = xverifyZipResult.Message // }; //}; var xverifyManager = new XVerifyManager(); var zipResponse = xverifyManager.VerifyZipAndIpAddress(ipAddress, lead.Zip, request.email); if (zipResponse.IpIsIrReputable) { return(new CoregPostResponse() { Success = false, ipIsIrReputable = true }); } if (zipResponse.NoMatch || zipResponse.ZipCodeInvalid) { return(new CoregPostResponse() { Success = false, zipIpVerificationFailed = true, InvalidZip = zipResponse.ZipCodeInvalid }); } UpdateLeadCityStateIP(xverifyManager, lead, ipAddress); var phone = PreparePhoneForPost(lead.Phone); request.TrustedForm = HttpUtility.UrlEncode(request.TrustedForm); //EncodeContact(lead); string consent = "Yes"; if (request.CampaignCode == CAMPAIGN_CODE_DEBT_COM) { consent = "1"; } var gender = GenderGetSingleCharacter(lead); var c = lead; string postData = $"campaign_code={request.CampaignCode}&lead[firstname]={c.Firstname}&lead[lastname]={c.Lastname}" + $"&lead[email]={c.EmailAddress}&lead[phone1]={phone}&lead[age]={GetAge(c.BirthDate)}" + $"&lead[gender]={gender}&lead_consent[tcpa_consent]={consent}&lead[ip]={c.Ip}&subid={request.SubIdTag}" + $"&lead_address[state]={c.State}&lead_address[address]={c.Address}&lead_address[city]={c.City}&lead_address[zip]={c.Zip}" + $"&lead[test]={isTest}&lead[media_type]=noncallcenter" + $"&lead_custom_value[trusted_form]={request.TrustedForm}"; string response = Post(postData, BASE_URL); if (!string.IsNullOrWhiteSpace(response)) { if (response.Contains("success")) { UpdateLeadAccepted(request, c); return(new CoregPostResponse() { Success = true }); } string errorUrl = BASE_URL + postData; WriteCoregError("ProvideMedia", postData, errorUrl, response); return(ParseResponse(response)); } return(new CoregPostResponse() { Success = false, Other = "No response." }); }