Add server shutdown to uninstaller

Shutdown still doesn't work on server end
This commit is contained in:
Eric Reed 2013-02-28 11:33:54 -05:00
parent 203f2fff12
commit bbb654c030

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,21 @@ namespace MediaBrowser.Uninstaller.Execute
if (Product == "Server")
{
RemoveShortcut(Path.Combine(startMenu, "MB Dashboard.lnk"));
using (var client = new WebClient())
{
lblHeading.Content = "Shutting Down 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);
}
}
}
}
// if the startmenu item is empty now - delete it too
if (Directory.GetFiles(startMenu).Length == 0)
@ -99,6 +115,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 +124,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"));