/* public static List<Guid> guidanceItem_SearchTitle(this TM_Xml_Database tmDatabase, string searchText) * { * var maxNumberOfItemsToReturn = 250000; * var lowercaseSearchText = searchText.lower(); * return (from guidanceItem in tmDatabase.GuidanceItems * where guidanceItem.title.lower().contains(lowercaseSearchText) || * guidanceItem.title.regEx(searchText) * select new Item() { Key =guidanceItem.title, * Value= guidanceItem.guidanceItemId.str() } * ).Take(maxNumberOfItemsToReturn) * .toList(); * }*/ public static List <TeamMentor_Article> getGuidanceItems_from_LibraryFolderOrView(this TM_Xml_Database tmDatabase, Guid id) { if (tmDatabase.tmLibrary(id).notNull()) // first search on the library { return(tmDatabase.tmGuidanceItems(id)); } if (tmDatabase.tmFolder(id).notNull()) // the on the folders { return(tmDatabase.xmlDB_GuidanceItems(tmDatabase.tmFolder(id))); } if (tmDatabase.tmView(id).notNull()) // then on the views { return(tmDatabase.xmlDB_GuidanceItems(tmDatabase.tmView(id).guidanceItems)); } return(null); }
public static List <TeamMentor_Article> getGuidanceItemsInView(this TM_Xml_Database tmDatabase, Guid viewId) { var tmView = tmDatabase.tmView(viewId); if (tmView.notNull()) { var guidanceItems = new List <TeamMentor_Article>(); foreach (var guidanceItemId in tmView.guidanceItems) { if (TM_Xml_Database.Current.Cached_GuidanceItems.hasKey(guidanceItemId)) { guidanceItems.add(TM_Xml_Database.Current.Cached_GuidanceItems[guidanceItemId]); } else { "[getGuidanceItemsInView]: in view ({0} {1}) could not find guidanceItem for id {2}".error(tmView.caption, tmView.viewId, guidanceItemId); } } return(guidanceItems); } //if (TM_Xml_Database.Current.GuidanceItems_InViews.hasKey(viewId)) // return TM_Xml_Database.Current.GuidanceItems_InViews[viewId]; "[TM_Xml_Database] getGuidanceItemsInView, requested viewId was not mapped: {0}".error(viewId); return(new List <TeamMentor_Article>()); }
[EditArticles] public static View_V3 newView(this TM_Xml_Database tmDatabase, Guid parentFolderId, View tmView) { var view = tmDatabase.xmlDB_NewView(parentFolderId, tmView); return((view.notNull()) ? tmDatabase.tmView(view.id.guid()) : null); }
[EditArticles] public static bool xmlDB_MoveViewToFolder(this TM_Xml_Database tmDatabase, Guid viewId, Guid targetFolderId, Guid targetLibraryId) { UserRole.EditArticles.demand(); try { var viewToMove = tmDatabase.xmlDB_View(viewId); if (viewToMove.notNull()) { var tmView = tmDatabase.tmView(viewToMove.id.guid()); //"found viewToMove : {0}".info(viewToMove.caption); var tmSourceLibrary = tmDatabase.tmLibrary(tmView.libraryId); var tmTargetLibrary = tmDatabase.tmLibrary(targetLibraryId); tmDatabase.xmlDB_RemoveView(tmSourceLibrary, tmView.viewId); tmSourceLibrary.xmlDB_Save_GuidanceExplorer(tmDatabase); if (targetFolderId == Guid.Empty) // add view to Library root { var guidanceExplorer = tmTargetLibrary.guidanceExplorer(tmDatabase); guidanceExplorer.library.libraryStructure.view.Add(viewToMove); "Moved view to library root".info(); } else { var targetFolder = tmDatabase.xmlDB_Folder(targetFolderId); targetFolder.view.Add(viewToMove); "Moved view to folder : {0}".info(targetFolder.caption); } //if (tmTargetLibrary.Id != tmSourceLibrary.Id) tmTargetLibrary.xmlDB_Save_GuidanceExplorer(tmDatabase); return(true); } } catch (Exception ex) { ex.log(); } return(false); }