public ActionResult Create(DirectEmployerClientCampusProgram item) { try { if (ModelState.IsValid) { DirectEmployerClientCampusProgramClient programclient = new DirectEmployerClientCampusProgramClient(); item.PostedDateTime = DateTime.UtcNow; AttributeMaskCalculator amc = new AttributeMaskCalculator(); item.AttributeMask = amc.GetMask(item); ImportantThingsMaskCalculator itmc = new ImportantThingsMaskCalculator(); item.ImportantThingsMask = itmc.GetMask(item); try { programclient.AddNewItem(item); return(RedirectToAction("Edit", "DirectEmployerClientCampuses", new { id = item.CampusId })); } catch { ModelState.AddModelError("error", "Error creating new program"); } } DirectEmployerClientCampusClient campusclient = new DirectEmployerClientCampusClient(); DirectEmployerClientCampus campus = campusclient.GetByRowKey(item.CampusId); ViewBag.Campus = campus; DirectEmployerClientClient dscc = new DirectEmployerClientClient(); ViewBag.Client = dscc.GetByRowKey(item.ClientRowKey); return(View(item)); } catch { DirectEmployerClientCampusClient campusclient = new DirectEmployerClientCampusClient(); DirectEmployerClientCampus campus = campusclient.GetByRowKey(item.CampusId); ViewBag.Campus = campus; DirectEmployerClientClient dscc = new DirectEmployerClientClient(); ViewBag.Client = dscc.GetByRowKey(item.ClientRowKey); return(View()); } }
public ActionResult CreateListing(JobPosting newposting) { JobPostingClient jpc = new JobPostingClient(); newposting.PostedDateTime = DateTime.UtcNow; AttributeMaskCalculator amc = new AttributeMaskCalculator(); newposting.AttributeMask = amc.GetMask(newposting); ImportantThingsMaskCalculator itmc = new ImportantThingsMaskCalculator(); newposting.ImportantThingsMask = itmc.GetMask(newposting); jpc.AddNewItem(newposting); return(RedirectToAction("new20")); }
public ActionResult EditListing(JobPosting posting) { JobPostingClient jpc = new JobPostingClient(); posting.PostedDateTime = DateTime.UtcNow; AttributeMaskCalculator amc = new AttributeMaskCalculator(); posting.AttributeMask = amc.GetMask(posting); ImportantThingsMaskCalculator itmc = new ImportantThingsMaskCalculator(); posting.ImportantThingsMask = itmc.GetMask(posting); jpc.Update(posting); return(RedirectToAction("jobpostings", new { am = 262143 })); }
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 ActionResult Edit(string id, DirectEmployerClientCampusProgram updateditem) { DirectEmployerClientCampusProgramClient programclient = new DirectEmployerClientCampusProgramClient(); DirectEmployerClientCampusProgram currentitem = programclient.GetByRowKey(updateditem.RowKey); if (updateditem.GeoAddNational == null) { updateditem.GeoAddNational = ""; } if (updateditem.GeoAddStates == null) { updateditem.GeoAddStates = ""; } if (updateditem.GeoAddZips == null) { updateditem.GeoAddZips = ""; } if (updateditem.GeoSubtractStates == null) { updateditem.GeoSubtractStates = ""; } if (updateditem.GeoSubtractZips == null) { updateditem.GeoSubtractZips = ""; } try { AttributeMaskCalculator amc = new AttributeMaskCalculator(); updateditem.AttributeMask = amc.GetMask(updateditem); ImportantThingsMaskCalculator itmc = new ImportantThingsMaskCalculator(); updateditem.ImportantThingsMask = itmc.GetMask(updateditem); if (PublishGeoIndex2(currentitem, updateditem)) { BlobStringManager.Instance.SaveString(NullString(updateditem.Html), updateditem.RowKey, "skillcowjobs", "HTML"); object htmljson = new { html = updateditem.Html.ToJSONSafeString().Replace("'", "\'") }; BlobJsonResourceManager.Instance.SaveJsonResource("customhtml", "skillcowjobs", "JSON", updateditem.RowKey, htmljson.ToJSON()); updateditem.GeoAddStates = ""; updateditem.GeoAddZips = ""; updateditem.GeoSubtractStates = ""; updateditem.GeoSubtractZips = ""; updateditem.Html = ""; programclient.Update(updateditem); //Save LeadCap LeadCapClient leadcapclient = new LeadCapClient(); LeadCap leadcap = leadcapclient.GetByRowKey(updateditem.RowKey); bool createnewcap = false; if (leadcap == null) { leadcap = new LeadCap(); leadcap.RowKey = updateditem.RowKey; createnewcap = true; } leadcap.Total = updateditem.TotalCap; leadcap.Annually = updateditem.AnnualCap; leadcap.Monthly = updateditem.MonthlyCap; leadcap.Weekly = updateditem.WeeklyCap; leadcap.Daily = updateditem.DailyCap; if (createnewcap) { leadcapclient.AddNewItem(leadcap); } else { leadcapclient.Update(leadcap); } //Create LeadCounter if doesn't exist LeadCounterClient leadcounterclient = new LeadCounterClient(); LeadCounter leadcounter = leadcounterclient.GetByRowKey(updateditem.RowKey); if (leadcounter == null) { leadcounter = new LeadCounter(); leadcounter.RowKey = updateditem.RowKey; leadcounter.Total = 0; leadcounter.Annually = 0; leadcounter.Monthly = 0; leadcounter.Weekly = 0; leadcounter.Daily = 0; leadcounterclient.AddNewItem(leadcounter); } } else { throw new Exception("Failed to publish GEO index"); } return(RedirectToAction("Edit", "DirectEmployerClientCampusPrograms", new { id = updateditem.RowKey })); } catch { DirectEmployerClientCampusClient campusclient = new DirectEmployerClientCampusClient(); DirectEmployerClientCampus campus = campusclient.GetByRowKey(updateditem.CampusRowKey); ViewBag.Campus = campus; DirectEmployerClientClient dscc = new DirectEmployerClientClient(); ViewBag.Client = dscc.GetByRowKey(updateditem.ClientRowKey); ViewBag.GeoAddStates = BlobStringManager.Instance.GetString("skillcowemployerprogramgeoindex", "AddStates", id); ViewBag.GeoAddZips = BlobStringManager.Instance.GetString("skillcowemployerprogramgeoindex", "AddZips", id); ViewBag.GeoSubtractStates = BlobStringManager.Instance.GetString("skillcowemployerprogramgeoindex", "SubtractStates", id); ViewBag.GeoSubtractZips = BlobStringManager.Instance.GetString("skillcowemployerprogramgeoindex", "SubtractZips", id); ViewBag.Html = BlobStringManager.Instance.GetString("skillcowjobs", "HTML", id); ModelState.AddModelError("error", "Failed to save"); return(View(updateditem)); } }
public ActionResult MatchJobs(string zip, string attributes, string things) { try { ZipCodeClient zcc = new ZipCodeClient(); ZipCode zipcode = zcc.GetByRowKey(zip); if (zipcode == null) { throw new Exception("Invalid ZIP"); } JObject oattributes = JObject.Parse(attributes); JObject othings = JObject.Parse(things); AttributeMaskCalculator amc = new AttributeMaskCalculator(); long attributemask = amc.GetMask(oattributes); ImportantThingsMaskCalculator itmc = new ImportantThingsMaskCalculator(); long importantthingsmask = itmc.GetMask(othings); JobPostingClient jpc = new JobPostingClient(); List <object> jobs = new List <object>(); foreach (JobPosting posting in jpc.GetAllBySource("TEN").Execute().Where(x => x.IsLive != null && x.IsLive == true)) { if (posting.AttributeMask != null && (posting.AttributeMask & attributemask) == attributemask) { bool targetsusa = false; bool targetsstate = false; bool targetszip = false; if (posting.GeoTarget != null) { targetsusa = posting.GeoTarget.Contains("USA"); targetsstate = posting.GeoTarget.Contains(zipcode.StateCode); targetszip = posting.GeoTarget.Contains(zipcode.RowKey); } else { Console.Write("geo target not set"); } if (targetsusa || targetsstate || targetszip) { try { jobs.Add(new { id = posting.RowKey, jobtitle = posting.JobTitle != null ? posting.JobTitle.ToJSONSafeString() : "", description = posting.Description != null ? posting.Description.ToJSONSafeString() : "", clientid = posting.ClientId, clientname = posting.CompanyName != null ? posting.CompanyName.ToJSONSafeString() : "", formattedlocation = posting.FormattedLocation != null ? posting.FormattedLocation.ToJSONSafeString() : "", logoimage = posting.Logo, formid = posting.FormId, campuskey = posting.PositionLocationId, campusvalue = posting.PositionLocationName != null ? posting.PositionLocationName.ToJSONSafeString() : "", //zips = node.E("zips"), //keywords = node.E("keywords"), date = posting.PostedDateTime != null ? posting.PostedDateTime.ToString("dd/MM/yyyy HH:mm") : "", referencenumber = posting.ReferenceId, dimattitude = posting.DimensionAttitude, dimaction = posting.DimensionAction, dimcompensation = posting.DimensionCompensation, dimconcentration = posting.DimensionConcentration, dimendurance = posting.DimensionEndurance, diminformation = posting.DimensionInformation, dimpatterns = posting.DimensionPatterns, dimprocessing = posting.DimensionProcessing, dimpresence = posting.DimensionPresence, thingadmiration = posting.ImportantThingsAdmiration, thingadventure = posting.ImportantThingsAdventure, thinganimals = posting.ImportantThingsAnimals, thingbeauty = posting.ImportantThingsBeauty, thingcompetition = posting.ImportantThingsCompetition, thingcreativity = posting.ImportantThingsCreativity, thingduty = posting.ImportantThingsDuty, thingeasy = posting.ImportantThingsEasy, thinggrowth = posting.ImportantThingsGrowth, thinghelping = posting.ImportantThingsHelping, thingpeople = posting.ImportantThingsPeople, thingpolitics = posting.ImportantThingsPolitics, thingsafety = posting.ImportantThingsSafety, thingscience = posting.ImportantThingsScience, thingtechnology = posting.ImportantThingsTechnology, attributescore = posting.GetAttributeScore(oattributes), importantthingsscore = posting.GetImportantThingsScore(othings) }); } catch (Exception ex) { Console.Write(ex.Message); } } } } Response.ContentType = "application/json"; string retvalue = (new { result = "ok", jobs = jobs.ToArray() }).ToJSON(); Response.Write(retvalue); Response.End(); } catch (Exception ex) { Response.ContentType = "application/json"; Response.Write(DefaultErrorResponse(ex.Message)); Response.End(); } return(null); }