示例#1
0
		public FullImagesTimedResponse GetFullImagesOfUser(int userId, DateTime since)
		{
			FullImagesTimedResponse fullImagesTimed = null;
			List<ImageResponse> images = null;
			
			var we = new ManualResetEvent(false);
			
			string uri = string.Format("http://storage.21offserver.com/json/syncreply/FullImages?WhereUserId={0}&Since={1}&Count={2}", 
					userId, since.Ticks, 5);
			
			JsonUtility.Launch(uri, false, s =>
	        {
				try
				{
					fullImagesTimed = new FullImagesTimedResponse();
					images = new List<ImageResponse>();
					fullImagesTimed.Images = images;
					
					var json = JsonArray.Load (s);
					if (json.ContainsKey("Time"))
					{
						DateTime? time = ActivitiesService.JsonToTime((JsonValue)json["Time"]);
						fullImagesTimed.Time = time;
					}
					foreach (JsonObject obj in json["Images"])
					{		
						try
						{
							JsonObject imgJson = (JsonObject)obj["Image"];							
							int likesCount = Convert.ToInt32(obj["LikesCount"].ToString());							
							
							var keywords = new List<Keyword>();
							foreach (JsonObject jsonObj in obj["Keywords"])
							{
								keywords.Add(KeywordsService.JsonToKeyword(jsonObj));
							}
							
							var comments = new List<CommentResponse>();
							foreach (JsonObject jsonObj in obj["Comments"])
							{
								JsonObject comm = (JsonObject)jsonObj["Comment"];
								JsonObject user = (JsonObject)jsonObj["User"];
								
								var cresp = new CommentResponse()
								{
									Comment = CommentsService.JsonToComment(comm),
									User = UsersService.JsonToUser(user),
								};
								comments.Add(cresp);
							}
							
							var imgResp = new ImageResponse()
							{
								Comments = comments,
								Image = JsonToImage(imgJson),
								LikesCount = likesCount,
								Keywords = keywords,
							};
							images.Add(imgResp);
						}
						catch (Exception ex)
						{
							Util.LogException("GetFullImagesOfUser", ex);
						}
					}
				}
				catch (Exception ex)
				{
					Util.LogException("GetaImagesOfUser", ex);
				}
				we.Set();
			});
			
			we.WaitOne(5000);			
			
			return fullImagesTimed;			
		}
示例#2
0
		private void DownloadAsync(ImageResponse imageResponse, List<Comment> comments, List<User> commentsUsers)
		{
			while (Root[0].Count > 0)
				Root[0].Remove (0);				
			
			NSTimer.CreateScheduledTimer (0.1, delegate {
				try
				{			
					var mPhotoEl = new MemberPhotoElement(new Tweet()
		            { 
						User = _ImageOwner,
						Image = _Image,
						Keywords = imageResponse.Keywords,
						
						Comments = comments,												
						CommentsUsers = commentsUsers,
						
						LikesCount = imageResponse.LikesCount,
						DeleteAction = DeleteAction,
						UrlTapAction = UrlTap,
					}, GoToUserPhotos);
					
					Root[0].Add(mPhotoEl);
					
				}
				catch (Exception ex)
				{
					Util.LogException("CreateScheduledTimer PhotoDetailsView", ex);
				}
				
				// Notify the dialog view controller that we are done
				// this will hide the progress info				
				this.BeginInvokeOnMainThread (delegate { ReloadComplete (); });
			});
		}
示例#3
0
		public ImageResponse GetFullImage(int id)
		{
			var images = new List<ImageResponse>();				
			
			var we = new ManualResetEvent(false);
			string uri = string.Format("http://storage.21offserver.com/json/syncreply/FullImages?ImageId={0}", id);
			
			JsonUtility.Launch(uri, false, s =>
	        {
				try
				{
					var json = JsonArray.Load (s);
					foreach (JsonObject obj in json["Images"])
					{		
						try
						{
							JsonObject imgJson = (JsonObject)obj["Image"];							
							int likesCount = Convert.ToInt32(obj["LikesCount"].ToString());							
							
							var keywords = new List<Keyword>();
							foreach (JsonObject jsonObj in obj["Keywords"])
							{
								keywords.Add(KeywordsService.JsonToKeyword(jsonObj));
							}
							
							var comments = new List<CommentResponse>();
							foreach (JsonObject jsonObj in obj["Comments"])
							{
								JsonObject comm = (JsonObject)jsonObj["Comment"];
								JsonObject user = (JsonObject)jsonObj["User"];
								
								var cresp = new CommentResponse()
								{
									Comment = CommentsService.JsonToComment(comm),
									User = UsersService.JsonToUser(user),
								};
								comments.Add(cresp);
							}
							
							var imgResp = new ImageResponse()
							{
								Comments = comments,
								Image = JsonToImage(imgJson),
								LikesCount = likesCount,
								Keywords = keywords,
							};
							images.Add(imgResp);
						}
						catch (Exception ex)
						{
							Util.LogException("GetFullImagesOfUser", ex);
						}
					}
				}
				catch (Exception ex)
				{
					Util.LogException("GetaImagesOfUser", ex);
				}
				we.Set();
			});
			
			we.WaitOne();
			
			return images.FirstOrDefault();
		}