Exemplo n.º 1
0
        public static bool       xmlDB_Save_GuidanceExplorer(this guidanceExplorer guidanceExplorer, TM_Xml_Database tmDatabase)
        {
            if (tmDatabase.UsingFileStorage)
            {
                var libraryName = guidanceExplorer.library.caption;
                if (tmDatabase.GuidanceExplorers_Paths.hasKey(guidanceExplorer).isFalse())
                {
                    var libraryFolder  = tmDatabase.Path_XmlLibraries.pathCombine(libraryName).createDir();
                    var libraryXmlFile = libraryFolder.pathCombine("{0}.xml".format(libraryName));
                    tmDatabase.GuidanceExplorers_Paths.add(guidanceExplorer, libraryXmlFile);
                }

                var libraryPath = tmDatabase.GuidanceExplorers_Paths.value(guidanceExplorer);
                if (libraryPath.notNull())
                {
                    "[xmlDB_Save_GuidanceExplorer] saving GuidanceExplorer '{0}' to {1}'".debug(libraryName, libraryPath);

                    libraryPath.parentFolder().createDir();         // ensure library folder exists
                    guidanceExplorer.SaveLibraryTo(libraryPath);
                    tmDatabase.triggerGitCommit();
                }
                else
                {
                    return(false);
                }
            }
            return(true);
        }
        public static TM_Xml_Database setupGitSupport(this TM_Xml_Database tmDatabase)
        {
            var gitConfig = tmDatabase.tmConfig().Git;

            if (gitConfig.LibraryData_Git_Enabled)
            {
                foreach (var library in tmDatabase.tmLibraries())
                {
                    var libraryPath = tmDatabase.xmlDB_Path_Library_XmlFile(library).parentFolder();
                    if (libraryPath.isGitRepository())
                    {
                        var nGit = libraryPath.git_Open();
                        try
                        {
                            nGit.git_Pull_Library();
                            nGit.git_Push_Library();
                        }
                        catch (Exception ex)
                        {
                            ex.log();
                        }

                        tmDatabase.NGits.Add(nGit);
                    }
                }
                tmDatabase.triggerGitCommit();
            }
            return(tmDatabase);
        }
Exemplo n.º 3
0
        public static TM_Xml_Database setupGitSupport(this TM_Xml_Database tmDatabase)
        {
            if (tmDatabase.AutoGitCommit)
            {
                foreach (var library in tmDatabase.tmLibraries())
                {
                    var libraryPath = tmDatabase.xmlDB_LibraryPath(library.Caption).parentFolder();
                    if (libraryPath.isGitRepository())
                    {
                        var nGit = libraryPath.git_Open();
                        try
                        {
                            nGit.pull();
                            nGit.push();
                        }
                        catch (Exception ex)
                        {
                            ex.log();
                        }

                        tmDatabase.NGits.Add(nGit);
                    }
                }
                tmDatabase.triggerGitCommit();

                /*tmDatabase.NGit = tmDatabase.Path_XmlLibraries.isGitRepository()
                 *                      ? tmDatabase.Path_XmlLibraries.git_Open()
                 *                      : tmDatabase.Path_XmlLibraries.git_Init();
                 * tmDatabase.triggerGitCommit();*/
            }
            return(tmDatabase);
        }
Exemplo n.º 4
0
        /*public static guidanceExplorer       xmlDB_Save_GuidanceExplorer(this guidanceExplorer guidanceExplorer, TM_Xml_Database tmDatabase)
         * {
         *  return guidanceExplorer.xmlDB_Save_GuidanceExplorer(tmDatabase, true);
         * }*/
        public static guidanceExplorer       xmlDB_Save_GuidanceExplorer(this guidanceExplorer guidanceExplorer, TM_Xml_Database tmDatabase)//, bool reloadGuidanceItemsMappings)
        {
            if (tmDatabase.UsingFileStorage)
            {
                if (tmDatabase.GuidanceExplorers_Paths.hasKey(guidanceExplorer).isFalse())
                {
                    var libraryName    = guidanceExplorer.library.caption;
                    var libraryFolder  = tmDatabase.Path_XmlLibraries.pathCombine(libraryName).createDir();
                    var libraryXmlFile = libraryFolder.pathCombine("{0}.xml".format(libraryName));
                    tmDatabase.GuidanceExplorers_Paths.add(guidanceExplorer, libraryXmlFile);
                }

                var libraryPath = tmDatabase.GuidanceExplorers_Paths[guidanceExplorer];
                var caption     = guidanceExplorer.library.caption;
                "[xmlDB_Save_GuidanceExplorer] saving GuidanceExplorer '{0}' to {1}'".debug(caption, libraryPath);
                if (libraryPath.notNull())
                {
                    libraryPath.parentFolder().createDir(); // ensure library folder exists
                    guidanceExplorer.Save(libraryPath);
                    //if (reloadGuidanceItemsMappings)
                    //    tmDatabase.reloadGuidanceExplorerObjects();
                    tmDatabase.triggerGitCommit();
                    return(guidanceExplorer);
                }

                //"[xmlDB_Save_GuidanceExplorer] could not find libraryPath for GuidanceExplorer: {0} - {1}".error(guidanceExplorer.library.caption, guidanceExplorer.library.name);
            }
            return(null);
            //TM_Xml_Database.Current.mapGuidanceItemsViews();
        }
Exemplo n.º 5
0
        public static TM_Xml_Database setupGitSupport(this TM_Xml_Database tmDatabase)
        {
            if (tmDatabase.AutoGitCommit)
            {
                var online = MiscUtils.online();
                if (online)
                {
                    "[TM_Xml_Database] [setupGitSupport] we are online, so git Pull and Pull will be attempted".info();
                }
                else
                {
                    "[TM_Xml_Database] [setupGitSupport] we are offline, so no git Pull and Pulls".info();
                }
                foreach (var library in tmDatabase.tmLibraries())
                {
                    var libraryPath = tmDatabase.xmlDB_Path_Library_XmlFile(library).parentFolder();
                    if (libraryPath.isGitRepository())
                    {
                        var nGit = libraryPath.git_Open();
                        if (online)
                        {
                            try
                            {
                                "[TM_Xml_Database] [setupGitSupport] doing git Pull and Push for: {0}".debug(libraryPath.folderName());
                                nGit.pull();
                                nGit.push();
                            }
                            catch (Exception ex)
                            {
                                ex.log();
                            }
                        }
                        tmDatabase.NGits.Add(nGit);
                    }
                    else
                    {
                        "[TM_Xml_Database] [setupGitSupport]  library {0} is currently not a git repo".info(libraryPath.folderName());
                    }
                }
                tmDatabase.triggerGitCommit();

                /*tmDatabase.NGit = tmDatabase.Path_XmlLibraries.isGitRepository()
                 *                      ? tmDatabase.Path_XmlLibraries.git_Open()
                 *                      : tmDatabase.Path_XmlLibraries.git_Init();
                 * tmDatabase.triggerGitCommit();*/
            }
            return(tmDatabase);
        }
 public static TM_Xml_Database                    save_GuidanceItemsToCache(this TM_Xml_Database tmDatabase)
 {
     if (tmDatabase.UsingFileStorage)
     {
         var cacheFile = tmDatabase.getCacheLocation();
         if (cacheFile.notNull())
         {
             var o2Timer = new O2Timer("saveGuidanceItemsToCache").start();
             lock (TM_Xml_Database.Current.Cached_GuidanceItems)
             {
                 TM_Xml_Database.Current.Cached_GuidanceItems.Values.toList().saveAs(cacheFile);
                 tmDatabase.triggerGitCommit();
             }
             o2Timer.stop();
         }
     }
     return(tmDatabase);
 }
        public static bool xmlDB_Save_GuidanceExplorer(this guidanceExplorer guidanceExplorer, TM_Xml_Database tmDatabase)
        {
            if (tmDatabase.UsingFileStorage)
            {
                var libraryName = guidanceExplorer.library.caption;
                if (tmDatabase.GuidanceExplorers_Paths.hasKey(guidanceExplorer).isFalse())
                {
                    var libraryFolder = tmDatabase.Path_XmlLibraries.pathCombine(libraryName).createDir();
                    var libraryXmlFile = libraryFolder.pathCombine("{0}.xml".format(libraryName));
                    tmDatabase.GuidanceExplorers_Paths.add(guidanceExplorer, libraryXmlFile);
                }

                var libraryPath = tmDatabase.GuidanceExplorers_Paths.value(guidanceExplorer);
                if (libraryPath.notNull())
                {
                    "[xmlDB_Save_GuidanceExplorer] saving GuidanceExplorer '{0}' to {1}'".debug(libraryName, libraryPath);

                    libraryPath.parentFolder().createDir();         // ensure library folder exists
                    guidanceExplorer.SaveLibraryTo(libraryPath);
                    tmDatabase.triggerGitCommit();
                }
                else
                    return false;
            }
            return true;
        }
        //, bool reloadGuidanceItemsMappings)
        /*public static guidanceExplorer       xmlDB_Save_GuidanceExplorer(this guidanceExplorer guidanceExplorer, TM_Xml_Database tmDatabase)
        {
            return guidanceExplorer.xmlDB_Save_GuidanceExplorer(tmDatabase, true);
        }*/
        public static guidanceExplorer xmlDB_Save_GuidanceExplorer(this guidanceExplorer guidanceExplorer, TM_Xml_Database tmDatabase)
        {
            if (tmDatabase.UsingFileStorage)
            {
                if (tmDatabase.GuidanceExplorers_Paths.hasKey(guidanceExplorer).isFalse())
                {
                    var libraryName = guidanceExplorer.library.caption;
                    var libraryFolder = tmDatabase.Path_XmlLibraries.pathCombine(libraryName).createDir();
                    var libraryXmlFile = libraryFolder.pathCombine("{0}.xml".format(libraryName));
                    tmDatabase.GuidanceExplorers_Paths.add(guidanceExplorer, libraryXmlFile);
                }

                var libraryPath = tmDatabase.GuidanceExplorers_Paths[guidanceExplorer];
                var caption = guidanceExplorer.library.caption;
                "[xmlDB_Save_GuidanceExplorer] saving GuidanceExplorer '{0}' to {1}'".debug(caption, libraryPath);
                if (libraryPath.notNull())
                {
                    libraryPath.parentFolder().createDir(); // ensure library folder exists
                    guidanceExplorer.Save(libraryPath);
                    //if (reloadGuidanceItemsMappings)
                    //    tmDatabase.reloadGuidanceExplorerObjects();
                    tmDatabase.triggerGitCommit();
                    return guidanceExplorer;
                }

                //"[xmlDB_Save_GuidanceExplorer] could not find libraryPath for GuidanceExplorer: {0} - {1}".error(guidanceExplorer.library.caption, guidanceExplorer.library.name);
            }
            return null;
            //TM_Xml_Database.Current.mapGuidanceItemsViews();
        }