public HierarchicalCatalog(Model.Sage.F_CATALOGUE sageParent, Model.Local.Catalog localParent) { Children = new ObservableCollection <TCatalog>(); Sage = sageParent; Local = localParent; }
private IEnumerable <Model.Sage.F_CATALOGUE> GetCatalogs(Model.Sage.F_CATALOGUE catalog) { if (catalog == null) { foreach (var root in Catalogs) { yield return(root); foreach (var child in GetCatalogs(root)) { yield return(child); } } } else { foreach (var root in catalog.SortChildren) { yield return(root); foreach (var child in GetCatalogs(root)) { yield return(child); } } } }
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 IEnumerable <Model.Sage.F_CATALOGUE> GetToImportCatalogs(Model.Sage.F_CATALOGUE catalog) { foreach (var child in catalog.SortChildren) { if (child.ToImport) { yield return(child); } foreach (var current in GetToImportCatalogs(child)) { yield return(current); } } }
public void ChangeToImportCatalogs(Model.Sage.F_CATALOGUE catalog, bool toImport) { if (AutoSelectCatalogParent) { // <JG> 12/07/2013 gestion (dé)sélection auto parents Model.Sage.F_CATALOGUE current = catalog; if (current.F_CATALOGUE1 != null) { do { current = current.F_CATALOGUE1; if ((toImport && current.F_CATALOGUE2.Count(c => c.ExistLocal == false && c.ToImport == toImport) == 1) || (!toImport && current.F_CATALOGUE2.Count(c => c.ExistLocal == false && c.ToImport == !toImport) == 0)) { current.CheckChild = false; current.ToImport = toImport; current.CheckChild = true; } }while (current.F_CATALOGUE1 != null); } } if (!catalog.ExistLocal) { catalog.ToImport = toImport; } if (AutoSelectCatalogEnfant || !toImport) { if (catalog.CheckChild) { foreach (var child in catalog.SortChildren) { ChangeToImportCatalogs(child, toImport); } } } }