private void ExecLocalToDistant(Model.Local.Article Article, Model.Prestashop.PsProduct Product, Model.Local.ArticleRepository ArticleRepository, Model.Prestashop.PsProductRepository ProductRepository, Boolean isProduct) { try { if (isProduct) { Model.Local.CatalogRepository CatalogRepository = new Model.Local.CatalogRepository(); Model.Local.Catalog Catalog = CatalogRepository.ReadId(Article.Cat_Id); if (Catalog.Pre_Id != null && new Model.Prestashop.PsCategoryRepository().ExistId((int)Catalog.Pre_Id)) { Product.IDCategoryDefault = Convert.ToUInt32(Catalog.Pre_Id); ProductRepository.Save(); this.AssignCatalogProduct(Article, Product, ArticleRepository); // <JG> 17/12/2012 this.ExecShopProduct(Product); } } } catch (Exception ex) { Core.Error.SendMailError(ex.ToString()); } }
public HierarchicalCatalog(Model.Sage.F_CATALOGUE sageParent, Model.Local.Catalog localParent) { Children = new ObservableCollection <TCatalog>(); Sage = sageParent; Local = localParent; }
private void ExecDistantLocal(Model.Prestashop.PsCategory Category, Model.Local.Catalog Catalog, Model.Local.CatalogRepository CatalogRepository) { try { // Recovery Data From CatalogLang Model.Prestashop.PsCategoryLangRepository CategoryLangRepository = new Model.Prestashop.PsCategoryLangRepository(); Model.Prestashop.PsCategoryLang CategoryLang = new Model.Prestashop.PsCategoryLang(); if (CategoryLangRepository.ExistCategoryLang((Int32)Category.IDCategory, Core.Global.Lang, Global.CurrentShop.IDShop)) { CategoryLang = CategoryLangRepository.ReadCategoryLang((Int32)Category.IDCategory, Core.Global.Lang, Global.CurrentShop.IDShop); Catalog.Cat_Name = CategoryLang.Name; Catalog.Cat_Description = CategoryLang.Description; Catalog.Cat_MetaTitle = CategoryLang.MetaTitle; Catalog.Cat_MetaKeyword = CategoryLang.MetaKeywords; Catalog.Cat_MetaDescription = CategoryLang.MetaDescription; Catalog.Cat_LinkRewrite = CategoryLang.LinkRewrite; } bool find_parent = false; if (Category.IDParent != Core.Global.CurrentShop.IDCategory) { if (!CatalogRepository.ExistPre_Id((int)Category.IDParent)) { // todo import catalogue depuis prestashop Core.ImportPrestashop.ImportCatalogue ImportCatalogue = new ImportPrestashop.ImportCatalogue(); ImportCatalogue.Exec((int)Category.IDParent); find_parent = CatalogRepository.ExistPre_Id((int)Category.IDParent); } else { find_parent = true; } if (find_parent) { Catalog.Cat_Level = Category.LevelDepth; } } else { Catalog.Cat_Level = Category.LevelDepth; } //Catalog.Cat_Position = (Int32)Category.Position; Catalog.Cat_Active = Convert.ToBoolean(Category.Active); Catalog.Cat_Date = (Category.DateUpd != null && Category.DateUpd > new DateTime(1753, 1, 2)) ? Category.DateUpd : DateTime.Now.Date; CatalogRepository.Save(); int parent = (Category.IDParent != Core.Global.CurrentShop.IDCategory) ? CatalogRepository.ReadPre_Id((int)Category.IDParent).Cat_Id : 0; CatalogRepository.WriteParent(Catalog.Cat_Id, parent); } catch (Exception ex) { Core.Error.SendMailError(ex.ToString()); } }
private void ChangeChildrenToSyncCatalogs(Model.Local.Catalog catalog, bool toSync) { catalog.Cat_Sync = toSync; foreach (var child in catalog.Catalog2) { ChangeChildrenToSyncCatalogs(child, toSync); } }
public void Exec(Int32 F_CATALOGUESend, out List <String> log_out) { log = new List <string>(); try { Model.Local.CatalogRepository CatalogRepository = new Model.Local.CatalogRepository(); if (CatalogRepository.ExistSag_Id(F_CATALOGUESend) == false) { Model.Sage.F_CATALOGUERepository F_CATALOGUERepository = new Model.Sage.F_CATALOGUERepository(); Model.Sage.F_CATALOGUE F_CATALOGUE = F_CATALOGUERepository.ReadCatalogue(F_CATALOGUESend); string dft = Core.Global.RemovePurge(F_CATALOGUE.CL_Intitule, 128); Model.Local.Catalog Catalog = new Model.Local.Catalog() { Cat_Name = dft, Cat_Description = F_CATALOGUE.CL_Intitule, Cat_MetaTitle = dft, Cat_MetaDescription = dft, Cat_MetaKeyword = Core.Global.RemovePurgeMeta(dft, 255), Cat_LinkRewrite = Core.Global.ReadLinkRewrite(dft), Cat_Active = true, Cat_Date = DateTime.Now, Cat_Sync = true, Cat_Level = 2, Sag_Id = F_CATALOGUE.cbMarq }; //if (F_CATALOGUERepository.ExistParent(F_CATALOGUE.CL_NoParent.Value)) //{ // Model.Sage.F_CATALOGUE F_CATALOGUEParent = F_CATALOGUERepository.ReadParent(F_CATALOGUE.CL_NoParent.Value); // Catalog.Cat_Parent = F_CATALOGUEParent.cbMarq; //} //<YH> 19/11/2012 : L'usage du Cat_Parent a été modifié //<JG> 29/01/2013 Correction récupération du Cat_Id par rapport au cbMarq du parent dans la base locale et non au CL_No // <JG> 07/10/2016 correction calcul niveau catalogue si import des enfants sans les parents if (F_CATALOGUERepository.ExistParent(F_CATALOGUE.CL_NoParent.Value) && CatalogRepository.ExistSag_Id(F_CATALOGUE.F_CATALOGUE1.cbMarq)) { Model.Local.Catalog parent = CatalogRepository.ReadSag_Id(F_CATALOGUE.F_CATALOGUE1.cbMarq); Catalog.Cat_Parent = parent.Cat_Id; Catalog.Cat_Level = parent.Cat_Level + 1; } CatalogRepository.Add(Catalog); log.Add("IC10- Import du catalogue Sage [ " + F_CATALOGUE.ComboText + " ]"); } } catch (Exception ex) { Core.Error.SendMailError("IC01- Une erreur est survenue : " + ex.ToString()); } finally { log_out = log; } }
private void ChangeParentToSyncCatalogs(Model.Local.Catalog catalog, bool toSync) { catalog.Cat_Sync = toSync; foreach (var parent in Catalogs) { if (toSync) { foreach (var child in parent.Catalog2) { if (child.Cat_Id.Equals(catalog.Cat_Id)) { ChangeParentToSyncCatalogs(parent, toSync); } } } else { bool find = false; bool atLeastOne = false; foreach (var child in parent.Catalog2) { if (child.Cat_Id.Equals(catalog.Cat_Id)) { find = true; break; } } if (find) { foreach (var child in parent.Catalog2) { if (child.Cat_Sync) { atLeastOne = true; break; } } if (!atLeastOne) { foreach (var child in parent.Catalog2) { if (child.Cat_Id.Equals(catalog.Cat_Id)) { ChangeParentToSyncCatalogs(parent, toSync); } } } } } } }
private void ChangeLevelChilds(Model.Local.Catalog Catalog) { if (Catalog.Catalog2 != null && Catalog.Catalog2.Count > 0) { foreach (Model.Local.Catalog child in Catalog.Catalog2) { child.Cat_Level = Catalog.Cat_Level + 1; ChangeLevelChilds(child); } } }
public void ChangeToSyncCatalogs(Model.Local.Catalog catalog, bool toSync) { if (!ChangeParentToSyncIsBusy) { ChangeChildrenToSyncCatalogs(catalog, toSync); } ChangeParentToSyncIsBusy = true; ChangeParentToSyncCatalogs(catalog, toSync); ChangeParentToSyncIsBusy = false; }
//public void Exec(Int32 CategorySend) //{ // try // { // if (CategorySend != 1) // { // CatalogRepository CatalogRepository = new CatalogRepository(); // if (CatalogRepository.ExistPre_Id(CategorySend) == false) // { // PsCategoryLangRepository PsCategoryLangRepository = new PsCategoryLangRepository(); // if (PsCategoryLangRepository.ExistCategoryLang(CategorySend, Core.Global.Lang)) // { // PsCategoryRepository PsCategoryRepository = new PsCategoryRepository(); // PsCategory PsCategory = PsCategoryRepository.ReadId(CategorySend); // PsCategoryLang PsCategoryLang = PsCategoryLangRepository.ReadCategoryLang(CategorySend, Core.Global.Lang); // F_CATALOGUERepository F_CATALOGUERepository = new F_CATALOGUERepository(); // if (F_CATALOGUERepository.ExistIntituleNiveau(PsCategoryLang.Name, Convert.ToInt16(PsCategory.LevelDepth - 1))) // { // F_CATALOGUE F_CATALOGUE = F_CATALOGUERepository.ReadIntituleNiveau(PsCategoryLang.Name, Convert.ToInt16(PsCategory.LevelDepth - 1)); // Catalog Catalog = new Catalog() // { // Cat_Name = PsCategoryLang.Name, // Cat_Description = PsCategoryLang.Description, // Cat_Level = PsCategory.LevelDepth, // Cat_MetaTitle = PsCategoryLang.MetaTitle, // Cat_MetaKeyword = PsCategoryLang.MetaKeywords, // Cat_Active = Convert.ToBoolean(PsCategory.Active), // Cat_MetaDescription = PsCategoryLang.MetaDescription, // Cat_LinkRewrite = PsCategoryLang.LinkRewrite, // Cat_Sync = true, // Cat_Date = PsCategory.DateUpd, // Sag_Id = F_CATALOGUE.cbMarq, // Pre_Id = Convert.ToInt32(PsCategory.IDCategory) // }; // if (PsCategory.IDParent != 0 && PsCategory.IDParent != 1) // { // if (PsCategoryRepository.ExistId(Convert.ToInt32(PsCategory.IDParent))) // { // PsCategory PsCategoryParent = PsCategoryRepository.ReadId(Convert.ToInt32(PsCategory.IDParent)); // if (CatalogRepository.ExistPre_Id(Convert.ToInt32(PsCategoryParent.IDCategory))) // { // Catalog CatalogParent = CatalogRepository.ReadPre_Id(Convert.ToInt32(PsCategoryParent.IDCategory)); // Catalog.Cat_Parent = CatalogParent.Cat_Id; // } // } // } // CatalogRepository.Add(Catalog); // } // } // } // } // } // catch (Exception ex) // { // Core.Error.SendMailError(ex.ToString()); // } //} //public void Exec(Int32 CategorySend) //{ // try // { // if (CategorySend != 1) // { // CatalogRepository catalogs = new CatalogRepository(); // //Vérifie si le catalogue PS est référence dans PC // if (!catalogs.ExistPre_Id(CategorySend)) // { // PsCategoryLangRepository langs = new PsCategoryLangRepository(); // //Vérifie que le catalogue existe bien dans la langue définit dans PC // if (langs.ExistCategoryLang(CategorySend, Global.Lang,Global.CurrentShop.IDShop)) // { // PsCategoryRepository categories = new PsCategoryRepository(); // //Récupération du catalogue dans PS // PsCategory category = categories.ReadId(CategorySend); // PsCategoryLang lang = langs.ReadCategoryLang(CategorySend, Global.Lang, Global.CurrentShop.IDShop); // //Récupération de tous les catalogues S suceptible de correspondre au catalogue PS // List<F_CATALOGUE> correspondances = new List<F_CATALOGUE>( // new F_CATALOGUERepository().ReadIntituleNiveau(lang.Name, Convert.ToInt16(category.LevelDepth - 1))); // if (correspondances.Count > 0) // { // PsCategory parentPrestashop = null; // //Récupération du parent dans PS // //Le catalogue 1 correspond à au noeud racine "Accueil" dans PS (il n'est ni utilisable, ni supprimable, ni exportable) // if (category.IDParent != 0 && category.IDParent != 1) // parentPrestashop = categories.ReadId(Convert.ToInt32(category.IDParent)); // Catalog nouveauCatalogue = null; // if (correspondances.Count == 1) // nouveauCatalogue = GetCatalogue(category, lang, correspondances[0].cbMarq); // else if (correspondances.Count > 1) // foreach (var correspondanceSage in correspondances) // if (correspondanceSage.CL_NoParent.HasValue) // { // //Récupération de la référence au parent de la correspondance en cours dans PC // Catalog parentCorrespondance = catalogs.ReadSag_Id(correspondanceSage.CL_NoParent.Value); // //Comparaison de l'ID de la réf PS du parent de la correspondance avec l'id du parent PS. // if (parentCorrespondance != null) // if (parentCorrespondance.Pre_Id == parentPrestashop.IDCategory) // { // nouveauCatalogue = GetCatalogue(category, lang, correspondanceSage.cbMarq); // break; // } // } // if (nouveauCatalogue != null && parentPrestashop != null) // { // //Si l'identifiant PS du parent existe dans PC // if (catalogs.ExistPre_Id(Convert.ToInt32(parentPrestashop.IDCategory))) // nouveauCatalogue.Cat_Parent = catalogs.ReadPre_Id(Convert.ToInt32(parentPrestashop.IDCategory)).Sag_Id; // } // catalogs.Add(nouveauCatalogue); // } // } // } // } // } // catch (Exception ex) // { // Core.Error.SendMailError(ex.ToString()); // } //} public void Exec(Int32 CategorySend) { try { if (CategorySend != Core.Global.CurrentShop.IDCategory) { Model.Local.CatalogRepository CatalogRepository = new Model.Local.CatalogRepository(); //Vérifie si le catalogue PS est référence dans PC if (!CatalogRepository.ExistPre_Id(CategorySend)) { Model.Prestashop.PsCategoryLangRepository PsCategoryLangRepository = new Model.Prestashop.PsCategoryLangRepository(); //Vérifie que le catalogue existe bien dans la langue définit dans PC if (PsCategoryLangRepository.ExistCategoryLang(CategorySend, Global.Lang, Core.Global.CurrentShop.IDShop)) { Model.Prestashop.PsCategoryRepository PsCategoryRepository = new Model.Prestashop.PsCategoryRepository(); //Récupération du catalogue dans PS Model.Prestashop.PsCategory PsCategory = PsCategoryRepository.ReadId((UInt32)CategorySend); Model.Prestashop.PsCategoryLang PsCategoryLang = PsCategoryLangRepository.ReadCategoryLang(CategorySend, Global.Lang, Core.Global.CurrentShop.IDShop); Model.Prestashop.PsCategory parentPrestashop = null; //Récupération du parent dans PS //Le catalogue 1 correspond à au noeud racine "Accueil" dans PS (il n'est ni utilisable, ni supprimable, ni exportable) if (PsCategory.IDParent != 0 && PsCategory.IDParent != 1 && PsCategory.IDParent != Core.Global.CurrentShop.IDShop) { parentPrestashop = PsCategoryRepository.ReadId(PsCategory.IDParent); } Model.Local.Catalog nouveauCatalogue = GetCatalogue(PsCategory, PsCategoryLang, 0); if (nouveauCatalogue != null && parentPrestashop != null) { //Si l'identifiant PS du parent existe dans PC if (CatalogRepository.ExistPre_Id(Convert.ToInt32(parentPrestashop.IDCategory))) { nouveauCatalogue.Cat_Parent = CatalogRepository.ReadPre_Id(Convert.ToInt32(parentPrestashop.IDCategory)).Cat_Id; } } CatalogRepository.Add(nouveauCatalogue); } } } } catch (Exception ex) { Core.Error.SendMailError(ex.ToString()); } }
public void CreateCatalog(Model.Local.Catalog parent) { Model.Local.Catalog local = new Model.Local.Catalog() { Name = "Nouveau catalogue", Cat_Level = (parent == null) ? 2 : parent.Cat_Level + 1, Cat_Parent = (parent == null) ? 0 : parent.Cat_Id, Cat_Date = DateTime.Now, Sag_Id = 0, Pre_Id = null, }; CatalogRepository.Add(local); this.LoadCatalogs(); }
public void LoadCatalogs() { IsBusy = true; LoadingStep = "Chargement des catalogues ..."; Application.Current.Dispatcher.BeginInvoke(new Action(delegate { Mouse.OverrideCursor = Cursors.Wait; }), null); CatalogRepository = new Model.Local.CatalogRepository(); Catalogs = new ObservableCollection <Model.Local.Catalog>(CatalogRepository.ListParent(0)); SelectedCatalog = null; LoadingStep = string.Empty; IsBusy = false; Application.Current.Dispatcher.BeginInvoke(new Action(delegate { Mouse.OverrideCursor = null; }), null); }
public void DeleteCatalog(Model.Local.Catalog catalog) { Model.Local.ArticleCatalogRepository ArticleCatalogRepository = new Model.Local.ArticleCatalogRepository(); //Suppression de tous les liens articles foreach (var articleCatalog in ArticleCatalogRepository.ListCatalog(catalog.Cat_Id)) { ArticleCatalogRepository.Delete(articleCatalog); } //Suppression image Model.Local.CatalogImageRepository CatalogImageRepository = new Model.Local.CatalogImageRepository(); if (catalog.CatalogImage != null && catalog.CatalogImage.Count > 0) { foreach (Model.Local.CatalogImage catalogimage in CatalogImageRepository.ListCatalog(catalog.Cat_Id)) { catalogimage.EraseFiles(); CatalogImageRepository.Delete(catalogimage); } } CatalogRepository.Delete(catalog); // <JG> 04/02/2013 ajout de la tentative de suppression du catalogue Prestashop try { if (catalog.Pre_Id != null) { Model.Prestashop.PsCategoryRepository PsCategoryRepository = new Model.Prestashop.PsCategoryRepository(); if (PsCategoryRepository.ExistId((int)catalog.Pre_Id)) { PsCategoryRepository.Delete(PsCategoryRepository.ReadId((UInt32)catalog.Pre_Id)); Core.Global.LaunchAlternetis_RegenerateCategoryTree(); Core.Global.LaunchAlternetis_ClearSmartyCache(); } } } catch (Exception ex) { Core.Error.SendMailError(ex.ToString()); } this.LoadCatalogs(); }
private Model.Local.Catalog GetCatalogue(Model.Prestashop.PsCategory category, Model.Prestashop.PsCategoryLang lang, int sageId) { Model.Local.Catalog result = new Model.Local.Catalog() { Cat_Name = lang.Name, Cat_Description = lang.Description, Cat_Level = category.LevelDepth, Cat_MetaTitle = lang.MetaTitle, Cat_MetaKeyword = lang.MetaKeywords, Cat_Active = Convert.ToBoolean(category.Active), Cat_MetaDescription = lang.MetaDescription, Cat_LinkRewrite = lang.LinkRewrite, Cat_Sync = true, Cat_Date = (category.DateUpd != null && category.DateUpd > new DateTime(1753, 1, 2)) ? category.DateUpd : DateTime.Now.Date, Sag_Id = sageId, Pre_Id = Convert.ToInt32(category.IDCategory) }; return(result); }
public AssociateCatalog(Model.Local.Article item, Model.Local.Catalog localParent) : base(null, localParent) { Item = item; }
public SyncCatalog(Model.Local.Catalog localParent) : base(null, localParent) { }
public void Exec(Int32 CatalogSend) { try { Model.Local.CatalogRepository CatalogRepository = new Model.Local.CatalogRepository(); Model.Local.Catalog Catalog = CatalogRepository.ReadId(CatalogSend); // if the catalog have a parent Boolean isSync = false; uint IdParent = 0; if (Catalog.Cat_Parent != 0) { if (CatalogRepository.ExistId(Catalog.Cat_Parent)) { Model.Local.Catalog CatalogParent = CatalogRepository.ReadId(Catalog.Cat_Parent); if (CatalogParent.Pre_Id != null && CatalogParent.Pre_Id != 0) { IdParent = (uint)CatalogParent.Pre_Id.Value; isSync = true; } } } // default IdParent is defined on shop in Prestashop else { isSync = true; IdParent = Global.CurrentShop.IDCategory; } if (isSync == true) { Boolean isCategory = false; Model.Prestashop.PsCategory Category = new Model.Prestashop.PsCategory(); Model.Prestashop.PsCategoryRepository CategoryRepository = new Model.Prestashop.PsCategoryRepository(); // If the Catalog have a connection with Prestashop if (Catalog.Pre_Id != null) { Catalog.Cat_Date = Catalog.Cat_Date.AddMilliseconds(-Catalog.Cat_Date.Millisecond); if (CategoryRepository.ExistId(Catalog.Pre_Id.Value)) { Category = CategoryRepository.ReadId((UInt32)Catalog.Pre_Id.Value); isCategory = true; if (Category.DateUpd.Ticks > Catalog.Cat_Date.Ticks) { this.ExecDistantLocal(Category, Catalog, CatalogRepository); } else if (Category.DateUpd.Ticks < Catalog.Cat_Date.Ticks) { this.ExecLocalDistant(Catalog, Category, CatalogRepository, CategoryRepository, isCategory, IdParent); } else { ExecGroupsLocalDistant(Category); } } } // We need to sync Catalog with Category else { this.ExecLocalDistant(Catalog, Category, CatalogRepository, CategoryRepository, isCategory, IdParent); } } } catch (Exception ex) { Core.Error.SendMailError(ex.ToString()); } }
private void ExecLocalDistant(Model.Local.Catalog Catalog, Model.Prestashop.PsCategory Category, Model.Local.CatalogRepository CatalogRepository, Model.Prestashop.PsCategoryRepository CategoryRepository, Boolean isCategory, uint IdParent) { try { bool flag_move = (Category.IDParent != IdParent); Core.Temp.SyncCatalogue_ClearSmartyCache = true; Core.Temp.SyncCatalogue_RegenerateTree = true; // Assign data from Catalog to Category //Category.Position = (uint)Catalog.Cat_Position; Category.Active = Convert.ToByte(Catalog.Cat_Active); Category.LevelDepth = (Byte)Catalog.Cat_Level; Category.IDParent = IdParent; Category.DateUpd = Catalog.Cat_Date; // use cron for function "regenerateEntireNtree" //Category.NLeft = CategoryRepository.ReadId(IdParent).NLeft; //Category.NRight = CategoryRepository.ReadId(IdParent).NRight; Category.IDShopDefault = Global.CurrentShop.IDShop; if (isCategory == false) { Category.DateAdd = Category.DateUpd; Category.IsRootCategory = Convert.ToSByte(false); Category.Position = 0; CategoryRepository.Add(Category, Global.CurrentShop.IDShop); // We assign the CategoryId to Catalog Catalog.Pre_Id = (Int32)Category.IDCategory; CatalogRepository.Save(); } else { CategoryRepository.Save(); if (flag_move) { Model.Prestashop.PsCategoryShopRepository PsCategoryShopRepository = new Model.Prestashop.PsCategoryShopRepository(); if (PsCategoryShopRepository.ExistCategoryShop(Category.IDCategory, Core.Global.CurrentShop.IDShop)) { Model.Prestashop.PsCategoryShop PsCategoryShop = PsCategoryShopRepository.ReadCategoryShop(Category.IDCategory, Core.Global.CurrentShop.IDShop); PsCategoryShop.Position = new Model.Prestashop.PsCategoryRepository().ReadNextPosition(1, Category, (uint)Core.Global.CurrentShop.IDShop); PsCategoryShopRepository.Save(); Category.Position = PsCategoryShop.Position; CategoryRepository.Save(); } } } // We need to update CategoryLang too Boolean isCategoryLang = false; Model.Prestashop.PsCategoryLangRepository CategoryLangRepository = new Model.Prestashop.PsCategoryLangRepository(); Model.Prestashop.PsCategoryLang CategoryLang = new Model.Prestashop.PsCategoryLang(); if (CategoryLangRepository.ExistCategoryLang((Int32)Category.IDCategory, Core.Global.Lang, Global.CurrentShop.IDShop)) { CategoryLang = CategoryLangRepository.ReadCategoryLang((Int32)Category.IDCategory, Core.Global.Lang, Global.CurrentShop.IDShop); isCategoryLang = true; } CategoryLang.Name = Core.Global.RemovePurge(Catalog.Cat_Name, 128); CategoryLang.Description = Catalog.Cat_Description; CategoryLang.LinkRewrite = Core.Global.ReadLinkRewrite(Catalog.Cat_LinkRewrite); CategoryLang.MetaTitle = Core.Global.RemovePurge(Catalog.Cat_MetaTitle, 70); CategoryLang.MetaDescription = Core.Global.RemovePurge(Catalog.Cat_MetaDescription, 160); CategoryLang.MetaKeywords = Core.Global.RemovePurgeMeta(Catalog.Cat_MetaKeyword, 255); if (isCategoryLang == false) { CategoryLang.IDShop = Global.CurrentShop.IDShop; CategoryLang.IDLang = (uint)Core.Global.Lang; CategoryLang.IDCategory = Category.IDCategory; CategoryLangRepository.Add(CategoryLang); } else { CategoryLangRepository.Save(); } // <JG> 26/12/2012 ajout insertion autres langues actives si non renseignées try { Model.Prestashop.PsLangRepository PsLangRepository = new Model.Prestashop.PsLangRepository(); foreach (Model.Prestashop.PsLang PsLang in PsLangRepository.ListActive(1, Global.CurrentShop.IDShop)) { if (!CategoryLangRepository.ExistCategoryLang((int)Category.IDCategory, PsLang.IDLang, Global.CurrentShop.IDShop)) { CategoryLang = new Model.Prestashop.PsCategoryLang(); CategoryLang.IDShop = Global.CurrentShop.IDShop; CategoryLang.IDCategory = Category.IDCategory; CategoryLang.IDLang = PsLang.IDLang; CategoryLang.Name = Core.Global.RemovePurge(Catalog.Cat_Name, 128); CategoryLang.Description = Catalog.Cat_Description; CategoryLang.LinkRewrite = Core.Global.ReadLinkRewrite(Catalog.Cat_LinkRewrite); CategoryLang.MetaTitle = Core.Global.RemovePurge(Catalog.Cat_MetaTitle, 70); CategoryLang.MetaDescription = Core.Global.RemovePurge(Catalog.Cat_MetaDescription, 160); CategoryLang.MetaKeywords = Core.Global.RemovePurgeMeta(Catalog.Cat_MetaKeyword, 255); CategoryLangRepository.Add(CategoryLang); } } } catch (Exception ex) { Core.Error.SendMailError(ex.ToString()); } this.ExecGroupsLocalDistant(Category); // We need to send pictures this.ExecLocalDistantImage(Catalog, Category); } catch (Exception ex) { Core.Error.SendMailError(ex.ToString()); } }
private void ExecLocalDistantImage(Model.Local.Catalog Catalog, Model.Prestashop.PsCategory PsCategory) { // We need to send pictures Model.Local.CatalogImageRepository CatalogImageRepository = new Model.Local.CatalogImageRepository(); Model.Local.CatalogImage CatalogImage = CatalogImageRepository.ReadCatalog(Catalog.Cat_Id, true); if (CatalogImage != null) { Model.Prestashop.PsImageTypeRepository PsImageTypeRepository = new Model.Prestashop.PsImageTypeRepository(); List <Model.Prestashop.PsImageType> ListPsImageType = PsImageTypeRepository.ListCategorie(1); if (Core.Global.GetConfig().ConfigFTPActive) { String FTP = Core.Global.GetConfig().ConfigFTPIP; String User = Core.Global.GetConfig().ConfigFTPUser; String Password = Core.Global.GetConfig().ConfigFTPPassword; string extension = System.IO.Path.GetExtension(CatalogImage.ImaCat_Image); String PathImgTmp = System.IO.Path.Combine(Global.GetConfig().Folders.TempCatalog, String.Format("{0}" + extension, CatalogImage.ImaCat_Id)); if (System.IO.File.Exists(PathImgTmp)) { string ftpfullpath = FTP + "/img/c/" + PsCategory.IDCategory + ".jpg"; System.Net.FtpWebRequest ftp = (System.Net.FtpWebRequest)System.Net.FtpWebRequest.Create(ftpfullpath); ftp.Credentials = new System.Net.NetworkCredential(User, Password); //userid and password for the ftp server to given ftp.UseBinary = true; ftp.UsePassive = true; ftp.EnableSsl = Core.Global.GetConfig().ConfigFTPSSL; ftp.Method = System.Net.WebRequestMethods.Ftp.UploadFile; System.IO.FileStream fs = System.IO.File.OpenRead(PathImgTmp); byte[] buffer = new byte[fs.Length]; fs.Read(buffer, 0, buffer.Length); fs.Close(); System.IO.Stream ftpstream = ftp.GetRequestStream(); ftpstream.Write(buffer, 0, buffer.Length); ftpstream.Close(); ftp.Abort(); foreach (Model.Prestashop.PsImageType PsImageType in ListPsImageType) { String PathImg = System.IO.Path.Combine(Global.GetConfig().Folders.RootCatalog, String.Format("{0}-{1}" + extension, CatalogImage.ImaCat_Id, PsImageType.Name)); if (System.IO.File.Exists(PathImg)) { ftpfullpath = FTP + "/img/c/" + PsCategory.IDCategory + "-" + PsImageType.Name + ".jpg"; ftp = (System.Net.FtpWebRequest)System.Net.FtpWebRequest.Create(ftpfullpath); ftp.Credentials = new System.Net.NetworkCredential(User, Password); //userid and password for the ftp server to given ftp.UseBinary = true; ftp.UsePassive = true; ftp.EnableSsl = Core.Global.GetConfig().ConfigFTPSSL; ftp.Method = System.Net.WebRequestMethods.Ftp.UploadFile; fs = System.IO.File.OpenRead(PathImg); buffer = new byte[fs.Length]; fs.Read(buffer, 0, buffer.Length); fs.Close(); ftpstream = ftp.GetRequestStream(); ftpstream.Write(buffer, 0, buffer.Length); ftpstream.Close(); ftp.Abort(); } } Core.Temp.SyncCatalogue_ClearSmartyCache = true; Core.Temp.SyncCatalogue_RegenerateTree = true; } } } }
public DeplacementCatalogue(Model.Local.Catalog Catalog) { InitializeComponent(); DataContext = new DeplacementCatalogueContext(); DataContext.TargetCatalog = Catalog; }
//private ImportCatalog parent; //public ImportCatalog Parent //{ // get { return parent; } // set { parent = value; OnPropertyChanged("Parent"); } //} //private bool checkChild; //public bool CheckChild //{ // get { return checkChild; } // set // { // checkChild = value; // OnPropertyChanged("CheckChild"); // } //} #endregion #region Constructors //public ImportCatalog(Model.Sage.F_CATALOGUE F_CATALOGUE, Model.Local.Catalog local, Model.Internal.ImportCatalog parent) // : base(F_CATALOGUE, local) //{ // CheckChild = true; // Parent = parent; // //ToImport = !ExistToLocal; // ToImport = false; //} public ImportCatalog(Model.Local.Catalog localParent) : base(null, localParent) { //ToImport = !ExistToLocal; //ToImport = false; }