/// <summary> /// Initialize the Petra server and connect to the database /// </summary> /// <param name="AConfigName">just provide the server config file, plus AutoLogin and AutoLoginPasswd</param> public static TServerManager Connect(string AConfigName) { if (File.Exists(AConfigName)) { new TAppSettingsManager(AConfigName); } else { new TAppSettingsManager(); } new TLogging(TAppSettingsManager.GetValue("Server.LogFile")); CommonNUnitFunctions.InitRootPath(); Catalog.Init(); TServerManager ServerManager = new TServerManager(); DBAccess.GDBAccessObj = new TDataBase(); DBAccess.GDBAccessObj.EstablishDBConnection(TSrvSetting.RDMBSType, TSrvSetting.PostgreSQLServer, TSrvSetting.PostgreSQLServerPort, TSrvSetting.PostgreSQLDatabaseName, TSrvSetting.DBUsername, TSrvSetting.DBPassword, ""); bool SystemEnabled; int ProcessID; TPetraPrincipal UserInfo = (TPetraPrincipal)TClientManager.PerformLoginChecks(TAppSettingsManager.GetValue("AutoLogin").ToUpper(), TAppSettingsManager.GetValue("AutoLoginPasswd"), "NUNITTEST", "127.0.0.1", out ProcessID, out SystemEnabled); if (FDomain != null) { FDomain.StopClientAppDomain(); } TClientManager ClientManager = new TClientManager(); DomainManager.UClientManagerCallForwarderRef = new TClientManagerCallForwarder(ClientManager); // do the same as in Ict.Petra.Server.App.Main.TRemoteLoader.LoadDomainManagerAssembly FDomain = new TClientDomainManager("0", TClientServerConnectionType.csctLocal, DomainManager.UClientManagerCallForwarderRef, new TSystemDefaultsCache(), new TCacheableTablesManager(null), UserInfo); FDomain.InitAppDomain(TSrvSetting.ServerSettings); new TCallForwarding(); // we don't need to establish the database connection anymore // FDomain.EstablishDBConnection(); return(ServerManager); }
/// <summary> /// shutdown the server /// </summary> public static void Disconnect() { FDomain.CloseDBConnection(); FDomain.StopClientAppDomain(); FDomain = null; }