/// <summary> /// todoComment /// </summary> /// <param name="AUserName"></param> /// <param name="APassword"></param> /// <param name="AProcessID"></param> /// <param name="AWelcomeMessage"></param> /// <param name="ASystemEnabled"></param> /// <param name="AError"></param> /// <returns></returns> public bool ConnectToServer(String AUserName, String APassword, out Int32 AProcessID, out String AWelcomeMessage, out Boolean ASystemEnabled, out String AError) { IPrincipal LocalUserInfo; if (!ConnectToServer(AUserName, APassword, out AProcessID, out AWelcomeMessage, out ASystemEnabled, out AError, out LocalUserInfo)) { return(false); } Ict.Petra.Shared.UserInfo.GUserInfo = (TPetraPrincipal)LocalUserInfo; FRemoteConferenceObjects = (IMConferenceNamespace)FConnector.GetRemoteObject(FRemotingURL_MConference, typeof(IMConferenceNamespace)); FRemotePersonnelObjects = (IMPersonnelNamespace)FConnector.GetRemoteObject(FRemotingURL_MPersonnel, typeof(IMPersonnelNamespace)); FRemoteCommonObjects = (IMCommonNamespace)FConnector.GetRemoteObject(FRemotingURL_MCommon, typeof(IMCommonNamespace)); FRemotePartnerObjects = (IMPartnerNamespace)FConnector.GetRemoteObject(FRemotingURL_MPartner, typeof(IMPartnerNamespace)); FRemoteFinanceObjects = (IMFinanceNamespace)FConnector.GetRemoteObject(FRemotingURL_MFinance, typeof(IMFinanceNamespace)); FRemoteReportingObjects = (IMReportingNamespace)FConnector.GetRemoteObject(FRemotingURL_MReporting, typeof(IMReportingNamespace)); FRemoteSysManObjects = (IMSysManNamespace)FConnector.GetRemoteObject(FRemotingURL_MSysMan, typeof(IMSysManNamespace)); // // initialise object that holds references to all our remote object .NET Remoting Proxies // FRemote = new TRemote(FClientManager, FRemoteCommonObjects, FRemoteConferenceObjects, FRemotePartnerObjects, FRemotePersonnelObjects, FRemoteFinanceObjects, FRemoteReportingObjects, FRemoteSysManObjects); return(true); }
/// <summary> /// Connects to the PetraServer and provides a menu with a number of functions, /// including stopping the PetraServer. /// </summary> /// <returns>void</returns> public static void Start() { Ict.Petra.ServerAdmin.App.Core.TConnector TheConnector; IServerAdminInterface TRemote; String ClientID; Boolean SilentSysadm; SilentSysadm = false; try { new TLogging(); new TAppSettingsManager(); SilentSysadm = true; if (TAppSettingsManager.HasValue("DebugLevel")) { TLogging.DebugLevel = TAppSettingsManager.GetInt32("DebugLevel"); } if ((!TAppSettingsManager.HasValue("Command") || (TAppSettingsManager.GetValue("Command") == "Stop"))) { SilentSysadm = false; } if (TAppSettingsManager.HasValue("ServerAdmin.LogFile")) { new TLogging(TAppSettingsManager.GetValue("ServerAdmin.LogFile")); } if ((!SilentSysadm)) { Console.WriteLine(); TLogging.Log( "PETRAServerADMIN " + System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString() + ' ' + "Build " + System.IO.File.GetLastWriteTime( Process.GetCurrentProcess().MainModule.FileName).ToString() + " (OS: " + CommonTypes.ExecutingOSEnumToString(Utilities.DetermineExecutingOS()) + ')'); TLogging.Log(Catalog.GetString("Configuration file: " + TAppSettingsManager.ConfigFileName)); // System.Reflection.Assembly.GetEntryAssembly.FullName does not return the file path TLogging.Log("Connecting to PETRAServer..."); Console.WriteLine(); } // Instantiate a TServerManager object, which has all logic for Server // startup and shutdown TheConnector = new Ict.Petra.ServerAdmin.App.Core.TConnector(); TheConnector.GetServerConnection(TAppSettingsManager.ConfigFileName, out TRemote); if (TAppSettingsManager.HasValue("Command")) { if (TAppSettingsManager.GetValue("Command") == "Stop") { ShutDown(TRemote, false); } else if (TAppSettingsManager.GetValue("Command") == "StopAndCloseClients") { ShutDownControlled(TRemote, false); } else if (TAppSettingsManager.GetValue("Command") == "ConnectedClients") { System.Console.WriteLine(TRemote.FormatClientList(false)); } else if (TAppSettingsManager.GetValue("Command") == "ConnectedClientsSysadm") { System.Console.WriteLine(TRemote.FormatClientListSysadm(false)); } else if (TAppSettingsManager.GetValue("Command") == "DisconnectedClients") { System.Console.WriteLine(TRemote.FormatClientList(true)); } else if (TAppSettingsManager.GetValue("Command") == "DisconnectClient") { ClientID = TAppSettingsManager.GetValue("ClientID"); DisconnectClient(TRemote, ClientID); } else if (TAppSettingsManager.GetValue("Command") == "LoadYmlGz") { RestoreDatabase(TRemote, TAppSettingsManager.GetValue("YmlGzFile")); } else if (TAppSettingsManager.GetValue("Command") == "RefreshAllCachedTables") { RefreshAllCachedTables(TRemote); } else if (TAppSettingsManager.GetValue("Command") == "AddUser") { AddUser(TRemote, TAppSettingsManager.GetValue("UserId")); } } else { Menu(TRemote); } // All exceptions that are raised are handled here // Note: ServerAdmin stops after handling these exceptions!!! } catch (RemotingException remexp) { if ((!SilentSysadm)) { Console.WriteLine("RemotingException occured while connecting/communicating to PETRAServer: " + remexp.Message); } return; } catch (Exception exp) { if ((!SilentSysadm)) { Console.WriteLine("Exception occured while connecting/communicating to PETRAServer: " + exp.ToString()); } return; } // THE VERY END OF SERVERADMIN :( }