Inheritance: INotifyPropertyChanged
        /// <summary>Adds an application to Seven Update.</summary>
        /// <param name="application">The application to add to Seven Update.</param>
        internal static void AddSua(Sua application)
        {
            if (!Connect())
            {
                return;
            }

            Task.Factory.StartNew(WaitForAdmin).ContinueWith(
                delegate
            {
                try
                {
                    context.AddApp(application);
                }
                catch (CommunicationObjectAbortedException)
                {
                    context     = null;
                    IsConnected = false;
                }
                catch (Exception e)
                {
                    ErrorOccurred(
                        null,
                        new ErrorOccurredEventArgs(Utilities.GetExceptionAsString(e), ErrorType.FatalError));
                    throw;
                }
            });
        }
Exemple #2
0
        /// <summary>Installs the shortcuts of an update.</summary>
        /// <param name="shortcuts">The shortcuts to install on the system.</param>
        /// <param name="appInfo">The application information.</param>
        static void SetShortcuts(IList <Shortcut> shortcuts, Sua appInfo)
        {
            if (shortcuts == null)
            {
                return;
            }

            // Choose the path for the shortcut
            for (int x = 0; x < shortcuts.Count; x++)
            {
                shortcuts[x].Location = Utilities.ExpandInstallLocation(
                    shortcuts[x].Location, appInfo.Directory, appInfo.Platform, appInfo.ValueName);
                string linkName = Utilities.GetLocaleString(shortcuts[x].Name);

                if (shortcuts[x].Action == ShortcutAction.Add
                    ||
                    (shortcuts[x].Action == ShortcutAction.Update &&
                     File.Exists(Path.Combine(shortcuts[x].Location, linkName + ".lnk"))))
                {
                    if (!Directory.Exists(shortcuts[x].Location))
                    {
                        Directory.CreateDirectory(shortcuts[x].Location);
                    }

                    File.Delete(Path.Combine(shortcuts[x].Location, linkName + ".lnk"));

                    Shortcut.CreateShortcut(shortcuts[x]);
                }

                if (shortcuts[x].Action == ShortcutAction.Delete)
                {
                    File.Delete(shortcuts[x].Location);
                }

                int installProgress = (x * 100) / shortcuts.Count;
                if (installProgress > 90)
                {
                    installProgress -= 15;
                }

                ReportProgress(installProgress);
            }
        }
Exemple #3
0
 /// <summary>Initializes a new instance of the <see cref="Sui" /> class.</summary>
 /// <param name="appInfo">The software information for the application updates.</param>
 /// <param name="updates">The collection of updates for the application.</param>
 public Sui(Sua appInfo, ObservableCollection <Update> updates)
 {
     this.AppInfo = appInfo;
     this.Updates = updates;
 }
Exemple #4
0
        /// <summary>Raises the <c>InstanceAwareApplication.Startup</c> event.</summary>
        /// <param name="e">The <c>System.Windows.StartupEventArgs</c> instance containing the event data.</param>
        /// <param name="isFirstInstance">If set to <c>True</c> the current instance is the first application instance.</param>
        protected override void OnStartup(StartupEventArgs e, bool isFirstInstance)
        {
            Init();
            if (e.Args.Length > 0)
            {
                if (e.Args[0].EndsWith(@".sua", StringComparison.OrdinalIgnoreCase))
                {
                    e.Args[0] = e.Args[0].Replace(@"sevenupdate://", null);
                    Sua app = null;
                    try
                    {
                        app = Utilities.Deserialize <Sua>(Utilities.DownloadFile(e.Args[0]));
                    }
                    catch (WebException)
                    {
                        Core.ShowMessage(
                            string.Format(
                                CultureInfo.CurrentCulture, SevenUpdate.Properties.Resources.ErrorDownloading, e.Args[0]),
                            TaskDialogStandardIcon.Error,
                            TaskDialogStandardButtons.Ok);
                        Environment.Exit(0);
                    }

                    string appName = Utilities.GetLocaleString(app.Name);
                    if (Utilities.IsRunning64BitOS == false && app.Platform == Platform.X64)
                    {
                        Core.ShowMessage(
                            string.Format(
                                CultureInfo.CurrentCulture, SevenUpdate.Properties.Resources.Not64BitCompat, appName),
                            TaskDialogStandardIcon.Error,
                            TaskDialogStandardButtons.Ok);
                        Environment.Exit(0);
                    }

                    TaskDialogResult result =
                        Core.ShowMessage(
                            string.Format(
                                CultureInfo.CurrentCulture, SevenUpdate.Properties.Resources.AddToSevenUpdate, appName),
                            TaskDialogStandardIcon.ShieldBlue,
                            TaskDialogStandardButtons.Cancel,
                            string.Format(
                                CultureInfo.CurrentCulture, SevenUpdate.Properties.Resources.AllowUpdates, appName),
                            null,
                            SevenUpdate.Properties.Resources.Add,
                            true);

                    if (result != TaskDialogResult.Cancel)
                    {
                        app.IsEnabled = true;
                        WcfService.AddSua(app);
                    }
                    else
                    {
                        Environment.Exit(0);
                    }
                }
            }

            base.OnStartup(e, isFirstInstance);

            if (!isFirstInstance)
            {
                this.Shutdown(1);
            }
            else
            {
                RegisterApplicationRecoveryAndRestart();
                MyServiceHost.StartService();
                Args = e.Args;
                SetJumpList();
                Utilities.ErrorOccurred += LogError;
            }
        }
Exemple #5
0
        /// <summary>Installs the shortcuts of an update.</summary>
        /// <param name="shortcuts">The shortcuts to install on the system.</param>
        /// <param name="appInfo">The application information.</param>
        static void SetShortcuts(IList<Shortcut> shortcuts, Sua appInfo)
        {
            if (shortcuts == null)
            {
                return;
            }

            // Choose the path for the shortcut
            for (int x = 0; x < shortcuts.Count; x++)
            {
                shortcuts[x].Location = Utilities.ExpandInstallLocation(
                    shortcuts[x].Location, appInfo.Directory, appInfo.Platform, appInfo.ValueName);
                string linkName = Utilities.GetLocaleString(shortcuts[x].Name);

                if (shortcuts[x].Action == ShortcutAction.Add
                    ||
                    (shortcuts[x].Action == ShortcutAction.Update
                     && File.Exists(Path.Combine(shortcuts[x].Location, linkName + ".lnk"))))
                {
                    if (!Directory.Exists(shortcuts[x].Location))
                    {
                        Directory.CreateDirectory(shortcuts[x].Location);
                    }

                    File.Delete(Path.Combine(shortcuts[x].Location, linkName + ".lnk"));

                    Shortcut.CreateShortcut(shortcuts[x]);
                }

                if (shortcuts[x].Action == ShortcutAction.Delete)
                {
                    File.Delete(shortcuts[x].Location);
                }

                int installProgress = (x * 100) / shortcuts.Count;
                if (installProgress > 90)
                {
                    installProgress -= 15;
                }

                ReportProgress(installProgress);
            }
        }