[EditArticles] public static bool xmlDB_Save_Article(this TeamMentor_Article article, Guid libraryId, TM_Xml_Database tmDatabase) { if (libraryId == Guid.Empty) // ensure we have a library to put the Article in { "[xmlDB_Save_GuidanceItem] no LibraryId was provided".error(); return(false); } article.sanitize(); article.Metadata.Library_Id = libraryId; // ensure the LibraryID is correct if (article.serialize(false).notValid()) // make sure the article can be serilialized correctly { return(false); } article.update_Cache_GuidanceItems(tmDatabase); // add it to in Memory cache if (tmDatabase.UsingFileStorage) // save to disk { var guidanceXmlPath = tmDatabase.getXmlFilePathForGuidanceId(article.Metadata.Id, libraryId); if (guidanceXmlPath.valid()) { "Saving GuidanceItem {0} to {1}".info(article.Metadata.Id, guidanceXmlPath); article.saveAs(guidanceXmlPath); return(guidanceXmlPath.fileExists()); } } return(true); }
[ReadArticles] public static string xmlDB_guidanceItemXml(this TM_Xml_Database tmDatabase, Guid guidanceItemId) { if (guidanceItemId == Guid.Empty) { return(null); } var guidanceXmlPath = tmDatabase.getXmlFilePathForGuidanceId(guidanceItemId); return(guidanceXmlPath.fileContents());//.xmlFormat(); }
[EditArticles] public static bool xmlDB_Save_Article(this TeamMentor_Article article, Guid libraryId, TM_Xml_Database tmDatabase) { if (libraryId == Guid.Empty) // ensure we have a library to put the Article in { "[xmlDB_Save_GuidanceItem] no LibraryId was provided".error(); return(false); } if (article.Content.DataType.lower() == "html") // tidy the html { var cdataContent = article.Content.Data.Value.replace("]]>", "]] >"); // xmlserialization below will break if there is a ]]> in the text var tidiedHtml = cdataContent.tidyHtml(); article.Content.Data.Value = tidiedHtml; if (article.serialize(false).inValid()) // see if the tidied content can be serialized and if not use the original data { article.Content.Data.Value = cdataContent; } } article.Metadata.Library_Id = libraryId; // ensure the LibraryID is correct if (article.serialize(false).notValid()) // make sure the article can be serilialized correctly { return(false); } article.update_Cache_GuidanceItems(tmDatabase); // add it to in Memory cache if (tmDatabase.UsingFileStorage) // save to disk { var guidanceXmlPath = tmDatabase.getXmlFilePathForGuidanceId(article.Metadata.Id, libraryId); if (guidanceXmlPath.valid()) { "Saving GuidanceItem {0} to {1}".info(article.Metadata.Id, guidanceXmlPath); article.saveAs(guidanceXmlPath); return(guidanceXmlPath.fileExists()); } } return(true); }
public static bool xmlDB_Save_Article(this TeamMentor_Article article, Guid libraryId, TM_Xml_Database tmDatabase) { if (libraryId == Guid.Empty) // ensure we have a library to put the Article in { "[xmlDB_Save_GuidanceItem] no LibraryId was provided".error(); return false; } if(article.Content.DataType.lower() == "html") // tidy the html { var cdataContent= article.Content.Data.Value.replace("]]>", "]] >"); // xmlserialization below will break if there is a ]]> in the text var tidiedHtml = cdataContent.tidyHtml(); article.Content.Data.Value = tidiedHtml; if (article.serialize(false).inValid()) // see if the tidied content can be serialized and if not use the original data article.Content.Data.Value = cdataContent; } article.Metadata.Library_Id = libraryId; // ensure the LibraryID is correct if (article.serialize(false).notValid()) // make sure the article can be serilialized correctly return false; article.update_Cache_GuidanceItems(tmDatabase); // add it to in Memory cache if(tmDatabase.UsingFileStorage) // save to disk { var guidanceXmlPath = tmDatabase.getXmlFilePathForGuidanceId(article.Metadata.Id, libraryId); "Saving GuidanceItem {0} to {1}".info(article.Metadata.Id, guidanceXmlPath); article.saveAs(guidanceXmlPath); return guidanceXmlPath.fileExists(); } return true; }
public static string getXmlFilePathForGuidanceId(this TM_Xml_Database tmDatabase, Guid guidanceItemId) { return(tmDatabase.getXmlFilePathForGuidanceId(guidanceItemId, Guid.Empty)); }
public static bool xmlDB_Save_Article(this TeamMentor_Article article, Guid libraryId, TM_Xml_Database tmDatabase) { if (libraryId == Guid.Empty) // ensure we have a library to put the Article in { "[xmlDB_Save_GuidanceItem] no LibraryId was provided".error(); return false; } //article.sanitize(); article.Metadata.Library_Id = libraryId; // ensure the LibraryID is correct if (article.serialize(false).notValid()) // make sure the article can be serilialized correctly return false; article.update_Cache_GuidanceItems(tmDatabase); // add it to in Memory cache if(tmDatabase.UsingFileStorage) // save to disk { var guidanceXmlPath = tmDatabase.getXmlFilePathForGuidanceId(article.Metadata.Id, libraryId); if (guidanceXmlPath.valid()) { "Saving GuidanceItem {0} to {1}".info(article.Metadata.Id, guidanceXmlPath); article.saveAs(guidanceXmlPath); return guidanceXmlPath.fileExists(); } } return true; }