public void Exec(Int32 ArticleSend) { try { Model.Local.ArticleRepository ArticleRepository = new Model.Local.ArticleRepository(); Model.Local.Article Article = ArticleRepository.ReadArticle(ArticleSend); Model.Prestashop.PsProductRepository ProductRepository = new Model.Prestashop.PsProductRepository(); Model.Prestashop.PsProduct Product = new Model.Prestashop.PsProduct(); // If the Article have a connection with Prestashop if (Article.Pre_Id != null) { //Article.Art_Date = Article.Art_Date.AddMilliseconds(-Article.Art_Date.Millisecond); if (ProductRepository.ExistId(Convert.ToUInt32(Article.Pre_Id.Value))) { Product = ProductRepository.ReadId(Convert.ToUInt32(Article.Pre_Id.Value)); Model.Sage.F_ARTICLERepository F_ARTICLERepository = new Model.Sage.F_ARTICLERepository(); if (F_ARTICLERepository.ExistArticle(Article.Sag_Id)) { SynchronisationArticle.ExecFeature(Article); } } } } catch (Exception ex) { Core.Error.SendMailError(ex.ToString()); } }
public void Exec(Int32 ArticleSend) { try { Model.Local.ArticleRepository ArticleRepository = new Model.Local.ArticleRepository(); Model.Local.Article Article = ArticleRepository.ReadArticle(ArticleSend); // If the catalog is sync with Prestashop if (Article.Catalog.Pre_Id != null || Article.Catalog.Pre_Id != 0) { Model.Prestashop.PsProductRepository ProductRepository = new Model.Prestashop.PsProductRepository(); Model.Prestashop.PsProduct Product = new Model.Prestashop.PsProduct(); // If the Article have a connection with Prestashop if (Article.Pre_Id != null) { if (ProductRepository.ExistId(Convert.ToUInt32(Article.Pre_Id.Value))) { this.ExecLocalToDistant(Article); } } } } catch (Exception ex) { Core.Error.SendMailError(ex.ToString()); } }
public void Exec(Int32 ArticleSend) { try { Model.Local.ArticleRepository ArticleRepository = new Model.Local.ArticleRepository(); Model.Local.Article Article = ArticleRepository.ReadArticle(ArticleSend); // If the catalog is sync with Prestashop //if (Article.Catalog.Pre_Id != null || Article.Catalog.Pre_Id != 0) { Model.Prestashop.PsProductRepository ProductRepository = new Model.Prestashop.PsProductRepository(); Boolean isProduct = false; // If the Article have a connection with Prestashop if (Article.Pre_Id != null && ProductRepository.ExistId(Convert.ToUInt32(Article.Pre_Id.Value))) { Model.Prestashop.PsProduct Product = ProductRepository.ReadId(Convert.ToUInt32(Article.Pre_Id.Value)); isProduct = true; if (Product.DateUpd.Ticks > Article.Art_Date.Ticks) { this.ExecDistantToLocal(Product, Article, ArticleRepository); } else if (Product.DateUpd.Ticks < Article.Art_Date.Ticks) { this.ExecLocalToDistant(Article, Product, ArticleRepository, ProductRepository, isProduct); } } } } catch (Exception ex) { Core.Error.SendMailError(ex.ToString()); } }
private void ExecLocalToDistant(Model.Local.Article Article, Model.Local.ArticleRepository ArticleRepository, Model.Prestashop.PsProduct Product, Model.Prestashop.PsProductRepository ProductRepository) { try { Model.Sage.F_ARTICLERepository F_ARTICLERepository = new Model.Sage.F_ARTICLERepository(); if (F_ARTICLERepository.ExistArticle(Article.Sag_Id)) { Model.Sage.F_ARTICLE F_ARTICLE = F_ARTICLERepository.ReadArticle(Article.Sag_Id); Model.Prestashop.PsPackRepository PsPackRepository = new Model.Prestashop.PsPackRepository(); List <Model.Prestashop.PsPack> ListPsPack = PsPackRepository.ListProductPack(Product.IDProduct); foreach (Model.Prestashop.PsPack PsPack in ListPsPack) { PsPackRepository.Delete(PsPack); } #region Pack/nomenclature if (Article.Art_Pack == true) { Model.Sage.F_NOMENCLATRepository F_NOMENCLATRepository = new Model.Sage.F_NOMENCLATRepository(); List <Model.Sage.F_NOMENCLAT> ListF_NOMENCLAT = F_NOMENCLATRepository.ListRef(F_ARTICLE.AR_Ref); Model.Sage.F_ARTICLE F_ARTICLENOMENCLAT; Model.Local.Article ArticleNomenclat; Model.Prestashop.PsPack PsPackAdd; foreach (Model.Sage.F_NOMENCLAT F_NOMENCLAT in ListF_NOMENCLAT) { if (F_ARTICLERepository.ExistReference(F_NOMENCLAT.NO_RefDet)) { F_ARTICLENOMENCLAT = F_ARTICLERepository.ReadReference(F_NOMENCLAT.NO_RefDet); if (ArticleRepository.ExistSag_Id(F_ARTICLENOMENCLAT.cbMarq) && F_ARTICLENOMENCLAT.AR_SuiviStock != (short)ABSTRACTION_SAGE.F_ARTICLE.Obj._Enum_AR_SuiviStock.Aucun) // pour ne pas prendre en compte les articles non suivi en stock { ArticleNomenclat = ArticleRepository.ReadSag_Id(F_ARTICLENOMENCLAT.cbMarq); if (ArticleNomenclat.Pre_Id != null && ArticleNomenclat.Pre_Id.Value != 0) { if (ProductRepository.ExistId((UInt32)ArticleNomenclat.Pre_Id.Value)) { PsPackAdd = new Model.Prestashop.PsPack() { IDProductPack = Product.IDProduct, IDProductItem = (UInt32)ArticleNomenclat.Pre_Id.Value, Quantity = (UInt32)F_NOMENCLAT.NO_Qte.Value }; PsPackRepository.Add(PsPackAdd); } } } } } } #endregion } } catch (Exception ex) { Core.Error.SendMailError(ex.ToString()); } }
public void Exec(Int32 ArticleSend, out List <string> log_chrono, out uint pre_id) { log_chrono = new List <string>(); pre_id = 0; try { Model.Local.ArticleRepository ArticleRepository = new Model.Local.ArticleRepository(); Model.Local.Article Article = ArticleRepository.ReadArticle(ArticleSend); DateTime start = DateTime.UtcNow; if (Core.Global.GetConfig().ChronoSynchroStockPriceActif) { log_chrono.Add("----" + Article.Art_Ref + "----" + start.ToString("HH:mm:ss.fff", System.Globalization.CultureInfo.InvariantCulture)); } Model.Prestashop.PsProductRepository ProductRepository = new Model.Prestashop.PsProductRepository(); Model.Prestashop.PsProduct Product = new Model.Prestashop.PsProduct(); // If the Article have a connection with Prestashop if (Article.Pre_Id != null) { //Article.Art_Date = Article.Art_Date.AddMilliseconds(-Article.Art_Date.Millisecond); if (ProductRepository.ExistId(Convert.ToUInt32(Article.Pre_Id.Value))) { Product = ProductRepository.ReadId(Convert.ToUInt32(Article.Pre_Id.Value)); List <string> log; this.ExecLocalToDistant(Article, Product, ProductRepository, out log); if (log != null && log.Count > 0) { log_chrono.AddRange(log); } pre_id = Product.IDProduct; } } if (Core.Global.GetConfig().ChronoSynchroStockPriceActif) { log_chrono.Add("----" + Article.Art_Ref + "----" + (DateTime.UtcNow - start).ToString()); } } catch (Exception ex) { Core.Error.SendMailError(ex.ToString()); } }
public void Exec(Int32 ArticleSend) { try { Model.Local.ArticleRepository ArticleRepository = new Model.Local.ArticleRepository(); Model.Local.Article Article = ArticleRepository.ReadArticle(ArticleSend); Model.Prestashop.PsProductRepository ProductRepository = new Model.Prestashop.PsProductRepository(); Model.Prestashop.PsProduct Product = new Model.Prestashop.PsProduct(); // If the Article have a connection with Prestashop if (Article.Pre_Id != null) { //Article.Art_Date = Article.Art_Date.AddMilliseconds(-Article.Art_Date.Millisecond); if (ProductRepository.ExistId(Convert.ToUInt32(Article.Pre_Id.Value))) { Product = ProductRepository.ReadId(Convert.ToUInt32(Article.Pre_Id.Value)); this.ExecLocalToDistant(Article, ArticleRepository, Product, ProductRepository); } } } catch (Exception ex) { Core.Error.SendMailError(ex.ToString()); } }