public ActionResult Delete(string id) { DirectEmployerClientCampusProgramClient programclient = new DirectEmployerClientCampusProgramClient(); DirectEmployerClientCampusProgram program = programclient.GetByRowKey(id); //Unpublish string currentGeoAddStates = BlobStringManager.Instance.GetString("skillcowemployerprogramgeoindex", "AddStates", id); string currentGeoAddZips = BlobStringManager.Instance.GetString("skillcowemployerprogramgeoindex", "AddZips", id); string currentGeoSubtractStates = BlobStringManager.Instance.GetString("skillcowemployerprogramgeoindex", "SubtractStates", id); string currentGeoSubtractZips = BlobStringManager.Instance.GetString("skillcowemployerprogramgeoindex", "SubtractZips", id); List <string> currentcategories = new List <string>(); if (program.ProgramCategories != null) { currentcategories = new List <string>(program.ProgramCategories.Split(',')); } GeoIndexNationalClient addnational = new GeoIndexNationalClient(); foreach (string programcategory in currentcategories) { addnational.RemoveProgram(programcategory, program.RowKey); RemoveProgramCategory("AddStates", currentGeoAddStates, programcategory.Trim(), program.RowKey, new GeoIndexAddStateClient()); RemoveProgramCategory("AddZips", currentGeoAddZips, programcategory.Trim(), program.RowKey, new GeoIndexAddZipClient()); RemoveProgramCategory("SubtractStates", currentGeoSubtractStates, programcategory.Trim(), program.RowKey, new GeoIndexSubtractStateClient()); RemoveProgramCategory("SubtractZips", currentGeoSubtractZips, programcategory.Trim(), program.RowKey, new GeoIndexSubtractZipClient()); } programclient.Delete(program); BlobStringManager.Instance.DeleteString(id, "skillcowemployerprogramgeoindex", "AddStates"); BlobStringManager.Instance.DeleteString(id, "skillcowemployerprogramgeoindex", "AddZips"); BlobStringManager.Instance.DeleteString(id, "skillcowemployerprogramgeoindex", "SubtractStates"); BlobStringManager.Instance.DeleteString(id, "skillcowemployerprogramgeoindex", "SubtractZips"); return(RedirectToAction("Edit", "DirectEmployerClientCampuses", new { id = program.CampusRowKey })); }
public List <object> FindPositions(HttpRequestBase Request, string zipcode, string attributes, string things, string gender, string programid) { bool demomode = Request["demo"] != null && Request["demo"] == "1"; LeadCounterClient leadcounterclient = new LeadCounterClient(); List <LeadCounter> leadcounters = null; LeadCapClient leadcapclient = new LeadCapClient(); List <LeadCap> leadcaps = null; List <object> results = new List <object>(); bool validprogramcategoryid = false; if (programid != "" && !programid.StartsWith("c")) { validprogramcategoryid = true; } //ZipCodeClient zipclient = new ZipCodeClient(); //ZipCode zipobject = zipclient.GetByRowKey(zipcode); string zipjson = BlobJsonResourceManager.Instance.GetJsonResource("skillcow", "zipcodes", zipcode); JObject jzip = null; if (zipjson != "") { jzip = JObject.Parse(zipjson); } GeoIndexNationalClient nclient = new GeoIndexNationalClient(); GeoIndexAddStateClient addstateclient = new GeoIndexAddStateClient(); GeoIndexAddZipClient addzipclient = new GeoIndexAddZipClient(); GeoIndexSubtractStateClient subtractstateclient = new GeoIndexSubtractStateClient(); GeoIndexSubtractZipClient subtractzipclient = new GeoIndexSubtractZipClient(); List <IGeoIndex> allresults = new List <IGeoIndex>(); List <IGeoIndex> subtractions = new List <IGeoIndex>(); //By program id if (validprogramcategoryid) { allresults.AddRange(nclient.GetAllByPartition(programid)); if (jzip != null) { //allresults.AddRange(addstateclient.GetAllByPartition(zipobject.StateCode + "-" + programid)); allresults.AddRange(addstateclient.GetAllByPartition(jzip["statecode"].ToString() + "-" + programid)); allresults.AddRange(addzipclient.GetAllByPartition(zipcode + "-" + programid)); } if (jzip != null) { //subtractions.AddRange(subtractstateclient.GetAllByPartition(zipobject.StateCode + "-" + programid)); subtractions.AddRange(subtractstateclient.GetAllByPartition(jzip["statecode"].ToString() + "-" + programid)); subtractions.AddRange(subtractzipclient.GetAllByPartition(zipcode + "-" + programid)); } } else { allresults.AddRange(nclient.GetAllByPartition("attr")); if (jzip != null) { //allresults.AddRange(addstateclient.GetAllByPartition(zipobject.StateCode)); allresults.AddRange(addstateclient.GetAllByPartition(jzip["statecode"].ToString())); allresults.AddRange(addzipclient.GetAllByPartition(zipcode)); } if (jzip != null) { //subtractions.AddRange(subtractstateclient.GetAllByPartition(zipobject.StateCode)); subtractions.AddRange(subtractstateclient.GetAllByPartition(jzip["statecode"].ToString())); subtractions.AddRange(subtractzipclient.GetAllByPartition(zipcode)); } } IEnumerable <IGeoIndex> difference = allresults.Except(subtractions, new CompareGeoIndexResults()); DirectEmployerClientClient clientclient = new DirectEmployerClientClient(); DirectEmployerClientCampusClient campusclient = new DirectEmployerClientCampusClient(); DirectEmployerClientCampusProgramClient programclient = new DirectEmployerClientCampusProgramClient(); JObject oattributes = null; JObject othings = null; long attributemask = 0; long importantthingsmask = 0; if (attributes != null && attributes != "") { oattributes = JObject.Parse(attributes); AttributeMaskCalculator amc = new AttributeMaskCalculator(); attributemask = amc.GetMask(oattributes); } if (things != null && things != "") { othings = JObject.Parse(things); ImportantThingsMaskCalculator itmc = new ImportantThingsMaskCalculator(); importantthingsmask = itmc.GetMask(othings); } foreach (IGeoIndex geoindex in allresults) { if (geoindex.AttributeMask != null && (geoindex.AttributeMask & attributemask) == attributemask) { DirectEmployerClientCampusProgram job = programclient.GetByRowKey(geoindex.RowKey); if (job.Status == "Live" || (demomode == true && job.Status == "Demo")) { bool filtered = false; //Apply other filters if (gender != "" && job.Gender != null && job.Gender != "") { if (job.Gender != gender) { filtered = true; } } if (!filtered) { DirectEmployerClientCampus campus = campusclient.GetByRowKey(geoindex.CampusRowKey); DirectEmployerClient employer = clientclient.GetByRowKey(geoindex.ClientRowKey); bool acceptingleads = false; if (employer.Status == "Live" || (demomode == true && employer.Status == "Demo")) { if (campus.Status == "Live" || (demomode == true && campus.Status == "Demo")) { //List<DirectEmployerClientCampusProgram> campusprograms = new List<DirectEmployerClientCampusProgram>(programclient.GetAllByClientId(employer.RowKey).Where(x => x.CampusRowKey == campus.RowKey)); if (leadcounters == null) { leadcounters = new List <LeadCounter>(leadcounterclient.GetAll()); leadcaps = new List <LeadCap>(leadcapclient.GetAll()); } LeadCap schoolcap = leadcaps.Find(x => x.RowKey == employer.RowKey); LeadCap programcap = leadcaps.Find(x => x.RowKey == job.RowKey); LeadCounter schoolcounter = leadcounters.Find(x => x.RowKey == employer.RowKey); LeadCounter programcounter = leadcounters.Find(x => x.RowKey == job.RowKey); acceptingleads = AcceptingLeads(schoolcap, programcap, schoolcounter, programcounter); if (acceptingleads) { results.Add(new { clienttype = employer.ClientType, clientid = employer.ClientId, clientsetid = employer.ClientId, logoclientid = employer.ClientId, program = programid, formid = employer.FormId, distance = 0, campustype = campus.CampusType, campuskey = campus.CampusId, programkey = geoindex.RowKey, clientrowkey = employer.RowKey, jobkey = job.RowKey, jobtitle = job.JobTitle, company = employer.Name.ToJSONSafeString(), companylogo = "https://chaindate.blob.core.windows.net/resources/employerlogos/" + employer.ClientType + employer.RowKey, city = campus.City, state = campus.State, date = job.PostedDateTime.ToString("ddd, dd MMM yyyy HH:mm:ss") + " GMT", snippet = job.Description, attributescore = oattributes != null ? job.GetAttributeScore(oattributes) : 0, importantthingsscore = othings != null ? job.GetImportantThingsScore(othings) : 0 }); } } } } } } } return(results); }
public List <object> FindSchools(HttpRequestBase Request, string zipcode, string programcategoryid, string edulevel, ref List <string> directclientnames) { bool demomode = Request["demo"] != null && Request["demo"] == "1"; LeadCounterClient leadcounterclient = new LeadCounterClient(); List <LeadCounter> leadcounters = null; LeadCapClient leadcapclient = new LeadCapClient(); List <LeadCap> leadcaps = null; List <object> results = new List <object>(); if (programcategoryid.StartsWith("c")) { return(results); } ZipCodeClient zipclient = new ZipCodeClient(); ZipCode zipobject = zipclient.GetByRowKey(zipcode); GeoIndexNationalClient nclient = new GeoIndexNationalClient(); GeoIndexAddStateClient addstateclient = new GeoIndexAddStateClient(); GeoIndexAddZipClient addzipclient = new GeoIndexAddZipClient(); GeoIndexSubtractStateClient subtractstateclient = new GeoIndexSubtractStateClient(); GeoIndexSubtractZipClient subtractzipclient = new GeoIndexSubtractZipClient(); List <IGeoIndex> allresults = new List <IGeoIndex>(); allresults.AddRange(nclient.GetAllByPartition(programcategoryid)); if (zipobject != null) { allresults.AddRange(addstateclient.GetAllByPartition(zipobject.StateCode + "-" + programcategoryid)); allresults.AddRange(addzipclient.GetAllByPartition(zipcode + "-" + programcategoryid)); } List <IGeoIndex> subtractions = new List <IGeoIndex>(); if (zipobject != null) { subtractions.AddRange(subtractstateclient.GetAllByPartition(zipobject.StateCode + "-" + programcategoryid)); subtractions.AddRange(subtractzipclient.GetAllByPartition(zipcode + "-" + programcategoryid)); } IEnumerable <IGeoIndex> difference = allresults.Except(subtractions, new CompareGeoIndexResults()); IEnumerable <IGrouping <string, IGeoIndex> > bycampus = difference.GroupBy(x => x.CampusRowKey); DirectSchoolClientClient clientclient = new DirectSchoolClientClient(); DirectSchoolClientCampusClient campusclient = new DirectSchoolClientCampusClient(); DirectSchoolClientCampusProgramClient programclient = new DirectSchoolClientCampusProgramClient(); foreach (IGrouping <string, IGeoIndex> campusgroup in bycampus) { DirectSchoolClientCampus campus = campusclient.GetByRowKey(campusgroup.Key); DirectSchoolClient school = clientclient.GetByRowKey(campus.ClientRowKey); bool acceptingleads = false; if (school.Status == "Live" || (demomode == true && school.Status == "Demo")) { if (campus.Status == "Live" || (demomode == true && campus.Status == "Demo")) { List <DirectSchoolClientCampusProgram> campusprograms = new List <DirectSchoolClientCampusProgram>(programclient.GetAllBySchoolId(school.RowKey).Where(x => x.CampusRowKey == campus.RowKey)); string programkey = ""; bool gotprogramkey = false; List <object> programitems = new List <object>(); foreach (IGeoIndex programresult in campusgroup) { DirectSchoolClientCampusProgram program = campusprograms.SingleOrDefault(x => x.RowKey == programresult.RowKey); if (program.Status == "Live" || (demomode == true && program.Status == "Demo")) { if (leadcounters == null) { leadcounters = new List <LeadCounter>(leadcounterclient.GetAll()); leadcaps = new List <LeadCap>(leadcapclient.GetAll()); } LeadCap schoolcap = leadcaps.Find(x => x.RowKey == school.RowKey); LeadCap programcap = leadcaps.Find(x => x.RowKey == program.RowKey); LeadCounter schoolcounter = leadcounters.Find(x => x.RowKey == school.RowKey); LeadCounter programcounter = leadcounters.Find(x => x.RowKey == program.RowKey); //see if counters need to be reset schoolcounter.ResetCountersIfNeeded(leadcounterclient); programcounter.ResetCountersIfNeeded(leadcounterclient); acceptingleads = AcceptingLeads(schoolcap, programcap, schoolcounter, programcounter); if (acceptingleads) { programitems.Add(new { id = program.ProgramId + "." + program.RowKey, type = program.ProgramType, typename = program.ResolveProgramTypeName(), isprimary = 1, name = program.Name.ToJSONSafeString() }); if (!gotprogramkey) { if (",hs,ged,crt,sc,as,inhs,none,".Contains("," + edulevel.ToLower() + ",")) { string testprogramkey = program.ProgramType; //Exclude MS if (!(",ms,ma,maed,mba,me,mfa,ms,mst,".Contains("," + testprogramkey.ToLower() + ","))) { programkey = HttpUtility.UrlDecode(program.ProgramId); gotprogramkey = true; } } else { programkey = HttpUtility.UrlDecode(program.ProgramId); gotprogramkey = true; } } } } } if (acceptingleads) { if (!directclientnames.Contains(school.Name)) { directclientnames.Add(school.Name); } results.Add(new { clienttype = "direct", formname = school.Name.ToJSONSafeString(), clientfrontendname = school.Name.ToJSONSafeString(), formdescription = school.Description.ToJSONSafeString(), city = campus.City, state = campus.State, image = "https://chaindate.blob.core.windows.net/resources/schoollogos/" + school.RowKey, clientid = school.ClientId, clientsetid = school.ClientId, logoclientid = school.ClientId, program = programcategoryid, formid = school.FormId, distance = 0, campustype = campus.CampusType, campuskey = campus.CampusId, programs = programitems.ToArray(), programkey = programkey, clientrowkey = school.RowKey }); } } } } return(results); }
/* * private bool PublishGeoIndex(DirectEmployerClientCampusProgram currentitem, DirectEmployerClientCampusProgram updateditem) * { * bool programschanged = false; * * //See which program categories need to be added or removed * List<string> currentcategories = new List<string>(); * if (currentitem.ProgramCategories != null) * { * currentcategories = new List<string>(currentitem.ProgramCategories.Split(',')); * } * * List<string> updatedcategories = new List<string>(); * if (updateditem.ProgramCategories != null) * { * updatedcategories = new List<string>(updateditem.ProgramCategories.Split(',')); * } * * if (currentcategories.Count == 0 && updatedcategories.Count == 0) * { * programschanged = true; * } * else * { * programschanged = true; * } * * if (programschanged) * { * List<string> categoriestoremove = new List<string>(); * List<string> categoriestoadd = new List<string>(); * * //find strings to remove * foreach (string token in currentcategories) * { * if (!updatedcategories.Contains(token)) * { * categoriestoremove.Add(token); * } * } * * //find strings to add * foreach (string token in updatedcategories) * { * if (!currentcategories.Contains(token)) * { * categoriestoadd.Add(token); * } * } * * GeoIndexNationalClient addnational = new GeoIndexNationalClient(); * * foreach (string programcategory in categoriestoremove) * { * addnational.RemoveProgram(programcategory, updateditem.RowKey); * * RemoveProgramCategory("AddStates", updateditem.GeoAddStates, programcategory.Trim(), updateditem.RowKey, new GeoIndexAddStateClient()); * RemoveProgramCategory("AddZips", updateditem.GeoAddZips, programcategory.Trim(), updateditem.RowKey, new GeoIndexAddZipClient()); * RemoveProgramCategory("SubtractStates", updateditem.GeoSubtractStates, programcategory.Trim(), updateditem.RowKey, new GeoIndexSubtractStateClient()); * RemoveProgramCategory("SubtractZips", updateditem.GeoSubtractZips, programcategory.Trim(), updateditem.RowKey, new GeoIndexSubtractZipClient()); * } * * * * foreach (string programcategory in updatedcategories) * { * bool newcategory = !currentcategories.Contains(programcategory); * * if (updateditem.GeoAddNational == "National") * { * addnational.AddProgram(programcategory, updateditem.RowKey, updateditem.CampusRowKey, updateditem.ClientRowKey, 0, 0); * } * else * { * addnational.RemoveProgram(programcategory, updateditem.RowKey); * } * * ProcessGeoTargetingListString("AddStates", updateditem.GeoAddStates, programcategory.Trim(), newcategory, updateditem.RowKey, updateditem.CampusRowKey, updateditem.ClientRowKey, new GeoIndexAddStateClient()); * ProcessGeoTargetingListString("AddZips", updateditem.GeoAddZips, programcategory.Trim(), newcategory, updateditem.RowKey, updateditem.CampusRowKey, updateditem.ClientRowKey, new GeoIndexAddZipClient()); * ProcessGeoTargetingListString("SubtractStates", updateditem.GeoSubtractStates, programcategory.Trim(), newcategory, updateditem.RowKey, updateditem.CampusRowKey, updateditem.ClientRowKey, new GeoIndexSubtractStateClient()); * ProcessGeoTargetingListString("SubtractZips", updateditem.GeoSubtractZips, programcategory.Trim(), newcategory, updateditem.RowKey, updateditem.CampusRowKey, updateditem.ClientRowKey, new GeoIndexSubtractZipClient()); * } * * * } * * string currentGeoAddStates = BlobStringManager.Instance.GetString("skillcowemployerprogramgeoindex", "AddStates", updateditem.RowKey); * string currentGeoAddZips = BlobStringManager.Instance.GetString("skillcowemployerprogramgeoindex", "AddZips", updateditem.RowKey); * string currentGeoSubtractStates = BlobStringManager.Instance.GetString("skillcowemployerprogramgeoindex", "SubtractStates", updateditem.RowKey); * string currentGeoSubtractZips = BlobStringManager.Instance.GetString("skillcowemployerprogramgeoindex", "SubtractZips", updateditem.RowKey); * * if (currentGeoAddStates != updateditem.GeoAddStates) * { * BlobStringManager.Instance.SaveString(NullString(updateditem.GeoAddStates), updateditem.RowKey, "skillcowemployerprogramgeoindex", "AddStates"); * } * if (currentGeoAddZips != updateditem.GeoAddZips) * { * BlobStringManager.Instance.SaveString(NullString(updateditem.GeoAddZips), updateditem.RowKey, "skillcowemployerprogramgeoindex", "AddZips"); * } * if (currentGeoSubtractStates != updateditem.GeoSubtractStates) * { * BlobStringManager.Instance.SaveString(NullString(updateditem.GeoSubtractStates), updateditem.RowKey, "skillcowemployerprogramgeoindex", "SubtractStates"); * } * if (currentGeoSubtractZips != updateditem.GeoSubtractZips) * { * BlobStringManager.Instance.SaveString(NullString(updateditem.GeoSubtractZips), updateditem.RowKey, "skillcowemployerprogramgeoindex", "SubtractZips"); * } * return true; * } */ private bool PublishGeoIndex2(DirectEmployerClientCampusProgram currentitem, DirectEmployerClientCampusProgram updateditem) { bool programschanged = false; //See which program categories need to be added or removed List <string> currentcategories = new List <string>(); if (currentitem.ProgramCategories != null) { currentcategories = new List <string>(currentitem.ProgramCategories.Split(',')); } List <string> updatedcategories = new List <string>(); if (updateditem.ProgramCategories != null) { updatedcategories = new List <string>(updateditem.ProgramCategories.Split(',')); } if (currentcategories.Count == 0 && updatedcategories.Count == 0) { programschanged = false; } else { programschanged = true; } GeoIndexNationalClient addnational = new GeoIndexNationalClient(); if (programschanged) { List <string> categoriestoremove = new List <string>(); List <string> categoriestoadd = new List <string>(); //find strings to remove foreach (string token in currentcategories) { if (!updatedcategories.Contains(token)) { categoriestoremove.Add(token); } } //find strings to add foreach (string token in updatedcategories) { if (!currentcategories.Contains(token)) { categoriestoadd.Add(token); } } foreach (string programcategory in categoriestoremove) { addnational.RemoveProgram(programcategory, updateditem.RowKey); RemoveProgramCategory("AddStates", updateditem.GeoAddStates, programcategory.Trim(), updateditem.RowKey, new GeoIndexAddStateClient()); RemoveProgramCategory("AddZips", updateditem.GeoAddZips, programcategory.Trim(), updateditem.RowKey, new GeoIndexAddZipClient()); RemoveProgramCategory("SubtractStates", updateditem.GeoSubtractStates, programcategory.Trim(), updateditem.RowKey, new GeoIndexSubtractStateClient()); RemoveProgramCategory("SubtractZips", updateditem.GeoSubtractZips, programcategory.Trim(), updateditem.RowKey, new GeoIndexSubtractZipClient()); } foreach (string programcategory in updatedcategories) { bool newcategory = !currentcategories.Contains(programcategory); if (updateditem.GeoAddNational == "National") { addnational.AddProgram(programcategory, updateditem.RowKey, updateditem.CampusRowKey, updateditem.ClientRowKey, 0, 0); } else { addnational.RemoveProgram(programcategory, updateditem.RowKey); } ProcessGeoTargetingListString("AddStates", updateditem.GeoAddStates, programcategory.Trim(), newcategory, updateditem.RowKey, updateditem.CampusRowKey, updateditem.ClientRowKey, 0, 0, false, new GeoIndexAddStateClient()); ProcessGeoTargetingListString("AddZips", updateditem.GeoAddZips, programcategory.Trim(), newcategory, updateditem.RowKey, updateditem.CampusRowKey, updateditem.ClientRowKey, 0, 0, false, new GeoIndexAddZipClient()); ProcessGeoTargetingListString("SubtractStates", updateditem.GeoSubtractStates, programcategory.Trim(), newcategory, updateditem.RowKey, updateditem.CampusRowKey, updateditem.ClientRowKey, 0, 0, false, new GeoIndexSubtractStateClient()); ProcessGeoTargetingListString("SubtractZips", updateditem.GeoSubtractZips, programcategory.Trim(), newcategory, updateditem.RowKey, updateditem.CampusRowKey, updateditem.ClientRowKey, 0, 0, false, new GeoIndexSubtractZipClient()); } } //Publish for attributes bool maskschanged = (updateditem.AttributeMask != currentitem.AttributeMask || updateditem.ImportantThingsMask != currentitem.ImportantThingsMask); if (updateditem.GeoAddNational == "National") { if (maskschanged) { addnational.RemoveProgram("attr", updateditem.RowKey); } addnational.AddProgram("attr", updateditem.RowKey, updateditem.CampusRowKey, updateditem.ClientRowKey, updateditem.AttributeMask, updateditem.ImportantThingsMask); } else { addnational.RemoveProgram("attr", updateditem.RowKey); } ProcessGeoTargetingListString("AddStates", updateditem.GeoAddStates, "", false, updateditem.RowKey, updateditem.CampusRowKey, updateditem.ClientRowKey, updateditem.AttributeMask, updateditem.ImportantThingsMask, maskschanged, new GeoIndexAddStateClient()); ProcessGeoTargetingListString("AddZips", updateditem.GeoAddZips, "", false, updateditem.RowKey, updateditem.CampusRowKey, updateditem.ClientRowKey, updateditem.AttributeMask, updateditem.ImportantThingsMask, maskschanged, new GeoIndexAddZipClient()); ProcessGeoTargetingListString("SubtractStates", updateditem.GeoSubtractStates, "", false, updateditem.RowKey, updateditem.CampusRowKey, updateditem.ClientRowKey, updateditem.AttributeMask, updateditem.ImportantThingsMask, maskschanged, new GeoIndexSubtractStateClient()); ProcessGeoTargetingListString("SubtractZips", updateditem.GeoSubtractZips, "", false, updateditem.RowKey, updateditem.CampusRowKey, updateditem.ClientRowKey, updateditem.AttributeMask, updateditem.ImportantThingsMask, maskschanged, new GeoIndexSubtractZipClient()); string currentGeoAddStates = BlobStringManager.Instance.GetString("skillcowemployerprogramgeoindex", "AddStates", updateditem.RowKey); string currentGeoAddZips = BlobStringManager.Instance.GetString("skillcowemployerprogramgeoindex", "AddZips", updateditem.RowKey); string currentGeoSubtractStates = BlobStringManager.Instance.GetString("skillcowemployerprogramgeoindex", "SubtractStates", updateditem.RowKey); string currentGeoSubtractZips = BlobStringManager.Instance.GetString("skillcowemployerprogramgeoindex", "SubtractZips", updateditem.RowKey); if (currentGeoAddStates != updateditem.GeoAddStates) { BlobStringManager.Instance.SaveString(NullString(updateditem.GeoAddStates), updateditem.RowKey, "skillcowemployerprogramgeoindex", "AddStates"); } if (currentGeoAddZips != updateditem.GeoAddZips) { BlobStringManager.Instance.SaveString(NullString(updateditem.GeoAddZips), updateditem.RowKey, "skillcowemployerprogramgeoindex", "AddZips"); } if (currentGeoSubtractStates != updateditem.GeoSubtractStates) { BlobStringManager.Instance.SaveString(NullString(updateditem.GeoSubtractStates), updateditem.RowKey, "skillcowemployerprogramgeoindex", "SubtractStates"); } if (currentGeoSubtractZips != updateditem.GeoSubtractZips) { BlobStringManager.Instance.SaveString(NullString(updateditem.GeoSubtractZips), updateditem.RowKey, "skillcowemployerprogramgeoindex", "SubtractZips"); } return(true); }
private bool PublishGeoIndex(DirectSchoolClientCampusProgram currentitem, DirectSchoolClientCampusProgram updateditem) { //List<string> programcategories = new List<string>(); //if (updateditem.ProgramCategories != null) //{ // programcategories = new List<string>(updateditem.ProgramCategories.Split(',')); //} //See which program categories need to be added or removed List <string> currentcategories = new List <string>(); if (currentitem.ProgramCategories != null) { currentcategories = new List <string>(currentitem.ProgramCategories.Split(',')); } List <string> updatedcategories = new List <string>(); if (updateditem.ProgramCategories != null) { updatedcategories = new List <string>(updateditem.ProgramCategories.Split(',')); } if (currentcategories.Count == 0 && updatedcategories.Count == 0) { return(true); } else { Console.Write("Categories changed"); } List <string> categoriestoremove = new List <string>(); List <string> categoriestoadd = new List <string>(); //find strings to remove foreach (string token in currentcategories) { if (!updatedcategories.Contains(token)) { categoriestoremove.Add(token); } } //find strings to add foreach (string token in updatedcategories) { if (!currentcategories.Contains(token)) { categoriestoadd.Add(token); } } GeoIndexNationalClient addnational = new GeoIndexNationalClient(); foreach (string programcategory in categoriestoremove) { addnational.RemoveProgram(programcategory, updateditem.RowKey); RemoveProgramCategory("AddStates", updateditem.GeoAddStates, programcategory.Trim(), updateditem.RowKey, new GeoIndexAddStateClient()); RemoveProgramCategory("AddZips", updateditem.GeoAddZips, programcategory.Trim(), updateditem.RowKey, new GeoIndexAddZipClient()); RemoveProgramCategory("SubtractStates", updateditem.GeoSubtractStates, programcategory.Trim(), updateditem.RowKey, new GeoIndexSubtractStateClient()); RemoveProgramCategory("SubtractZips", updateditem.GeoSubtractZips, programcategory.Trim(), updateditem.RowKey, new GeoIndexSubtractZipClient()); } foreach (string programcategory in updatedcategories) { bool newcategory = !currentcategories.Contains(programcategory); if (updateditem.GeoAddNational == "National") { addnational.AddProgram(programcategory, updateditem.RowKey, updateditem.CampusRowKey, updateditem.ClientRowKey, 0, 0); } else { addnational.RemoveProgram(programcategory, updateditem.RowKey); } ProcessGeoTargetingListString("AddStates", updateditem.GeoAddStates, programcategory.Trim(), newcategory, updateditem.RowKey, updateditem.CampusRowKey, updateditem.ClientRowKey, new GeoIndexAddStateClient()); ProcessGeoTargetingListString("AddZips", updateditem.GeoAddZips, programcategory.Trim(), newcategory, updateditem.RowKey, updateditem.CampusRowKey, updateditem.ClientRowKey, new GeoIndexAddZipClient()); ProcessGeoTargetingListString("SubtractStates", updateditem.GeoSubtractStates, programcategory.Trim(), newcategory, updateditem.RowKey, updateditem.CampusRowKey, updateditem.ClientRowKey, new GeoIndexSubtractStateClient()); ProcessGeoTargetingListString("SubtractZips", updateditem.GeoSubtractZips, programcategory.Trim(), newcategory, updateditem.RowKey, updateditem.CampusRowKey, updateditem.ClientRowKey, new GeoIndexSubtractZipClient()); } string currentGeoAddStates = BlobStringManager.Instance.GetString("skillcowschoolprogramgeoindex", "AddStates", updateditem.RowKey); string currentGeoAddZips = BlobStringManager.Instance.GetString("skillcowschoolprogramgeoindex", "AddZips", updateditem.RowKey); string currentGeoSubtractStates = BlobStringManager.Instance.GetString("skillcowschoolprogramgeoindex", "SubtractStates", updateditem.RowKey); string currentGeoSubtractZips = BlobStringManager.Instance.GetString("skillcowschoolprogramgeoindex", "SubtractZips", updateditem.RowKey); if (currentGeoAddStates != updateditem.GeoAddStates) { BlobStringManager.Instance.SaveString(NullString(updateditem.GeoAddStates), updateditem.RowKey, "skillcowschoolprogramgeoindex", "AddStates"); } if (currentGeoAddZips != updateditem.GeoAddZips) { BlobStringManager.Instance.SaveString(NullString(updateditem.GeoAddZips), updateditem.RowKey, "skillcowschoolprogramgeoindex", "AddZips"); } if (currentGeoSubtractStates != updateditem.GeoSubtractStates) { BlobStringManager.Instance.SaveString(NullString(updateditem.GeoSubtractStates), updateditem.RowKey, "skillcowschoolprogramgeoindex", "SubtractStates"); } if (currentGeoSubtractZips != updateditem.GeoSubtractZips) { BlobStringManager.Instance.SaveString(NullString(updateditem.GeoSubtractZips), updateditem.RowKey, "skillcowschoolprogramgeoindex", "SubtractZips"); } return(true); }