public KeywordProbabilityObject[] GetKeywords(List<string> categories, string companyName, string[] searchEngines, string searchTerm, string description, string[] adds, string url, GeoTargetObject[] gt, Int32[] nGrams) { string returnData = string.Empty; try { var jsonHash = new Dictionary<string, string>(); String jsonCategories = JsonConvert.SerializeObject(categories); jsonHash.Add("categories", jsonCategories); jsonHash.Add("companyName", companyName); jsonHash.Add("searchTerm", searchTerm); string jsonAdds = JsonConvert.SerializeObject(adds, Formatting.Indented); jsonHash.Add("adds", jsonAdds); string jsonSEngines = JsonConvert.SerializeObject(searchEngines); jsonHash.Add("searchEngines", jsonSEngines); string jsonGt = JsonConvert.SerializeObject(gt); jsonHash.Add("gt", jsonGt); jsonHash.Add("description", description); jsonHash.Add("url", url); nGrams = new[] { 50, 50 }; //nGrams = new Int32[] { 1,2,3 }; string jsonNgrams = JsonConvert.SerializeObject(nGrams); jsonHash.Add("nGrams", jsonNgrams); string jsonstr = JsonConvert.SerializeObject(jsonHash); //string returnData = string.Empty; returnData = runMethod(_baseURLTest, SERVICEOFFERED, "getKeywords", jsonstr, timeoutMS); var dict = JsonConvert.DeserializeObject<Dictionary<string, string>>(returnData); List<string> lis = dict.Values.ToList(); string jsonstrlist = lis[0]; if (jsonstrlist == "Service Timeout") { throw new Exception("Service Timeout for GetKeywords"); } //var listoflist = JsonConvert.DeserializeObject<List<List<string>>>(jsonstrlist); //var listoflist = JsonConvert.DeserializeObject<List<KeywordProbabilityObject>>(jsonstrlist); var listoflist = JsonConvert.DeserializeObject<KeywordProbabilityObject[]>(jsonstrlist); foreach (var kpolis in listoflist) { kpolis.keyword = kpolis.keyword.Trim(); } return listoflist; } catch { if (string.IsNullOrEmpty(returnData)) throw; else throw new Exception(returnData); } }
public KeywordProbabilityObject[] GetKeywords(List<string> categories, string companyName, string[] searchEngines, string searchTerm, string description, string[] adds, string url, GeoTargetObject[] gt) { try { var jsonHash = new Dictionary<string, string>(); String jsonCategories = JsonConvert.SerializeObject(categories); jsonHash.Add("categories", jsonCategories); jsonHash.Add("companyName", companyName); jsonHash.Add("searchTerm", searchTerm); string jsonAdds = JsonConvert.SerializeObject(adds, Formatting.Indented); jsonHash.Add("adds", jsonAdds); string jsonSEngines = JsonConvert.SerializeObject(searchEngines); jsonHash.Add("searchEngines", jsonSEngines); string jsonGt = JsonConvert.SerializeObject(gt); jsonHash.Add("gt", jsonGt); jsonHash.Add("description", description); jsonHash.Add("url", url); Int32[] nGrams = new[] {300, 300, 100}; string jsonNgrams = JsonConvert.SerializeObject(nGrams); jsonHash.Add("nGrams", jsonNgrams); string jsonstr = JsonConvert.SerializeObject(jsonHash); var dict = RunMethod(_baseURLTest, Serviceoffered, "getKeywords", jsonstr); List<string> lis = dict.Values.ToList(); string jsonstrlist = lis[0]; var listoflist = JsonConvert.DeserializeObject<KeywordProbabilityObject[]>(jsonstrlist); foreach (var kpolis in listoflist) kpolis.keyword = kpolis.keyword.Trim(); return listoflist; } catch(Exception ex) { Helpers.ExceptionHelper.LogException(ex); } return null; }
private List<GeoTargetObject> SerializeToGeoTargetObjectArray(CampaignSetupModel model) { var geoList = new List<GeoTargetObject>(); var sr = new StateRepository(); foreach (var geo in model.AdModelProp.Addresses) { if (!geo.IsState && !geo.Delete && !geo.IsCountry) { var geoTObj = new GeoTargetObject(); geoTObj.address = geo.Address; geoTObj.city = geo.City; if (geo.StateCodeFK != int.MinValue) geoTObj.state = sr.GetStateNameFromCode((int)geo.StateCodeFK); geoTObj.zip = geo.Zip; geoTObj.radius = (double?)(geo.ProximityRadius ?? null); geoTObj.latitude = (double?)(geo.Latitude ?? null); geoTObj.longitude = (double?)(geo.Longitude ?? null); geoList.Add(geoTObj); } } return geoList; }
private List<GeoTargetObject> SerializeToGeoTargetObjectArray(CampaignSetupModel model) { var geoList = new List<GeoTargetObject>(); foreach (var geo in model.AdModelProp.Addresses) { if (!geo.IsState) { var geoTObj = new GeoTargetObject(); geoTObj.address = geo.Address; geoTObj.city = geo.City; if (geo.StateCodeFK != null) geoTObj.state = GetStateNameFromDb((int)geo.StateCodeFK); geoTObj.zip = geo.Zip; geoTObj.radius = (double)(geo.ProximityRadius ?? 0); geoTObj.latitude = (double)(geo.Latitude ?? 0); geoTObj.longitude = (double)(geo.Longitude ?? 0); geoList.Add(geoTObj); } } return geoList; }
public List<GeoTargetObject> SerializeToGeoTargetObjectArray(CampaignSetupModel model) { var geoList = new List<GeoTargetObject>(); foreach (var geo in model.AdModelProp.Addresses) { if (geo.PromotionFK > 0) { var geoTObj = new GeoTargetObject(); geoTObj.setAddress(geo.Address); geoTObj.setCity(geo.City); if (geo.StateCodeFK != null) geoTObj.setState(GetStateNameFromDb((int)geo.StateCodeFK)); geoTObj.setZip(geo.Zip); geoTObj.setRadius((double)(geo.ProximityRadius ?? 0)); geoTObj.setLatitude((double)(geo.Latitude ?? 0)); geoTObj.setLongitude((double)(geo.Longitude ?? 0)); geoList.Add(geoTObj); } } return geoList; }