private void DataGridCatalogue_SelectionChanged(object sender, SelectionChangedEventArgs e) { Model.Local.Catalog Catalog = this.DataGridCatalogue.SelectedItem as Model.Local.Catalog; if (Catalog != null && this.CheckBoxSearchOnlyCatalog.IsChecked == true) { this.SearchArticle(); } }
public void ExecCatalog(Int32 CatalogueSend) { this.Semaphore.WaitOne(); try { Model.Local.CatalogRepository CatalogRepository = new Model.Local.CatalogRepository(); Model.Local.Catalog Catalog = CatalogRepository.ReadId(CatalogueSend); string url = Core.Global.ReadLinkRewrite(Catalog.Cat_LinkRewrite); if (url != Catalog.Cat_LinkRewrite) { Catalog.Cat_LinkRewrite = url; if (!this.RewritePrestaShop) { Catalog.Cat_Date = DateTime.Now; } CatalogRepository.Save(); if (this.RewritePrestaShop && Catalog.Pre_Id != null) { Model.Prestashop.PsCategoryLangRepository PsCategoryLangRepository = new Model.Prestashop.PsCategoryLangRepository(); if (PsCategoryLangRepository.ExistCategoryLang(Catalog.Pre_Id.Value, Core.Global.Lang, Core.Global.CurrentShop.IDShop)) { Model.Prestashop.PsCategoryLang PsCategoryLang = PsCategoryLangRepository.ReadCategoryLang(Catalog.Pre_Id.Value, Core.Global.Lang, Core.Global.CurrentShop.IDShop); PsCategoryLang.LinkRewrite = url; PsCategoryLangRepository.Save(); } } } } catch (Exception ex) { Core.Error.SendMailError(ex.ToString()); } lock (this) { this.CurrentCount += 1; } this.ReportProgressCatalogue(this.CurrentCount * 100 / this.ListCount); this.Semaphore.Release(); }
private void SearchArticle() { Model.Local.ArticleRepository ArticleRepository = new Model.Local.ArticleRepository(); List <Model.Local.Article> ListArticleDisplay = new List <Model.Local.Article>(); Model.Local.Catalog Catalog = this.DataGridCatalogue.SelectedItem as Model.Local.Catalog; if (Catalog != null && this.CheckBoxSearchOnlyCatalog.IsChecked == true) { this.ListArticle = ArticleRepository.ListCatalog(Catalog.Cat_Id); Model.Local.ArticleCatalogRepository ArticleCatalogRepository = new Model.Local.ArticleCatalogRepository(); List <Model.Local.ArticleCatalog> ListArticleCatalog = ArticleCatalogRepository.ListCatalog(Catalog.Cat_Id); foreach (Model.Local.ArticleCatalog ArticleCatalog in ListArticleCatalog) { Boolean Add = true; foreach (Model.Local.Article Article in ListArticle) { if (Article.Art_Id == ArticleCatalog.Art_Id) { Add = false; break; } } if (Add == true) { this.ListArticle.Add(ArticleCatalog.Article); } } } else { this.ListArticle = ArticleRepository.List(); } Boolean isArticle; foreach (Model.Local.Article Article in this.ListArticle) { isArticle = true; if (this.TextBoxSearchArticleName.Text != "" && this.TextBoxSearchArticleName.Text.Replace("%", "") != "") { if (this.TextBoxSearchArticleName.Text.Contains("%")) { if (Article.Art_Name.ToUpper().Contains(this.TextBoxSearchArticleName.Text.Replace("%", "").ToUpper()) == false) { isArticle = false; } } else { if (Article.Art_Name.ToUpper().StartsWith(this.TextBoxSearchArticleName.Text.ToUpper()) == false) { isArticle = false; } } } if (this.TextBoxSearchArticleEan13.Text != "" && this.TextBoxSearchArticleEan13.Text.Replace("%", "") != "") { if (Article.Art_Ean13 != null) { if (this.TextBoxSearchArticleEan13.Text.Contains("%")) { if (Article.Art_Ean13.ToUpper().Contains(this.TextBoxSearchArticleEan13.Text.Replace("%", "").ToUpper()) == false) { isArticle = false; } } else { if (Article.Art_Ean13.ToUpper().StartsWith(this.TextBoxSearchArticleEan13.Text.ToUpper()) == false) { isArticle = false; } } } else { isArticle = false; } } if (this.TextBoxSearchArticleRef.Text != "" && this.TextBoxSearchArticleRef.Text.Replace("%", "") != "") { if (this.TextBoxSearchArticleRef.Text.Contains("%")) { if (Article.Art_Ref.ToUpper().Contains(this.TextBoxSearchArticleRef.Text.Replace("%", "").ToUpper()) == false) { isArticle = false; } } else { if (Article.Art_Ref.ToUpper().StartsWith(this.TextBoxSearchArticleRef.Text.ToUpper()) == false) { isArticle = false; } } } if (Article.Art_Sync != this.CheckBoxSearchArticleSync.IsChecked) { isArticle = false; } if (Article.Art_Active != this.CheckBoxSearchArticleActif.IsChecked) { isArticle = false; } if (isArticle == true) { ListArticleDisplay.Add(Article); } } this.DataGridArticle.ItemsSource = ListArticleDisplay; }
public ImportSageArticle(List <Int32> ListArticleSend, Model.Local.Catalog Catalogue) { this.InitializeComponent(); this.ListArticle = ListArticleSend; this.CatId = (Catalogue != null) ? Catalogue.Cat_Id : 0; Model.Sage.F_ARTICLERepository F_ARTICLERepository = new Model.Sage.F_ARTICLERepository(); List <Model.Sage.F_ARTICLE_Light> ListF_ARTICLE = F_ARTICLERepository.ListLight(); ListF_ARTICLE = ListF_ARTICLE.AsParallel().Where(a => ListArticleSend.Contains(a.cbMarq)).AsParallel().ToList(); ListF_ARTICLE = Core.Tools.FiltreImportSage.ImportSageFilter(ListF_ARTICLE); List <string> list_arref = ListF_ARTICLE.Select(a => a.AR_Ref).ToList(); // ajout pré-import gammes / conditionnements // !!! traitement en parallèle déconseillé !!! // occurences d'énumérés pouvant se recouper entre les articles List <short?> gammes = new List <short?>(); gammes.AddRange(ListF_ARTICLE.Where(a => a.AR_Gamme1 != null && a.AR_Gamme1 != 0).Select(a => a.AR_Gamme1).Distinct()); gammes.AddRange(ListF_ARTICLE.Where(a => a.AR_Gamme2 != null && a.AR_Gamme2 != 0).Select(a => a.AR_Gamme2).Distinct()); // import gammes ImportSageGamme importsagegamme = new ImportSageGamme(gammes); importsagegamme.ShowDialog(); // import énumérés de gammes List <Model.Sage.F_ARTENUMREF> declinaisons = new Model.Sage.F_ARTENUMREFRepository().List().ToList(); #if !(SAGE_VERSION_16 || SAGE_VERSION_17) declinaisons = declinaisons.Where(d => d.AE_Sommeil == 0).ToList(); #endif declinaisons = Core.Tools.FiltreImportSage.ImportSageFilter(declinaisons); List <Model.Sage.F_ARTGAMME> enumeres_gammes = new Model.Sage.F_ARTGAMMERepository().List(); List <int> localAttribute = new Model.Local.AttributeRepository().List().Select(a => a.Sag_Id).AsParallel().ToList(); enumeres_gammes = enumeres_gammes.AsParallel().Where(e => list_arref.Contains(e.AR_Ref) && !localAttribute.Contains(e.cbMarq) && declinaisons.Count(d => d.AG_No1 == e.AG_No || d.AG_No2 == e.AG_No) > 0).ToList(); enumeres_gammes = Core.Tools.FiltreImportSage.ImportSageFilter(enumeres_gammes); ImportSageGammeEnumere importsagegammeenumere = new ImportSageGammeEnumere(enumeres_gammes); importsagegammeenumere.ShowDialog(); // import conditionnements if (Core.Global.GetConfig().ArticleImportConditionnementActif) { List <short?> conditionnements = ListF_ARTICLE.Where(a => a.AR_Condition != null && a.AR_Condition != 0).Select(a => a.AR_Condition).Distinct().ToList(); ImportSageConditionnement importsageconditionnement = new ImportSageConditionnement(conditionnements); importsageconditionnement.ShowDialog(); List <Model.Sage.F_CONDITION> enumeres_conditionnement = new Model.Sage.F_CONDITIONRepository().List(); List <int> localConditioning = new Model.Local.ConditioningRepository().List().Select(c => c.Sag_Id).AsParallel().ToList(); enumeres_conditionnement = enumeres_conditionnement.AsParallel().Where(e => list_arref.Contains(e.AR_Ref) && !localConditioning.Contains(e.cbMarq)).ToList(); enumeres_conditionnement = Core.Tools.FiltreImportSage.ImportSageFilter(enumeres_conditionnement); ImportSageConditionnementEnumere importsageconditionnementenumere = new ImportSageConditionnementEnumere(enumeres_conditionnement); importsageconditionnementenumere.ShowDialog(); } // fin this.ListCount = ListF_ARTICLE.Count; Context = SynchronizationContext.Current; this.ParallelOptions.MaxDegreeOfParallelism = MaximumThreadCount; this.ReportProgress(0); Task.Factory.StartNew(() => { Parallel.ForEach(ListF_ARTICLE, this.ParallelOptions, Sync); }); }