예제 #1
0
        public async void ConnectionTest()
        {
            var    p = new Ping();
            string primaryServerStatus   = "checking...";
            string secondaryServerStatus = "waiting...";

            SubsonicConnectionTest = "Primary server: " + primaryServerStatus + "\n" +
                                     "Secondary server: " + secondaryServerStatus;

            // Primary server
            var url = PrimaryServerAddress;

            if (String.IsNullOrEmpty(url) == false)
            {
                if (url.EndsWith("/") == false)
                {
                    url = url + "/";
                }

                var result = false;

                await Task.Run(() => p.CheckServer(url, IgnoreSSLcertificateError, SubsonicID, SubsonicPassword, out result));

                if (result)
                {
                    primaryServerStatus = "OK!";
                }
                else
                {
                    primaryServerStatus = "Cant reach server :(";
                }
            }
            else
            {
                primaryServerStatus = "N/A";
            }
            secondaryServerStatus  = "checking...";
            SubsonicConnectionTest = "Primary server: " + primaryServerStatus + "\n" +
                                     "Secondary server: " + secondaryServerStatus;

            // Secondary server
            url = SecondaryServerAddress;
            if (String.IsNullOrEmpty(url) == false)
            {
                if (url.EndsWith("/") == false)
                {
                    url = url + "/";
                }

                var result = false;

                await Task.Run(() => p.CheckServer(url, IgnoreSSLcertificateError, SubsonicID, SubsonicPassword, out result));

                if (result)
                {
                    secondaryServerStatus = "OK!";
                }
                else
                {
                    secondaryServerStatus = "Cant reach server :(";
                }
            }
            else
            {
                secondaryServerStatus = "N/A";
            }

            SubsonicConnectionTest = "Primary server: " + primaryServerStatus + "\n" +
                                     "Secondary server: " + secondaryServerStatus;
        }