Exemplo n.º 1
0
        static void Main(string[] args)
        {
            if (Default.LoggingEnabled)
            {
                EasyLogger.BackupLogs(EasyLogger.LogFile, 30);
                EasyLogger.AddListener(EasyLogger.LogFile);
            }

            if (Default.UpgradeRequired)
            {
                Default.Upgrade();
                Default.UpgradeRequired = false;
                Default.Save();
                Default.Reload();
            }
            if (Default.FirstRun)
            {
                Default.FirstRun = false;
                Default.Save();
                Default.Reload();

                SettingsForm settings = new SettingsForm();
                settings.ShowDialog();

                Environment.Exit(0);
            }

            if (args.Length > 0)
            {
                try
                {
                    string A0 = args[0].ToLower();

                    if (args[0] == "/optimize" || args[0] == "-optimize")
                    {
                        StartLightCleanup();
                    }
                    else
                    {
                        StartLightCleanup();
                    }
                }
                catch (Exception ex)
                {
                    EasyLogger.Info(ex.Message);
                }
            }
            else
            {
                // Run Settings and Close
                SettingsForm settings = new SettingsForm();
                settings.ShowDialog();
            }

            EasyLogger.Info("*********************  END OF OPTIMIZATIONS  *********************");

            EasyLogger.RemoveListener();

#if DEBUG
            using (StreamReader sr = File.OpenText(EasyLogger.LogFile))
            {
                string lines = sr.ReadToEnd();

                if (lines.ToLower().Contains("[error]"))
                {
                    MessageBox.Show("The log file contains errors!", "Maintenance", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                    Process.Start(EasyLogger.LogDirectory);
                }
            }
#endif

            Environment.Exit(0);
        }