예제 #1
0
 public override void InitializeFromDefaultSettings()
 {
     Settings = PanoramaSettings.InitializeFromDefaults();
     _appControl.SetUIPanoramaSettings(Settings);
     if (!Settings.PublishToPanorama)
     {
         _appControl.DisablePanoramaSettings();
     }
 }
예제 #2
0
        protected bool Equals(PanoramaSettings other)
        {
            var equal = PublishToPanorama == other.PublishToPanorama &&
                        string.Equals(PanoramaServerUrl, other.PanoramaServerUrl) &&
                        string.Equals(PanoramaUserEmail, other.PanoramaUserEmail) &&
                        string.Equals(PanoramaPassword, other.PanoramaPassword) &&
                        string.Equals(PanoramaFolder, other.PanoramaFolder);

            return(equal);
        }
예제 #3
0
 public void SetUIPanoramaSettings(PanoramaSettings panoramaSettings)
 {
     RunUI(() =>
     {
         textPanoramaUrl.Text        = panoramaSettings.PanoramaServerUrl;
         textPanoramaEmail.Text      = panoramaSettings.PanoramaUserEmail;
         textPanoramaPasswd.Text     = panoramaSettings.PanoramaPassword;
         textPanoramaFolder.Text     = panoramaSettings.PanoramaFolder;
         cbPublishToPanorama.Checked = panoramaSettings.PublishToPanorama;
     });
 }
예제 #4
0
        public static PanoramaSettings InitializeFromDefaults()
        {
            var settings = new PanoramaSettings()
            {
                PanoramaServerUrl = Settings.Default.PanoramaUrl,
                PanoramaUserEmail = Settings.Default.PanoramaUserEmail,
                PanoramaPassword  = Settings.Default.PanoramaPassword,
                PanoramaFolder    = Settings.Default.PanoramaFolder,
                PublishToPanorama = Settings.Default.PublishToPanorama,
            };

            return(settings);
        }
예제 #5
0
        public static PanoramaSettings InitializeFromDefaults()
        {
            var settings = new PanoramaSettings()
            {
                PanoramaServerUrl = Settings.Default.PanoramaUrl,
                PanoramaUserEmail = Settings.Default.PanoramaUserEmail,
                PanoramaPassword = Settings.Default.PanoramaPassword,
                PanoramaFolder = Settings.Default.PanoramaFolder,
                PublishToPanorama = Settings.Default.PublishToPanorama,
            };

            return settings;
        }
예제 #6
0
        private PanoramaSettings GetPanoramaSettingsFromUI()
        {
            var panoramaSettings = new PanoramaSettings()
            {
                PanoramaServerUrl = textPanoramaUrl.Text,
                PanoramaUserEmail = textPanoramaEmail.Text,
                PanoramaPassword  = textPanoramaPasswd.Text,
                PanoramaFolder    = textPanoramaFolder.Text,
                PublishToPanorama = cbPublishToPanorama.Checked
            };

            return(panoramaSettings);
        }
예제 #7
0
파일: AutoQcConfig.cs 프로젝트: zrolfs/pwiz
        public void ReadXml(XmlReader reader)
        {
            Name = reader.GetAttribute(ATTR.name);

            // TODO: Configurations shouldn't start automatically when the program starts up.
            //       Remove this attribute from the config XML?
            IsEnabled = false; // reader.GetBoolAttribute(ATTR.is_enabled);
            User      = reader.GetAttribute(ATTR.user);
            DateTime dateTime;

            DateTime.TryParse(reader.GetAttribute(ATTR.created), out dateTime);
            Created = dateTime;
            DateTime.TryParse(reader.GetAttribute(ATTR.modified), out dateTime);
            Modified = dateTime;

            do
            {
                reader.Read();
            } while (reader.NodeType != XmlNodeType.Element);

            var mainSettings = new MainSettings();

            mainSettings.ReadXml(reader);
            MainSettings = mainSettings;
            do
            {
                reader.Read();
            } while (reader.NodeType != XmlNodeType.Element);

            var panoramaSettings = new PanoramaSettings();

            panoramaSettings.ReadXml(reader);
            PanoramaSettings = panoramaSettings;
            do
            {
                reader.Read();
            } while (reader.NodeType != XmlNodeType.EndElement);
        }
예제 #8
0
        public void ReadXml(XmlReader reader)
        {
            Name = reader.GetAttribute(ATTR.name);

            IsEnabled = reader.GetBoolAttribute(ATTR.is_enabled);
            User      = reader.GetAttribute(ATTR.user);
            DateTime dateTime;

            DateTime.TryParse(reader.GetAttribute(ATTR.created), out dateTime);
            Created = dateTime;
            DateTime.TryParse(reader.GetAttribute(ATTR.modified), out dateTime);
            Modified = dateTime;

            do
            {
                reader.Read();
            } while (reader.NodeType != XmlNodeType.Element);

            var mainSettings = new MainSettings();

            mainSettings.ReadXml(reader);
            MainSettings = mainSettings;
            do
            {
                reader.Read();
            } while (reader.NodeType != XmlNodeType.Element);

            var panoramaSettings = new PanoramaSettings();

            panoramaSettings.ReadXml(reader);
            PanoramaSettings = panoramaSettings;
            do
            {
                reader.Read();
            } while (reader.NodeType != XmlNodeType.EndElement);
        }
예제 #9
0
        public void TestValidatePanoramaSettings()
        {
            var logger = new TestLogger();
            var settings = new PanoramaSettings();

            var mainControl = new TestAppControl();
            mainControl.SetUIPanoramaSettings(settings);

            var panoramaSettingsTab = new PanoramaSettingsTab(mainControl, logger);

            Assert.IsTrue(panoramaSettingsTab.ValidateSettings());
            var log = logger.GetLog();
            Assert.IsTrue(log.Contains("Will NOT publish Skyline documents to Panorama."));

            settings.PublishToPanorama = true;
            logger.Clear();
            panoramaSettingsTab.Settings = settings;
            Assert.IsFalse(panoramaSettingsTab.ValidateSettings());
            log = logger.GetLog();
            Assert.IsTrue(log.Contains("Please specify a Panorama server URL."));
            Assert.IsTrue(log.Contains("Please specify a Panorama login name."));
            Assert.IsTrue(log.Contains("Please specify a Panorama user password."));
            Assert.IsTrue(log.Contains("Please specify a folder on the Panorama server."));
        }
예제 #10
0
 public void SetUIPanoramaSettings(PanoramaSettings panoramaSettings)
 {
     _panoramaSettings = panoramaSettings;
 }
예제 #11
0
 public PanoramaSettingsTab(IAppControl appControl, IAutoQCLogger logger)
     : base(appControl, logger)
 {
     Settings = new PanoramaSettings();
 }
예제 #12
0
 public PanoramaPinger(PanoramaSettings panoramaSettings, IAutoQcLogger logger)
 {
     _panoramaSettings = panoramaSettings;
     _logger           = logger;
 }
예제 #13
0
 public PanoramaSettingsTab(IAppControl appControl, IAutoQCLogger logger)
     : base(appControl, logger)
 {
     Settings = new PanoramaSettings();
 }
예제 #14
0
        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;
        }
예제 #15
0
 public override void InitializeFromDefaultSettings()
 {
     Settings = PanoramaSettings.InitializeFromDefaults();
     _appControl.SetUIPanoramaSettings(Settings);
     if (!Settings.PublishToPanorama)
     {
         _appControl.DisablePanoramaSettings();
     }
 }
예제 #16
0
        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);
        }