Conflicts:
	MediaBrowser.ServerApplication/ApplicationHost.cs
This commit is contained in:
LukePulverenti 2013-02-28 14:41:25 -05:00
commit 7cacbeee7b
7 changed files with 106 additions and 31 deletions

View File

@ -123,10 +123,7 @@ namespace MediaBrowser.Api
if (updateCheckResult.IsUpdateAvailable)
{
result.Add(new PackageVersionInfo
{
versionStr = updateCheckResult.AvailableVersion.ToString()
});
result.Add(updateCheckResult.Package);
}
}

View File

@ -8,6 +8,6 @@ namespace MediaBrowser.Common.Constants
{
public static class Constants
{
public const string MBAdminUrl = "http://mb3admin.com/admin/";
public const string MBAdminUrl = "http://www.mb3admin.com/admin/";
}
}

View File

@ -112,31 +112,59 @@ namespace MediaBrowser.Installer
// Determine Package version
var version = await GetPackageVersion();
lblStatus.Content = string.Format("Downloading {0} (version {1})...", FriendlyName, version.versionStr);
// Now in the background - try and shut down the server if that is what we are installing
if (PackageName == "MBServer")
{
Task.Run(async () =>
// Now try and shut down the server if that is what we are installing and it is running
if (PackageName == "MBServer" && Process.GetProcessesByName("mediabrowser.serverapplication").Length != 0)
{
lblStatus.Content = "Shutting Down Media Browser Server...";
using (var client = new WebClient())
{
try
{
await client.UploadStringTaskAsync("http://localhost:8096/mediabrowser/system/shutdown", "").ConfigureAwait(false);
client.UploadString("http://localhost:8096/mediabrowser/System/Shutdown", "");
}
catch (WebException e)
{
if (e.GetStatus() == HttpStatusCode.NotFound || e.Message.StartsWith("Unable to connect",StringComparison.OrdinalIgnoreCase)) return; // just wasn't running
MessageBox.Show("Error shutting down server.\n\n" + e.GetStatus() + "\n\n" + e.Message);
MessageBox.Show("Error shutting down server. Please be sure it is not running before hitting OK.\n\n" + e.GetStatus() + "\n\n" + e.Message);
}
}
});
}
else
{
if (PackageName == "MBTheater")
{
// Uninstalling MBT - shut it down if it is running
var processes = Process.GetProcessesByName("mediabrowser.ui");
if (processes.Length > 0)
{
lblStatus.Content = "Shutting Down Media Browser Theater...";
try
{
processes[0].Kill();
}
catch (Exception ex)
{
MessageBox.Show("Unable to shutdown Media Browser Theater. Please ensure it is not running before hitting OK.\n\n" + ex.Message, "Error");
}
}
}
}
// Download
var archive = await DownloadPackage(version);
string archive = null;
lblStatus.Content = string.Format("Downloading {0} (version {1})...", FriendlyName, version.versionStr);
try
{
archive = await DownloadPackage(version);
}
catch (Exception e)
{
SystemClose("Error Downloading Package - " + e.GetType().FullName + "\n\n" + e.Message);
}
dlAnimation.StopAnimation();
prgProgress.Visibility = btnCancel.Visibility = Visibility.Hidden;

View File

@ -29,7 +29,7 @@
<PublisherName>Media Browser Team</PublisherName>
<SuiteName>Media Browser</SuiteName>
<OpenBrowserOnPublish>false</OpenBrowserOnPublish>
<ApplicationRevision>21</ApplicationRevision>
<ApplicationRevision>28</ApplicationRevision>
<ApplicationVersion>0.1.1.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>

View File

@ -17,6 +17,15 @@ namespace MediaBrowser.Model.Updates
/// Gets or sets the available version.
/// </summary>
/// <value>The available version.</value>
public Version AvailableVersion { get; set; }
public Version AvailableVersion
{
get { return Package != null ? Package.version : new Version(0, 0); }
set { } // need this for the serializer
}
/// <summary>
/// Get or sets package information for an available update
/// </summary>
public PackageVersionInfo Package { get; set; }
}
}

View File

@ -11,6 +11,7 @@ using MediaBrowser.Common.IO;
using MediaBrowser.Common.Kernel;
using MediaBrowser.Common.Net;
using MediaBrowser.Common.ScheduledTasks;
using MediaBrowser.Common.Updates;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Library;
using MediaBrowser.IsoMounter;
@ -148,7 +149,7 @@ namespace MediaBrowser.ServerApplication
/// <value><c>true</c> if this instance can self update; otherwise, <c>false</c>.</value>
public bool CanSelfUpdate
{
get { return ClickOnceHelper.IsNetworkDeployed; }
get { return true; }
}
/// <summary>
@ -157,10 +158,14 @@ namespace MediaBrowser.ServerApplication
/// <param name="cancellationToken">The cancellation token.</param>
/// <param name="progress">The progress.</param>
/// <returns>Task{CheckForUpdateResult}.</returns>
public Task<CheckForUpdateResult> CheckForApplicationUpdate(CancellationToken cancellationToken, IProgress<double> progress)
public async Task<CheckForUpdateResult> CheckForApplicationUpdate(CancellationToken cancellationToken, IProgress<double> progress)
{
// Get package manager using Resolve<IPackageManager>()
return new ApplicationUpdateCheck().CheckForApplicationUpdate(cancellationToken, progress);
var pkgManager = Resolve<IPackageManager>();
var availablePackages = await pkgManager.GetAvailablePackages(Resolve<IHttpClient>(), Resolve<INetworkManager>(), Kernel.SecurityManager, Kernel.ResourcePools, Resolve<IJsonSerializer>(), CancellationToken.None).ConfigureAwait(false);
var version = Kernel.InstallationManager.GetLatestCompatibleVersion(availablePackages, "MBServer", Kernel.Configuration.SystemUpdateLevel);
return version != null ? new CheckForUpdateResult {AvailableVersion = version.version, IsUpdateAvailable = version.version > ApplicationVersion, Package = version} :
new CheckForUpdateResult();
}
/// <summary>

View File

@ -1,5 +1,6 @@
using System;
using System.Diagnostics;
using System.Net;
using System.Reflection;
using System.IO;
using System.Threading;
@ -78,6 +79,41 @@ namespace MediaBrowser.Uninstaller.Execute
if (Product == "Server")
{
RemoveShortcut(Path.Combine(startMenu, "MB Dashboard.lnk"));
if (Process.GetProcessesByName("mediabrowser.serverapplication").Length != 0)
{
using (var client = new WebClient())
{
lblHeading.Content = "Shutting Down Media Browser Server...";
try
{
client.UploadString("http://localhost:8096/mediabrowser/system/shutdown", "");
}
catch (WebException ex)
{
if (ex.Status != WebExceptionStatus.ConnectFailure && !ex.Message.StartsWith("Unable to connect", StringComparison.OrdinalIgnoreCase))
{
MessageBox.Show("Error shutting down server. Please be sure it is not running before hitting OK.\n\n" + ex.Status + "\n\n" + ex.Message);
}
}
}
}
}
else
{
// Installing MBT - shut it down if it is running
var processes = Process.GetProcessesByName("mediabrowser.ui");
if (processes.Length > 0)
{
lblHeading.Content = "Shutting Down Media Browser Theater...";
try
{
processes[0].Kill();
}
catch (Exception ex)
{
MessageBox.Show("Unable to shutdown Media Browser Theater. Please ensure it is not running before hitting OK.\n\n" + ex.Message, "Error");
}
}
}
// if the startmenu item is empty now - delete it too
if (Directory.GetFiles(startMenu).Length == 0)
@ -99,6 +135,7 @@ namespace MediaBrowser.Uninstaller.Execute
var rootPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "MediaBrowser" + RootSuffix);
lblHeading.Content = "Removing System Files...";
if (cbxRemoveAll.IsChecked == true)
{
// Just remove our whole directory
@ -107,7 +144,6 @@ namespace MediaBrowser.Uninstaller.Execute
else
{
// First remove the system
lblHeading.Content = "Removing System Files...";
RemovePath(Path.Combine(rootPath, "System"));
RemovePath(Path.Combine(rootPath, "MediaTools"));