public static TM_Xml_Database queue_Save_GuidanceItemsCache(this TM_Xml_Database tmDatabase) { if (tmDatabase.UsingFileStorage) { // do this on a separate thread so that we don't hang the current request if (thread_Save_GuidanceItemsCache.isNull()) { thread_Save_GuidanceItemsCache = O2Thread.mtaThread( () => { tmDatabase.sleep(1000, false); tmDatabase.save_GuidanceItemsToCache(); thread_Save_GuidanceItemsCache = null; }); } } return(tmDatabase); }
public static TM_Xml_Database xmlDB_Load_GuidanceItems_and_Create_CacheFile(this TM_Xml_Database tmDatabase) { if (tmDatabase.UsingFileStorage) { var pathXmlLibraries = TM_Xml_Database.Current.Path_XmlLibraries; if (pathXmlLibraries.notNull() && pathXmlLibraries.notNull()) { lock (pathXmlLibraries) { //if (tmDatabase.getCacheLocation().fileExists().isFalse()) //{ "[TM_Xml_Database] in xmlDB_Load_GuidanceItems, creating cache file".debug(); var o2Timer = new O2Timer("loaded GuidanceItems from disk").start(); //Load GuidanceItem from the disk foreach (var item in tmDatabase.GuidanceExplorers_Paths) { var guidanceExplorer = item.Key; var pathToLibraryGuidanceItems = item.Value.parentFolder(); var libraryId = guidanceExplorer.library.name.guid(); "libraryId: {0} : {1}".info(libraryId, pathToLibraryGuidanceItems); var filesToLoad = pathToLibraryGuidanceItems.files(true, "*.xml"); tmDatabase.xmlDB_Load_GuidanceItemsV3(libraryId, filesToLoad); } //save it to the local cache file (reduces load time from 8s to 0.5s) tmDatabase.save_GuidanceItemsToCache(); tmDatabase.ensureFoldersAndViewsIdsAreUnique(); tmDatabase.removeMissingGuidanceItemsIdsFromViews(); o2Timer.stop(); //} } } } return(tmDatabase); }