/// <summary>Adds an application to Seven Update, so it can manage updates for it.</summary> /// <param name="application">The application to add to Seven Update.</param> public void AddApp(Sua application) { if (application == null) { throw new ArgumentNullException("application"); } Collection<Sua> sul = null; if (File.Exists(App.ApplicationsFile)) { sul = Utilities.Deserialize<Collection<Sua>>(App.ApplicationsFile); } if (sul == null) { sul = new Collection<Sua>(); } for (int x = 0; x < sul.Count; x++) { if (sul[x].Platform != application.Platform || sul[x].Directory != application.Directory) { continue; } sul.RemoveAt(x); x--; continue; } application.IsEnabled = true; sul.Add(application); Utilities.Serialize(sul, App.ApplicationsFile); }
/// <summary>Creates a new project.</summary> internal static void NewProject() { ResetPages(); IsNewProject = true; AppIndex = -1; UpdateIndex = -1; AppInfo = new Sua(); UpdateInfo = new Update { ReleaseDate = DateTime.Now.ToShortDateString() }; MainWindow.NavService.Navigate(AppInfoPage); }
/// <summary>Adds an application to Seven Update, so it can manage updates for it.</summary> /// <param name="application">The application to add to Seven Update.</param> public void AddApp(Sua application) { if (application == null) { throw new ArgumentNullException("application"); } Collection <Sua> sul = null; if (File.Exists(App.ApplicationsFile)) { sul = Utilities.Deserialize <Collection <Sua> >(App.ApplicationsFile); } if (sul == null) { sul = new Collection <Sua>(); } for (int x = 0; x < sul.Count; x++) { if (sul[x].Platform != application.Platform || sul[x].Directory != application.Directory) { continue; } sul.RemoveAt(x); x--; continue; } application.IsEnabled = true; sul.Add(application); Utilities.Serialize(sul, App.ApplicationsFile); }
/// <summary>Processes the command line arguments.</summary> /// <param name="args">The arguments to process.</param> static void ProcessArgs(IList<string> args) { if (args.Count <= 0) { } else { if (string.Compare(args[0], "Abort", true) == 0) { try { using ( FileStream fs = File.Create( Path.Combine( Environment.ExpandEnvironmentVariables("%WINDIR%"), "Temp", "abort.lock"))) { fs.WriteByte(0); } } catch (Exception e) { if ( !(e is OperationCanceledException || e is UnauthorizedAccessException || e is InvalidOperationException || e is NotSupportedException)) { ErrorOccurred( null, new ErrorOccurredEventArgs(Utilities.GetExceptionAsString(e), ErrorType.FatalError)); throw; } Utilities.ReportError(e, ErrorType.GeneralError); } ShutdownApp(); } if (string.Compare(args[0], "Auto", true) == 0) { if ( File.Exists( Path.Combine(Environment.ExpandEnvironmentVariables("%WINDIR%"), "Temp", "abort.lock"))) { try { File.Delete( Path.Combine(Environment.ExpandEnvironmentVariables("%WINDIR%"), "Temp", "abort.lock")); } catch (Exception e) { if ( !(e is OperationCanceledException || e is UnauthorizedAccessException || e is InvalidOperationException || e is NotSupportedException)) { ErrorOccurred( null, new ErrorOccurredEventArgs(Utilities.GetExceptionAsString(e), ErrorType.FatalError)); throw; } Utilities.ReportError(e, ErrorType.GeneralError); } } isAutoInstall = true; IsInstalling = true; notifyIcon.BalloonTipClicked += RunSevenUpdate; notifyIcon.Click += RunSevenUpdate; notifyIcon.Visible = true; Search.ErrorOccurred += ErrorOccurred; var apps = new Collection<Sua>(); if (File.Exists(ApplicationsFile)) { apps = Utilities.Deserialize<Collection<Sua>>(ApplicationsFile); } var publisher = new ObservableCollection<LocaleString>(); var ls = new LocaleString { Value = "Seven Software", Lang = "en" }; publisher.Add(ls); var name = new ObservableCollection<LocaleString>(); ls = new LocaleString { Value = "Seven Update", Lang = "en" }; name.Add(ls); var app = new Sua(name, publisher) { AppUrl = @"http://sevenupdate.com/", Directory = @"HKLM\Software\Microsoft\Windows\CurrentVersion\App Paths\SevenUpdate.exe", ValueName = "Path", HelpUrl = @"http://sevenupdate.com/support/", Platform = Platform.AnyCpu, IsEnabled = true, SuiUrl = @"http://apps.sevenupdate.com/SevenUpdate" }; string channel = null; try { channel = Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Seven Update", "channel", null).ToString(); } catch (NullReferenceException) { } catch (AccessViolationException) { } switch (channel) { case "dev": app.SuiUrl += @"-dev.sui"; break; case "beta": app.SuiUrl += @"-beta.sui"; break; default: app.SuiUrl += @".sui"; break; } apps.Insert(0, app); Search.SearchForUpdates(apps, Path.Combine(AllUserStore, "downloads")); } else { ShutdownApp(); } } }
/// <summary>Processes the command line arguments.</summary> /// <param name="args">The arguments to process.</param> static void ProcessArgs(IList <string> args) { if (args.Count <= 0) { } else { if (string.Compare(args[0], "Abort", true) == 0) { try { using ( FileStream fs = File.Create( Path.Combine( Environment.ExpandEnvironmentVariables("%WINDIR%"), "Temp", "abort.lock"))) { fs.WriteByte(0); } } catch (Exception e) { if ( !(e is OperationCanceledException || e is UnauthorizedAccessException || e is InvalidOperationException || e is NotSupportedException)) { ErrorOccurred( null, new ErrorOccurredEventArgs(Utilities.GetExceptionAsString(e), ErrorType.FatalError)); throw; } Utilities.ReportError(e, ErrorType.GeneralError); } ShutdownApp(); } if (string.Compare(args[0], "Auto", true) == 0) { if ( File.Exists( Path.Combine(Environment.ExpandEnvironmentVariables("%WINDIR%"), "Temp", "abort.lock"))) { try { File.Delete( Path.Combine(Environment.ExpandEnvironmentVariables("%WINDIR%"), "Temp", "abort.lock")); } catch (Exception e) { if ( !(e is OperationCanceledException || e is UnauthorizedAccessException || e is InvalidOperationException || e is NotSupportedException)) { ErrorOccurred( null, new ErrorOccurredEventArgs(Utilities.GetExceptionAsString(e), ErrorType.FatalError)); throw; } Utilities.ReportError(e, ErrorType.GeneralError); } } isAutoInstall = true; IsInstalling = true; notifyIcon.BalloonTipClicked += RunSevenUpdate; notifyIcon.Click += RunSevenUpdate; notifyIcon.Visible = true; Search.ErrorOccurred += ErrorOccurred; var apps = new Collection <Sua>(); if (File.Exists(ApplicationsFile)) { apps = Utilities.Deserialize <Collection <Sua> >(ApplicationsFile); } var publisher = new ObservableCollection <LocaleString>(); var ls = new LocaleString { Value = "Seven Software", Lang = "en" }; publisher.Add(ls); var name = new ObservableCollection <LocaleString>(); ls = new LocaleString { Value = "Seven Update", Lang = "en" }; name.Add(ls); var app = new Sua(name, publisher) { AppUrl = @"http://sevenupdate.com/", Directory = @"HKLM\Software\Microsoft\Windows\CurrentVersion\App Paths\SevenUpdate.exe", ValueName = "Path", HelpUrl = @"http://sevenupdate.com/support/", Platform = Platform.AnyCpu, IsEnabled = true, SuiUrl = @"http://apps.sevenupdate.com/SevenUpdate" }; string channel = null; try { channel = Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Seven Update", "channel", null).ToString(); } catch (NullReferenceException) { } catch (AccessViolationException) { } switch (channel) { case "dev": app.SuiUrl += @"-dev.sui"; break; case "beta": app.SuiUrl += @"-beta.sui"; break; default: app.SuiUrl += @".sui"; break; } apps.Insert(0, app); Search.SearchForUpdates(apps, Path.Combine(AllUserStore, "downloads")); } else { ShutdownApp(); } } }