Example #1
0
        private void Window_ContentRendered(object sender, EventArgs e)
        {
            progressBar.IsIndeterminate = true;

            BackgroundWorker worker = new BackgroundWorker();

            worker.WorkerReportsProgress      = true;
            worker.WorkerSupportsCancellation = true;

            worker.ProgressChanged    += Worker_ProgressChanged;
            worker.RunWorkerCompleted += Worker_WorkCompleted;

            IDictionary <CommandLineParameter, string> parameters = CommandLineParameter.Parse(Environment.GetCommandLineArgs());

            /*if (parameters != null)
             *  foreach (KeyValuePair<CommandLineParameter, string> kp in parameters)
             *      MessageBox.Show(kp.Key + "=" + kp.Value);*/

            UpdateService updateService = new UpdateService(worker, parameters);

            IUpdateManifest manifest = updateService.GetProcess().GetManifest();
            IUpdateStatus   status   = updateService.GetProcess().GetUpdater().Status();

            lblTitle.Content = manifest.Application.Name + " " + status.LatestVersion.Tag;

            updateService.Start();
        }
 public void OnProgress(IUpdateStatus status)
 {
     lock (this)
     {
         FireAsync(this.Progress, this, status);
     }
 }
 public static void OnStatusUpdate(IUpdateStatus sender, string status, StatusChangeEvent handler)
 {
     if (handler != null)
     {
         handler(status);
     }
 }
		public void OnProgress(IUpdateStatus status)
		{
			lock(this)
			{
				FireAsync(this.Progress, this, status);
			}
		}
Example #5
0
		public void Add(object s, IUpdateStatus status)
		{
			if (started == null)
				started = DateTime.Now;
			
			if (TimeDifference < 1)
			{
				this.form.Label.Text = "Estimating...";
				return;
			}
			
			var ratio = status.Current / TimeDifference;
			
			this.form.Label.Text = string.Format("Inserted {0} / {1} rows. Inserting at {2} per second", 
			                                     status.Current, status.MaxValue,
			                                    ratio);
			
		}
Example #6
0
 public Communicator(IUpdateStatus updateStatus)
 {
     _updateStatus          = updateStatus;
     _teensy                = GetDevice();
     _refreshTimer          = new Timer(200);
     _refreshTimer.Elapsed += (sender, e) =>
     {
         if (_teensy == null || _updateStatus.Availability == Availability.Disabled || _updateStatus.Availability == Availability.Disconnected)
         {
             _teensy = GetDevice();
         }
     };
     _statusTimer            = new Timer(2000);
     _statusTimer.Elapsed   += (sender, e) => { GetStatus(); };
     _refreshTimer.AutoReset = true;
     _statusTimer.AutoReset  = true;
     _refreshTimer.Start();
     _statusTimer.Start();
 }
        public void Add(object s, IUpdateStatus status)
        {
            if (started == null)
            {
                started = DateTime.Now;
            }

            if (TimeDifference < 1)
            {
                this.form.Label.Text = "Estimating...";
                return;
            }

            var ratio = status.Current / TimeDifference;

            this.form.Label.Text = string.Format("Inserted {0} / {1} rows. Inserting at {2} per second",
                                                 status.Current, status.MaxValue,
                                                 ratio);
        }
Example #8
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

// #if EXE
//             var hostFile = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName);
//             ConfigurationManager.OpenExeConfiguration(hostFile+".config");
// #endif

            try
            {
                var packageName = Configuration.Package;
            }
            catch (Exception)
            {
                var crashWindow = new MainWindow();
                crashWindow.Show();

                var configFileLocation = typeof(MainWindow).Assembly.Location;

                crashWindow.HandleStartupCrash(
                    $"Application's package information is missing. Please provide the package as a launch argument for ExeLauncher. {Environment.NewLine}{Environment.NewLine}package=Id of the app's nuget package{Environment.NewLine}{Environment.NewLine}" +
                    $"Example: {Environment.NewLine}{Environment.NewLine}exelauncher \"MyCompany.MyApplication\" " + Environment.NewLine + Environment.NewLine +
                    $"Running folder of ExeLauncher is {configFileLocation}");

                return;
            }

            InitializeLogging();
            var fullConfiguration = Configuration.GetFullConfiguration();

            _logger.Debug("Default configuration file path: {ConfigFilePath}. Application configuration file path: {ApplicationConfigFilePath}", Configuration.DefaultConfigurationFilePath, Configuration.ApplicationConfigurationFilePath);
            _logger.Debug("Configuration:");

            foreach (var config in fullConfiguration)
            {
                _logger.Debug("{ConfigKey}: {ConfigValue}", config.Key, config.Value);
            }

            var showUi = Configuration.ShowLauncher;

            IUpdateStatus statusUpdater = null;

            if (showUi == ShowLauncherEnum.Always || showUi == ShowLauncherEnum.FirstLaunch)
            {
                _logger.Info("Gui is enabled. Displaying launcher window.");
                var window = new MainWindow();

                if (showUi == ShowLauncherEnum.Always)
                {
                    window.Show();
                }

                statusUpdater = window;
            }
            else
            {
                _logger.Info("Gui is disabled. Only show the actual application and not the launcher.");
            }

            if (statusUpdater != null)
            {
                statusUpdater.LogPath = _logFileName;
            }

            if (!string.IsNullOrWhiteSpace(Configuration.ExportPath))
            {
                statusUpdater?.UpdateStatus($"Exporting configuration to {Configuration.ExportPath}");

                try
                {
                    var exporter = new ExporterService();

                    exporter.Export();

                    statusUpdater?.UpdateStatus($"Configuration exported to {Configuration.ExportPath}", manualClose: true);
                }
                catch (Exception)
                {
                    statusUpdater?.UpdateStatus($"Error when exporting configuration to {Configuration.ExportPath}");
                }

                return;
            }

            try
            {
                if (statusUpdater != null)
                {
                    _launcher = new LauncherService((statusText, hasCrashed, isReady, appHasClosed, manualClose, isFirstLaunch) =>
                                                    statusUpdater.UpdateStatus(statusText, hasCrashed, isReady, appHasClosed, manualClose, isFirstLaunch));
                }
                else
                {
                    _launcher = new LauncherService(async(statusText, hasCrashed, isReady, appHasClosed, manualClose, isFirstLaunch) =>
                    {
                        if (appHasClosed.GetValueOrDefault() == false)
                        {
                            return;
                        }

                        await Current.Dispatcher.BeginInvoke(new Action((() =>
                        {
                            Current.Shutdown();
                        })));
                    });
                }
            }
            catch (Exception exception)
            {
                _logger.Error(exception, "Failed to initialize launcher");
                statusUpdater?.UpdateStatus("Failed to initialize launcher.", true);
            }

            Task.Run(() => _launcher.Launch());
        }