public AllImagesResponse GetFullImageList (FilterType filterType, GeoLoc geoLoc, int startIndex, int maximumImages, int userId) { DateTime dt = DateTime.Now; try { var req = new Images() { WhereGeo = geoLoc, Filter = (int)filterType, WhereMyId = userId, Max = maximumImages, Start = startIndex }; var slim = new ManualResetEventSlim(false); AllImagesResponse fullImgResp = null; ThreadPool.QueueUserWorkItem(o=> { try { fullImgResp = GetFullImageListDel(req); } catch (Exception ex) { Util.LogException("GetFullImageListDel", ex); } slim.Set(); }); slim.Wait(6000); return fullImgResp; } catch (Exception ex) { Util.LogException("GetFullImageList", ex); return null; } finally { Util.Log("GetFullImageList: " + (DateTime.Now - dt)); } }
public IEnumerable<Image> GetImageList (FilterType filterType, GeoLoc geoLoc, int startIndex, int maximumImages, int userId) { try { var req = new Images() { WhereGeo = geoLoc, Filter = (int)filterType, WhereMyId = userId, Max = maximumImages, Start = startIndex }; var uri = new Uri("http://storage.21offserver.com/json/syncreply/Images"); var request = (HttpWebRequest) WebRequest.Create (uri); request.Method = "PUT"; using (var reqStream = request.GetRequestStream()) { ServiceStack.Text.JsonSerializer.SerializeToStream(req, typeof(Images), reqStream); }; using (var response = request.GetResponse()) { using (var stream = response.GetResponseStream()) { var json = JsonObject.Load(stream); var images = new List<Image>(); foreach (JsonObject obj in json["Images"]) { images.Add(JsonToImage(obj)); } return images; } } } catch (Exception ex) { Util.LogException("GetImageList", ex); return null; } }
public IEnumerable<Image> GetImageList (FilterType filterType, GeoLoc geoLoc, int startIndex, int maximumImages, int userId) { CLLocationCoordinate2D location = geoLoc == null ? default(CLLocationCoordinate2D) : new CLLocationCoordinate2D(geoLoc.Latitude, geoLoc.Longitude); var res = GetDBImageList(filterType, userId); res = res.Where(img => { if (geoLoc == null) return true; var coord = new CLLocationCoordinate2D(img.Latitude, img.Longitude); if (MapUtilities.DistanceBetween(location, coord) <= 0.2) return true; else return false; }); return res.Take(maximumImages); }