Browse Source

Fixed little bug with checking for update location

Kenric Nugteren 7 months ago
parent
commit
b55e0399b2
1 changed files with 24 additions and 17 deletions
  1. 24 17
      prs.desktop/MainWindow.xaml.cs

+ 24 - 17
prs.desktop/MainWindow.xaml.cs

@@ -3112,26 +3112,33 @@ public partial class MainWindow : IPanelHostControl
     {
         if (App.DatabaseSettings.DatabaseType == DatabaseType.Networked)
         {
-            string url = "";
-            //var domain = App.DatabaseSettings.URL.Split(new[] { "://" }, StringSplitOptions.RemoveEmptyEntries).Last();
-            //var port = App.DatabaseSettings.Port;
-            var domain = ClientFactory.Parameters?.FirstOrDefault()?.ToString() ?? "";
-            domain = domain.Split(new[] { "://" }, StringSplitOptions.RemoveEmptyEntries).LastOrDefault() ?? "";
-            if (!String.IsNullOrWhiteSpace(domain))
-            {
-                
-                try
+            if(ClientFactory.ClientType == typeof(RestClient<>))
+            {
+                string url = "";
+                //var domain = App.DatabaseSettings.URL.Split(new[] { "://" }, StringSplitOptions.RemoveEmptyEntries).Last();
+                //var port = App.DatabaseSettings.Port;
+                var domain = ClientFactory.Parameters?.FirstOrDefault()?.ToString() ?? "";
+                domain = domain.Split(new[] { "://" }, StringSplitOptions.RemoveEmptyEntries).LastOrDefault() ?? "";
+                if (!String.IsNullOrWhiteSpace(domain))
                 {
-                    var client = new HttpClient { BaseAddress = new Uri($"https://{domain}") };
-                    client.GetAsync("operations").Wait();
-                    url = $"https://{domain}";
-                }
-                catch (Exception)
-                {
-                    url = $"http://{domain}";
+                    
+                    try
+                    {
+                        var client = new HttpClient { BaseAddress = new Uri($"https://{domain}") };
+                        client.GetAsync("operations").Wait();
+                        url = $"https://{domain}";
+                    }
+                    catch (Exception)
+                    {
+                        url = $"http://{domain}";
+                    }
                 }
+                return url;
+            }
+            else
+            {
+                return "";
             }
-            return url;
         }
         else
             return Path.Combine(CoreUtils.GetCommonAppData("PRSServer"), "update");