/// <summary> /// Removes a user from a course in the EJS. /// </summary> public static void RemoveUserFromCourse( ejsSessionToken sessionToken, ejsUserInfo userInfo, ejsCourse course) { EjsPublicServiceClient _client = null; try { _client = new EjsPublicServiceClient(); _client.Endpoint.Address = new EndpointAddress(ejsBridgeManager.EjsAddress); _client.RemoveUserFromCourse(sessionToken, userInfo, course); } catch (FaultException <ejsFailureReport> ex) { if (ex.Detail._failureCode == 7) { sessionToken._isAuthenticated = false; } throw new ApplicationException(ex.Detail._header + "\n" + ex.Detail._originalException.Message); } catch (Exception) { sessionToken._isAuthenticated = false; throw new ApplicationException("EJSと接続する際に失敗しました。"); } finally { if (_client != null) { _client.Close(); } } }
private void OnSetCourseRegistrations(object sender, RoutedEventArgs e) { if (this._lv_UserList.SelectedItem == null) { return; } ejsUserInfo u = null; if (this._lv_UserList.SelectedItem is mngCourseRegistration) { mngCourseRegistration cr = this._lv_UserList.SelectedItem as mngCourseRegistration; u = cr.UserInfoObject; } else { u = this._lv_UserList.SelectedItem as ejsUserInfo; } if (u != null) { this.SetCourseRegistrationsForUser(u); } }
/// <summary> /// Registers a new User in the eJournalServer /// </summary> public static void AddNewUser(ejsSessionToken sessionToken, ejsUserInfo newUser, int userGroup, string password) { EjsPublicServiceClient _client = null; try { _client = new EjsPublicServiceClient(); _client.Endpoint.Address = new EndpointAddress(ejsBridgeManager.EjsAddress); _client.RegisterNewUser(sessionToken, newUser, newUser.UserName, password, userGroup, newUser.IsAccountActive); } catch (FaultException <ejsFailureReport> ex) { if (ex.Detail._failureCode == 7) { sessionToken._isAuthenticated = false; } throw new ApplicationException(ex.Detail._header + "\n" + ex.Detail._originalException.Message); } catch (Exception) { sessionToken._isAuthenticated = false; throw new ApplicationException("EJSと接続する際に失敗しました。"); } finally { if (_client != null) { _client.Close(); } } }
internal static int RegisterUserToCourse_adm(SqlConnection dBconnection, ejsSessionToken sessionToken, ejsUserInfo User, ejsCourse Course) { SqlCommand command = new SqlCommand(); command.CommandTimeout = 60; try { command.Connection = dBconnection; command.CommandType = System.Data.CommandType.StoredProcedure; command.CommandText = "RegisterUserToCourse"; command.Parameters.Add("CourseId", System.Data.SqlDbType.Int).Value = Course.Id; command.Parameters.Add("UserId", System.Data.SqlDbType.UniqueIdentifier).Value = new Guid(User.Id); command.Parameters.Add("RegistrationDate", System.Data.SqlDbType.DateTime).Value = DateTime.Now; SqlParameter returnValue = new SqlParameter("@RETURN_VALUE", SqlDbType.Int); returnValue.Direction = ParameterDirection.ReturnValue; command.Parameters.Add(returnValue); command.ExecuteNonQuery(); int resultCode = (int)returnValue.Value; return(resultCode); } finally { command.Dispose(); } }
private void SetCourseRegistrationsForUser(ejsUserInfo user) { CourseRegistrationsWindow w = new CourseRegistrationsWindow(user, this.CurrentUserToken, this); w.ShowDialog(); if (w.NeedsUpdate) { this.UpdateData(); } }
private bool ConfirmCanDelete(ejsUserInfo userToDelete) { if (userToDelete.IsAccountActive) { MessageBox.Show("Users can only be deleted when their accounts are not active.\n" + "To delete a User, first uncheck the Can Login check box.", "Error", MessageBoxButton.OK, MessageBoxImage.Information); return(false); } else { return(true); } }
public CourseRegistrationsWindow(ejsUserInfo user, ejsSessionToken userToken, ejsManagerStage parentStage) { InitializeComponent(); this._currentUserToken = userToken; this._currentUserInfo = user; this._parentStage = parentStage; this.BuildCourseLists(); this._l_CurrentUserName.Content = user.LastName + ", " + user.FirstName; }
private void UpdateUser(ejsUserInfo userToUpdate, string newPassword) { lock (this.threadLock) { if (this._isStageBusy) { return; } this._isStageBusy = true; BackgroundWorker bgw = new BackgroundWorker(); bgw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(UpdateItemOperationCompleted); bgw.WorkerSupportsCancellation = true; bgw.DoWork += delegate(object sender, DoWorkEventArgs e) { try { if (StringValidation.ValidSqlInputVariable(userToUpdate.Email) || StringValidation.ValidSqlInputVariable(userToUpdate.FirstName) || StringValidation.ValidSqlInputVariable(userToUpdate.LastName) || StringValidation.ValidSqlInputVariable(userToUpdate.UserName) ) { MessageBox.Show("User Info contains invalid data", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } if (newPassword != "") { if (StringValidation.ValidSqlInputVariable(newPassword)) { MessageBox.Show("The specified Password is not valid.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } } ejsBridgeManager.UpdateUser(this.CurrentUserToken, userToUpdate, newPassword); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); e.Cancel = true; } }; bgw.RunWorkerAsync(); this.RaiseAsyncOperationStartedEvent("Updating User Info on eJournalServer..."); } }
private void OnUpdateCurrentItem(object sender, RoutedEventArgs e) { //TODO: Implement Update if (this._lv_UserList.SelectedItem == null) { return; } if (this.GetUpdateConfirmation() == true) { ejsUserInfo u = this._lv_UserList.SelectedItem as ejsUserInfo; this.UpdateUser(u, this._tb_Password.Text); } }
private void OnDeleteCurrentItem(object sender, RoutedEventArgs e) { //TODO: Implement Delete if (this._lv_UserList.SelectedItem == null) { return; } ejsUserInfo u = this._lv_UserList.SelectedItem as ejsUserInfo; if (this.ConfirmCanDelete(u) == true) { if (this.GetDeleteConfirmation() == true) { this.DeleteUser(u, false); } } }
private void DeleteUser(ejsUserInfo userToDelete, bool confirmCanDelete) { if (confirmCanDelete) { if (this.ConfirmCanDelete(userToDelete) == false) { return; } } lock (this.threadLock) { if (this._isStageBusy) { return; } this._isStageBusy = true; BackgroundWorker bgw = new BackgroundWorker(); bgw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(UpdateItemOperationCompleted); bgw.WorkerSupportsCancellation = true; bgw.DoWork += delegate(object sender, DoWorkEventArgs e) { try { ejsBridgeManager.DeleteUser(this.CurrentUserToken, userToDelete); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); e.Cancel = true; } }; bgw.RunWorkerAsync(); this.RaiseAsyncOperationStartedEvent("Deleting User Record on eJournalServer..."); } }
protected override void AddNewItem() { if (StringValidation.ValidSqlInputVariable(this._tb_Email.Text) || StringValidation.ValidSqlInputVariable(this._tb_FirstName.Text) || StringValidation.ValidSqlInputVariable(this._tb_Password.Text) || StringValidation.ValidSqlInputVariable(this._tb_UserName.Text) || StringValidation.ValidSqlInputVariable(this._tb_LastName.Text)) { return; } else { try { if (this._tb_Email.Text.Length == 0 || this._tb_FirstName.Text.Length == 0 || this._tb_UserName.Text.Length == 0 || this._tb_LastName.Text.Length == 0 || this._tb_Password.Text.Length == 0) { return; } bool isActive = (bool)this._cb_CanLogin.IsChecked; ejsUserInfo uInfo = new ejsUserInfo() { FirstName = this._tb_FirstName.Text, LastName = this._tb_LastName.Text, Email = this._tb_Email.Text, IsAccountActive = isActive, UserName = this._tb_UserName.Text, Id = Guid.NewGuid().ToString() }; int groupid = 3; if (this._cb_IsTeacher.IsChecked == true) { groupid = 2; } string password = this._tb_Password.Text; BackgroundWorker bgw = new BackgroundWorker(); bgw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(OperationCompleted); bgw.WorkerSupportsCancellation = true; bgw.DoWork += delegate(object sender, DoWorkEventArgs e) { try { ejsBridgeManager.AddNewUser(this._currentUserToken, uInfo, groupid, password); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); e.Cancel = true; } }; bgw.RunWorkerAsync(); this._parentStage.RaiseAsyncOperationStartedEvent("Creating New User Record."); } catch (Exception) { throw; } } }