static bool Ft_Check_Equals_Feed(List <Id_Feed> mas, Id_Feed obj) { foreach (Id_Feed item in mas) { if (String.Equals(item.id, obj.id) == true) { return(false); } } return(true); }
static int Ft_Check_Equals_Feed(Database1Entities model, Id_Feed obj) { int i; i = 0; foreach (Feed item in model.Feeds) { i++; if (String.Equals(obj.id, item.Id_Feed) == true) { return(-1); } } return(i); }
static int Ft_Final_Rec_Feed(List <IWebElement> webElements, IWebElement iteam, List <string> list_id, int i, int col, bool flag) { string id; id = iteam.FindElement(By.CssSelector("._post.post")).GetAttribute("id"); list_id.Add(id); List <string> str = new List <string>(); List <IWebElement> Brouser = iteam.FindElements(By.TagName("a")).ToList(); foreach (IWebElement web in Brouser) { if (web.GetAttribute("href") != null && web.GetAttribute("href") != "") { str.Add(web.GetAttribute("href")); } } Id_Feed feed = new Id_Feed(id, str); List <Id_Feed> mas = new List <Id_Feed>(); DataContractJsonSerializer jsonFormatter1 = new DataContractJsonSerializer(typeof(List <Id_Feed>)); FileInfo fileInfo = new FileInfo(@"E:\institute\operating-system\Chrome\WindowsFormsApp1\WindowsFormsApp1\bin\Debug\ID_Feed.json"); if (flag == true) { mufeed.WaitOne(); } FileStream fs1 = new FileStream(@"E:\institute\operating-system\Chrome\WindowsFormsApp1\WindowsFormsApp1\bin\Debug\ID_Feed.json", FileMode.OpenOrCreate); if (fileInfo.Length > 0) { mas = jsonFormatter1.ReadObject(fs1) as List <Id_Feed>; } if (Ft_Check_Equals_Feed(mas, feed) == true) { mas.Add(feed); fs1.Position = 0; jsonFormatter1.WriteObject(fs1, mas); i++; } fs1.Close(); if (flag == true) { mufeed.ReleaseMutex(); } return(i); }