/// <summary>
        /// Validates a users credentials by calling the Login method
        /// on the web service object. If successful, main bug manager
        /// is displayed and login window closed.
        /// </summary>
        /// <param name="loginParameter">Custom object to store login parameters.</param>
        public void Login()
        {
            if (IsRememberMeChecked)
            {
                StoreUserCredentials();
            }
            else
            {
                FlushUserCredentials();
            }

            // Tell the service container to create a new service with these credentials
            ClientBase <ITrackerService> svc = _ServiceFactory.CreateService(Username, Password);

            svc.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode =
                System.ServiceModel.Security.X509CertificateValidationMode.None;

            IsLoadingVisible = true;

            Task openConnection = new Task(() => {
                try
                {
                    // Test if we can open the communication channel
                    svc.Open();
                }
                // Display message if invalid credentials.
                catch (MessageSecurityException)
                {
                    IsLoadingVisible = false;
                    MessageBox.Show("Invalid username or password!");
                }
                catch (FaultException)
                {
                    IsLoadingVisible = false;
                    MessageBox.Show("Could not connect to web service.");
                }
            });

            Task openWindow = openConnection.ContinueWith(p =>
            {
                if (p.Exception == null)
                {
                    _WindowFactory.CreateMainWindow().Show();
                    RequestClose(this, null);
                }
                else
                {
                    MessageBox.Show("Could not connect to web service.");
                    IsLoadingVisible = false;
                }
            }, TaskScheduler.FromCurrentSynchronizationContext());

            openConnection.Start();
        }
Exemple #2
0
        public void ShowMainWindow()
        {
            if (main == null)
            {
                main = factory.CreateMainWindow();
            }

            mainIsShown = true;
            main.Show();
        }
Exemple #3
0
        private IWindow GetWindowByType(WindowType type)
        {
            switch (type)
            {
            case WindowType.BarometricPressureHistory:
                return(_windowFactory.CreateBarPressureHistory());

            case WindowType.TemperatureHistory:
                return(_windowFactory.CreateTemperatureHistory());

            case WindowType.UnitSettings:
                return(_windowFactory.CreateUnitSettingsWindow());

            case WindowType.MainWindow:
                return(_windowFactory.CreateMainWindow());

            case WindowType.DateAndTimeSettings:
                return(_windowFactory.CreateDateAndTimeSettingsWindow());
            }
            throw new NotSupportedException();
        }