public ChangeStorageMode() { this.InitializeComponent(); Model.Local.ArticleImageRepository ArticleImageRepository = new Model.Local.ArticleImageRepository(); List <Model.Local.ArticleImage> ListImage = ArticleImageRepository.List(); this.ListCount = ListImage.Count; Context = SynchronizationContext.Current; this.ParallelOptions.MaxDegreeOfParallelism = MaximumThreadCount; this.ReportProgress(0); Task.Factory.StartNew(() => { Parallel.ForEach(ListImage, this.ParallelOptions, ExecImage); }); }
public ImportPrestashopArticleImage(bool forceImportImage) { this.InitializeComponent(); Model.Prestashop.PsImageRepository PsImageRepository = new Model.Prestashop.PsImageRepository(); List <UInt32> ListPsImage = PsImageRepository.ListId(Core.Global.CurrentShop.IDShop); if (!forceImportImage) { Model.Local.ArticleImageRepository ArticleImageRepository = new Model.Local.ArticleImageRepository(); List <Int32?> ListArticleImage = ArticleImageRepository.List().Select(ai => ai.Pre_Id).ToList(); ListPsImage = ListPsImage.Where(i => ListArticleImage.Count(ai => ai != null && ai.Value == i) == 0).ToList(); } this.ListCount = ListPsImage.Count; this.Context = SynchronizationContext.Current; this.ParallelOptions.MaxDegreeOfParallelism = MaximumThreadCount; this.ReportProgress(0); Task.Factory.StartNew(() => { Parallel.ForEach(ListPsImage, this.ParallelOptions, Sync); }); }
private void LoadWorkerListArticle_DoWork(object sender, DoWorkEventArgs e) { List <Int32> ListIdArticleSend = (List <Int32>)e.Argument; if (ListIdArticleSend != null) { Core.Transfert.TransfertArticleImage sync = new Core.Transfert.TransfertArticleImage(); if (!Core.Global.GetConfig().ConfigImageSynchroPositionLegende) { Model.Local.ArticleImageRepository ArticleImageRepository = new Model.Local.ArticleImageRepository(); List <int> listarticlewithimagetosync = ArticleImageRepository.ListIDArticleNotSync(); ListIdArticleSend = ListIdArticleSend.Where(a => listarticlewithimagetosync.Contains(a)).ToList(); } int count = ListIdArticleSend.Count; for (int i = 0; i < count; i++) { sync.Exec(ListIdArticleSend[i]); LoadWorkerListArticle.ReportProgress((((i + 1) * 100) / count)); } } }