[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); }
public static Tracking_Application saveLog(this Tracking_Application tracking) { try { var logData = PublicDI.log.LogRedirectionTarget.prop("LogData").str() ; if (logData.notNull()) { //tracking.Name = DateTime.Now.str().safeFileName(); var logFile = tracking.LogFilePath; //var logFile = tracking.Location.pathCombine("ApplicationLog.txt"); "Saving Application Tracking Log to: {0}".info(logFile); var tmArticle = new TeamMentor_Article { Metadata = {Title = "Log Files"}, Content = {Data = {Value = logData}} }; tmArticle.saveAs(logFile + ".xml"); logData.saveAs(logFile); } } catch (Exception ex) { ex.log("[Tracking_Application] in saveLog"); } return tracking; }
public static Tracking_Application saveLog(this Tracking_Application tracking) { try { var logData = PublicDI.log.LogRedirectionTarget.prop("LogData").str(); if (logData.notNull()) { //tracking.Name = DateTime.Now.str().safeFileName(); var logFile = tracking.LogFilePath; //var logFile = tracking.Location.pathCombine("ApplicationLog.txt"); "Saving Application Tracking Log to: {0}".info(logFile); var tmArticle = new TeamMentor_Article { Metadata = { Title = "Log Files" }, Content = { Data = { Value = logData } } }; tmArticle.saveAs(logFile + ".xml"); logData.saveAs(logFile); } } catch (Exception ex) { ex.log("[Tracking_Application] in saveLog"); } return(tracking); }
public static bool article_Save(this TM_FileStorage tmFileStorage, TeamMentor_Article article) { editArticles.demand(); var libraryId = article.Metadata.Library_Id; var guidanceXmlPath = tmFileStorage.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; }
[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); }