private void LoadCatalogParent(List <Model.Local.Catalog> ListParent, String Add)
 {
     Model.Local.CatalogRepository CatalogRepository = new Model.Local.CatalogRepository();
     foreach (Model.Local.Catalog Catalog in ListParent)
     {
         if (this.ArrayCatalog.Contains(Catalog.Cat_Id) == false)
         {
             this.ArrayCatalog.Add(Catalog.Cat_Id);
             Catalog.Cat_IdWithParent = Add + " - " + Catalog.Cat_Id;
             this.ListCatalogDisplay.Add(Catalog);
             List <Model.Local.Catalog> ListNewParent = CatalogRepository.ListParent(Catalog.Cat_Id);
             if (ListParent.Count > 0)
             {
                 this.LoadCatalogParent(ListNewParent, Add + " - " + Catalog.Cat_Id);
             }
         }
     }
 }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            this.ArrayCatalog       = new List <int>();
            this.ListCatalogDisplay = new List <Model.Local.Catalog>();
            Model.Local.CatalogRepository CatalogRepository = new Model.Local.CatalogRepository();
            CheckBoxSearchOnlyCatalog.IsChecked = Global.GetConfig().ArticleUniquementEnStock;
            this.ListCatalog = CatalogRepository.ListOrderByLevel();
            Boolean AddCatalog = false;
            String  Add        = "";

            foreach (Model.Local.Catalog Catalog in this.ListCatalog)
            {
                AddCatalog = false;
                Add        = "";
                if (this.ArrayCatalog.Contains(Catalog.Cat_Id) == false)
                {
                    if (Catalog.Cat_Parent != 0)
                    {
                        if (this.ArrayCatalog.Contains(Catalog.Cat_Parent) == false)
                        {
                            AddCatalog = true;
                        }
                    }
                    else
                    {
                        AddCatalog = true;
                    }
                }
                if (AddCatalog == true)
                {
                    Catalog.Cat_IdWithParent = Catalog.Cat_Id.ToString();
                    this.ArrayCatalog.Add(Catalog.Cat_Id);
                    this.ListCatalogDisplay.Add(Catalog);
                    Add += Catalog.Cat_Id;
                    List <Model.Local.Catalog> ListParent = CatalogRepository.ListParent(Catalog.Cat_Id);
                    if (ListParent.Count > 0)
                    {
                        this.LoadCatalogParent(ListParent, Add);
                    }
                }
            }
            this.DataGridCatalogue.ItemsSource = this.ListCatalogDisplay;
        }
Пример #3
0
        public ControlURLRewrite(bool rewritePrestashop)
        {
            this.InitializeComponent();

            Model.Local.CatalogRepository CatalogRepository = new Model.Local.CatalogRepository();
            List <Int32> ListCatalog = CatalogRepository.ListId();

            this.ListCount = ListCatalog.Count;

            this.RewritePrestaShop = rewritePrestashop;

            Context = SynchronizationContext.Current;
            this.ParallelOptions.MaxDegreeOfParallelism = MaximumThreadCount;
            this.ReportProgressCatalogue(0);
            Task.Factory.StartNew(() =>
            {
                Parallel.ForEach(ListCatalog, this.ParallelOptions, ExecCatalog);
            });
        }
Пример #4
0
        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 LoadWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            List <int> CatalogIds = new Model.Local.CatalogRepository().ListIdSyncOrderByLevel(true);

            if (CatalogIds != null)
            {
                if (e.Argument != null && e.Argument is List <Int32> )
                {
                    List <Int32> list = (List <Int32>)e.Argument;
                    CatalogIds = CatalogIds.Where(c => list.Count(sc => sc == c) > 0).ToList();
                }

                Core.Sync.SynchronisationCatalogue sync = new Core.Sync.SynchronisationCatalogue();

                int count = CatalogIds.Count;

                for (int i = 0; i < count; i++)
                {
                    sync.Exec(CatalogIds[i]);
                    LoadWorker.ReportProgress((((i + 1) * 100) / count));
                }
            }
        }