Example #1
0
		public void GetEntryData (SiteData Site)
			{
			Client.AccessToken = GetAccessToken;
			Client.AppId = AppID;
			Client.AppSecret = AppSecret;
			Facebook.JsonObject Result = Client.Get (Site.ID) as Facebook.JsonObject;
			if (Result == null)
				return;
			foreach (String Key in Result.Keys)
				{
				if (Key == "name")
					Site.Name = Result [Key].ToString ();
				if (Key == "link")
					Site.Link = Result [Key].ToString ();
				}

			Facebook.JsonObject Datas = Client.Get (Site.ID + "/" + Site.GroupType) as Facebook.JsonObject;

			PostData ActuallPost = null;
			String PreviousCommand = String.Empty;
			String NextCommand = String.Empty;
			bool NotFinish = true;
			while (NotFinish == true)
				{
				foreach (String Key in Datas.Keys)
					{
					if (Key == "data")
						{
						Facebook.JsonArray Posts = Datas [Key] as Facebook.JsonArray;
						foreach (Facebook.JsonObject Post in Posts)
							{
							foreach (String PostKey in Post.Keys)
								{
								if (PostKey == "id")
									{
									ActuallPost = new PostData() {ID = Post [PostKey].ToString()};
									Site.Posts.Add(ActuallPost);
									}
								if (PostKey == "link")
									ActuallPost.Link = Post [PostKey].ToString();
								if (PostKey == "name")
									ActuallPost.Name = Post [PostKey].ToString();
								if (PostKey == "message")
									ActuallPost.Message = Post [PostKey].ToString();
								if (PostKey == "type")
									ActuallPost.Type = Post [PostKey].ToString();
								if (PostKey == "caption")
									ActuallPost.Caption = Post [PostKey].ToString ();
								if (PostKey == "updated_time")
									ActuallPost.UpdatedTime = DateTime.Parse (Post [PostKey].ToString ());
								if (PostKey == "story")
									ActuallPost.Story = Post [PostKey].ToString ();
								}
							if (WMB.DataWrapper.Instance.CheckOrImportFaceBookPost(Site, ActuallPost) == false)
								{
								NotFinish = false;
								break;
								}
							}
						if (Posts.Count == 0)
							NotFinish = false;
						if (NotFinish == false)
							break;
						}
					if (Key == "paging")
						{
						Facebook.JsonObject Command = Datas [Key] as Facebook.JsonObject;
						foreach (String CommandKey in Command.Keys)
							{
							if (CommandKey == "previous")
								{
								PreviousCommand = Command [CommandKey].ToString();
								}
							if (CommandKey == "next")
								{
								NextCommand = Command [CommandKey].ToString();
								}
							}


						if (String.IsNullOrEmpty(NextCommand))
							NotFinish = false;
						}
					}
					
				if (NotFinish)
					Datas = Client.Get (NextCommand) as Facebook.JsonObject;
				}
			}
Example #2
0
		public bool CheckOrImportFaceBookPost(WMB.SiteData FaceBookSite, PostData PostEntry)
			{
			String TableName = FaceBookSite.TableName;
			String ID = PostEntry.ID;
			DataSet BeitraegeDataSet = DataBaseFromName["WPMedia"].GetCommonDataSet
											 ("Select * from BeitragBeschreibungen where TableName = '" + FaceBookSite.TableName
											+ "' and NameID = '" + PostEntry.ID + "'");
			if (BeitraegeDataSet.Tables["BeitragBeschreibungen"].Rows.Count == 0)
				{
				DataRow NewRow = BeitraegeDataSet.Tables["BeitragBeschreibungen"].NewRow();
				NewRow["BeitragID"] = System.Guid.NewGuid();
				NewRow["TableName"] = FaceBookSite.TableName; ;
				NewRow["NameID"] = PostEntry.ID;
				NewRow["Beschreibung"] = PostEntry.Name;
				NewRow["FileFoundInDirectory"] = PostEntry.Link;
				NewRow["Type"] = "FaceBookPosts";
				NewRow["LastUpdateTimeStamp"] = PostEntry.UpdatedTime;
				NewRow["LastCheckTimeStamp"] = DateTime.Now;
				NewRow["LastUpdateToken"] = Basics.GetNextLastUpdateTokenHelperAsByteArray();
				BeitraegeDataSet.Tables["BeitragBeschreibungen"].Rows.Add(NewRow);
				}
			else
				{
				if (Convert.ToDateTime(BeitraegeDataSet.Tables["BeitragBeschreibungen"].Rows[0]["LastUpdateTimeStamp"])
					!= PostEntry.UpdatedTime)
					BeitraegeDataSet.Tables["BeitragBeschreibungen"].Rows[0]["LastUpdateTimeStamp"]
						= PostEntry.UpdatedTime;
				else
					return false;
				}
			DataSet Updates = BeitraegeDataSet.GetChanges();
			if (Updates != null)
				{
				DataBaseFromName["WPMedia"].SetCommonDataSet(Updates);
				}

			return true;
			}