public void setup() { this.tmProxy_Refresh(); tmFileStorage = tmProxy.TmFileStorage.assert_Not_Null(); tmServer = tmProxy.TmServer.assert_Not_Null(); path_SiteData = tmFileStorage.path_SiteData(); }
public static TM_Server active_UserData(this TM_Server tmServer, TM_Server.Config config) { if (tmServer.isNull() || config.isNull()) return null; tmServer.UserData_Configs.active_Config(config); return tmServer; }
public static TM_FileStorage tmServer_Load(this TM_FileStorage tmFileStorage) { UserRole.Admin.demand(); if (tmFileStorage.isNull()) return tmFileStorage; var tmServer = new TM_Server(); tmServer.setDefaultData(); var location = tmFileStorage.tmServer_Location(); if (location.valid()) { if (location.fileExists().isFalse()) { "[TM_Xml_Database][load_TMServer_Config] expected TM_Server file didn't exist, so creating it: {0}".info(location); tmServer.saveAs(location); } var loadedTmServer = location.load<TM_Server>(); if (loadedTmServer.isNull()) "[TM_Xml_Database][load_TMServer_Config] Failed to load tmServer file: {0} Default values will be used".error(location); else tmServer = loadedTmServer; } //tmDatabase.Events.After_TmServer_Load.raise(); tmFileStorage.Server = tmServer; return tmFileStorage; }
public TM_FileStorage(bool loadData) { Server = new TM_Server(); TMXmlDatabase = new TM_Xml_Database(); UserData = new TM_UserData(); GuidanceExplorers_Paths = new Dictionary<guidanceExplorer,string>(); GuidanceItems_FileMappings = new Dictionary<Guid,string>(); if (loadData) { Current = this; this.set_WebRoot() // defines where the web root will exist .set_Path_XmlDatabase() // the WebRoot is used to calculate the root of the XML Database .tmServer_Load() // the TM_Server is loaded from the root of the Path_XmlDatabase .set_Path_UserData() // the Path_UserData are Path_SiteData are both .set_Path_SiteData() // set based on info from TM_Server and Path_XmlDatabase .tmConfig_Load() // tm TM_Config is loaded from the root of the UserData .set_Path_XmlLibraries() // the Path_XmlLibraries is set based on info from TM_Config and Path_XmlDatabase .load_UserData() // after all is configured we can load the users .load_Libraries(); // and libraries this.hook_Events_TM_UserData() // hook events to FileStorage handlers so that actions on TeamMentor.Database .hook_Events_TM_Xml_Database(); // and TeamMentor.UserData are saved or deleted from disk } }
public void add_UserData_Repo() { var tmServer = new TM_Server().setDefaultData(); var userData_Config1a = new TM_Server.Config { Name = 10.randomLetters() }; var userData_Config1b = new TM_Server.Config { Name = userData_Config1a.Name }; var userData_Config2 = new TM_Server.Config { Name = 10.randomLetters() }; Assert.IsNotEmpty(tmServer.UserData_Configs); // there should be at least one default UserData config tmServer.UserData_Configs.clear(); tmServer.add_UserData(userData_Config1a); Assert.AreEqual( tmServer.UserData_Configs.size() ,1); Assert.AreEqual( tmServer.UserData_Configs.first() ,userData_Config1a); tmServer.add_UserData(userData_Config2); // should add userData_Config2 Assert.AreEqual( tmServer.UserData_Configs.size() ,2); Assert.AreEqual( tmServer.UserData_Configs.first() ,userData_Config1a); Assert.AreEqual( tmServer.UserData_Configs.second() ,userData_Config2); tmServer.add_UserData(userData_Config1b); // should reaplce userData_GitRepo1a with userData_GitRepo1b Assert.AreEqual(tmServer.UserData_Configs.size() , 2); Assert.AreEqual(tmServer.UserData_Configs.first() , userData_Config2); Assert.AreEqual(tmServer.UserData_Configs.second() , userData_Config1b); }
//site data public static TM_Server add_SiteData(this TM_Server tmServer, TM_Server.Config config) { if (tmServer.notNull() && config.notNull()) { tmServer.SiteData_Configs.add_Config(config); } return(tmServer); }
//userActivites public static TM_Server userActivities_Disable_Logging(this TM_Server tmServer, bool value) { if (tmServer.notNull()) { tmServer.UserActivities_Disable_Logging = value; } return(tmServer); }
public static TM_Server realTime_Logs(this TM_Server tmServer, bool value) { if (tmServer.notNull()) { tmServer.RealTime_Logs = value; } return(tmServer); }
public static bool tmServer_Save(this TM_FileStorage tmFileStorage, TM_Server tmServer) { UserRole.Admin.demand(); if (tmFileStorage.isNull() || tmServer.isNull()) return false; var location = tmFileStorage.tmServer_Location(); return (location.valid()) && tmServer.saveAs(location); }
public static List<TM_Server.Config> active_Config(this List<TM_Server.Config> configs, TM_Server.Config config) { if (configs.notNull() && config.notNull()) { configs.ForEach(_config => _config.Active = false); config.Active = true; } return configs; }
public static TM_Server active_UserData(this TM_Server tmServer, TM_Server.Config config) { if (tmServer.isNull() || config.isNull()) { return(null); } tmServer.UserData_Configs.active_Config(config); return(tmServer); }
public static List<TM_Server.Config> add_Config(this List<TM_Server.Config> configs, TM_Server.Config config) { if (configs.notNull() && config.notNull()) { var existingConfig = configs.config(config.Name); if (existingConfig.notNull()) // if it already exists, remove it (before adding) configs.remove(existingConfig); configs.add(config); } return configs; }
public TM_XmlDatabase_FileStorage() { SendEmails.Disable_EmailEngine = true; UserGroup.Admin.assert(); tmFileStorage = new TM_FileStorage(); tmXmlDatabase = tmFileStorage.TMXmlDatabase; //new TM_Xml_Database().setup(); userData = tmFileStorage.UserData; tmServer = tmFileStorage.Server; tmConfig = TMConfig.Current; CheckDatabaseSetup(); UserGroup.None.assert(); }
public void getActive_UserData_Repo_Remote_GitPath() { var tmServer = new TM_Server(); var userData_Config = new TM_Server.Config { Name = 10.randomLetters(), Remote_GitPath = 10.randomLetters() }; tmServer.add_UserData(userData_Config); tmServer.active_UserData(userData_Config); var active_GitConfig = tmServer.userData_Config(); var remote_GitPath = tmServer.userData_Config().Remote_GitPath; Assert.NotNull (active_GitConfig); Assert.AreEqual(userData_Config, active_GitConfig); Assert.AreEqual(userData_Config.Remote_GitPath, remote_GitPath); ; }
public static TM_Server setDefaultData(this TM_Server tmServer) { var userData_Config = new TM_Server.Config { Name = TMConsts.TM_SERVER_DEFAULT_NAME_USERDATA, Active = true, // Use_FileSystem = false, // Enable_Git_Support = false }; var siteData_Config = new TM_Server.Config { Name = TMConsts.TM_SERVER_DEFAULT_NAME_SITEDATA, Active = true, // Use_FileSystem = false, // Enable_Git_Support = false }; tmServer.add_UserData(userData_Config); tmServer.add_SiteData(siteData_Config); return(tmServer); }
public void setDefaultData() { var tmServer = new TM_Server(); tmServer.setDefaultData(); Assert.IsNotEmpty(tmServer.UserData_Configs); Assert.IsNotEmpty(tmServer.SiteData_Configs); Assert.AreEqual(1, tmServer.UserData_Configs.size()); Assert.AreEqual(1, tmServer.SiteData_Configs.size()); var userData = tmServer.userData_Config(); Assert.AreEqual(userData.Name , TMConsts.TM_SERVER_DEFAULT_NAME_USERDATA); Assert.AreEqual(userData.Active , true); // Assert.AreEqual(userData.Use_FileSystem , false); // Assert.AreEqual(userData.Enable_Git_Support , false); var siteData = tmServer.siteData_Config(); Assert.AreEqual(siteData.Name , TMConsts.TM_SERVER_DEFAULT_NAME_SITEDATA); Assert.AreEqual(siteData.Active , true); // Assert.AreEqual(siteData.Use_FileSystem , false); // Assert.AreEqual(siteData.Enable_Git_Support , false); }
public void tm_Server_Save() { var tmFileStorage = new TM_FileStorage(); Assert.NotNull(tmFileStorage.path_XmlDatabase()); var tmServerLocation = tmFileStorage.tmServer_Location(); var tmServer_withDefaultData = new TM_Server().setDefaultData(); Assert.IsTrue(tmServerLocation.fileExists()); // Assert.Ignore("TO FIX (Refactor Side Effect"); Assert.AreEqual(tmFileStorage.Server.toXml(), tmServer_withDefaultData.toXml()); var tmpName1 = 10.randomLetters(); tmFileStorage.Server.UserData_Configs.first().Name = tmpName1; Assert.IsTrue(tmFileStorage.tmServer_Save()); Assert.AreEqual(tmServerLocation.load<TM_Server>().UserData_Configs.first().Name, tmpName1); //check that it was saved /* // this works but makes the test run in 10s (and the test being done is if there is no exception) var tmpName2 = 10.randomLetters(); tmServerLocation.fileInfo() .setAccessControl("Users", FileSystemRights.Write, AccessControlType.Deny); tmXmlDatabase.Server.UserData_Configs.first().Name = tmpName2; Assert.IsFalse(tmXmlDatabase.tmServer_Save()); Assert.AreEqual(tmServerLocation.load<TM_Server>().UserData_Configs.first().Name, tmpName1); //check that it was not saved Assert.IsTrue(tmServerLocation.delete_File()); Assert.IsFalse(tmServerLocation.fileExists()); */ tmFileStorage.delete_Database(); Assert.IsFalse(tmServerLocation.fileExists()); Assert.IsFalse(tmFileStorage.path_XmlDatabase().dirExists()); //check when not UsingFileStorage //check for nulls tmFileStorage.Path_XmlDatabase = null; Assert.IsFalse(tmFileStorage.tmServer_Save()); Assert.IsFalse(new TM_FileStorage(false).tmServer_Save()); }
//user data public static TM_Server add_UserData(this TM_Server tmServer, TM_Server.Config config) { if (tmServer.notNull() && config.notNull()) tmServer.UserData_Configs.add_Config(config); return tmServer; }
public void tm_Server_Load_UsingFileStorage() { var tmFileStorage = new TM_FileStorage(false); var baseReadOnlyDir = "_tmp_webRoot".tempDir(); var webRootVirualPath = @"site\wwwroot"; // simulates use of AppData tmFileStorage.WebRoot = baseReadOnlyDir.pathCombine(webRootVirualPath).createDir(); tmFileStorage.set_Path_XmlDatabase() .set_Path_UserData() .tmServer_Load(); var tmServerFile = tmFileStorage.tmServer_Location(); var expectedLocation = tmFileStorage.Path_XmlDatabase.pathCombine(TMConsts.TM_SERVER_FILENAME); Assert.IsNotNull(tmFileStorage.path_XmlDatabase()); Assert.IsTrue (TM_Status.Current.TM_Database_Location_Using_AppData); Assert.NotNull (tmFileStorage.Server); Assert.IsTrue (tmServerFile.fileExists()); Assert.AreEqual(tmServerFile, expectedLocation); // Assert.Ignore("TO FIX (Refactor Side Effect"); // Assert.Ignore("TO FIX (Refactor Side Effect"); var tmServer_withDefaultData = new TM_Server().setDefaultData(); Assert.AreEqual(tmFileStorage.Server.toXml(), tmServer_withDefaultData.toXml()); //make a change, saved it and ensure it gets loaded ok var tmpName1 = 10.randomLetters(); var tmpName2 = 10.randomLetters(); tmFileStorage.Server.UserData_Configs.first().Name = tmpName1; tmFileStorage.tmServer_Save(); tmFileStorage.Server.UserData_Configs.first().Name = tmpName2; tmFileStorage.tmServer_Load(); Assert.AreEqual (tmFileStorage.Server.UserData_Configs.first().Name, tmpName1); Assert.AreNotEqual(tmFileStorage.Server.toXml(), tmServer_withDefaultData.toXml()); //Try loading up an corrupted tmServer (whcih will default to load a default TM_Server "aaaa".saveAs(tmServerFile); tmFileStorage.tmServer_Load(); Assert.AreNotEqual(tmFileStorage.Server.UserData_Configs.first().Name, tmpName1); Assert.AreEqual (tmFileStorage.Server.toXml(), tmServer_withDefaultData.toXml()); Files.deleteFolder(baseReadOnlyDir, true); Assert.IsFalse(baseReadOnlyDir.dirExists()); //tmXmlDatabase.delete_Database(); }
public void tm_Server_Load__In_Memory() { var tmFileStorage = new TM_FileStorage(false); var tmServer_defaultData = new TM_Server();//.setDefaultData(); Assert.NotNull (tmFileStorage.Server); Assert.AreEqual(tmFileStorage.Server.toXml(), tmServer_defaultData.toXml()); // check if the value matches a new object of type TM_Server }
public static bool realTime_Logs(this TM_Server tmServer) { return((tmServer.notNull()) && tmServer.RealTime_Logs); }
public static TM_Server.Git_Config git(this TM_Server tmServer) { return(tmServer.notNull() ? tmServer.Git : null); }
public static TM_FileStorage tmServer(this TM_FileStorage tmFileStorage, TM_Server tmServer) { UserRole.Admin.demand(); tmFileStorage.Server = tmServer; return tmFileStorage; }
public static bool userActivities_Disable_Logging(this TM_Server tmServer) { return(tmServer.isNull() || tmServer.UserActivities_Disable_Logging); }
public static TM_Server.Config userData_Config(this TM_Server tmServer) { return((tmServer.notNull()) ? tmServer.UserData_Configs.where (config => config.Active).first() : null); }
public void setDefaultValues() { var tmServer = new TM_Server(); Assert.NotNull(tmServer); Assert.IsEmpty(tmServer.UserData_Configs); Assert.IsEmpty(tmServer.SiteData_Configs); tmServer.assert_Equals(TM_Server.Current); // Assert.IsTrue (tmServer.Users_Create_Default_Admin); //Assert.IsFalse(tmServer.TM_Database_Use_AppData_Folder); Assert.IsFalse(tmServer.UserActivities_Disable_Logging); }
public bool SetTMServerFile(TM_Server tmServer) { admin.demand(); tmFileStorage.Server = tmServer; return tmFileStorage.tmServer_Save(tmServer); }
public static TM_Server.Config userData_Config(this TM_Server tmServer, string name) { return((tmServer.notNull()) ? tmServer.UserData_Configs.config(name) : null); }
public static TM_Server active_UserData(this TM_Server tmServer, string name) { return(tmServer.active_UserData(tmServer.userData_Config(name))); }
public void setUp() { UserGroup.Admin.assert(); //create TM_FileStorage on temp Custom_WebRoot for this TestFixture TM_FileStorage.Custom_WebRoot = "custom_WebRoot".tempDir(); tmFileStorage = new TM_FileStorage(false); tmFileStorage.set_WebRoot() .set_Path_XmlDatabase() .tmServer_Load() .set_Path_UserData() .load_UserData(); tmFileStorage.hook_Events_TM_UserData(); tmXmlDatabase = tmFileStorage.TMXmlDatabase .assert_Not_Null(); userData = tmFileStorage.UserData .assert_Not_Null(); tmServer = tmFileStorage.Server .assert_Not_Null(); tmFileStorage.Path_XmlDatabase.assert_Folder_Exists(); tmFileStorage.Path_UserData .assert_Folder_Exists(); userDataGit = tmFileStorage .setup_UserData_Git_Support(); // adds Git Support for UserData repos tmFileStorage.Path_UserData.isGitRepository().assert_True(); Assert.NotNull(tmFileStorage.Server.userData_Config()); userData .createDefaultAdminUser(); userDataGit.triggerGitCommit(); nGit = userDataGit.NGit; nGit.commits().assert_Size_Is(2, "there should be two commits here"); UserGroup.None.assert(); }
[WebMethod(EnableSession = true)][Admin] public bool SetTMServerFile(TM_Server tmServer) { admin.demand(); tmFileStorage.Server = tmServer; return(tmFileStorage.tmServer_Save(tmServer)); }