public void UpdateImpression(string adId, int type) { try { // Full path to GeoLiteCity.dat file string fullDBPath = Server.MapPath("App_Data/GeoLiteCity.dat"); // Visitor's IP address string visitorIP = Request.ServerVariables["REMOTE_ADDR"]; // Create objects needed for geo targeting var ls = new Geotargeting.LookupService(fullDBPath, Geotargeting.LookupService.GEOIP_STANDARD); //Geotargeting.Location visitorLocation = ls.getLocation(VisitorIP); //testing var visitorLocation = ls.getLocation("68.70.88.2"); var myWebVisitor = new WebsiteVisitor(HttpContext.Current); //YOU Need to account for NULL AND FOR LOWER CASE!!!!!!!!!!!!!!/////////////// //YOU Need to account for NULL AND FOR LOWER CASE!!!!!!!!!!!!!!/////////////// int countryID; int regionID; int cityID; using (var context = new SidejobEntities()) { try { var selected = (from c in context.CountriesUpdates where c.ISO2 == visitorLocation.countryCode select c).ToList(); var selectedCountryID = selected.ToList().FirstOrDefault(); if (selectedCountryID != null) { countryID = Convert.ToInt32(selectedCountryID.CountryId.ToString(CultureInfo.InvariantCulture)); //var selectedCountryID = // from c in context.CountriesUpdates // where c.ISO2 == visitorLocation.countryCode // select c.CountryId; // countryID = selectedCountryID.FirstOrDefault(); if (countryID == 0) { //Default: US countryID = 254; } var selectedRegionID = from c in context.regionsUpdates where c.Code == visitorLocation.region && c.CountryId == Convert.ToInt32(selectedCountryID) select c.RegionId; regionID = Convert.ToInt32(selectedRegionID); if (regionID == 0) { //Default: NY regionID = 154; } var selectedCityID = from c in context.CitiesUpdates where c.City == visitorLocation.city select c.CityId; cityID = Convert.ToInt32(selectedCityID); if (cityID == 0) { //Default: NY cityID = 10182; } } else { //Default: US countryID = 254; //Default: NY regionID = 154; //Default: NY cityID = 10182; } } catch (Exception) { //Default: US countryID = 254; //Default: NY regionID = 154; //Default: NY cityID = 10182; } } /////////////// string refURL = "Exception"; /////////////// ImpressionUtility.UpdateImpression(Convert.ToInt32(adId), Convert.ToDateTime( DateTime.Today.ToString( CultureInfo.InvariantCulture)), type, visitorIP, visitorLocation.countryCode, visitorLocation.region, visitorLocation.postalCode, visitorLocation.area_code, visitorLocation.dma_code, visitorLocation.latitude, visitorLocation.longitude, refURL, myWebVisitor.BrowserType, myWebVisitor.BrowserName, myWebVisitor.BrowserPlatform, myWebVisitor.UserHostAddress, myWebVisitor.UserHostName, myWebVisitor.UserLanguages, myWebVisitor.MobileDeviceManufacturer, myWebVisitor.MobileDeviceModel, myWebVisitor.DeviceType, 100, "PRO", "haithem", "smith", "address", countryID, visitorLocation.countryCode, regionID, visitorLocation.region, cityID, visitorLocation.city, "91340605", 28, 1, "emailAddress", "photoPath", 5, 52, 1); //// UpdateImpression(int adId, DateTime entryData, int type, string iPAddress, string countryCode, string region, string postalcode, //int areaCode, int metroCode, double latiture, double longitude, string refURL, string browserType, string browserName, string browserPlatform, string userHostAddress, //string userHostName, //string userLanguage,string mobileDeviceManufacturer, // string mobileDeviceModel, string deviceType, int userId, string userRole, string firstName, //string lastName, string address, int countryID, string countryName, int regionID, //string regionName, int cityID, string cityName, string phone, int age, int gender, //string emailAddress, string photoPath, int industryID, int professionID, int lcid) } catch (Exception) { } }
public static void SimplifiedUpdateClik(string adId, int type, string fullDBPath, string visitorIP, string currentURL, int userId, string userRole, string firstName, string lastName, string address, string phone, int age, int gender, string emailAddress, string photoPath, int industryID, int professionID, int lcid) { try { // Full path to GeoLiteCity.dat file //fullDBPath = Server.MapPath("~/App_Data/GeoLiteCity.dat"); // Visitor's IP address //string visitorIP = Request.ServerVariables["REMOTE_ADDR"]; // Create objects needed for geo targeting var ls = new Geotargeting.LookupService(fullDBPath, Geotargeting.LookupService.GEOIP_STANDARD); //Geotargeting.Location visitorLocation = ls.getLocation(VisitorIP); //testing //var visitorLocation = ls.getLocation("68.70.88.2"); var visitorLocation = ls.getLocation(visitorIP); var myWebVisitor = new WebsiteVisitor(HttpContext.Current); int countryID; int regionID; int cityID; using (var context = new SidejobEntities()) { try { var selectedCountryID = from c in context.CountriesUpdates where c.ISO2 == visitorLocation.countryCode select c.CountryId; countryID = selectedCountryID.FirstOrDefault(); if (countryID == 0) { //Default: US countryID = 254; } int cid = countryID; var selectedRegionID = from c in context.regionsUpdates where c.Code == visitorLocation.region && c.CountryId == cid select c.RegionId; regionID = selectedRegionID.FirstOrDefault(); if (regionID == 0) { //Default: NY regionID = 154; } var selectedCityID = from c in context.CitiesUpdates where c.City == visitorLocation.city select c.CityId; cityID = selectedCityID.FirstOrDefault(); if (cityID == 0) { //Default: NY cityID = 10182; } } catch (Exception) { //Default: US countryID = 254; //Default: NY regionID = 154; //Default: NY cityID = 10182; } } UpdateImpression(Convert.ToInt32(adId), Convert.ToDateTime(DateTime.Today.ToString(CultureInfo.InvariantCulture)), type, visitorIP, visitorLocation.countryCode, visitorLocation.region, visitorLocation.postalCode, visitorLocation.area_code, visitorLocation.dma_code, visitorLocation.latitude, visitorLocation.longitude, currentURL, myWebVisitor.BrowserType, myWebVisitor.BrowserName, myWebVisitor.BrowserPlatform, myWebVisitor.UserHostAddress, myWebVisitor.UserHostName, myWebVisitor.UserLanguages, myWebVisitor.MobileDeviceManufacturer, myWebVisitor.MobileDeviceModel, myWebVisitor.DeviceType, userId, userRole, firstName, lastName, address, countryID, visitorLocation.countryCode, regionID, visitorLocation.region, cityID, visitorLocation.city, phone, age, gender, emailAddress, photoPath, industryID, professionID, lcid); } catch (Exception) { } }
public static UserMachineLocation GetInfo() { try { // Full path to GeoLiteCity.dat file string fullDBPath = HttpContext.Current.Server.MapPath("~/App_Data/GeoLiteCity.dat"); // Visitor's IP address string visitorIP = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]; // Create objects needed for geo targeting var ls = new Geotargeting.LookupService(fullDBPath, Geotargeting.LookupService.GEOIP_STANDARD); Geotargeting.Location visitorLocation = ls.getLocation(visitorIP); //testing //var visitorLocation = ls.getLocation("68.70.88.2"); var myWebVisitor = new WebsiteVisitor(HttpContext.Current); //YOU Need to account for NULL AND FOR LOWER CASE!!!!!!!!!!!!!!/////////////// //YOU Need to account for NULL AND FOR LOWER CASE!!!!!!!!!!!!!!/////////////// int countryID; int regionID; int cityID; using (var context = new SidejobEntities()) { try { var selectedCountryID = from c in context.CountriesUpdates where c.ISO2 == visitorLocation.countryCode select c.CountryId; countryID = selectedCountryID.FirstOrDefault(); if (countryID == 0) { //Default: US countryID = 254; } var selectedRegionID = from c in context.regionsUpdates where c.Code == visitorLocation.region && c.CountryId == Convert.ToInt32(selectedCountryID) select c.RegionId; regionID = Convert.ToInt32(selectedRegionID); if (regionID == 0) { //Default: NY regionID = 154; } var c1 = from c in context.CitiesUpdates where c.City == visitorLocation.city select c; var city = ""; cityID = 10182; var c2 = c1.FirstOrDefault(); if (c2 != null) { var selectedCityID = c2.CityId; cityID = Convert.ToInt32(selectedCityID); city = c2.City; } if (cityID == 0) { //Default: NY cityID = 10182; } return new UserMachineLocation(countryID, regionID, cityID, GetZipcode(countryID, regionID,city,visitorLocation.postalCode)); } catch (Exception) { //Default: US countryID = 254; //Default: NY regionID = 154; //Default: NY cityID = 10182; //Defauly Zipcode //10185 : NY NY return new UserMachineLocation(254, 154, 10182, "10185"); } } } catch (Exception) { return new UserMachineLocation(254, 154, 10182, "10185"); } }