예제 #1
0
		public static Keyword JsonToKeyword(JsonObject obj)
		{			
			var keyword = new Keyword()
			{				
				Id = Convert.ToInt32(obj["Id"].ToString()),
				ParentId = Convert.ToInt32(obj["ParentId"].ToString()),
				Name = obj["Name"].ToString().Replace("\"",""),						
				//Time =  DateTime.ParseExact (obj ["Time"], "ddd MMM dd HH:mm:ss zzz yyyy", CultureInfo.InvariantCulture),
			};			
			
			return keyword;
		}
예제 #2
0
		private Element CreateLoadMore(Section section)
		{
           var loadMore2 = new AddLoadMoreWithImageElement("Add keyword", ImageStore.DefaultImage, lme => {
				lme.FetchValue();
				if (!string.IsNullOrWhiteSpace(lme.Value))
				{			
					// Launch a thread to do some work
					ThreadPool.QueueUserWorkItem (delegate {
						try
						{
							var keyword = new Keyword()
							{
								Name = lme.Value,
								ParentId = _ImageID,
								//UserId = AppDelegateIPhone.AIphone.MainUser.Id,
								//Time = DateTime.UtcNow,
							};
							
							//	TODO : get the keyword id from the server. We need it
							//	TODO : for the deletion process
							AppDelegateIPhone.AIphone.KeywServ.PutNewKeyword(keyword);
						
							// Now make sure we invoke on the main thread the updates
							this.BeginInvokeOnMainThread(delegate {
								lme.Animating = false;
														
								var act = new KeywordElement(keyword.Name, keyword);
								section.Insert(1, act);
								lme.Value = null;							
							});
						}
						catch (Exception ex)
						{
							Util.LogException("Add keyword", ex);
							this.BeginInvokeOnMainThread(delegate {
								lme.Animating = false;
							});
						}					
					});
				}
				else
					lme.Animating = false;
				
			});
			
			return loadMore2;
		}
예제 #3
0
		public KeywordElement(string @value, Keyword keyword) : base(@value)
		{
			this.keyword = keyword;
		}
예제 #4
0
		private List<Keyword> GetKeyword()
		{
			Section section = this.root.ElementAtOrDefault(0);
			var keywords = new List<Keyword>();
			for (int i = 0; i < section.Elements.Count; i++)
			{
				if (section.Elements[i] is StringElement)
				{
					var strElement = (StringElement)section.Elements[i];
					if (!string.IsNullOrWhiteSpace(strElement.Caption))
					{
						var keyword = new Keyword()
						{
							Name = strElement.Caption
						};
						keywords.Add(keyword);
					}
				}
				if (addLoadMore != null)
				{
					addLoadMore.FetchValue();
					
					if (!string.IsNullOrWhiteSpace(addLoadMore.Value))
					{
						if (!keywords.Any(e => e.Name == addLoadMore.Value))
						{						
							var keyword = new Keyword()
							{
								Name = addLoadMore.Value,
							};
							keywords.Add(keyword);
						}
					}
					
					addLoadMore.Value = "";
					addLoadMore.FetchValue();
				}
			}
			
			return keywords;
		}		
예제 #5
0
		public void PutNewKeyword(Keyword keyword)
		{	
			var cms = new Keywords() { Keyword = keyword };
			var uri = string.Format("http://storage.21offserver.com/json/syncreply/Keywords");
			
			var request = (HttpWebRequest) WebRequest.Create (uri);
			request.Method = "PUT";	
			using (var reqStream = request.GetRequestStream())
			{
				ServiceStack.Text.JsonSerializer.SerializeToStream(cms, typeof(Keywords), reqStream);
				//reqStream.Write(bytes, 0, bytes.Length);
			};
			using (var response = request.GetResponse())
			{
				using (var stream = response.GetResponseStream())
				{
					var responseString = new StreamReader(stream).ReadToEnd();
				}
			}			
		}