public CourseTreeViewItem(ejsCourse course) { //Give som space... this.Margin = new Thickness(0, 2, 0, 2); //Set the assignment this._course = course; //Build the visual StackPanel panel = new StackPanel(); panel.Orientation = Orientation.Horizontal; this.Header = panel; this._textTitle = new TextBlock(); this._textTitle.FontWeight = FontWeights.Bold; this._textTitle.VerticalAlignment = VerticalAlignment.Center; this._textTitle.Margin = new Thickness(0, 0, 6, 0); panel.Children.Add(this._textTitle); this._textDetails = new TextBlock(); this._textDetails.VerticalAlignment = VerticalAlignment.Center; panel.Children.Add(this._textDetails); //Set the text of the visual this._textTitle.Text = this._course._name; this._textDetails.Text = " (" + this._course._description + ")"; }
private void RegisterUserToCourse(string newCourseName) { ejsCourse rCourse = this.GetCourseByName(newCourseName); if (rCourse != null) { try { BackgroundWorker bgw = new BackgroundWorker(); bgw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(AddOperationCompleted); bgw.WorkerSupportsCancellation = true; bgw.DoWork += delegate(object sender, DoWorkEventArgs e) { try { ejsBridgeManager.RegisterUserToCourse_adm(this._currentUserToken, this._currentUserInfo, rCourse); e.Result = newCourseName; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); e.Cancel = true; } }; bgw.RunWorkerAsync(); this._parentStage.RaiseAsyncOperationStartedEvent("Registering User to Course."); this.BringIntoView(); } catch (Exception) { throw; } } }
/// <summary> /// Registers a user to a course in the EJS. /// </summary> public static void RegisterUserToCourse( ejsService.ejsSessionToken sessionToken, ejsCourse course) { EjsPublicServiceClient _client = null; try { _client = new EjsPublicServiceClient(); _client.Endpoint.Address = new EndpointAddress(ejsBridgeManager.EjsAddress); _client.RegisterUserToCourse(sessionToken, course); } catch (FaultException <ejsFailureReport> ex) { if (ex.Detail._failureCode == 7) { sessionToken._isAuthenticated = false; } throw new ApplicationException(ex.Detail._header + "\n" + ex.Detail._message); } catch (Exception) { sessionToken._isAuthenticated = false; //throw new ApplicationException(Properties.Resources.EX_EjsConnectionFailed); } finally { if (_client != null) { _client.Close(); } } }
/// <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 DeleteCourse(ejsCourse courseToDelete) { 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.DeleteCourse(this.CurrentUserToken, courseToDelete); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); e.Cancel = true; } }; bgw.RunWorkerAsync(); this.RaiseAsyncOperationStartedEvent("Deleting Course on eJournalServer..."); } }
protected override void AddNewItem() { if (StringValidation.ValidSqlInputVariable(this._tb_Description.Text) || StringValidation.ValidSqlInputVariable(this._tb_Name.Text) || StringValidation.ValidSqlInputVariable(this._tb_Owner.Text)) { return; } else { try { if (this._tb_Description.Text.Length == 0 || this._tb_Name.Text.Length == 0 || this._tb_Owner.Text.Length == 0) { return; } bool isActive = (bool)this._cb_IsActive.IsChecked; ejsCourse course = new ejsCourse() { _creationDate = DateTime.Now, _description = this._tb_Description.Text, _isActive = isActive, _name = this._tb_Name.Text, _owner = this._tb_Owner.Text }; BackgroundWorker bgw = new BackgroundWorker(); bgw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(OperationCompleted); bgw.WorkerSupportsCancellation = true; bgw.DoWork += delegate(object sender, DoWorkEventArgs e) { try { ejsBridgeManager.AddNewCourse(this._currentUserToken, course); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); e.Cancel = true; } }; bgw.RunWorkerAsync(); this._parentStage.RaiseAsyncOperationStartedEvent("Uploading and Saving Course Document."); } catch (Exception) { throw; } } }
private void OnCourseListSelectionChanged(object sender, SelectionChangedEventArgs e) { if (this._cb_Courses.SelectedValue != null) { ejsCourse course = this._cb_Courses.SelectedValue as ejsCourse; this._tv_Assignments.Items.Clear(); //First add all the original assignments AssignmentTreeViewItem tParent = null; foreach (ejsAssignment ass in this._assignments) { //1 = Commented Assignment if (ass.AssignmentContentType == 1) { continue; //We only add the 'real' assignments first } if (ass.CourseId == course._id) //does this assignment belong to the current course? { AssignmentTreeViewItem t = new AssignmentTreeViewItem(ass); t.DefaultImage = new BitmapImage(new Uri("pack://application:,,,/imgData/aTvS.png")); t.SelectedImage = new BitmapImage(new Uri("pack://application:,,,/imgData/aTvD.png")); this._tv_Assignments.Items.Add(t); tParent = t; } } foreach (ejsAssignment ass in this._assignments) { //0 = Normal Assignment if (ass.AssignmentContentType == 0) { continue; //We're only adding the Commented Assignments } if (ass.CourseId == -1) //-1 = commented assignments do not belong to courses { foreach (AssignmentTreeViewItem ParentAssignment in this._tv_Assignments.Items) { this.BuildAssignmentTree(ParentAssignment, ass, ParentAssignment); } } } foreach (AssignmentTreeViewItem ParentAssignment in this._tv_Assignments.Items) { ParentAssignment.TextDetails.Text += " Comments: " + ParentAssignment.Assignment.CommentCount.ToString(); } } }
private void OnDeleteCurrentItem(object sender, RoutedEventArgs e) { if (this._lv_CourseList.SelectedItem == null) { return; } if (this.GetDeleteConfirmation() == true) { ejsCourse c = this._lv_CourseList.SelectedItem as ejsCourse; this.DeleteCourse(c); } }
private void OnUpdateCurrentItem(object sender, RoutedEventArgs e) { //TODO: Implement Update if (this._lv_CourseList.SelectedItem == null) { return; } if (this.GetUpdateConfirmation() == true) { ejsCourse c = this._lv_CourseList.SelectedItem as ejsCourse; this.UpdateCourse(c); } }
private void OnCourseListSelectionChanged(object sender, SelectionChangedEventArgs e) { if (this._cb_Courses.SelectedValue != null) { ObservableAssignmentList cList = this.Resources["AssignmentList"] as ObservableAssignmentList; ejsCourse course = this._cb_Courses.SelectedValue as ejsCourse; cList.Clear(); foreach (ejsAssignment ass in this._assignments) { if (ass.CourseId == course._id) { cList.Add(ass); } } } }
private void UpdateCourse(ejsCourse courseToUpdate) { 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(courseToUpdate._description) || StringValidation.ValidSqlInputVariable(courseToUpdate._name) || StringValidation.ValidSqlInputVariable(courseToUpdate._owner)) { MessageBox.Show("Invalid Course Data.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } ejsBridgeManager.UpdateCourse(this.CurrentUserToken, courseToUpdate); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); e.Cancel = true; } }; bgw.RunWorkerAsync(); this.RaiseAsyncOperationStartedEvent("Updating Course on eJournalServer..."); } }