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()); } }
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) { try { Model.Local.ArticleRepository ArticleRepository = new Model.Local.ArticleRepository(); Model.Local.Article Article = ArticleRepository.ReadArticle(ArticleSend); Model.Sage.F_ARTICLERepository F_ARTICLERepository = new Model.Sage.F_ARTICLERepository(); Model.Sage.F_ARTICLE F_ARTICLE = new Model.Sage.F_ARTICLE(); F_ARTICLE = F_ARTICLERepository.ReadArticle(Article.Sag_Id); Core.ImportSage.ImportArticle ImportArticle = new ImportSage.ImportArticle(); ImportArticle.ImportCatalogueInfoLibre(F_ARTICLE, Article); //Model.Local.CatalogRepository CatalogRepository = new Model.Local.CatalogRepository(); //Model.Local.InformationLibreArticleRepository InformationLibreArticleRepository = new Model.Local.InformationLibreArticleRepository(); //Model.Local.InformationLibreArticle InformationLibreArticleCatalogueParent = new Model.Local.InformationLibreArticle(); //Model.Local.Catalog Parent; //foreach (Model.Local.InformationLibreArticle InformationLibreArticle in InformationLibreArticleRepository.List()) //{ // CatalogRepository = new Model.Local.CatalogRepository(); // if (InformationLibreArticle.Inf_Catalogue == 2) // { // if (CatalogRepository.ExistParent(InformationLibreArticle.Inf_Parent, InformationLibreArticle.Inf_Catalogue)) // { // CreateCatalogueInfoLibre(InformationLibreArticle, F_ARTICLE, Article, InformationLibreArticle.Inf_Catalogue + 1, CatalogRepository.ReadParent(InformationLibreArticle.Inf_Parent, InformationLibreArticle.Inf_Catalogue).Cat_Id); // } // } // else // { // if (InformationLibreArticleRepository.ExistInfoLibreLevel(InformationLibreArticle.Inf_Parent, 2)) // { // InformationLibreArticleCatalogueParent = InformationLibreArticleRepository.ReadInfoLibre(InformationLibreArticle.Inf_Parent, (int)InformationLibreArticle.Inf_Catalogue - 1); // if (CatalogRepository.ExistName(F_ARTICLERepository.ReadArticleInformationLibreText(InformationLibreArticleCatalogueParent.Sag_InfoLibreArticle, F_ARTICLE.AR_Ref))) // { // Parent = CatalogRepository.ReadParent(F_ARTICLERepository.ReadArticleInformationLibreText(InformationLibreArticleCatalogueParent.Sag_InfoLibreArticle, F_ARTICLE.AR_Ref), 2); // if (Parent != null) // { // CreateCatalogueInfoLibre(InformationLibreArticle, F_ARTICLE, Article, 3, Parent.Cat_Id); // } // } // } // } //} } catch (Exception ex) { Core.Error.SendMailError(ex.ToString()); } }
public void Exec(Int32 ArticleSend) { try { Model.Local.ArticleRepository ArticleRepository = new Model.Local.ArticleRepository(); if (ArticleRepository.ExistArticle(ArticleSend)) { Model.Local.Article Article = ArticleRepository.ReadArticle(ArticleSend); Model.Sage.F_ARTICLERepository F_ARTICLERepository = new Model.Sage.F_ARTICLERepository(); string AR_Ref = Article.Art_Ref; // ajout gestion lecture des informations pour une composition if (!F_ARTICLERepository.ExistReference(Article.Art_Ref) && Article.TypeArticle == Model.Local.Article.enum_TypeArticle.ArticleComposition && Article.CompositionArticle != null && Article.CompositionArticle.Count > 0) { int sag_id = (from Table in Article.CompositionArticle orderby Table.ComArt_Default descending select Table.ComArt_F_ARTICLE_SagId).FirstOrDefault(); Model.Sage.F_ARTICLE_Light light = F_ARTICLERepository.ReadLight(sag_id); if (light != null && !string.IsNullOrWhiteSpace(light.AR_Ref)) { AR_Ref = light.AR_Ref; } } if (F_ARTICLERepository.ExistReference(AR_Ref)) { if (ImportValues(Article, AR_Ref)) { if (Core.Temp.UpdateDateActive) { Article.Art_Date = DateTime.Now; } ArticleRepository.Save(); } } } } catch (Exception ex) { Core.Error.SendMailError(ex.ToString()); } }
private void ExecLocalToDistant(Model.Local.Article Article, Model.Prestashop.PsProduct Product, Model.Prestashop.PsProductRepository ProductRepository) { try { if (Article.TypeArticle == Model.Local.Article.enum_TypeArticle.ArticleComposition) { if (Core.UpdateVersion.License.Option2) { Product.Quantity = 0; Product.Price = 0; SynchronisationArticle.WriteStockAvailableProduct(Product); SynchronisationArticle.ExecCompositionArticle(Article, Product, ProductRepository); } } else { 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); if ((F_ARTICLE.AR_Gamme1 != null && F_ARTICLE.AR_Gamme1 != 0) || (F_ARTICLE.AR_Condition != null && F_ARTICLE.AR_Condition != 0)) { int CatComptaArticle = Core.Global.GetConfig().ConfigArticleCatComptable; Model.Sage.F_TAXE TaxeTVA = SynchronisationArticle.ReadTaxe(F_ARTICLE, Product, CatComptaArticle); Model.Sage.F_TAXE TaxeEco = SynchronisationArticle.ReadEcoTaxe(F_ARTICLE, Product, TaxeTVA, CatComptaArticle); SynchronisationArticle.ReadPrice(F_ARTICLE, Product, TaxeTVA); // <JG> 19/02/2013 déplacement pour correction problème prix spécifiques lors de la création de l'article SynchronisationArticle.ExecAttribute(Article, Product, ProductRepository, TaxeTVA); SynchronisationArticle.ExecConditioning(Article, Product, ProductRepository, TaxeTVA); //List<string> log; //SynchronisationArticle.ExecSpecificPrice(F_ARTICLE, Product, Article.Art_Id, TaxeTVA, TaxeEco, out log); } } } } catch (Exception ex) { Core.Error.SendMailError(ex.ToString()); } }
private void LoadSelectedCatalogItemsWorker_DoWork(object sender, DoWorkEventArgs e) { Application.Current.Dispatcher.BeginInvoke(new Action(delegate { Mouse.OverrideCursor = Cursors.Wait; }), null); IsBusy = true; LoadingStep = "Chargement des articles du catalogue ..."; bool sommeil = Core.Global.GetConfig().ArticleEnSommeil; bool nonpublie = Core.Global.GetConfig().ArticleNonPublieSurLeWeb; Model.Sage.F_ARTICLERepository F_ArticleRepository = new Model.Sage.F_ARTICLERepository(); Core.Temp.ListArticleLocal = new Model.Local.ArticleRepository().ListSageId(); Core.Temp.ListArticleLocal.AddRange(new Model.Local.CompositionArticleRepository().ListF_ARTICLESageId()); List <Model.Sage.F_ARTICLE_Import> articles = (SelectedCatalog == null) ? ((SearchWithoutCatalogs) ? F_ArticleRepository.ListWithoutCatalog() : F_ArticleRepository.ListInCatalog()) : F_ArticleRepository.ListFullCatalogue(SelectedCatalog.CL_No.Value); articles = articles.Where(a => (sommeil || a.AR_Sommeil == 0) && (nonpublie || a.AR_Publie == 1) && (!MaskImportedProducts || a.Exist == false) && (!OnlyStandardProducts || ((a.AR_Gamme1 == null || a.AR_Gamme1 == 0) && (a.AR_Gamme2 == null || a.AR_Gamme2 == 0) && (a.AR_Condition == null || a.AR_Condition == 0))) // <JG> 12/07/2013 ajout filtres && (string.IsNullOrWhiteSpace(Filter) || (Core.Global.RemoveDiacritics(a.AR_Design.ToLower()).Contains(Filter.ToLower()) || a.AR_Ref.ToLower().Contains(Filter.ToLower()) || a.AF_Ref.ToLower().Contains(Filter.ToLower()) || (!string.IsNullOrWhiteSpace(a.AR_CodeBarre) && a.AR_CodeBarre.ToLower().Contains(Filter))))).ToList(); // <JG> 02/11/2015 ajout filtres d'import par exclusion int filtered_products = articles.Count; articles = Core.Tools.FiltreImportSage.ImportSageFilter(articles); StrFilteredProducts = (articles.Count < filtered_products) ? ("" + (filtered_products - articles.Count) + " article(s) dans les filtres d'exclusion") : string.Empty; SelectedCatalogItems = new ObservableCollection <Model.Sage.F_ARTICLE_Import>(articles); }
public Boolean ImportValues(Model.Local.Article Article, string AR_Ref) { Boolean HasValue = false; try { Model.Sage.F_ARTICLERepository F_ARTICLERepository = new Model.Sage.F_ARTICLERepository(); #region Informations libre Article Model.Local.InformationLibreRepository InformationLibreRepository = new Model.Local.InformationLibreRepository(); foreach (Model.Local.InformationLibre InformationLibre in InformationLibreRepository.ListSync()) { // <JG> 21/08/2017 ajout filtre info libre pour automates if (Core.Temp.TaskImportStatInfoLibreFilter == null || Core.Temp.TaskImportStatInfoLibreFilter.Contains(Core.Global.EscapeArgumentSyntax(InformationLibre.Sag_InfoLibre))) { Model.Sage.cbSysLibreRepository.CB_Type TypeInfoLibre = new Model.Sage.cbSysLibreRepository().ReadTypeInformationLibre(InformationLibre.Sag_InfoLibre, Model.Sage.cbSysLibreRepository.CB_File.F_ARTICLE); switch (TypeInfoLibre) { case Model.Sage.cbSysLibreRepository.CB_Type.SageText: case Model.Sage.cbSysLibreRepository.CB_Type.SageTable: #region text if (F_ARTICLERepository.ExistArticleInformationLibreText(InformationLibre.Sag_InfoLibre, AR_Ref)) { if (!string.IsNullOrWhiteSpace(Core.Global.SageValueReplacement(F_ARTICLERepository.ReadArticleInformationLibreText(InformationLibre.Sag_InfoLibre, AR_Ref)))) { Model.Local.CharacteristicRepository CharacteristicRepository = new Model.Local.CharacteristicRepository(); Model.Local.Characteristic ArticleCharacteristic; if (CharacteristicRepository.ExistFeatureArticle(InformationLibre.Cha_Id, Article.Art_Id)) { ArticleCharacteristic = CharacteristicRepository.ReadFeatureArticle(InformationLibre.Cha_Id, Article.Art_Id); string temp_text = ArticleCharacteristic.Cha_Value; int? temp_id = ArticleCharacteristic.Pre_Id; ArticleCharacteristic.Cha_Value = Core.Global.SageValueReplacement(F_ARTICLERepository.ReadArticleInformationLibreText(InformationLibre.Sag_InfoLibre, AR_Ref));; switch (InformationLibre.Inf_Mode) { case (short)Core.Parametres.InformationLibreValeursMode.Predefinies: ArticleCharacteristic.Cha_Custom = false; ArticleCharacteristic.Pre_Id = CreateFeatureValue(ArticleCharacteristic.Cha_Value, InformationLibre.Cha_Id); break; case (short)Core.Parametres.InformationLibreValeursMode.Personnalisees: ArticleCharacteristic.Cha_Custom = true; break; } CharacteristicRepository.Save(); if (temp_text != ArticleCharacteristic.Cha_Value || temp_id != ArticleCharacteristic.Pre_Id) { HasValue = true; } } else { HasValue = true; ArticleCharacteristic = new Model.Local.Characteristic() { Art_Id = Article.Art_Id, Cha_IdFeature = (int)InformationLibre.Cha_Id, Cha_Value = Core.Global.SageValueReplacement(F_ARTICLERepository.ReadArticleInformationLibreText(InformationLibre.Sag_InfoLibre, AR_Ref)), }; switch (InformationLibre.Inf_Mode) { case (short)Core.Parametres.InformationLibreValeursMode.Predefinies: ArticleCharacteristic.Cha_Custom = false; ArticleCharacteristic.Pre_Id = CreateFeatureValue(ArticleCharacteristic.Cha_Value, InformationLibre.Cha_Id); break; case (short)Core.Parametres.InformationLibreValeursMode.Personnalisees: ArticleCharacteristic.Cha_Custom = true; break; } CharacteristicRepository.Add(ArticleCharacteristic); } } else if (Core.Global.GetConfig().ArticleSuppressionAutoCaracteristique) { DeleteFeatureProduct(InformationLibre, Article); } } #endregion break; case Model.Sage.cbSysLibreRepository.CB_Type.SageValeur: case Model.Sage.cbSysLibreRepository.CB_Type.SageMontant: #region decimal if (F_ARTICLERepository.ExistArticleInformationLibreNumerique(InformationLibre.Sag_InfoLibre, AR_Ref)) { if (F_ARTICLERepository.ReadArticleInformationLibreNumerique(InformationLibre.Sag_InfoLibre, AR_Ref) != null) { Model.Local.CharacteristicRepository CharacteristicRepository = new Model.Local.CharacteristicRepository(); Model.Local.Characteristic ArticleCharacteristic; if (CharacteristicRepository.ExistFeatureArticle(InformationLibre.Cha_Id, Article.Art_Id)) { ArticleCharacteristic = CharacteristicRepository.ReadFeatureArticle(InformationLibre.Cha_Id, Article.Art_Id); string temp_text = ArticleCharacteristic.Cha_Value; int? temp_id = ArticleCharacteristic.Pre_Id; ArticleCharacteristic.Cha_Value = F_ARTICLERepository.ReadArticleInformationLibreNumerique(InformationLibre.Sag_InfoLibre, AR_Ref).Value .ToString((TypeInfoLibre == Model.Sage.cbSysLibreRepository.CB_Type.SageMontant) ? "0.00####" : "0.######"); switch (InformationLibre.Inf_Mode) { case (short)Core.Parametres.InformationLibreValeursMode.Predefinies: ArticleCharacteristic.Cha_Custom = false; ArticleCharacteristic.Pre_Id = CreateFeatureValue(ArticleCharacteristic.Cha_Value, InformationLibre.Cha_Id); break; case (short)Core.Parametres.InformationLibreValeursMode.Personnalisees: ArticleCharacteristic.Cha_Custom = true; break; } CharacteristicRepository.Save(); if (temp_text != ArticleCharacteristic.Cha_Value || temp_id != ArticleCharacteristic.Pre_Id) { HasValue = true; } } else { HasValue = true; ArticleCharacteristic = new Model.Local.Characteristic() { Art_Id = Article.Art_Id, Cha_IdFeature = (int)InformationLibre.Cha_Id, Cha_Value = F_ARTICLERepository.ReadArticleInformationLibreNumerique(InformationLibre.Sag_InfoLibre, AR_Ref).Value .ToString((TypeInfoLibre == Model.Sage.cbSysLibreRepository.CB_Type.SageMontant) ? "0.00####" : "0.######"), }; switch (InformationLibre.Inf_Mode) { case (short)Core.Parametres.InformationLibreValeursMode.Predefinies: ArticleCharacteristic.Cha_Custom = false; ArticleCharacteristic.Pre_Id = CreateFeatureValue(ArticleCharacteristic.Cha_Value, InformationLibre.Cha_Id); break; case (short)Core.Parametres.InformationLibreValeursMode.Personnalisees: ArticleCharacteristic.Cha_Custom = true; break; } CharacteristicRepository.Add(ArticleCharacteristic); } } else if (Core.Global.GetConfig().ArticleSuppressionAutoCaracteristique) { DeleteFeatureProduct(InformationLibre, Article); } } #endregion break; case Model.Sage.cbSysLibreRepository.CB_Type.SageDate: case Model.Sage.cbSysLibreRepository.CB_Type.SageSmallDate: #region datetime if (F_ARTICLERepository.ExistArticleInformationLibreDate(InformationLibre.Sag_InfoLibre, AR_Ref)) { if (F_ARTICLERepository.ReadArticleInformationLibreDate(InformationLibre.Sag_InfoLibre, AR_Ref) != null) { Model.Local.CharacteristicRepository CharacteristicRepository = new Model.Local.CharacteristicRepository(); Model.Local.Characteristic ArticleCharacteristic; if (CharacteristicRepository.ExistFeatureArticle(InformationLibre.Cha_Id, Article.Art_Id)) { ArticleCharacteristic = CharacteristicRepository.ReadFeatureArticle(InformationLibre.Cha_Id, Article.Art_Id); string temp_text = ArticleCharacteristic.Cha_Value; int? temp_id = ArticleCharacteristic.Pre_Id; ArticleCharacteristic.Cha_Value = F_ARTICLERepository.ReadArticleInformationLibreDate(InformationLibre.Sag_InfoLibre, AR_Ref).ToString(); switch (InformationLibre.Inf_Mode) { case (short)Core.Parametres.InformationLibreValeursMode.Predefinies: ArticleCharacteristic.Cha_Custom = false; ArticleCharacteristic.Pre_Id = CreateFeatureValue(ArticleCharacteristic.Cha_Value, InformationLibre.Cha_Id); break; case (short)Core.Parametres.InformationLibreValeursMode.Personnalisees: ArticleCharacteristic.Cha_Custom = true; break; } CharacteristicRepository.Save(); if (temp_text != ArticleCharacteristic.Cha_Value || temp_id != ArticleCharacteristic.Pre_Id) { HasValue = true; } } else { ArticleCharacteristic = new Model.Local.Characteristic() { Art_Id = Article.Art_Id, Cha_IdFeature = (int)InformationLibre.Cha_Id, Cha_Value = F_ARTICLERepository.ReadArticleInformationLibreDate(InformationLibre.Sag_InfoLibre, AR_Ref).ToString(), }; switch (InformationLibre.Inf_Mode) { case (short)Core.Parametres.InformationLibreValeursMode.Predefinies: ArticleCharacteristic.Cha_Custom = false; ArticleCharacteristic.Pre_Id = CreateFeatureValue(ArticleCharacteristic.Cha_Value, InformationLibre.Cha_Id); break; case (short)Core.Parametres.InformationLibreValeursMode.Personnalisees: ArticleCharacteristic.Cha_Custom = true; break; } CharacteristicRepository.Add(ArticleCharacteristic); } } else if (Core.Global.GetConfig().ArticleSuppressionAutoCaracteristique) { DeleteFeatureProduct(InformationLibre, Article); } } #endregion break; case Model.Sage.cbSysLibreRepository.CB_Type.Deleted: default: break; } } } #endregion // traitement uniquement si absence de filtre sur l'automate if (Core.Temp.TaskImportStatInfoLibreFilter == null) { #region Statistiques Article Model.Local.StatistiqueArticleRepository StatistiqueArticleRepository = new Model.Local.StatistiqueArticleRepository(); foreach (Model.Local.StatistiqueArticle StatistiqueArticle in StatistiqueArticleRepository.ListSync()) { Model.Sage.P_INTSTATARTRepository P_INTSTATARTRepository = new Model.Sage.P_INTSTATARTRepository(); if (P_INTSTATARTRepository.ExistStatArt(StatistiqueArticle.Sag_StatArt)) { Model.Sage.P_INTSTATART P_INTSTATART = P_INTSTATARTRepository.ReadStatArt(StatistiqueArticle.Sag_StatArt); Model.Sage.F_ARTICLE F_ARTICLE = F_ARTICLERepository.ReadReference(AR_Ref); String stat_value = null; switch (P_INTSTATART.cbMarq) { case 1: stat_value = F_ARTICLE.AR_Stat01; break; case 2: stat_value = F_ARTICLE.AR_Stat02; break; case 3: stat_value = F_ARTICLE.AR_Stat03; break; case 4: stat_value = F_ARTICLE.AR_Stat04; break; case 5: stat_value = F_ARTICLE.AR_Stat05; break; } if (!String.IsNullOrWhiteSpace(stat_value)) { Model.Local.CharacteristicRepository CharacteristicRepository = new Model.Local.CharacteristicRepository(); Model.Local.Characteristic ArticleCharacteristic; if (CharacteristicRepository.ExistFeatureArticle(StatistiqueArticle.Cha_Id, Article.Art_Id)) { ArticleCharacteristic = CharacteristicRepository.ReadFeatureArticle(StatistiqueArticle.Cha_Id, Article.Art_Id); string temp_text = ArticleCharacteristic.Cha_Value; int? temp_id = ArticleCharacteristic.Pre_Id; ArticleCharacteristic.Cha_Value = Core.Global.SageValueReplacement(stat_value); switch (StatistiqueArticle.Inf_Mode) { case (short)PRESTACONNECT.Core.Parametres.InformationLibreValeursMode.Predefinies: ArticleCharacteristic.Cha_Custom = false; ArticleCharacteristic.Pre_Id = CreateFeatureValue(ArticleCharacteristic.Cha_Value, StatistiqueArticle.Cha_Id); break; case (short)PRESTACONNECT.Core.Parametres.InformationLibreValeursMode.Personnalisees: ArticleCharacteristic.Cha_Custom = true; break; } CharacteristicRepository.Save(); if (temp_text != ArticleCharacteristic.Cha_Value || temp_id != ArticleCharacteristic.Pre_Id) { HasValue = true; } } else { HasValue = true; ArticleCharacteristic = new Model.Local.Characteristic() { Art_Id = Article.Art_Id, Cha_IdFeature = (int)StatistiqueArticle.Cha_Id, Cha_Value = Core.Global.SageValueReplacement(stat_value), }; switch (StatistiqueArticle.Inf_Mode) { case (short)PRESTACONNECT.Core.Parametres.InformationLibreValeursMode.Predefinies: ArticleCharacteristic.Cha_Custom = false; ArticleCharacteristic.Pre_Id = CreateFeatureValue(ArticleCharacteristic.Cha_Value, StatistiqueArticle.Cha_Id); break; case (short)PRESTACONNECT.Core.Parametres.InformationLibreValeursMode.Personnalisees: ArticleCharacteristic.Cha_Custom = true; break; } CharacteristicRepository.Add(ArticleCharacteristic); } } } } #endregion } #region Marque/Fabricant if (Core.Global.GetConfig().MarqueAutoStatistiqueActif&& Core.Temp.TaskImportStatInfoLibreFilter == null) { Model.Sage.P_INTSTATARTRepository P_INTSTATARTRepository = new Model.Sage.P_INTSTATARTRepository(); if (P_INTSTATARTRepository.ExistStatArt(Core.Global.GetConfig().MarqueAutoStatistiqueName)) { Model.Sage.P_INTSTATART P_INTSTATART = P_INTSTATARTRepository.ReadStatArt(Core.Global.GetConfig().MarqueAutoStatistiqueName); Model.Sage.F_ARTICLE F_ARTICLE = F_ARTICLERepository.ReadReference(AR_Ref); String stat_value = null; switch (P_INTSTATART.cbMarq) { case 1: stat_value = F_ARTICLE.AR_Stat01; break; case 2: stat_value = F_ARTICLE.AR_Stat02; break; case 3: stat_value = F_ARTICLE.AR_Stat03; break; case 4: stat_value = F_ARTICLE.AR_Stat04; break; case 5: stat_value = F_ARTICLE.AR_Stat05; break; } if (!String.IsNullOrWhiteSpace(stat_value)) { int temp_id = Article.Art_Manufacturer; Article.Art_Manufacturer = CreateManufacturer(Core.Global.SageValueReplacement(stat_value)); if (temp_id != Article.Art_Manufacturer) { HasValue = true; } } } } else if (Core.Global.GetConfig().MarqueAutoInfolibreActif) { Model.Sage.cbSysLibreRepository.CB_Type TypeInfoLibre = new Model.Sage.cbSysLibreRepository().ReadTypeInformationLibre(Core.Global.GetConfig().MarqueAutoInfolibreName, Model.Sage.cbSysLibreRepository.CB_File.F_ARTICLE); switch (TypeInfoLibre) { case PRESTACONNECT.Model.Sage.cbSysLibreRepository.CB_Type.SageText: case PRESTACONNECT.Model.Sage.cbSysLibreRepository.CB_Type.SageTable: #region text if (F_ARTICLERepository.ExistArticleInformationLibreText(Core.Global.GetConfig().MarqueAutoInfolibreName, AR_Ref) && !string.IsNullOrWhiteSpace(Core.Global.SageValueReplacement(F_ARTICLERepository.ReadArticleInformationLibreText(Core.Global.GetConfig().MarqueAutoInfolibreName, AR_Ref)))) { int temp_id = Article.Art_Manufacturer; Article.Art_Manufacturer = CreateManufacturer(Core.Global.SageValueReplacement(F_ARTICLERepository.ReadArticleInformationLibreText(Core.Global.GetConfig().MarqueAutoInfolibreName, AR_Ref))); if (temp_id != Article.Art_Manufacturer) { HasValue = true; } } #endregion break; default: break; } } #endregion #region Fournisseur if (Core.Global.GetConfig().FournisseurAutoStatistiqueActif&& Core.Temp.TaskImportStatInfoLibreFilter == null) { Model.Sage.P_INTSTATARTRepository P_INTSTATARTRepository = new Model.Sage.P_INTSTATARTRepository(); if (P_INTSTATARTRepository.ExistStatArt(Core.Global.GetConfig().FournisseurAutoStatistiqueName)) { Model.Sage.P_INTSTATART P_INTSTATART = P_INTSTATARTRepository.ReadStatArt(Core.Global.GetConfig().FournisseurAutoStatistiqueName); Model.Sage.F_ARTICLE F_ARTICLE = F_ARTICLERepository.ReadReference(AR_Ref); String stat_value = null; switch (P_INTSTATART.cbMarq) { case 1: stat_value = F_ARTICLE.AR_Stat01; break; case 2: stat_value = F_ARTICLE.AR_Stat02; break; case 3: stat_value = F_ARTICLE.AR_Stat03; break; case 4: stat_value = F_ARTICLE.AR_Stat04; break; case 5: stat_value = F_ARTICLE.AR_Stat05; break; } if (!String.IsNullOrWhiteSpace(stat_value)) { int temp_id = Article.Art_Supplier; Article.Art_Supplier = CreateSupplier(Core.Global.SageValueReplacement(stat_value)); if (temp_id != Article.Art_Supplier) { HasValue = true; } } } } else if (Core.Global.GetConfig().FournisseurAutoInfolibreActif) { Model.Sage.cbSysLibreRepository.CB_Type TypeInfoLibre = new Model.Sage.cbSysLibreRepository().ReadTypeInformationLibre(Core.Global.GetConfig().FournisseurAutoInfolibreName, Model.Sage.cbSysLibreRepository.CB_File.F_ARTICLE); switch (TypeInfoLibre) { case PRESTACONNECT.Model.Sage.cbSysLibreRepository.CB_Type.SageText: case PRESTACONNECT.Model.Sage.cbSysLibreRepository.CB_Type.SageTable: #region text if (F_ARTICLERepository.ExistArticleInformationLibreText(Core.Global.GetConfig().FournisseurAutoInfolibreName, AR_Ref) && !string.IsNullOrWhiteSpace(Core.Global.SageValueReplacement(F_ARTICLERepository.ReadArticleInformationLibreText(Core.Global.GetConfig().FournisseurAutoInfolibreName, AR_Ref)))) { int temp_id = Article.Art_Supplier; Article.Art_Supplier = CreateSupplier(Core.Global.SageValueReplacement(F_ARTICLERepository.ReadArticleInformationLibreText(Core.Global.GetConfig().FournisseurAutoInfolibreName, AR_Ref))); if (temp_id != Article.Art_Supplier) { HasValue = true; } } #endregion break; default: break; } } #endregion if (Core.Temp.TaskImportStatInfoLibreFilter == null) { #region Information Sage Model.Local.InformationArticleRepository InformationArticleRepository = new Model.Local.InformationArticleRepository(); foreach (Model.Local.InformationArticle InformationArticle in InformationArticleRepository.ListSync()) { { Model.Internal.SageInfoArticle SageInfoArticle = new Model.Internal.SageInfoArticle((Parametres.SageInfoArticle)InformationArticle.Sag_InfoArt); Model.Sage.F_ARTICLE F_ARTICLE = F_ARTICLERepository.ReadReference(AR_Ref); String stat_value = null; switch (SageInfoArticle._SageInfoArticle) { case PRESTACONNECT.Core.Parametres.SageInfoArticle.Substitut: stat_value = F_ARTICLE.AR_Substitut; break; case PRESTACONNECT.Core.Parametres.SageInfoArticle.FamilleCode: stat_value = F_ARTICLE.FA_CodeFamille; break; case PRESTACONNECT.Core.Parametres.SageInfoArticle.FamilleIntitule: if (F_ARTICLE.F_FAMILLE != null && !string.IsNullOrEmpty(F_ARTICLE.F_FAMILLE.FA_Intitule)) { stat_value = F_ARTICLE.F_FAMILLE.FA_Intitule; } break; case PRESTACONNECT.Core.Parametres.SageInfoArticle.Garantie: if (F_ARTICLE.AR_Garantie != null) { stat_value = F_ARTICLE.AR_Garantie.Value.ToString(); } break; case PRESTACONNECT.Core.Parametres.SageInfoArticle.Pays: stat_value = F_ARTICLE.AR_Pays; break; case PRESTACONNECT.Core.Parametres.SageInfoArticle.PoidsNet: if (F_ARTICLE.AR_PoidsNet != null && F_ARTICLE.AR_PoidsNet != 0) { stat_value = F_ARTICLE.AR_PoidsNet.ToString(); } break; case PRESTACONNECT.Core.Parametres.SageInfoArticle.PoidsBrut: if (F_ARTICLE.AR_PoidsBrut != null && F_ARTICLE.AR_PoidsBrut != 0) { stat_value = F_ARTICLE.AR_PoidsBrut.ToString(); } break; } if (!String.IsNullOrWhiteSpace(stat_value)) { Model.Local.CharacteristicRepository CharacteristicRepository = new Model.Local.CharacteristicRepository(); Model.Local.Characteristic ArticleCharacteristic; if (CharacteristicRepository.ExistFeatureArticle(InformationArticle.Cha_Id, Article.Art_Id)) { ArticleCharacteristic = CharacteristicRepository.ReadFeatureArticle(InformationArticle.Cha_Id, Article.Art_Id); string temp_text = ArticleCharacteristic.Cha_Value; int? temp_id = ArticleCharacteristic.Pre_Id; ArticleCharacteristic.Cha_Value = Core.Global.SageValueReplacement(stat_value); switch (InformationArticle.Inf_Mode) { case (short)PRESTACONNECT.Core.Parametres.InformationLibreValeursMode.Predefinies: ArticleCharacteristic.Cha_Custom = false; ArticleCharacteristic.Pre_Id = CreateFeatureValue(ArticleCharacteristic.Cha_Value, InformationArticle.Cha_Id); break; case (short)PRESTACONNECT.Core.Parametres.InformationLibreValeursMode.Personnalisees: ArticleCharacteristic.Cha_Custom = true; break; } CharacteristicRepository.Save(); if (temp_text != ArticleCharacteristic.Cha_Value || temp_id != ArticleCharacteristic.Pre_Id) { HasValue = true; } } else { HasValue = true; ArticleCharacteristic = new Model.Local.Characteristic() { Art_Id = Article.Art_Id, Cha_IdFeature = (int)InformationArticle.Cha_Id, Cha_Value = Core.Global.SageValueReplacement(stat_value), }; switch (InformationArticle.Inf_Mode) { case (short)PRESTACONNECT.Core.Parametres.InformationLibreValeursMode.Predefinies: ArticleCharacteristic.Cha_Custom = false; ArticleCharacteristic.Pre_Id = CreateFeatureValue(ArticleCharacteristic.Cha_Value, InformationArticle.Cha_Id); break; case (short)PRESTACONNECT.Core.Parametres.InformationLibreValeursMode.Personnalisees: ArticleCharacteristic.Cha_Custom = true; break; } CharacteristicRepository.Add(ArticleCharacteristic); } } } } #endregion } } catch (Exception ex) { Core.Error.SendMailError(ex.ToString()); } return(HasValue); }
private void ExecLocalToDistant(Model.Local.Article Article, Model.Prestashop.PsProduct Product, Model.Prestashop.PsProductRepository PsProductRepository, out List <string> log_chrono) { log_chrono = new List <string>(); try { if (Article.TypeArticle == Model.Local.Article.enum_TypeArticle.ArticleComposition) { if (Core.UpdateVersion.License.Option2) { Product.Price = 0; Product.Quantity = 0; SynchronisationArticle.WriteStockAvailableProduct(Product); ExecCompositionArticle(Article, Product); } } else { 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); SynchronisationArticle.ReadQuantity(F_ARTICLE, Product); #region Stock pack limité par composés if (Article.Art_Pack == true || F_ARTICLE.AR_Nomencl == (short)ABSTRACTION_SAGE.F_ARTICLE.Obj._Enum_AR_Nomencl.Commerciale_Composant || F_ARTICLE.AR_Nomencl == (short)ABSTRACTION_SAGE.F_ARTICLE.Obj._Enum_AR_Nomencl.Commerciale_Compose) // pour que les articles en nomenclature soient pris en compte { 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; Int32 QuantityPack = 0; 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 (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 { Int32 CurrentQuantity = SynchronisationArticle.ReadQuantityPack(F_ARTICLENOMENCLAT, F_NOMENCLAT.NO_Qte.Value); if (Core.Global.GetConfig().ArticleStockNegatifZero&& CurrentQuantity < 0) { CurrentQuantity = 0; } if (CurrentQuantity < QuantityPack) { QuantityPack = CurrentQuantity; } else if (QuantityPack == 0) { QuantityPack = CurrentQuantity; // <AM> 14/08/2014 Si un des articles composant n'a pas de stock on sort de la fonction pour que l'article parent ai un stock à 0 if (CurrentQuantity == 0) { break; } } } } } Product.Quantity = QuantityPack; } #endregion int CatComptaArticle = Core.Global.GetConfig().ConfigArticleCatComptable; Model.Sage.F_TAXE TaxeTVA = SynchronisationArticle.ReadTaxe(F_ARTICLE, Product, CatComptaArticle); Model.Sage.F_TAXE TaxeEco = SynchronisationArticle.ReadEcoTaxe(F_ARTICLE, Product, TaxeTVA, CatComptaArticle); // <JG> 03/06/2016 if (Article.Art_SyncPrice) { SynchronisationArticle.ReadPrice(F_ARTICLE, Product, TaxeTVA); } if (Core.Global.GetConfig().MajPoidsSynchroStock) { SynchronisationArticle.ReadWeight(F_ARTICLE, Product); } if (Core.Global.GetConfig().ArticleDateDispoInfoLibreActif) { SynchronisationArticle.ReadDateDispo(Product, F_ARTICLE); } PsProductRepository.Save(); PsProductRepository.WriteDate(Product.IDProduct); // <JG> 05/11/2013 déplacement pour application taxes et pdt spécifiques sur nouvelles déclinaisons this.ExecAttribute(Article, Product, TaxeTVA, PsProductRepository); this.ExecConditioning(Article, Product, TaxeTVA, PsProductRepository); // <JG> 03/06/2016 if (Article.Art_SyncPrice) { List <string> log; SynchronisationArticle.ExecSpecificPrice(F_ARTICLE, Product, Article, null, TaxeTVA, TaxeEco, out log); if (log != null && log.Count > 0) { log_chrono.AddRange(log); } } // <JG> 17/12/2012 SynchronisationArticle.ExecShopProduct(Product); SynchronisationArticle.WriteStockAvailableProduct(Product); } } } catch (Exception ex) { Core.Error.SendMailError(ex.ToString()); } }
private void ExecCompositionArticle(Model.Local.Article Article, Model.Prestashop.PsProduct Product) { Model.Sage.F_ARTICLERepository F_ARTICLERepository = new Model.Sage.F_ARTICLERepository(); Model.Local.CompositionArticleRepository CompositionArticleRepository = new Model.Local.CompositionArticleRepository(); List <Model.Local.CompositionArticle> ListCompositionArticle = CompositionArticleRepository.ListArticle(Article.Art_Id); foreach (var item in ListCompositionArticle) { try { Model.Sage.F_ARTICLE_Composition F_ARTICLE_Composition = F_ARTICLERepository.ReadComposition(item.ComArt_F_ARTICLE_SagId, item.ComArt_F_ARTENUMREF_SagId, item.ComArt_F_CONDITION_SagId); if (F_ARTICLE_Composition != null) { Model.Sage.F_ARTICLE F_ARTICLE = F_ARTICLERepository.ReadArticle(item.ComArt_F_ARTICLE_SagId); Model.Prestashop.PsProductAttributeRepository PsProductAttributeRepository = new Model.Prestashop.PsProductAttributeRepository(); Model.Prestashop.PsProductAttribute PsProductAttributeComposition = new Model.Prestashop.PsProductAttribute(); Boolean isProductAttribute = false; if (item.Pre_Id != null && PsProductAttributeRepository.ExistProductAttribute((uint)item.Pre_Id)) { PsProductAttributeComposition = PsProductAttributeRepository.ReadProductAttribute((uint)item.Pre_Id); if (PsProductAttributeComposition != null) { isProductAttribute = true; } } if (isProductAttribute == true) { int CatComptaArticle = Core.Global.GetConfig().ConfigArticleCatComptable; Model.Sage.F_TAXE TaxeTVA = SynchronisationArticle.ReadTaxe(F_ARTICLE, Product, CatComptaArticle); Model.Prestashop.PsProduct temp_product = new Model.Prestashop.PsProduct(); temp_product.taxe_famillesage = Product.taxe_famillesage; // temp_product sert pour conserver l'information "ecoraxeht_sage" pour la fonction SpecificPrice Model.Sage.F_TAXE TaxeEco = SynchronisationArticle.ReadEcoTaxe(F_ARTICLE, temp_product, TaxeTVA, CatComptaArticle); PsProductAttributeComposition.EcOtAx = temp_product.EcOtAx; if (F_ARTICLE_Composition.F_CONDITION_SagId == null && F_ARTICLE_Composition.F_ARTENUMREF_SagId == null) { if (Core.Global.GetConfig().MajPoidsSynchroStock) { SynchronisationArticle.ReadWeight(F_ARTICLE, PsProductAttributeComposition); } SynchronisationArticle.ReadQuantity(F_ARTICLE, PsProductAttributeComposition); // <JG> 03/06/2016 if (Article.Art_SyncPrice) { SynchronisationArticle.ReadPrice(F_ARTICLE, PsProductAttributeComposition, TaxeTVA); } //List<string> log; //this.ExecSpecificPrice(F_ARTICLE, Product, Article.Art_Id, TaxeTVA, TaxeEco, out log); //if (log != null && log.Count > 0) // log_chrono.AddRange(log); } else if (F_ARTICLE_Composition.F_ARTENUMREF_SagId != null) { Model.Prestashop.PsProduct temp_product_f_artenumref = new Model.Prestashop.PsProduct(); // lecture des valeurs pour F_ARTICLE if (Core.Global.GetConfig().MajPoidsSynchroStock) { SynchronisationArticle.ReadWeight(F_ARTICLE, temp_product_f_artenumref); } SynchronisationArticle.ReadQuantity(F_ARTICLE, temp_product_f_artenumref); // <JG> 03/06/2016 if (Article.Art_SyncPrice) { SynchronisationArticle.ReadPrice(F_ARTICLE, temp_product_f_artenumref, TaxeTVA); } // transformation en fonction de f_artenumref if (Core.Global.GetConfig().MajPoidsSynchroStock) { SynchronisationArticle.ReadWeightAttribute(temp_product_f_artenumref, PsProductAttributeComposition, F_ARTICLE, item.EnumereGamme1); PsProductAttributeComposition.Weight += temp_product_f_artenumref.Weight; } SynchronisationArticle.ReadQuantityAttribute(PsProductAttributeComposition, F_ARTICLE, item.EnumereGamme1, item.EnumereGamme2); //SynchronisationArticle.ReadRefEANAttribute(PsProductAttributeComposition, F_ARTICLE, item.EnumereGamme1, item.EnumereGamme2); // <JG> 03/06/2016 if (Article.Art_SyncPrice) { SynchronisationArticle.ReadPriceAttribute(temp_product_f_artenumref, PsProductAttributeComposition, F_ARTICLE, item.EnumereGamme1, item.EnumereGamme2, TaxeTVA); } PsProductAttributeComposition.Price += temp_product_f_artenumref.Price; } else if (F_ARTICLE_Composition.F_CONDITION_SagId != null) { Model.Prestashop.PsProduct temp_product_f_condition = new Model.Prestashop.PsProduct(); // lecture des valeurs pour F_ARTICLE if (Core.Global.GetConfig().MajPoidsSynchroStock) { SynchronisationArticle.ReadWeight(F_ARTICLE, temp_product_f_condition); } SynchronisationArticle.ReadQuantity(F_ARTICLE, temp_product_f_condition); // <JG> 03/06/2016 if (Article.Art_SyncPrice) { SynchronisationArticle.ReadPrice(F_ARTICLE, temp_product_f_condition, TaxeTVA); } // transformation en fonction de F_CONDITION if (Core.Global.GetConfig().MajPoidsSynchroStock) { SynchronisationArticle.ReadWeightConditioning(temp_product_f_condition, PsProductAttributeComposition, item.EnumereF_CONDITION); PsProductAttributeComposition.Weight += temp_product_f_condition.Weight; } SynchronisationArticle.ReadQuantityConditioning(PsProductAttributeComposition, F_ARTICLE, item.EnumereF_CONDITION); // <JG> 03/06/2016 if (Article.Art_SyncPrice) { SynchronisationArticle.ReadPriceConditioning(temp_product_f_condition, PsProductAttributeComposition, F_ARTICLE, item.EnumereF_CONDITION, TaxeTVA); } PsProductAttributeComposition.Price += temp_product_f_condition.Price; } //PsProductAttributeComposition.DefaultOn = (item.ComArt_Default) ? (byte)1 : (byte)0; PsProductAttributeRepository.Save(); SynchronisationArticle.ExecShopProductAttribute(PsProductAttributeComposition); SynchronisationArticle.WriteStockAvailableComposition(Product, PsProductAttributeComposition); // <JG> 03/06/2016 if (Article.Art_SyncPrice) { // prix spécifiques temp_product.Price = PsProductAttributeComposition.Price; temp_product.IDProduct = Product.IDProduct; List <string> log; SynchronisationArticle.ExecSpecificPrice(F_ARTICLE, temp_product, Article, item, TaxeTVA, TaxeEco, out log); if (log != null && log.Count > 0) { SynchronisationArticle.log_chrono.AddRange(log); } } } } } catch (Exception ex) { Core.Error.SendMailError(ex.ToString()); } } }
private void ExecConditioning(Model.Local.Article Article, Model.Prestashop.PsProduct PsProduct, Model.Sage.F_TAXE TaxeTVA, Model.Prestashop.PsProductRepository PsProductRepository) { 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.Local.ConditioningGroupRepository ConditioningGroupRepository = new Model.Local.ConditioningGroupRepository(); Model.Prestashop.PsAttributeGroupRepository PsAttributeGroupRepository = new Model.Prestashop.PsAttributeGroupRepository(); Boolean isProductAttribute; if (F_ARTICLE.AR_Condition != null && F_ARTICLE.AR_Condition != 0 && ConditioningGroupRepository.ExistSage((int)F_ARTICLE.AR_Condition) && PsAttributeGroupRepository.ExistAttributeGroup((uint)ConditioningGroupRepository.ReadSage((int)F_ARTICLE.AR_Condition).Pre_Id)) { Model.Local.ConditioningArticleRepository ConditioningArticleRepository = new Model.Local.ConditioningArticleRepository(); List <Model.Local.ConditioningArticle> ListConditioningArticle = ConditioningArticleRepository.ListArticleSync(Article.Art_Id, true); Model.Prestashop.PsProductAttributeRepository PsProductAttributeRepository = new Model.Prestashop.PsProductAttributeRepository(); Model.Prestashop.PsProductAttribute PsProductAttribute; int stockmaxunity = 0; foreach (Model.Local.ConditioningArticle ConditioningArticle in ListConditioningArticle) { if (ConditioningArticle.EnumereF_CONDITION != null) { PsProductAttribute = new Model.Prestashop.PsProductAttribute(); isProductAttribute = false; if (ConditioningArticle.Pre_Id != null && ConditioningArticle.Pre_Id != 0) { if (PsProductAttributeRepository.ExistProductAttribute((UInt32)ConditioningArticle.Pre_Id)) { PsProductAttribute = PsProductAttributeRepository.ReadProductAttribute((UInt32)ConditioningArticle.Pre_Id); isProductAttribute = true; } } if (Core.Global.GetConfig().MajPoidsSynchroStock) { SynchronisationArticle.ReadWeightConditioning(PsProduct, PsProductAttribute, ConditioningArticle.EnumereF_CONDITION); } SynchronisationArticle.ReadQuantityConditioning(PsProductAttribute, F_ARTICLE, ConditioningArticle.EnumereF_CONDITION); if (Core.Global.GetConfig().LimiteStockConditionnement&& PsProductAttribute.Quantity >= stockmaxunity) { stockmaxunity = PsProductAttribute.Quantity; PsProduct.Quantity = stockmaxunity; PsProductRepository.Save(); } // <JG> 03/06/2016 if (Article.Art_SyncPrice) { SynchronisationArticle.ReadPriceConditioning(PsProduct, PsProductAttribute, F_ARTICLE, ConditioningArticle.EnumereF_CONDITION, TaxeTVA); } //PsProductAttribute.DefaultOn = (ConditioningArticle.ConArt_Default) ? (byte)1 : (byte)0; if (isProductAttribute == true) { PsProductAttributeRepository.Save(); SynchronisationArticle.ExecShopProductAttribute(PsProductAttribute); SynchronisationArticle.WriteStockAvailableProductAttribute(PsProduct, PsProductAttribute); } } } PsProductAttributeRepository.WriteDate(PsProduct.IDProduct); } } } catch (Exception ex) { Core.Error.SendMailError(ex.ToString()); } }
private void ExecAttribute(Model.Local.Article Article, Model.Prestashop.PsProduct PsProduct, Model.Sage.F_TAXE TaxeTVA, Model.Prestashop.PsProductRepository PsProductRepository) { 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.Local.AttributeGroupRepository AttributeGroupRepository = new Model.Local.AttributeGroupRepository(); Model.Prestashop.PsAttributeGroupRepository PsAttributeGroupRepository = new Model.Prestashop.PsAttributeGroupRepository(); Boolean isProductAttribute; if (F_ARTICLE.AR_Gamme1 != null && F_ARTICLE.AR_Gamme1 != 0 && AttributeGroupRepository.ExistSage((int)F_ARTICLE.AR_Gamme1) && PsAttributeGroupRepository.ExistAttributeGroup((uint)AttributeGroupRepository.ReadSage((int)F_ARTICLE.AR_Gamme1).Pre_Id) && ((F_ARTICLE.AR_Gamme2 == null || F_ARTICLE.AR_Gamme2 == 0) || (AttributeGroupRepository.ExistSage((int)F_ARTICLE.AR_Gamme2) && PsAttributeGroupRepository.ExistAttributeGroup((uint)AttributeGroupRepository.ReadSage((int)F_ARTICLE.AR_Gamme2).Pre_Id)))) { Model.Local.AttributeArticleRepository AttributeArticleRepository = new Model.Local.AttributeArticleRepository(); List <Model.Local.AttributeArticle> ListAttributeArticle = AttributeArticleRepository.ListArticleSync(Article.Art_Id, true); Model.Prestashop.PsProductAttributeRepository PsProductAttributeRepository = new Model.Prestashop.PsProductAttributeRepository(); Model.Prestashop.PsProductAttribute PsProductAttribute; int CumulStockGammes = 0; foreach (Model.Local.AttributeArticle AttributeArticle in ListAttributeArticle) { if (AttributeArticle.EnumereF_ARTENUMREF != null) { PsProductAttribute = new Model.Prestashop.PsProductAttribute(); isProductAttribute = false; if (AttributeArticle.Pre_Id != null && AttributeArticle.Pre_Id != 0) { if (PsProductAttributeRepository.ExistProductAttribute((UInt32)AttributeArticle.Pre_Id)) { PsProductAttribute = PsProductAttributeRepository.ReadProductAttribute((UInt32)AttributeArticle.Pre_Id); isProductAttribute = true; } } if (isProductAttribute == true) { if (Core.Global.GetConfig().MajPoidsSynchroStock) { SynchronisationArticle.ReadWeightAttribute(PsProduct, PsProductAttribute, F_ARTICLE, AttributeArticle.EnumereGamme1); } SynchronisationArticle.ReadQuantityAttribute(PsProductAttribute, F_ARTICLE, AttributeArticle.EnumereGamme1, AttributeArticle.EnumereGamme2); CumulStockGammes += PsProductAttribute.Quantity; // <JG> 03/06/2016 if (Article.Art_SyncPrice) { SynchronisationArticle.ReadPriceAttribute(PsProduct, PsProductAttribute, F_ARTICLE, AttributeArticle.EnumereGamme1, AttributeArticle.EnumereGamme2, TaxeTVA); } PsProductAttributeRepository.Save(); SynchronisationArticle.ExecShopProductAttribute(PsProductAttribute); SynchronisationArticle.WriteStockAvailableProductAttribute(PsProduct, PsProductAttribute); } } } if (PsProduct.Quantity != CumulStockGammes) { PsProduct.Quantity = CumulStockGammes; PsProductRepository.Save(); } PsProductAttributeRepository.WriteDate(PsProduct.IDProduct); } } } catch (Exception ex) { Core.Error.SendMailError(ex.ToString()); } }
public void CreateCompositionArticle() { if (SelectedResultSearchCompositionArticle != null) { Model.Sage.F_ARTICLE F_ARTICLE = new Model.Sage.F_ARTICLERepository().ReadArticle(SelectedResultSearchCompositionArticle.cbMarq); if (F_ARTICLE != null) { Model.Local.ArticleRepository ArticleRepository = new Model.Local.ArticleRepository(); string dft = Core.Global.RemovePurge(SelectedResultSearchCompositionArticle.AR_Design, 255); Model.Local.Article Article = new Model.Local.Article() { Art_Name = dft, Art_Type = (short)Model.Local.Article.enum_TypeArticle.ArticleComposition, Art_Description = SelectedResultSearchCompositionArticle.AR_Design, Art_Description_Short = SelectedResultSearchCompositionArticle.AR_Design, Art_MetaTitle = dft, Art_MetaDescription = dft, Art_MetaKeyword = Core.Global.RemovePurgeMeta(dft, 255), Art_LinkRewrite = Core.Global.ReadLinkRewrite(dft), Art_Active = Core.Global.GetConfig().ImportArticleStatutActif, Art_Date = DateTime.Now, Art_Solde = false, Art_Sync = false, Sag_Id = 0, Cat_Id = 0, Art_RedirectType = new Model.Internal.RedirectType(Core.Parametres.RedirectType.NoRedirect404).Page, Art_RedirectProduct = 0, // champs non renseignés pour les compositions Art_Pack = false, Art_Ref = string.Empty, Art_Ean13 = string.Empty, }; Core.ImportSage.ImportArticle ImportArticle = new Core.ImportSage.ImportArticle(); Article.Cat_Id = ImportArticle.ReadCatalog(F_ARTICLE); if (Article.Cat_Id == 0 && Core.Temp.selectedcatalog_composition != 0) { Article.Cat_Id = Core.Temp.selectedcatalog_composition; } if (Article.Cat_Id != 0) { ArticleRepository.Add(Article); ImportArticle.AssignCatalog(0, Article.Cat_Id, Article, Core.Global.GetConfig().ImportArticleRattachementParents); Core.ImportSage.ImportStatInfoLibreArticle ImportStatInfoLibreArticle = new Core.ImportSage.ImportStatInfoLibreArticle(); ImportStatInfoLibreArticle.ImportValues(Article, F_ARTICLE.AR_Ref); PRESTACONNECT.Loading Loading = new PRESTACONNECT.Loading(); Loading.Show(); Core.Temp.selected_taxe_composition = SelectedF_TAXE; Core.Temp.reference_sage_composition = F_ARTICLE.AR_Ref; Core.Temp.designation_composition = F_ARTICLE.AR_Design; PRESTACONNECT.Article Form = new Article(Article); Loading.Close(); Form.ShowDialog(); if (FilterComposition) { SearchArticleComposition(); } } else { MessageBox.Show("Aucune correspondance catalogue n'a été trouvée !", "Lien catalogue absent", MessageBoxButton.OK, MessageBoxImage.Stop); } } } }
public void SearchArticleComposition() { if (SelectedF_TAXE == null) { MessageBox.Show("Veuillez sélectionner une taxe !", "Recherche article", MessageBoxButton.OK, MessageBoxImage.Error); } else { List <Model.Sage.F_ARTICLE_Composition> temp = new Model.Sage.F_ARTICLERepository().ListComposition(); // Filtres sommeil et publié bool sommeil = Core.Global.GetConfig().ArticleEnSommeil; bool nonpublie = Core.Global.GetConfig().ArticleNonPublieSurLeWeb; // <JG> 19/12/2016 ajout filtre gammes temp = temp.Where(ar => (sommeil || ar.AR_Sommeil == 0) && (nonpublie || ar.AR_Publie == 1) && (sommeil || ar.AE_Sommeil != 1)).ToList(); Model.Local.CompositionArticleRepository CompositionArticleRepository = new Model.Local.CompositionArticleRepository(); Model.Local.ArticleRepository ArticleRepository = new Model.Local.ArticleRepository(); // FILTRE TAXE OBLIGATOIRE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! #region Taxes switch (Core.Global.GetConfig().TaxSageTVA) { case PRESTACONNECT.Core.Parametres.TaxSage.CodeTaxe1: temp = temp.Where(a => a.TA_Code1 == SelectedF_TAXE.TA_Code || (string.IsNullOrEmpty(a.TA_Code1) && a.TA_CodeFamille1 == SelectedF_TAXE.TA_Code)).ToList(); break; case PRESTACONNECT.Core.Parametres.TaxSage.CodeTaxe2: temp = temp.Where(a => a.TA_Code2 == SelectedF_TAXE.TA_Code || (string.IsNullOrEmpty(a.TA_Code2) && a.TA_CodeFamille2 == SelectedF_TAXE.TA_Code)).ToList(); break; case PRESTACONNECT.Core.Parametres.TaxSage.CodeTaxe3: temp = temp.Where(a => a.TA_Code3 == SelectedF_TAXE.TA_Code || (string.IsNullOrEmpty(a.TA_Code3) && a.TA_CodeFamille3 == SelectedF_TAXE.TA_Code)).ToList(); break; case PRESTACONNECT.Core.Parametres.TaxSage.Empty: default: temp = new List <Model.Sage.F_ARTICLE_Composition>(); break; } #endregion if (temp.Count == 0) { MessageBox.Show("Aucun résultat pour la taxe sélectionnée !", "Recherche article", MessageBoxButton.OK, MessageBoxImage.Error); } else { // filtres if (SelectedF_FAMILLE != null) { temp = temp.Where(ar => ar.FA_CodeFamille == SelectedF_FAMILLE.FA_CodeFamille).ToList(); } if (SelectedP_GAMME1 != null) { temp = temp.Where(ar => ar.AR_Gamme1 == SelectedP_GAMME1.cbMarq).ToList(); } if (SelectedP_GAMME2 != null) { temp = temp.Where(ar => ar.AR_Gamme2 == SelectedP_GAMME1.cbMarq).ToList(); } if (SelectedP_CONDITIONNEMENT != null) { temp = temp.Where(ar => ar.AR_Condition == SelectedP_CONDITIONNEMENT.cbMarq).ToList(); } if (!string.IsNullOrWhiteSpace(FilterReferenceValue)) { if (FilterReferenceContains) { temp = temp.Where(ar => ar.AR_Ref.Contains(FilterReferenceValue)).ToList(); } if (FilterReferenceStartWith) { temp = temp.Where(ar => ar.AR_Ref.StartsWith(FilterReferenceValue)).ToList(); } } if (!string.IsNullOrWhiteSpace(FilterDesignationValue)) { if (FilterDesignationContains) { temp = temp.Where(ar => ar.AR_Design.ToLower().Contains(FilterDesignationValue.ToLower())).ToList(); } if (FilterDesignationStartWith) { temp = temp.Where(ar => ar.AR_Design.ToLower().StartsWith(FilterDesignationValue.ToLower())).ToList(); } } List <Int32> ListF_ARTICLE_SagId = null; List <Int32> ListF_ARTENUMREF_SagId = null; List <Int32> ListF_CONDITION_SagId = null; if (FilterComposition) { ListF_ARTICLE_SagId = CompositionArticleRepository.ListSageF_ARTICLE(); ListF_ARTENUMREF_SagId = CompositionArticleRepository.ListSageF_ARTENUMREF(); ListF_CONDITION_SagId = CompositionArticleRepository.ListSageF_CONDITION(); } if (FilterArticle) { if (ListF_ARTICLE_SagId != null) { ListF_ARTICLE_SagId.AddRange(ArticleRepository.ListSageId()); } else { ListF_ARTICLE_SagId = ArticleRepository.ListSageId(); } } if (ListF_ARTICLE_SagId != null) { temp = temp.Where(ar => !ListF_ARTICLE_SagId.Contains(ar.cbMarq)).ToList(); } if (ListF_ARTENUMREF_SagId != null) { temp = temp.Where(ar => ar.F_ARTENUMREF_SagId == null || (ar.F_ARTENUMREF_SagId != null && !ListF_ARTENUMREF_SagId.Contains(ar.F_ARTENUMREF_SagId.Value))).ToList(); } if (ListF_CONDITION_SagId != null) { temp = temp.Where(ar => ar.F_CONDITION_SagId == null || (ar.F_CONDITION_SagId != null && !ListF_CONDITION_SagId.Contains(ar.F_CONDITION_SagId.Value))).ToList(); } // filtres exclusion int count = temp.Count; List <Model.Sage.F_ARTICLE_Composition> results = Core.Tools.FiltreImportSage.ImportSageFilter(temp); StrCompositionFilteredProducts = (results.Count < count) ? ((count - results.Count) + " résultats dans les filtres d'exclusion") : string.Empty; if (!ShowResultInImportSageFilter) { temp = results; } ListResultSearchCompositionArticle = new ObservableCollection <Model.Sage.F_ARTICLE_Composition>(temp); } } }
private void ExecLocalToDistant(Model.Local.Article Article, Model.Prestashop.PsProduct Product, Model.Prestashop.PsProductRepository PsProductRepository) { try { if (Article.TypeArticle == Model.Local.Article.enum_TypeArticle.ArticleComposition) { if (Core.UpdateVersion.License.Option2) { Product.Quantity = 0; SynchronisationArticle.WriteStockAvailableProduct(Product); ExecCompositionArticle(Article, Product); } } else { 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); SynchronisationArticle.ReadQuantity(F_ARTICLE, Product); #region Stock pack limité par composés if (Article.Art_Pack == true || F_ARTICLE.AR_Nomencl == (short)ABSTRACTION_SAGE.F_ARTICLE.Obj._Enum_AR_Nomencl.Commerciale_Composant || F_ARTICLE.AR_Nomencl == (short)ABSTRACTION_SAGE.F_ARTICLE.Obj._Enum_AR_Nomencl.Commerciale_Compose) // pour que les articles en nomenclature soient pris en compte { 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; Int32 QuantityPack = 0; 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 (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 { Int32 CurrentQuantity = SynchronisationArticle.ReadQuantityPack(F_ARTICLENOMENCLAT, F_NOMENCLAT.NO_Qte.Value); if (Core.Global.GetConfig().ArticleStockNegatifZero&& CurrentQuantity < 0) { CurrentQuantity = 0; } if (CurrentQuantity < QuantityPack) { QuantityPack = CurrentQuantity; // <AM> 14/08/2014 Si un des articles composant n'a pas de stock on sort de la fonction pour que l'article parent ai un stock à 0 if (CurrentQuantity == 0) { break; } } else if (QuantityPack == 0) { QuantityPack = CurrentQuantity; // <AM> 14/08/2014 Si un des articles composant n'a pas de stock on sort de la fonction pour que l'article parent ai un stock à 0 if (CurrentQuantity == 0) { break; } } } } } Product.Quantity = QuantityPack; } #endregion // <JG> 29/10/2012 ajout synchronisation des stocks seule //SynchronisationArticle.ReadEcoTaxe(F_ARTICLE, Product); //SynchronisationArticle.ReadPrice(F_ARTICLE, Product); if (Core.Global.GetConfig().MajPoidsSynchroStock) { SynchronisationArticle.ReadWeight(F_ARTICLE, Product); } if (Core.Global.GetConfig().ArticleDateDispoInfoLibreActif) { SynchronisationArticle.ReadDateDispo(Product, F_ARTICLE); } PsProductRepository.Save(); PsProductRepository.WriteDate(Product.IDProduct); this.ExecAttribute(Article, Product, PsProductRepository); this.ExecConditioning(Article, Product, PsProductRepository); //SynchronisationArticle.ExecSpecificPrice(F_ARTICLE, Product); // <JG> 17/12/2012 SynchronisationArticle.ExecShopProduct(Product); SynchronisationArticle.WriteStockAvailableProduct(Product); } } } catch (Exception ex) { Core.Error.SendMailError(ex.ToString()); } }
public void Exec(Int32 ProductSend) { try { Model.Local.ArticleRepository ArticleRepository = new Model.Local.ArticleRepository(); if (ArticleRepository.ExistPre_Id(ProductSend) == false) { Model.Prestashop.PsProductLangRepository PsProductLangRepository = new Model.Prestashop.PsProductLangRepository(); if (PsProductLangRepository.ExistProductLang(ProductSend, Global.Lang, Global.CurrentShop.IDShop)) { Model.Prestashop.PsProductRepository PsProductRepository = new Model.Prestashop.PsProductRepository(); Model.Prestashop.PsProduct PsProduct = PsProductRepository.ReadId(Convert.ToUInt32(ProductSend)); Model.Prestashop.PsProductLang PsProductLang = PsProductLangRepository.ReadProductLang(ProductSend, Global.Lang, Global.CurrentShop.IDShop); Model.Sage.F_ARTICLERepository F_ARTICLERepository = new Model.Sage.F_ARTICLERepository(); string product_reference = PsProduct.Reference; product_reference = product_reference.Replace(" ", "_"); if (F_ARTICLERepository.ExistReference(product_reference)) { Model.Sage.F_ARTICLE F_ARTICLE = F_ARTICLERepository.ReadReference(product_reference); Model.Local.Article Article = new Model.Local.Article() { Art_Name = PsProductLang.Name, Art_Description = PsProductLang.Description, Art_Description_Short = PsProductLang.DescriptionShort, Art_LinkRewrite = PsProductLang.LinkRewrite, Art_MetaTitle = PsProductLang.MetaTitle, Art_MetaKeyword = PsProductLang.MetaKeywords, Art_MetaDescription = PsProductLang.MetaDescription, Art_Ref = PsProduct.Reference, Art_Ean13 = PsProduct.EAn13, Art_Pack = PsProduct.CacheIsPack == 1, Art_Solde = Convert.ToBoolean(PsProduct.OnSale), Art_Active = Convert.ToBoolean(PsProduct.Active), Art_Sync = true, Art_SyncPrice = true, Art_Date = (PsProduct.DateUpd != null && PsProduct.DateUpd > new DateTime(1753, 1, 2)) ? PsProduct.DateUpd : DateTime.Now.Date, Sag_Id = F_ARTICLE.cbMarq, Pre_Id = Convert.ToInt32(PsProduct.IDProduct), Cat_Id = this.ReadCatalog(PsProduct.IDCategoryDefault), Art_RedirectType = new Model.Internal.RedirectType(Core.Parametres.RedirectType.NoRedirect404).Page, Art_RedirectProduct = 0, Art_Manufacturer = (PsProduct.IDManufacturer != null) ? (int)PsProduct.IDManufacturer : 0, Art_Supplier = (PsProduct.IDSupplier != null) ? (int)PsProduct.IDSupplier : 0, }; if (Article.Cat_Id == 0) { foreach (Model.Prestashop.PsCategoryProduct PsCategoryProduct in new Model.Prestashop.PsCategoryProductRepository().ListProduct(PsProduct.IDProduct)) { Article.Cat_Id = this.ReadCatalog(PsCategoryProduct.IDCategory); if (Article.Cat_Id != 0) { break; } } } if (PsProduct.CacheIsPack == 1) { Article.Art_Pack = true; } if (Article.Cat_Id != 0) { ArticleRepository.Add(Article); RecoveryChildData(Article, PsProduct, ArticleRepository, false); } } } } else { Model.Local.Article Article = ArticleRepository.ReadPre_Id(ProductSend); Model.Prestashop.PsProductRepository PsProductRepository = new Model.Prestashop.PsProductRepository(); Model.Prestashop.PsProduct PsProduct = PsProductRepository.ReadId(Convert.ToUInt32(ProductSend)); RecoveryChildData(Article, PsProduct, ArticleRepository, true); } } catch (Exception ex) { Core.Error.SendMailError(ex.ToString()); } }