コード例 #1
0
        public Form1()
        {
            if (Properties.Settings.Default.UpgradeRequired)
            {
                Properties.Settings.Default.Upgrade();
                Properties.Settings.Default.Reload();
            }

            EasyLogger.BackupLogs(EasyLogger.LogFile, 7);
            EasyLogger.AddListener(EasyLogger.LogFile);

            InitializeComponent();

            Text += " - Directory Name: " + Path.GetFileName(Environment.CurrentDirectory);

            API_KEY_BOX.Text             = _API_KEY;
            ACCESS_TOKEN_BOX.Text        = _ACCESS_TOKEN;
            API_SECRET_KEY_BOX.Text      = _API_SECRET_KEY;
            ACCESS_TOKEN_SECRET_BOX.Text = _ACCESS_TOKEN_SECRET;
            BEARER_TOKEN_BOX.Text        = _BEARER_TOKEN;
            SCREEN_NAME_BOX.Text         = _SCREEN_NAME;

            FormClosing       += Form1_FormClosing;
            VERSION_LABEL.Text = "Version: " + Assembly.GetEntryAssembly().GetName().Version;

            _ = BackupAsync();
        }
コード例 #2
0
        private void Custom_Click(object sender, EventArgs e)
        {
            // Backup the log files in this location
            EasyLogger.BackupLogs(EasyLogger.LogDirectory + "TEST_CUSTOM.log");

            // Need to dispose so that we can set our new log location
            EasyLogger.RemoveListener();

            // Need to add a listener again
            EasyLogger.AddListener(EasyLogger.LogFile);

            // Log something
            EasyLogger.Info("TEST: The log file path is: " + EasyLogger.LogFile);
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: yoeria/xMenuTools
        private static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            // Logging
            TimeSpan ts = DateTime.Now - File.GetLastAccessTime(EasyLogger.LogFile);

            if (ts.Days > 30)
            {
                EasyLogger.BackupLogs(EasyLogger.LogFile);
            }
            EasyLogger.AddListener(EasyLogger.LogFile);

            Application.Run(new Main(args));
        }
コード例 #4
0
        public TEST()
        {
            // Backup the log files in this location after 30 days (Put here any location else EasyLogger.LogFile is default)
            EasyLogger.BackupLogs(EasyLogger.LogFile, 30);

            // Backup the log files in this location (Put here any location else EasyLogger.LogFile is default)
            //EasyLogger.BackupLogs(EasyLogger.LogFile);

            // Add listener so we can start logging
            EasyLogger.AddListener(EasyLogger.LogFile);

            // Log something
            EasyLogger.Info("TEST: The log file path is: " + EasyLogger.LogFile);

            InitializeComponent();
        }
コード例 #5
0
        public MainWindow()
        {
            InitializeComponent();

            EasyLogger.BackupLogs(EasyLogger.LogFile);
            EasyLogger.AddListener(EasyLogger.LogFile);

            ((MainWindow)Application.Current.MainWindow).mainWindow.StateChanged += MainWindow_StateChanged;

            HideThisWindow();

            Closing += MainWindow_Closing;

            if (Default.UpgradeRequired)
            {
                Default.Upgrade();

                Default.UpgradeRequired = false;

                Default.Save();

                Default.Reload();

                if (Default.FirstRun)
                {
                    Default.FirstRun = false;

                    SettingsWindow settingsWindow = new SettingsWindow();
                    settingsWindow.ShowDialog();

                    LocationBox locationBox = new LocationBox();
                    locationBox.ShowDialog();

                    MessageBox.Show("Right click on the Desktop App to change the weather location to your preferred location." + Environment.NewLine + Environment.NewLine + "You will need to find your lattitude and longitude in order for me to find your local weather.", "NWS Alerts", MessageBoxButton.OK, MessageBoxImage.Information);

                    Default.Save();

                    Default.Reload();
                }
            }

            NotifyTray.TrayIconCreate();

            if (Default.MuteToast)
            {
                NotifyTray.MuteMenuItem.Checked = true;
                ParseWeatherXML.MuteAlerts      = true;
            }

            NotificationActivatorBase.RegisterComType(typeof(NotificationActivator), OnActivated);

            NotificationHelper.RegisterComServer(typeof(NotificationActivator), Assembly.GetExecutingAssembly().Location);

            if (CheckForInternet.Connected())
            {
                ParseWeatherXML.NWSAlertsInfo();
            }
            else
            {
                ((MainWindow)Application.Current.MainWindow).AlertTextBody.Text = "You may not be connected to the internet...";
            }

            WeatherApp = new DesktopWeather();
            WeatherApp.Show();
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: xCONFLiCTiONx/Maintenance
        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);
        }
コード例 #7
0
        private static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            EasyLogger.BackupLogs(EasyLogger.LogFile, 7);
            EasyLogger.AddListener(EasyLogger.LogFile);

            EasyLogger.Info("Initializing...");

            int tries = 10;

            try
            {
                while (!SQLConnection.IsServerConnected(Properties.Settings.Default.SocialPostSchedulerConnectionString))
                {
                    tries--;
                    if (tries > 0)
                    {
                        Thread.Sleep(2000);
                    }
                    else
                    {
                        DialogResult result = MessageBox.Show("SQL Server is not responding. Would you like to try again?", "Social Post Scheduler", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        if (result == DialogResult.No)
                        {
                            Environment.Exit(0);
                        }
                        else
                        {
                            tries = 10;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                EasyLogger.Error(ex);
            }

            try
            {
                System.Reflection.Assembly assembly = typeof(Program).Assembly;
                GuidAttribute attribute             = (GuidAttribute)assembly.GetCustomAttributes(typeof(GuidAttribute), true)[0];
                string        id = attribute.Value;

                Mutex mutex = new Mutex(true, id);

                if (mutex.WaitOne(TimeSpan.Zero, true))
                {
                    try
                    {
                        StartApp();
                    }
                    finally
                    {
                        mutex.ReleaseMutex();
                    }
                }
                else
                {
                    ExitApp();
                }
            }
            catch (Exception ex)
            {
                EasyLogger.Error("Program - @Main(1): " + ex);
                MessageBox.Show(ex.Message, "social Post Scheduler", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }