Beispiel #1
0
        /// <summary>
        /// Event Handler for onFileChanged for our FileWatcher which is watching our app config
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnFileChange(object sender, FileSystemEventArgs e)
        {
            string usrname      = AppConfig.readFromAppConfig("username");
            string appConfLogin = AppConfig.readFromAppConfig("login");

            if (((!usrname.Equals("") || !usrname.Equals(" ")) && appConfLogin.Equals("success")))
            {
                this.dataContext.Login.UserName = usrname;                                  // update username to display it in the ui
                this.btnLogin.Visibility        = System.Windows.Visibility.Hidden;         //hidde login button
                this.btnLogout.Visibility       = System.Windows.Visibility.Visible;        //show logout button
                this.txbSuccessfullSaved.Text   = Properties.Resources.successFullLoggedIn; // notify user that all is nice

                // set login key in app.conig to null
                // reasone for that: if something in the app conf changs, this check obove will not be enabled again
                //
                AppConfig.writeToAppConfig("login", "");
            }

            if (appConfLogin.Equals("error"))
            {
                // Inform user about problem
                //
                MessageBox.Show("L10N", "L10N", MessageBoxButton.OK, MessageBoxImage.Error);

                // set login key in app.conig to null
                // reasone for that: if something in the app conf changs, this check obove will not be enabled again
                //
                AppConfig.writeToAppConfig("login", "");
            }
        }
Beispiel #2
0
        /// <summary>
        /// Saves the setting values
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void settingsOnClick(object sender, RoutedEventArgs e)
        {
            //if settings are saved save the settings to our app.config
            //

            // Storeing the Emergency Installation Path
            //
            bool emergencyInstallationPathSaved = AppConfig.writeToAppConfig("emergencyInstallationPath", tbxEmergencyPath.Text);

            // Storing the Compression Mode, zip or brotli
            //
            string compressionToConfig;

            #region ZipOrBrotliMode
            if (rbBrotli.IsChecked == true)
            {
                compressionToConfig = "brotli";
            }
            else
            {
                compressionToConfig = "zip";
            }
            #endregion

            bool settingUseZipOrBrotli = AppConfig.writeToAppConfig("compressionAlgorithm", compressionToConfig);


            // if the Installation path of emergency has changed our Emergency X has to be restarted (for reasons...)
            //

            if (oldEmergencyPath != tbxEmergencyPath.Text)
            {
                // Inform the user and restart the Application
                //
                MessageBox.Show(Properties.Resources.clientRestartNeeded, Properties.Resources.clientRestartNeededTitle, MessageBoxButton.OK, MessageBoxImage.Asterisk);
                System.Diagnostics.Process.Start(Application.ResourceAssembly.Location);
                Application.Current.Shutdown();
            }
            else
            {
                // After clean up close the window
                //
                Settings.GetWindow(SettingsWindow).Close();
            }
        }
Beispiel #3
0
        /// <summary>
        /// Logs the user with the given data in
        /// </summary>
        /// <param name="username">User provided username</param>
        /// <param name="password">User's password</param>
        /// <param name="remember">Remain logged in or not</param>
        public async void FullLogin(string username, string password, bool remember)
        {
            // SSL Crt (should been placed in Solution Dir with Build Option Copy always)
            //
            SslCredentials cred = new SslCredentials(File.ReadAllText("server.crt"));

            // new Channel and then a new client based on that Channel
            //
            var connectionChannel = new Channel("beta.emergencyx.de:50051", cred);
            var emx = EmergencyExplorerService.NewClient(connectionChannel);

            // For testing only hardcoded login informations
            //
            LoginRequest request = new LoginRequest {
                Username = username, Password = password, RememberMe = remember
            };
            LoginResponse response = await emx.LoginAsync(request);

            // stop if no success...
            //
            if (response.Success != true)
            {
                AppConfig.writeToAppConfig("login", "error");
                throw new NotSuccessFullLoggedInException();
            }

            //Save the responded date to re-login the user every program session until he logs out
            //
            AppConfig.writeToAppConfig("rememberMe", remember.ToString());
            AppConfig.writeToAppConfig("userId", response.UserId.ToString());
            AppConfig.writeToAppConfig("token", response.Token);
            AppConfig.writeToAppConfig("username", request.Username);
            AppConfig.writeToAppConfig("login", "success");

            //All done
            //
            connectionChannel.ShutdownAsync().Wait();
        }