public static string GetCatalogXMLPath(string CatalogPath, int portalID, int languageID)
{
if (!File.Exists(CatalogPath))
{
XmlDocument xmlDoc = new XmlDocument();
XmlElement xmlRoot = xmlDoc.CreateElement("Catalogs");
xmlDoc.AppendChild(xmlRoot);
List<Catalog> Catalogs = GetCatalogs(portalID, languageID);
List<Catalog> parentCatalogs = Catalogs != null ? Catalogs.Where(m => m.ParentCalalogID == 0).ToList() : null;
if (parentCatalogs != null)
foreach (Catalog item in parentCatalogs)
{
XmlElement xmlEle = xmlDoc.CreateElement("Catalog");
xmlRoot.AppendChild(xmlEle);
SetAttributeCatalogNode(xmlDoc, xmlEle, item);
SetElementChildCatalog(xmlDoc, xmlEle, Catalogs, item.ID);
}
XmlWriter xmlWriter = XmlWriter.Create(CatalogPath);
xmlDoc.WriteTo(xmlWriter);
xmlWriter.Flush();
xmlWriter.Close();
}
return CatalogPath;
}