Example #1
0
        public static TM_UserData   setupGitSupportAndLoadTMConfigFile(this TM_UserData userData)
        {
            if (userData.UsingFileStorage && userData.Path_UserData.notNull())
            {
                userData.load_UserData_FromGitRepo();               // will create the custom UserData repo clone (if mapped)
                userData.load_TMConfigFile();                       // loads the user configured TMConfig.Config file (from either the default or the custom UserData folder)

                var gitEnabled = userData.tmConfig().Git.UserData_Git_Enabled;

                if (gitEnabled)
                {
                    if (userData.Path_UserData.isGitRepository())
                    {
                        //"[TM_UserData][setupGitSupport] open repository: {0}".info(userData.Path_UserData);
                        "[TM_UserData][GitOpen]".info();
                        userData.NGit = userData.Path_UserData.git_Open();
                    }
                    else
                    {
                        //"[TM_UserData][setupGitSupport] initializing repository at: {0}".info(userData.Path_UserData);
                        "[TM_UserData][GitInit]".info();
                        userData.NGit = userData.Path_UserData.git_Init();
                    }
                    userData.triggerGitCommit();        // in case there are any files that need to be commited
                }
            }
            return(userData);
        }
        public static TM_SecretData secretData_Load(this TM_UserData userData)
        {
            try
            {
                if (userData.UsingFileStorage)
                {
                    var secretDataFile = userData.secretData_FileLocation();
                    if (secretDataFile.fileExists())
                    {
                        return(secretDataFile.load <TM_SecretData>());
                    }
                    if (secretDataFile.notNull())
                    {
                        var secretData = new TM_SecretData();
                        secretDataFile.parentFolder().createDir();
                        secretData.saveAs(secretDataFile);
                        userData.triggerGitCommit();
                        return(secretData);
                    }
                }
            }
            catch (Exception ex)
            {
                ex.log("in TM_SecretData secretData_Load");
            }

            return(new TM_SecretData());
        }
Example #3
0
        public static TM_UserData   setupGitSupport(this TM_UserData userData)
        {
            if (userData.UsingFileStorage && userData.Path_UserData.notNull())
            {
                userData.handle_UserData_ConfigActions();

                if (userData.AutoGitCommit)
                {
                    userData.handle_External_GitPull();
                    userData.handle_UserData_ConfigActions();               // run this again in case it was changed from the git pull

                    if (userData.Path_UserData.isGitRepository())
                    {
                        //"[TM_UserData][setupGitSupport] open repository: {0}".info(userData.Path_UserData);
                        "[TM_UserData][GitOpen]".info();
                        userData.NGit = userData.Path_UserData.git_Open();
                    }
                    else
                    {
                        //"[TM_UserData][setupGitSupport] initializing repository at: {0}".info(userData.Path_UserData);
                        "[TM_UserData][GitInit]".info();
                        userData.NGit = userData.Path_UserData.git_Init();
                    }
                    userData.triggerGitCommit();        // in case there are any files that need to be commited
                }
            }
            return(userData);
        }
        public static bool secretData_Save(this TM_UserData userData)
        {
            var result = true;

            if (userData.UsingFileStorage)
            {
                var secretDataFile = userData.secretData_FileLocation();
                result = userData.SecretData.saveAs(secretDataFile);
                userData.triggerGitCommit();
            }
            return(result);
        }
Example #5
0
 public static bool          deleteTmUser(this TM_UserData userData, TMUser tmUser)
 {
     if (tmUser.notNull())
     {
         userData.TMUsers.remove(tmUser);
         if (userData.UsingFileStorage)
         {
             lock (tmUser)
             {
                 tmUser.getTmUserXmlFile().file_Delete();
                 userData.triggerGitCommit();
             }
         }
         return(true);
     }
     return(false);
 }
Example #6
0
 public static bool          deleteTmUser(this TM_UserData userData, TMUser tmUser)
 {
     if (tmUser.notNull())
     {
         lock (userData.TMUsers)
         {
             userData.TMUsers.remove(tmUser);
             if (userData.UsingFileStorage)
             {
                 lock (tmUser)
                 {
                     tmUser.getTmUserXmlFile().file_Delete();
                     userData.triggerGitCommit();
                 }
             }
             userData.logTBotActivity("User Delete", "{0} - {1}".format(tmUser.UserName, tmUser.UserID));
             return(true);
         }
     }
     return(false);
 }