private Profile ReadProfile(misper_ person) { bool malePic = false; Profile profile = new Profile(); Misper_Extended extended = person.Misper_Extended.FirstOrDefault(); profile.LastSeen = person.Date_Went_Missing.Value; profile.Latitude = extended.Latitude.Value; profile.Longitude = extended.Longitude.Value; profile.UserID = person.Unique_ID; profile.ProfileURL = GetProfilePicURL(person.Gender); if (!string.IsNullOrEmpty(person.Birth_Year)) { profile.Age = DateTime.Now.Year - int.Parse(person.Birth_Year); } profile.Forename = person.Forenames; profile.Surname = person.Surname; profile.IsDangerous = extended.Is_Dangerous == "Y"; if (person.PeopleTags != null && person.PeopleTags.Count > 0) { foreach (var tag in person.PeopleTags) { profile.Tags.Add(tag.Tag.TagName); } } profile.Status = person.Status; profile.Tags.Add(person.Category); return(profile); }
// GET api/<controller> public List <Profile> Get() { List <Profile> retProfiles = new List <Profile>(); GMPRestApi.Models.GMPMissingPersonEntities entities = new GMPRestApi.Models.GMPMissingPersonEntities(); foreach (var person in entities.misper_.Where(x => x.Misper_Extended.Count > 0)) { Profile profile = new Profile(); Misper_Extended extended = person.Misper_Extended.FirstOrDefault(); profile.LastSeen = person.Date_Last_Seen.Value; profile.Latitude = extended.Latitude.Value; profile.Longtitude = extended.Longitude.Value; profile.ProfileURL = "tbd"; profile.UserID = person.Unique_ID; retProfiles.Add(profile); } return(retProfiles); }
private void LatLong_Click(object sender, EventArgs e) { int i = 0; int saveCount = 0; int total = 0; int personCount = 0; //https://code.google.com/archive/p/geocoordconversion/downloads int max = 21349; int min = 0; DataTidy.Models.GMPMissingPersonEntities entities = new DataTidy.Models.GMPMissingPersonEntities(); total = entities.misper_.Count(); while (min <= max) { var persons = entities.misper_.Where(x => x.ID >= min && x.ID <= min + 100); min = min + 100; foreach (var person in persons) { personCount += 1; lblCount.Text = "Processing " + personCount + " of " + total; lblCount.Refresh(); string xcoord = person.Output_Area_CenX_EPSG27700; int index; index = xcoord.IndexOf("."); if (index > 0) { xcoord = xcoord.Substring(0, index); } string ycoord = person.Output_Area_CenY_EPSG27700; index = ycoord.IndexOf("."); if (index > 0) { ycoord = ycoord.Substring(0, index); } long x = long.Parse(xcoord); long y = long.Parse(ycoord); var geo = new TDPG.GeoCoordConversion.GridReference(x, y); Misper_Extended extendedInfo; if (person.Misper_Extended == null || person.Misper_Extended.Count == 0) { extendedInfo = new Misper_Extended(); extendedInfo.UniqueID = person.Unique_ID; entities.Misper_Extended.Add(extendedInfo); } else { extendedInfo = person.Misper_Extended.FirstOrDefault(); } var latong = TDPG.GeoCoordConversion.GridReference.ChangeToPolarGeo(geo); extendedInfo.Latitude = latong.Lat; extendedInfo.Longitude = latong.Lon; extendedInfo.FacebookName = ""; extendedInfo.InstagramName = ""; extendedInfo.Is_Dangerous = "N"; if (i == 3) { i = 0; extendedInfo.Is_Dangerous = "Y"; } extendedInfo.TwitterName = ""; extendedInfo.image = null; entities.Misper_Extended.AddOrUpdate(); i++; } entities.SaveChanges(); } MessageBox.Show("Completed"); }