Exemplo n.º 1
0
        [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);
        }
Exemplo n.º 2
0
        [EditArticles] public static TeamMentor_Article xmlDB_Preview_Article(this TeamMentor_Article article)
        {
            article.sanitize();

            return(article);
        }