Browse Source

Add server shutdown to uninstaller

Shutdown still doesn't work on server end
Eric Reed 12 years ago
parent
commit
bbb654c030
1 changed files with 17 additions and 1 deletions
  1. 17 1
      MediaBrowser.Uninstaller.Execute/MainWindow.xaml.cs

+ 17 - 1
MediaBrowser.Uninstaller.Execute/MainWindow.xaml.cs

@@ -1,5 +1,6 @@
 using System;
 using System;
 using System.Diagnostics;
 using System.Diagnostics;
+using System.Net;
 using System.Reflection;
 using System.Reflection;
 using System.IO;
 using System.IO;
 using System.Threading;
 using System.Threading;
@@ -78,6 +79,21 @@ namespace MediaBrowser.Uninstaller.Execute
             if (Product == "Server")
             if (Product == "Server")
             {
             {
                 RemoveShortcut(Path.Combine(startMenu, "MB Dashboard.lnk"));
                 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 the startmenu item is empty now - delete it too
             if (Directory.GetFiles(startMenu).Length == 0)
             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);
             var rootPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "MediaBrowser" + RootSuffix);
 
 
+            lblHeading.Content = "Removing System Files...";
             if (cbxRemoveAll.IsChecked == true)
             if (cbxRemoveAll.IsChecked == true)
             {
             {
                 // Just remove our whole directory
                 // Just remove our whole directory
@@ -107,7 +124,6 @@ namespace MediaBrowser.Uninstaller.Execute
             else
             else
             {
             {
                 // First remove the system
                 // First remove the system
-                lblHeading.Content = "Removing System Files...";
                 RemovePath(Path.Combine(rootPath, "System"));
                 RemovePath(Path.Combine(rootPath, "System"));
                 RemovePath(Path.Combine(rootPath, "MediaTools"));
                 RemovePath(Path.Combine(rootPath, "MediaTools"));