[EditArticles]  public static urn.microsoft.guidanceexplorer.Folder xmlDB_Add_Folder(this TM_Library tmLibrary, Guid parentFolderId, string folderCaption, TM_Xml_Database tmDatabase)
 {
     try
     {
         var newFolder = new urn.microsoft.guidanceexplorer.Folder
         {
             caption  = folderCaption,
             folderId = Guid.NewGuid().str()
         };
         var guidanceExplorer = tmLibrary.guidanceExplorer(tmDatabase);
         if (parentFolderId == Guid.Empty)
         {
             //adding a folder to the library
             guidanceExplorer.library.libraryStructure.folder.Add(newFolder);
         }
         else
         {
             //adding a folder to folder
             var folder = tmDatabase.xmlDB_Folder(tmLibrary.Id, parentFolderId);
             if (folder == null)
             {
                 "[xmlDB_Add_Folder] couldn't find parent folder (to add folder) with id: {0}".error(parentFolderId);
                 return(null);
             }
             folder.folder1.Add(newFolder);
         }
         guidanceExplorer.xmlDB_Save_GuidanceExplorer(tmDatabase);
         return(tmDatabase.xmlDB_Folder(tmLibrary.Id, newFolder.folderId.guid()));
     }
     catch (Exception ex)
     {
         ex.log();
         return(null);
     }
 }
 [EditArticles]  public static bool                                          xmlDB_RemoveView(this TM_Xml_Database tmDatabase, TM_Library tmLibrary, Guid viewId)
 {
     if (tmLibrary.isNull())
     {
         "in xmlDB_RemoveViewFromFolder provided tmLibrary was null".error();
     }
     else
     {
         var view = tmDatabase.xmlDB_View(viewId);
         if (view.notNull())
         {
             var guidanceExplorer = tmLibrary.guidanceExplorer(tmDatabase);
             if (guidanceExplorer.library.libraryStructure.view.contains(view))          // the view was in the library root
             {
                 guidanceExplorer.library.libraryStructure.view.remove(view);
             }
             else
             {
                 foreach (var folder in tmDatabase.xmlDB_Folders_All(tmLibrary.Id))
                 {
                     if (folder.view.contains(view))
                     {
                         folder.view.remove(view);
                     }
                 }
             }
             tmLibrary.xmlDB_Save_GuidanceExplorer(tmDatabase);
             return(true);
         }
     }
     return(false);
 }
 public static List <urn.microsoft.guidanceexplorer.View> xmlDB_Views_InLibraryRoot(this TM_Library tmLibrary, TM_Xml_Database tmDatabase)
 {
     try
     {
         return(tmLibrary.guidanceExplorer(tmDatabase).library.libraryStructure.view.toList());
     }
     catch
     {
         return(new List <urn.microsoft.guidanceexplorer.View>());
     }
 }
Exemple #4
0
        public static string xmlDB_Path_Library_RootFolder(this TM_Xml_Database tmDatabase, TM_Library tmLibrary)
        {
            var guidanceExplorer = tmLibrary.guidanceExplorer(tmDatabase);

            return(tmDatabase.xmlDB_Path_Library_RootFolder(guidanceExplorer));
        }
 public static string xmlDB_Path_Library_RootFolder(this TM_FileStorage tmFileStorage, TM_Library tmLibrary)
 {
     var guidanceExplorer = tmLibrary.guidanceExplorer(tmFileStorage.tmXmlDatabase());
     return tmFileStorage.xmlDB_Path_Library_RootFolder(guidanceExplorer);
 }
 public static bool xmlDB_RemoveView(this TM_Xml_Database tmDatabase, TM_Library tmLibrary, Guid viewId )
 {
     UserRole.EditArticles.demand();
     if (tmLibrary.isNull())
         "in xmlDB_RemoveViewFromFolder provided tmLibrary was null".error();
     else
     {
         var view = tmDatabase.xmlDB_View(viewId);
         if (view.notNull())
         {
             var guidanceExplorer = tmLibrary.guidanceExplorer(tmDatabase);
             if (guidanceExplorer.library.libraryStructure.view.contains(view))          // the view was in the library root
             {
                 guidanceExplorer.library.libraryStructure.view.remove(view);
             }
             else
             {
                 foreach (var folder in tmDatabase.xmlDB_Folders_All(tmLibrary.Id))
                 {
                     if (folder.view.contains(view))
                         folder.view.remove(view);
                 }
             }
             tmLibrary.xmlDB_Save_GuidanceExplorer(tmDatabase);
             return true;
         }
     }
     return false;
 }
 public static string xmlDB_Path_Library_RootFolder(this TM_Xml_Database tmDatabase, TM_Library tmLibrary)
 {
     var guidanceExplorer = tmLibrary.guidanceExplorer(tmDatabase);
     return tmDatabase.xmlDB_Path_Library_RootFolder(guidanceExplorer);
 }