private void MogProcess() { while (!MOG_Main.isShutdown()) { try { MOG_Main.Process(); } catch (Exception ex) { MOG_Command pNotify = new MOG_Command(); pNotify.Setup_NotifySystemException("MogProcess:Exception Error durring Mog.Process" + "\n\nMessage: " + ex.ToString() + "\n\nStackTrace:" + ex.StackTrace.ToString()); MOG_ControllerSystem.GetCommandManager().CommandProcess(pNotify); MOG_REPORT.LogError("MogProcess", "Exception Error durring Mog.Process"); MOG_REPORT.LogError("MogProcess", ex.ToString()); MOG_REPORT.LogError("MogProcess", ex.StackTrace.ToString()); } Thread.Sleep(100); } Application.Exit(); mMogProcess.Abort(); mMogProcess = null; }
public static bool Init_Server(string configFilename, string name) { MOG_Main.SetName(name); // Make sure we have a valid config filename? if (configFilename.Length == 0) { configFilename = MOG_Main.BuildDefaultConfigFile(); } // Check our bootup precautions if (MOG_Main.CheckInitPrecautions(configFilename)) { // Initialize MOG_REPORT for the server MOG_Time time = new MOG_Time(); // MOG is really stable now so I am shutting off the log files so things will run faster // MOG_Prompt.SetMode(MOG_PROMPT_MODE_TYPE.MOG_PROMPT_FILE); MOG_Report.SetLogFileName(String.Concat(Application.StartupPath, "\\Logs\\Server\\Server.", time.FormatString(String.Concat("{Day.2}", "-", "{Month.2}", "-", "{Year.2}", " ", "{Hour.2}", ".", "{Minute.2}", "{ampm}")), ".log")); // Create a new system MOG_CommandServerCS server = new MOG_CommandServerCS(); return(MOG_ControllerSystemCS.InitializeServer(configFilename, server)); } return(false); }
private void MogProcess() { // Loop until we shutdown while (!MOG_Main.IsShutdown()) { // Only process while we are not shutting down? if (!MOG_Main.IsShutdownInProgress()) { try { MOG_Main.Process(); } catch (Exception ex) { MOG_Report.ReportSilent("MogProcess", ex.Message, ex.StackTrace, MOG_ALERT_LEVEL.CRITICAL); } } Thread.Sleep(1); } // Inform our parent thread that we have exited mMogProcess = null; // Gracefully wait a while to see if our parent thread will terminate the application for us? Thread.Sleep(500); // At this point, let's take the inititive and shut ourselves down Application.Exit(); }
public static bool SetLightVersionControl(ContextMenuStrip menu) { // If we are in 'Light' mode we need to disable this menu if (MOG_Main.IsUnlicensed() && menu != null) { foreach (ToolStripItem item in menu.Items) { // Make sure this menuItem is not a separator if (item is ToolStripMenuItem) { ToolStripMenuItem menuItem = item as ToolStripMenuItem; menuItem.Enabled = false; // Make sure this menu item does not already say 'Full Version' if (menuItem.Text.IndexOf(FullVerionText) == -1) { menuItem.Text = menuItem.Text + " " + FullVerionText; } } } return(false); } return(true); }
internal void Shutdown() { // Inform MOG we are shutting down MOG_Main.Shutdown(); // Play nice and let the processing thread shutdown on it's own int waitTime = 0; int sleepTime = 10; while (mMogProcess != null) { // Gracefully sleep while we wait for the process thread to shutdown Thread.Sleep(sleepTime); waitTime += sleepTime; // Check if we have waited long enough? if (waitTime >= 1000) { // Forcible terminate the processing thread mMogProcess.Abort(); mMogProcess = null; } } // Terminate our application Application.Exit(); }
static public bool MOGGlobalRepositoryLogin(MogMainForm main, bool forceRestart) { SelectValidRepository: MogForm_RepositoryBrowser_Client browser = new MogForm_RepositoryBrowser_Client(forceRestart); DialogResult rc = DialogResult.Cancel; if (!MOG_Main.IsShutdown()) { rc = browser.ShowDialog(); } if (rc == DialogResult.OK) { if (forceRestart) { main.Close(); } return(true); } else if (rc == DialogResult.Retry) { goto SelectValidRepository; } return(false); }
private void Shutdown() { // Inform MOG we are shutting down MOG_Main.Shutdown(); // Terminate our application Application.Exit(); }
public void InitializeSystem(SplashForm SplashScreen) { // Initialize the .Net style menus SplashScreen.updateSplash("Initializing menu system...", 10); // Initialize MOG SplashScreen.updateSplash("Connecting MOG SQL\\Server...", 40); try { // Check to see if we can init the server? if (!MOG_Main.Init_Client("", "Event Viewer")) { string message = "Was unable to initialize because there is another viewer already running."; throw(new Exception(message)); } criticalEventViewerControl1.RefreshEvents(); } catch (Exception e) { string message = e.Message + "\n" + e.StackTrace; throw(new Exception(message)); } MOG_Prompt.ClientForm = this; SplashScreen.updateSplash("Connected...", 100); SplashScreen.updateSplash("Done", 1); SplashScreen.mInitializationComplete = true; MogUtils_Settings.CreateSettings(Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "EventViewerPrefs.ini")); }
/// <summary> /// Clean up any resources being used. /// </summary> protected override void Dispose(bool disposing) { if (disposing) { if (components != null) { components.Dispose(); } } MOG_Main.Shutdown(true); base.Dispose(disposing); }
public static bool SetLightVersionControl(Button button) { // If we are in 'Light' mode we need to disable this menu if (MOG_Main.IsUnlicensed()) { button.Enabled = false; return(button.Enabled); } return(button.Enabled); }
private void InitializeMOG() { // Check to see if we can init the server if (!MOG_Main.Init_Client("", "Remote Server Manager")) { // Inform the user that we failed to connect and will continue in an offline mode string message = "Failed to connect to the MOG Server.\n" + "Please be advised that you will most likely experience limited functionality during this session."; MOG_Report.ReportMessage("Connection Failed", message, "", MOG_ALERT_LEVEL.ALERT); } RemoteServerSettings.Initialize(); }
static void Main(string[] args) { Control.CheckForIllegalCrossThreadCalls = false; SplashForm form = null; try { // Check for multiple instances Process mogProcess = RunningInstance(); if (mogProcess != null) { // we've got a duplicate process - ask the user if they want to continue anyway DialogResult res = MessageBox.Show("An instance of the MOG Server Manager is already running on this machine.\nIt is possible that this instance is the result of a crash or other problem,\nin which case you should contact your MOG or network administrator.\n\nWould you like to start the Manager anyway?", "Manager Already Running", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); // if not, shutdown if (res == DialogResult.No) { return; } // user wants to spawn a new instance } form = new SplashForm(args); form.Closing += new CancelEventHandler(form_Closing); form.Closed += new EventHandler(form_Closed); form.HandleDestroyed += new EventHandler(form_HandleDestroyed); Application.Run(form); } catch (Exception e) { MOG_Report.ReportMessage("Main", e.Message, e.StackTrace, MOG_ALERT_LEVEL.CRITICAL); // Write our problem out to our Output window in VS.NET System.Diagnostics.Debug.WriteLine(e.ToString() + "\n" + e.StackTrace); // Shutdown our process if (form != null) { form.Close(); if (form.mainForm.mMogProcess != null) { form.mainForm.mMogProcess.Abort(); } } // Exit our application so we can set a breakpoint here and try again MOG_Main.Shutdown(); Application.Exit(); } }
public SplashForm(string[] args) { // // Required for Windows Form Designer support // InitializeComponent(); StartTimer.Enabled = true; StartTimer.Start(); mCommandLineArgs = args; mInitializationComplete = false; this.Load += new System.EventHandler(this.Form1_Load); #if MOG_LIBRARY pictureBox1.Image = global::MOG_Client.Properties.Resources.SplashClientLibrary; #else // Are we a full version? if (MOG_Main.IsLicensed()) { pictureBox1.Image = global::MOG_Client.Properties.Resources.Splash_Client_2005; //SplashLabel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(39)))), ((int)(((byte)(96)))), ((int)(((byte)(159))))); //VersionLabel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(26)))), ((int)(((byte)(73)))), ((int)(((byte)(126))))); } else { // Load the light splash pictureBox1.Image = global::MOG_Client.Properties.Resources.Spash_Client_2005Light; VersionLabel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(117)))), ((int)(((byte)(190))))); SplashLabel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(10)))), ((int)(((byte)(121)))), ((int)(((byte)(238))))); } #endif // Setup our version number tempVersion = "Debug build"; // Make sure this isn't within our debug directory... if (!Application.StartupPath.EndsWith("\\bin\\Debug", StringComparison.CurrentCultureIgnoreCase)) { FileVersionInfo file = FileVersionInfo.GetVersionInfo(Application.ExecutablePath); if (file != null) { tempVersion = file.FileVersion; } } VersionLabel.Text = tempVersion; }
public SQLConnectForm() { // // Required for Windows Form Designer support // InitializeComponent(); packetSize = "4096"; security = "SSPI"; persistSecurity = "False"; dataSource = ""; initialCatalog = "MOG"; MOG_Ini config = new MOG_Ini(MOG_Main.GetExecutablePath() + "\\MOG.ini"); if (config.KeyExist("SQL", "ConnectionString")) { string connectionString = config.GetString("SQL", "ConnectionString"); string [] tokens; tokens = connectionString.Split(";".ToCharArray()); foreach (string token in tokens) { string [] values = token.Split("=".ToCharArray()); if (values != null && values.Length >= 2) { switch (values[0].ToLower()) { case "data source": dataSource = values[1]; break; case "initial catalog": initialCatalog = values[1]; break; } } } } // packet size=4096;integrated security=SSPI;data source="NEMESIS";persist security info=False;initial catalog=mog SQLServerComboBox.Text = dataSource; SQLDatabaseComboBox.Text = initialCatalog; mConnectString = ""; }
public PriviledgesForm() { // // Required for Windows Form Designer support // InitializeComponent(); this.OldWidth = this.Width; MOG_Main.Init_Client(""); mMogProcess = new Thread(new ThreadStart(this.MogProcess)); mMogProcess.Start(); MOG_ControllerProject.LoginProject("BlackJupiter", "CURRENT"); MOG_ControllerProject.LoginUser("Admin"); mPriviledges = MOG_ControllerProject.GetPriviledges(); InitializeMainTreeView(mPriviledges); }
public static bool SetLightVersionControl(ToolStripMenuItem menuItem) { // If we are in 'Light' mode we need to disable this menu if (MOG_Main.IsUnlicensed()) { menuItem.Enabled = false; // Make sure this menu item does not already say 'Full Version' if (menuItem.Text.IndexOf(FullVerionText) == -1) { menuItem.Text = menuItem.Text + " " + FullVerionText; } return(menuItem.Enabled); } return(menuItem.Enabled); }
public static bool SetLightVersionControl(TreeNode node) { // If we are in 'Light' mode we need to disable this menu if (MOG_Main.IsUnlicensed()) { node.ForeColor = SystemColors.GrayText; // Make sure this node does not already say 'Full Version' if (node.Text.IndexOf(FullVerionText) == -1) { node.Text = node.Text + " " + FullVerionText; } return(false); } return(true); }
public InstallUpdateLicenseForm() { InitializeComponent(); string license = Path.Combine(MOG_Main.GetExecutablePath_StripCurrentDirectory(), "mog_license"); if (File.Exists(license)) { MOG_TimeBomb timeBomb = new MOG_TimeBomb(license); PopulateLicenseInfo(timeBomb, "MOG_License"); } else { LicenseRichTextBox.Text = ""; LicenseRichTextBox.Text += "UnLicenced Server\n"; LicenseRichTextBox.Text += "Total UnLicensed Connections: 4 \n\n"; } }
public SplashForm(string[] args) { // // Required for Windows Form Designer support // InitializeComponent(); StartTimer.Enabled = true; StartTimer.Start(); mCommandLineArgs = args; mInitializationComplete = false; this.Load += new System.EventHandler(this.Form1_Load); // Are we a full version? if (MOG_Main.IsLicensed()) { pictureBox1.Image = global::MOG_ServerManager.Properties.Resources.Splash_Server_Manager_2005; //SplashLabel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(39)))), ((int)(((byte)(96)))), ((int)(((byte)(159))))); //VersionLabel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(26)))), ((int)(((byte)(73)))), ((int)(((byte)(126))))); } else { // Load the light splash pictureBox1.Image = global::MOG_ServerManager.Properties.Resources.Splash_Server_Manager_2005L; VersionLabel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(117)))), ((int)(((byte)(190))))); SplashLabel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(10)))), ((int)(((byte)(121)))), ((int)(((byte)(238))))); } // Setup our version number FileVersionInfo file = FileVersionInfo.GetVersionInfo(Application.ExecutablePath); if (file != null) { tempVersion = file.FileVersion; if (tempVersion == "3.0.0.0") { tempVersion = "Debug build"; } } VersionLabel.Text = tempVersion; }
public static bool SetOffline(MogMainForm mainForm, bool offline) { if (offline) { // TODO KIER How do we go offline now? // string targetPath = string.Concat(MOG_ControllerProject.GetGameData().GetGameDataPath(), "\\MOG\\Offline"); // if (MOG_ControllerProject.GetProject().Offline(targetPath)) // { // // Disconnect from the server // MOG_ControllerSystem.GoOffline(); // // if (MOG_ControllerSystem.GetSystem().Load(MOG_Main.BuildDefaultConfigFile(targetPath, "", ""))) // { // // Reload the project // MOG_ControllerProject.LoginProject(MOG_ControllerProject.GetProjectName(), MOG_ControllerProject.GetBranchName()); // // // Set our gui // guiStartup.ConnectionStatus(mainForm, false); // } // } } else { // Connect to the server MOG_ControllerSystem.GoOnline(); if (MOG_ControllerSystem.GetSystem().Load(MOG_Main.BuildDefaultConfigFile())) { // Reload the project MOG_ControllerProject.LoginProject(MOG_ControllerProject.GetProjectName(), MOG_ControllerProject.GetBranchName()); // Login user MOG_ControllerProject.LoginUser(MOG_ControllerProject.GetUser().GetUserName()); // Set our gui guiStartup.ConnectionStatus(mainForm, true); } } return(true); }
static public bool MOGGlobalSQLLogin() { // Attempt to get our SQL connection string string mConnectionString = ""; MOG_Ini config = new MOG_Ini(MOG_Main.GetExecutablePath() + "\\MOG.ini"); SQLConnectForm sql = new SQLConnectForm(); if (sql.ShowDialog() == DialogResult.OK) { mConnectionString = sql.mConnectString; config.PutString("SQL", "ConnectionString", mConnectionString); config.Save(); config = null; return(MOG_ControllerSystem.InitializeDatabase(mConnectionString, "", "")); } return(false); }
private void LoadLicenseFile() { if (LicenseOpenFileDialog.ShowDialog() == DialogResult.OK) { MOG_TimeBomb timeBomb = new MOG_TimeBomb(LicenseOpenFileDialog.FileName); if (PopulateLicenseInfo(timeBomb, LicenseOpenFileDialog.FileName)) { try { string installedLicense = Path.Combine(MOG_Main.GetExecutablePath_StripCurrentDirectory(), "mog_license"); File.Copy(LicenseOpenFileDialog.FileName, installedLicense, true); MessageBox.Show(string.Format("Restart your server for this new license file to take effect"), "MOG License"); } catch (Exception e) { MessageBox.Show(string.Format("Unable to deploy license file with error {0}!", e.Message), "MOG License"); } } } }
public void ParseArgs(string [] args, string defaultIniLocation) { configurationIni = defaultIniLocation; // Parse command line options if (args.Length > 0) { foreach (string arg in args) { if (arg.IndexOf("mog=") != -1) { configurationIni = arg.Substring(arg.IndexOf("=") + 1); FileInfo file = new FileInfo(configurationIni); if (!file.Exists) { MessageBox.Show(String.Concat("MOG Configutation file (", configurationIni, ") does not exist! Exiting..."), "INI Error"); MOG_Main.Shutdown(); Application.Exit(); } } } } }
public void SaveMOGConfiguration() { string configFilename = MOG_Main.FindInstalledConfigFile(); MOG_Ini ini = new MOG_Ini(); if (ini.Load(configFilename)) { // Save repository ini.PutString("MOG", "SystemRepositoryPath", mRepositoryPath); ini.PutString("MOG", "SystemConfiguration", mConfigFile); ini.Close(); // If we are the installed MOG, update the loaders ini too if (DosUtils.FileExistFast(MOG_Main.GetExecutablePath() + "\\..\\Loader.ini")) { MOG_Ini LoaderIni = new MOG_Ini(MOG_Main.GetExecutablePath() + "\\..\\Loader.ini"); LoaderIni.PutString("LOADER", "SystemRepositoryPath", mRepositoryPath); LoaderIni.Save(); } } }
public bool SaveRepositories(string iniFilename) { if (!Directory.Exists(Path.GetDirectoryName(iniFilename))) { return(false); } MOG_Ini ini = new MOG_Ini(iniFilename); if (ini == null) { return(false); } // remove all old repository data int i; if (ini.SectionExist("REPOSITORIES")) { for (i = 0; i < ini.CountKeys("REPOSITORIES"); i++) { // skip default if (ini.GetKeyNameByIndexSLOW("REPOSITORIES", i).ToLower() == "default") { continue; } ini.RemoveSection("REPOSITORIES." + ini.GetKeyNameByIndexSLOW("REPOSITORIES", i)); } ini.RemoveSection("REPOSITORIES"); } // and save the new data i = 0; foreach (ListViewItem item in this.lvRepositories.Items) { string mrString = "mr" + i.ToString(); ini.PutString("REPOSITORIES", mrString, ""); ini.PutString("REPOSITORIES." + mrString, "name", item.Text); ini.PutString("REPOSITORIES." + mrString, "path", item.SubItems[1].Text); if (item == this.lvRepositories.SelectedItems[0]) { // this one's the default ini.PutString("REPOSITORIES", "default", mrString); // is there an INI selected in lvIniFiles? if (this.lvIniFile.SelectedItems.Count > 0) { ini.PutString("REPOSITORIES." + mrString, "ini", item.SubItems[1].Text + "\\Tools\\" + this.lvIniFile.SelectedItems[0].Text); } else { ini.PutString("REPOSITORIES." + mrString, "ini", item.SubItems[1].Text + "\\" + MOG_Main.GetDefaultSystemRelativeConfigFileDefine()); } } else { ini.PutString("REPOSITORIES." + "mr" + i.ToString(), "ini", item.SubItems[1].Text + "\\" + MOG_Main.GetDefaultSystemRelativeConfigFileDefine()); } ++i; } ini.Save(); ini.Close(); return(true); }
private bool InitSlave(string[] args) { String configFilename; bool bInitialized = false; int argc = getNumArgs(args); // Default into SLAVE mode configFilename = ""; // Parse command line options if (args.Length > 0) { foreach (String arg in args) { if (arg.IndexOf("mog=") != -1) { configFilename = arg.Substring(arg.IndexOf("=") + 1); FileInfo file = new FileInfo(configFilename); if (!file.Exists) { MessageBox.Show(String.Concat("MOG Configutation file (", configFilename, ") does not exist! Exiting..."), "INI Error"); Shutdown(); return(false); } } } } // Check command-line argument #2 if (argc >= 2) { MessageBox.Show("Command line arguments are not yet supported."); } else { // Use the specified config file if (argc >= 2) { configFilename = args[1]; } try { // Attempt to initialize the Slave? if (MOG_Main.Init_Slave(configFilename, "Slave")) { // Make sure we obtain a valid NetworkID before continuing if (MOG_ControllerSystem.RequireNetworkIDInitialization()) { bInitialized = true; this.niconSystemTrayIcon.Text = RefreshConnectionToolText(); } else { // This is a great place to kill the application because there is already another server running MOG_Report.ReportMessage("Mog Initialization Error", "Slave was unable to obtain a NetworkID from the server.", "", MOG_ALERT_LEVEL.ALERT); MOG_Main.Shutdown(); return(false); } } else { // The server was shutdown Bitmap DisconnectedIcon = new Bitmap(SlaveIconsImageList.Images[1]); niconSystemTrayIcon.Icon = System.Drawing.Icon.FromHandle(DisconnectedIcon.GetHicon()); niconSystemTrayIcon.Text = "Server is disconnected!"; // This is a great place to kill the application because there is already another server running MOG_Report.ReportMessage("Mog Initialization Error", "Slave was unable to initialize.", "", MOG_ALERT_LEVEL.ALERT); MOG_Main.Shutdown(); return(false); } } catch (Exception e) { MOG_Report.ReportMessage("Mog Initialization Error", e.Message, e.StackTrace, MOG_ALERT_LEVEL.CRITICAL); MOG_Main.Shutdown(); return(false); } } return(bInitialized); }
public MOG_License() { mTimeBomb = new MOG_TimeBomb(String.Concat(MOG_Main.GetExecutablePath_StripCurrentDirectory(), "\\mog_license")); }
private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { MOG_Main.Shutdown(); RemoteServerSettings.SaveSettings(); }
private void lvIniFile_SelectedIndexChanged(object sender, System.EventArgs e) { if (this.lvIniFile.SelectedItems.Count > 0) { this.btnOK.Enabled = true; OnSelectedRepositoryChanged(this.lvRepositories.SelectedItems[0].SubItems[1].Text, this.lvRepositories.SelectedItems[0].SubItems[0].Text, this.lvIniFile.SelectedItems[0].Text); } else { this.btnOK.Enabled = false; OnSelectedRepositoryChanged(this.lvRepositories.SelectedItems[0].SubItems[1].Text, this.lvRepositories.SelectedItems[0].SubItems[0].Text, MOG_Main.GetDefaultSystemConfigFilenameDefine()); } }