Beispiel #1
0
        public MainWindow()
        {
            try
            {
                InitializeComponent();

                SetProcessPriority();

                ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;

                if (cursorVisible)
                {
                    Mouse.OverrideCursor = Cursors.Arrow;
                }
                else
                {
                    Mouse.OverrideCursor = Cursors.None;
                }

                #region Auto Update Process

                _updateService = new UpdateService();
                _updateService.EventAutoUpdateResult += AddAutoUpdateLog;
                //_updateService.EventAutoUpdateProcess += AddAutoUpdateProcess;

                try
                {
                    txtCurrentVersion.Content = _updateService.StartAutoUpdateProcess();
                }
                catch (Exception exception)
                {
                    new RMSAppException(this, "0500", "Window_Loaded - StartAutoUpdateProcess failed. " + exception.Message, exception, true);
                    try
                    {
                        var versionFilePathOnClient = applicationStartupPath + @"\version.txt";

                        if (File.Exists(versionFilePathOnClient))
                        {
                            txtCurrentVersion.Content = System.IO.File.ReadAllText(versionFilePathOnClient);
                        }
                    }
                    catch
                    {
                    }
                }
                #endregion

                this.Activate();
            }
            catch (Exception ex)
            {
                throw new RMSAppException(this, "0500", "MainWindow failed. " + ex.Message, ex, true);
            }
        }
Beispiel #2
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                logs.Add(new EventLog {
                    EventDateTime = DateTime.Now, EventType = "Agent", Message = "Application Startup", Detail = ""
                });
                dgLogs.ItemsSource = null;
                dgLogs.ItemsSource = logs;

                #region Auto Update Process

                _updateService = new UpdateService();
                _updateService.EventAutoUpdateResult  += AddAutoUpdateLog;
                _updateService.EventAutoUpdateProcess += AddAutoUpdateProcess;

                try
                {
                    txtCurrentVersion.Content = _updateService.StartAutoUpdateProcess();
                }
                catch (Exception exception)
                {
                    new RMSAppException(this, "0500", "Window_Loaded - StartAutoUpdateProcess failed. " + exception.Message, exception, true);
                }
                #endregion

                //txtCurrentVersion.Content = currentVerionOnClient;

                btnStart_Click(null, null);
            }
            catch (Exception ex)
            {
                new RMSAppException(this, "0500", "Window_Loaded failed. " + ex.Message, ex, true);
                logs.Add(new EventLog {
                    EventDateTime = DateTime.Now, EventType = "Error", Message = "Window_Loaded errors", Detail = ex.Message
                });
            }
        }
Beispiel #3
0
        public MainWindow()
        {
            try
            {
                InitializeComponent();

                SetProcessPriority();

                ni = new System.Windows.Forms.NotifyIcon();

                ni.Icon = RMS.Agent.Watchdog.Properties.Resources.icon_16;

                ni.Visible      = true;
                ni.DoubleClick +=
                    delegate(object sender, EventArgs args)
                {
                    this.Show();
                    this.WindowState = WindowState.Normal;
                };

                ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;

                lblAppStatus.Content = "Stopped";
                btnStart.IsEnabled   = true;
                btnStop.IsEnabled    = false;

                lblExecPath.Content = Assembly.GetExecutingAssembly().Location;

                ws = new WatchdogService();

                dispatcherTimer          = new System.Windows.Threading.DispatcherTimer();
                dispatcherTimer.Tick    += new EventHandler(dispatcherTimer_Tick);
                dispatcherTimer.Interval = new TimeSpan(0, 0, 3);

                #region Auto Update Process

                _updateService = new UpdateService();
                _updateService.EventAutoUpdateResult += AddAutoUpdateLog;

                try
                {
                    txtCurrentVersion.Content = _updateService.StartAutoUpdateProcess();
                }
                catch (Exception exception)
                {
                    new RMSAppException(this, "0500", "MainWindow - StartAutoUpdateProcess failed. " + exception.Message, exception, true);
                }

                #endregion

                FixAppConfig();
                System.Threading.Thread.Sleep(10000);
                btnStart_Click(null, null);

                try
                {
                    CreateTaskScheduler();
                }
                catch {}
            }
            catch (Exception ex)
            {
                new RMSAppException(this, "0500", "MainWindow failed. " + ex.Message, ex, true);

                System.Diagnostics.Process.Start(System.Windows.Application.ResourceAssembly.Location);
                System.Windows.Application.Current.Shutdown();
            }
        }