Exemple #1
0
        public void ValidateSettings()
        {
            if (!PublishToPanorama)
            {
                return;
            }

            if (string.IsNullOrWhiteSpace(PanoramaServerUrl))
            {
                throw new ArgumentException("Please specify a Panorama server URL.");
            }
            try
            {
                PanoramaServerUri = new Uri(PanoramaUtil.ServerNameToUrl(PanoramaServerUrl));
            }
            catch (UriFormatException)
            {
                throw new ArgumentException("Panorama server name is invalid.");
            }

            if (string.IsNullOrWhiteSpace(PanoramaUserEmail))
            {
                throw new ArgumentException("Please specify a Panorama login email.");
            }
            if (string.IsNullOrWhiteSpace(PanoramaPassword))
            {
                throw new ArgumentException("Please specify a Panorama user password.");
            }

            if (string.IsNullOrWhiteSpace(PanoramaFolder))
            {
                throw new ArgumentException("Please specify a folder on the Panorama server.");
            }

            // Verify that we can connect to the given Panorama server with the user's credentials.
            var panoramaClient = new WebPanoramaClient(PanoramaServerUri);

            try
            {
                PanoramaUtil.VerifyServerInformation(panoramaClient, PanoramaUserEmail, PanoramaPassword);
                PanoramaServerUri = panoramaClient.ServerUri ?? PanoramaServerUri;
                PanoramaServerUrl = PanoramaServerUri.AbsoluteUri;
            }
            catch (Exception ex)
            {
                throw new ArgumentException(ex.Message);
            }

            try
            {
                PanoramaUtil.VerifyFolder(panoramaClient,
                                          new Server(PanoramaServerUri, PanoramaUserEmail,
                                                     PanoramaPassword),
                                          PanoramaFolder);
            }
            catch (Exception ex)
            {
                throw new ArgumentException(ex.Message);
            }
        }
Exemple #2
0
        public void PingPanoramaServer()
        {
            var panoramaServerUri = _panoramaSettings.PanoramaServerUri;

            if (!_panoramaSettings.PublishToPanorama || panoramaServerUri == null)
            {
                return;
            }

            var panoramaClient = new WebPanoramaClient(panoramaServerUri);

            try
            {
                var success = panoramaClient.PingPanorama(_panoramaSettings.PanoramaFolder,
                                                          _panoramaSettings.PanoramaUserEmail,
                                                          _panoramaSettings.PanoramaPassword
                                                          );

                if (success && _status != 1)
                {
                    _logger.Log("Successfully pinged Panorama server.");
                    _status = 1;
                }
                if (!success && _status != 2)
                {
//                        _logger.LogErrorToFile("Error pinging Panorama server.  Please confirm that " + panoramaServerUri +
//                                 " is running LabKey Server 16.1 or higher.");
                    _status = 2;
                }
            }
            catch (Exception ex)
            {
                if (_status != 2)
                {
                    _logger.LogException(ex, "Error pinging Panorama server " + panoramaServerUri);
                    _status = 2;
                }
            }
        }
        public void PingPanoramaServer()
        {
            var panoramaServerUri = _panoramaSettingsTab.PanoramaServerUri;

            if (_panoramaSettingsTab.IsSelected() && panoramaServerUri != null)
            {
                var panoramaClient = new WebPanoramaClient(panoramaServerUri);
                try
                {
                    var success = panoramaClient.PingPanorama(_panoramaSettingsTab.Settings.PanoramaFolder,
                                                              _panoramaSettingsTab.Settings.PanoramaUserEmail,
                                                              _panoramaSettingsTab.DecryptPassword(_panoramaSettingsTab.Settings.PanoramaPassword
                                                                                                   ));

                    if (success && _status != 1)
                    {
                        _logger.Log("Successfully pinged Panorama server.");
                        _status = 1;
                    }
                    if (!success && _status != 2)
                    {
                        _logger.LogErrorToFile("Error pinging Panorama server.  Please confirm that " + panoramaServerUri +
                                               " is running LabKey Server 16.1 or higher.");
                        _status = 2;
                    }
                }
                catch (Exception ex)
                {
                    if (_status != 2)
                    {
                        _logger.LogError("Error pinging Panorama server " + panoramaServerUri);
                        _logger.LogException(ex);
                        _status = 2;
                    }
                }
            }
        }
        public override bool ValidateSettings()
        {
            var panoramaSettingsUI = _appControl.GetUIPanoramaSettings();

            if (!panoramaSettingsUI.PublishToPanorama)
            {
                LogOutput("Will NOT publish Skyline documents to Panorama.");
                Settings.PublishToPanorama = false;
                return(true);
            }

            LogOutput("Validating Panorama settings...");
            var error       = false;
            var panoramaUrl = panoramaSettingsUI.PanoramaServerUrl;
            Uri serverUri   = null;

            if (string.IsNullOrWhiteSpace(panoramaUrl))
            {
                LogErrorOutput("Please specify a Panorama server URL.");
                error = true;
            }
            else
            {
                try
                {
                    serverUri = new Uri(PanoramaUtil.ServerNameToUrl(panoramaUrl));
                }
                catch (UriFormatException)
                {
                    LogError("Panorama server name is invalid.");
                    return(false);
                }
            }

            var panoramaEmail  = panoramaSettingsUI.PanoramaUserEmail;
            var panoramaPasswd = panoramaSettingsUI.PanoramaPassword;
            var panoramaFolder = panoramaSettingsUI.PanoramaFolder;

            if (string.IsNullOrWhiteSpace(panoramaEmail))
            {
                LogErrorOutput("Please specify a Panorama login name.");
                error = true;
            }
            if (string.IsNullOrWhiteSpace(panoramaPasswd))
            {
                LogErrorOutput("Please specify a Panorama user password.");
                error = true;
            }
            else
            {
                if (!panoramaPasswd.Equals(Settings.PanoramaPassword))
                {
                    // Encrypt the password
                    try
                    {
                        panoramaPasswd = EncryptPassword(panoramaPasswd);
                        panoramaSettingsUI.PanoramaPassword = panoramaPasswd;
                    }
                    catch (ObjectDisposedException)
                    {
                    }
                }
            }
            if (string.IsNullOrWhiteSpace(panoramaFolder))
            {
                LogErrorOutput("Please specify a folder on the Panorama server.");
                error = true;
            }

            if (error)
            {
                return(false);
            }

            // Verify that we can connect to the given Panorama server with the user's credentials.
            var panoramaClient = new WebPanoramaClient(serverUri);

            try
            {
                PanoramaUtil.VerifyServerInformation(panoramaClient, serverUri, panoramaEmail,
                                                     DecryptPassword(panoramaPasswd));
            }
            catch (Exception ex)
            {
                LogErrorOutput(ex.Message);
                return(false);
            }

            try
            {
                PanoramaUtil.VerifyFolder(panoramaClient,
                                          new Server(serverUri, panoramaEmail, DecryptPassword(panoramaPasswd)),
                                          panoramaFolder);
            }
            catch (Exception ex)
            {
                LogErrorOutput(ex.Message);
                return(false);
            }

            PanoramaServerUri = serverUri;
            Settings          = panoramaSettingsUI;
            return(true);
        }
        public override bool ValidateSettings()
        {
            var panoramaSettingsUI = _appControl.GetUIPanoramaSettings();

            if (!panoramaSettingsUI.PublishToPanorama)
            {
                LogOutput("Will NOT publish Skyline documents to Panorama.");
                Settings.PublishToPanorama = false;
                return true;
            }

            LogOutput("Validating Panorama settings...");
            var error = false;
            var panoramaUrl = panoramaSettingsUI.PanoramaServerUrl;
            Uri serverUri = null;

            if (string.IsNullOrWhiteSpace(panoramaUrl))
            {
                LogErrorOutput("Please specify a Panorama server URL.");
                error = true;
            }
            else
            {
                try
                {
                    serverUri = new Uri(PanoramaUtil.ServerNameToUrl(panoramaUrl));
                }
                catch (UriFormatException)
                {
                    LogError("Panorama server name is invalid.");
                    return false;
                }
            }

            var panoramaEmail = panoramaSettingsUI.PanoramaUserEmail;
            var panoramaPasswd = panoramaSettingsUI.PanoramaPassword;
            var panoramaFolder = panoramaSettingsUI.PanoramaFolder;

            if (string.IsNullOrWhiteSpace(panoramaEmail))
            {
                LogErrorOutput("Please specify a Panorama login name.");
                error = true;
            }
            if (string.IsNullOrWhiteSpace(panoramaPasswd))
            {
                LogErrorOutput("Please specify a Panorama user password.");
                error = true;
            }
            else
            {
                if (!panoramaPasswd.Equals(Settings.PanoramaPassword))
                {
                    // Encrypt the password
                    try
                    {
                        panoramaPasswd = EncryptPassword(panoramaPasswd);
                        panoramaSettingsUI.PanoramaPassword = panoramaPasswd;
                    }
                    catch (ObjectDisposedException)
                    {
                    }
                }
            }
            if (string.IsNullOrWhiteSpace(panoramaFolder))
            {
                LogErrorOutput("Please specify a folder on the Panorama server.");
                error = true;
            }

            if (error)
            {
                return false;
            }

            // Verify that we can connect to the given Panorama server with the user's credentials.
            var panoramaClient = new WebPanoramaClient(serverUri);
            try
            {
                PanoramaUtil.VerifyServerInformation(panoramaClient, serverUri, panoramaEmail,
                    DecryptPassword(panoramaPasswd));
            }
            catch (Exception ex)
            {
                LogErrorOutput(ex.Message);
                return false;
            }

            try
            {
                PanoramaUtil.VerifyFolder(panoramaClient,
                    new Server(serverUri, panoramaEmail, DecryptPassword(panoramaPasswd)),
                    panoramaFolder);
            }
            catch (Exception ex)
            {
                LogErrorOutput(ex.Message);
                return false;
            }

            Settings = panoramaSettingsUI;
            return true;
        }