StartupWizard.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. using MediaBrowser.Common;
  2. using MediaBrowser.Controller.Configuration;
  3. using MediaBrowser.Controller.Library;
  4. using MediaBrowser.Controller.Plugins;
  5. using MediaBrowser.Model.Logging;
  6. using System.ComponentModel;
  7. using System.Linq;
  8. using System.Windows;
  9. namespace MediaBrowser.ServerApplication.EntryPoints
  10. {
  11. /// <summary>
  12. /// Class StartupWizard
  13. /// </summary>
  14. public class StartupWizard : IServerEntryPoint
  15. {
  16. /// <summary>
  17. /// The _app host
  18. /// </summary>
  19. private readonly IApplicationHost _appHost;
  20. /// <summary>
  21. /// The _user manager
  22. /// </summary>
  23. private readonly IUserManager _userManager;
  24. private readonly ILogger _logger;
  25. private readonly IServerConfigurationManager _configurationManager;
  26. /// <summary>
  27. /// Initializes a new instance of the <see cref="StartupWizard" /> class.
  28. /// </summary>
  29. /// <param name="appHost">The app host.</param>
  30. /// <param name="userManager">The user manager.</param>
  31. public StartupWizard(IApplicationHost appHost, IUserManager userManager, IServerConfigurationManager configurationManager)
  32. {
  33. _appHost = appHost;
  34. _userManager = userManager;
  35. _configurationManager = configurationManager;
  36. }
  37. /// <summary>
  38. /// Runs this instance.
  39. /// </summary>
  40. public void Run()
  41. {
  42. if (_appHost.IsFirstRun)
  43. {
  44. LaunchStartupWizard();
  45. }
  46. }
  47. /// <summary>
  48. /// Launches the startup wizard.
  49. /// </summary>
  50. private void LaunchStartupWizard()
  51. {
  52. var user = _userManager.Users.FirstOrDefault(u => u.Configuration.IsAdministrator);
  53. try
  54. {
  55. App.OpenDashboardPage("wizardStart.html", user, _configurationManager);
  56. }
  57. catch (Win32Exception ex)
  58. {
  59. _logger.ErrorException("Error launching startup wizard", ex);
  60. MessageBox.Show("There was an error launching the Media Browser startup wizard. Please ensure a web browser is installed on the machine and is configured as the default browser.", "Media Browser");
  61. }
  62. }
  63. /// <summary>
  64. /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
  65. /// </summary>
  66. public void Dispose()
  67. {
  68. }
  69. }
  70. }