private async void OK_Click(object sender, RoutedEventArgs e) { var taskScheduler = new Shared.TaskScheduler(); if (TaskSettings.UseBackgroundService) { // let background service do renewals var prefs = await AppViewModel.Current.CertifyClient.GetPreferences(); prefs.UseBackgroundServiceAutoRenewal = true; await AppViewModel.Current.SetPreferences(prefs); //remove any existing scheduled task taskScheduler.DeleteWindowsScheduledTask(); Close(); } else { //create/update scheduled task if (!string.IsNullOrEmpty(Username.Text) && (!string.IsNullOrEmpty(Password.Password))) { if (taskScheduler.CreateWindowsScheduledTask(Username.Text, Password.Password)) { // set pref to use scheduled task for auto renewal let background service do renewals var prefs = await AppViewModel.Current.CertifyClient.GetPreferences(); prefs.UseBackgroundServiceAutoRenewal = false; await AppViewModel.Current.SetPreferences(prefs); MessageBox.Show(SR.ScheduledTaskConfig_TaskCreated); Close(); } else { MessageBox.Show(SR.ScheduledTaskConfig_FailedToCreateTask); } } else { MessageBox.Show(SR.ScheduledTaskConfig_PleaseProvideCredential); } } }
private void OK_Click(object sender, RoutedEventArgs e) { //create/update scheduled task if (!String.IsNullOrEmpty(Username.Text) && (!String.IsNullOrEmpty(Password.Password))) { var taskScheduler = new Shared.TaskScheduler(); if (taskScheduler.CreateWindowsScheduledTask(Username.Text, Password.Password)) { MessageBox.Show(SR.ScheduledTaskConfig_TaskCreated); this.Close(); } else { MessageBox.Show(SR.ScheduledTaskConfig_FailedToCreateTask); } } else { MessageBox.Show(SR.ScheduledTaskConfig_PleaseProvideCredential); } }