private async void lblDivarCategory_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { try { var all = await DivarCategoryBussines.GetAllAsync(); if (all.Count > 0) { if (MessageBox.Show($@"تعداد {all.Count} دسته بندی موجود است. درصورت ادامه، دسته بندی فعلی حذف و دسته بندی جدید جایگزین می شود آیا ادامه میدهید؟", @"هشدار", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } } var div = await DivarAdv.GetInstance(); await div.GetCategory(); Utility.CloseAllChromeWindows(); } catch (Exception ex) { WebErrorLog.ErrorInstence.StartErrorLog(ex); } }
private async Task LoadCombo() { try { var advList = await DivarCategoryBussines.GetAllAsync(Guid.Empty); advList = advList.OrderBy(q => q.Name).ToList(); Adv1BindingSource.DataSource = advList; Chat1BindingSource.DataSource = advList; } catch (Exception ex) { WebErrorLog.ErrorInstence.StartErrorLog(ex); } }
private async void cmbAdv1_SelectedIndexChanged(object sender, EventArgs e) { try { if (cmbAdv1.SelectedValue == null) { return; } var advList = await DivarCategoryBussines.GetAllAsync((Guid)cmbAdv1.SelectedValue); advList = advList.OrderBy(q => q.Name).ToList(); Adv2BindingSource.DataSource = advList; } catch (Exception ex) { WebErrorLog.ErrorInstence.StartErrorLog(ex); } }
public async Task GetCategory() { try { _driver = Utility.RefreshDriver(_driver); _driver.Navigate().GoToUrl("https://divar.ir/new"); await Utility.Wait(); var listCat = _driver.FindElements(By.ClassName("expanded-category-selector__item")) .ToList(); var listAll = await DivarCategoryBussines.GetAllAsync(); listAll = listAll.ToList(); if (listAll.Count > 0) { await DivarCategoryBussines.RemoveRangeAsync(listAll.Select(q => q.Guid).ToList()); } foreach (var item in listCat) { var a = new DivarCategoryBussines() { Guid = Guid.NewGuid(), Name = item.Text.Trim(), ParentGuid = Guid.Empty, }; await a.SaveAsync(); } listAll = await DivarCategoryBussines.GetAllAsync(); listAll = listAll.ToList(); if (listAll.Count <= 0) { return; } foreach (var element in listAll) { _driver.FindElements(By.ClassName("expanded-category-selector__item")) .FirstOrDefault(q => q.Text == element.Name)?.Click(); await Utility.Wait(); var listCat2 = _driver.FindElements(By.ClassName("expanded-category-selector__item")) .ToList(); foreach (var item in listCat2) { var a = new DivarCategoryBussines() { Guid = Guid.NewGuid(), Name = item.Text.Trim(), ParentGuid = element.Guid, }; await a.SaveAsync(); } var newList = await DivarCategoryBussines.GetAllAsync(element.Guid); if (newList.Count <= 0) { continue; } foreach (var item in newList) { _driver.FindElements(By.ClassName("expanded-category-selector__item")) .FirstOrDefault(q => q.Text == item.Name)?.Click(); await Utility.Wait(); var listCat3 = _driver.FindElements(By.ClassName("expanded-category-selector__item")) .ToList(); if (listCat3.Count <= 0) { await Utility.Wait(2); var element10 = _driver .FindElements(By.ClassName("category-selector-action")).Any(); while (!element10) { element10 = _driver .FindElements(By.ClassName("category-selector-action")).Any(); await Utility.Wait(2); } _driver.FindElement(By.ClassName("category-selector-action")).Click(); await Utility.Wait(); continue; } foreach (var ne in listCat3) { var a = new DivarCategoryBussines() { Guid = Guid.NewGuid(), Name = ne.Text.Trim(), ParentGuid = item.Guid, }; await a.SaveAsync(); } await Utility.Wait(2); _driver.FindElement(By.ClassName("expanded-category-selector__back-icon")).Click(); await Utility.Wait(); } var a10 = _driver.FindElements(By.ClassName("expanded-category-selector__back-icon")) .Any(); if (a10) { _driver.FindElement(By.ClassName("expanded-category-selector__back-icon")).Click(); } await Utility.Wait(); } } catch (Exception ex) { WebErrorLog.ErrorInstence.StartErrorLog(ex); } }