コード例 #1
0
ファイル: ImagesService.cs プロジェクト: 21Off/21Off
		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;
			}
		}
コード例 #2
0
ファイル: ImagesService.cs プロジェクト: 21Off/21Off
		private AllImagesResponse GetFullImageListDel(Images req)
		{
			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 fullImgResp = new AllImagesResponse();
					
					foreach (JsonObject obj in json["FriendsImages"])
					{		
					   	fullImgResp.FriendsImages.Add(JsonToImage(obj));					
					}
					foreach (JsonObject obj in json["RecentImages"])
					{		
					   	fullImgResp.RecentImages.Add(JsonToImage(obj));					
					}
					foreach (JsonObject obj in json["LikedImages"])
					{		
					   	fullImgResp.LikedImages.Add(JsonToImage(obj));					
					}
					foreach (JsonObject obj in json["EventsImages"])
					{		
					   	fullImgResp.EventsImages.Add(JsonToImage(obj));					
					}					
					
					return fullImgResp;
				}
			}			
		}		
コード例 #3
0
ファイル: ImagesService.cs プロジェクト: 21Off/21Off
		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));				
			}
		}