Esempio n. 1
0
        /// <summary>
        /// Restores a single Assignment in the eJournalServer
        /// </summary>
        public static void RestoreAssignment(ejsSessionToken sessionToken, ejsAssignment assignmentToRestore)
        {
            EjsPublicServiceClient _client = null;

            try
            {
                _client = new EjsPublicServiceClient();
                _client.Endpoint.Address = new EndpointAddress(ejsBridgeManager.EjsAddress);
                _client.RestoreAssignment(sessionToken, assignmentToRestore);
            }
            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();
                }
            }
        }
 /// <summary>
 /// Called to update the branches of the tree once the root nodes
 /// have been added. This method is meant to be called recursively.
 /// </summary>
 /// <param name="root">Root node</param>
 /// <param name="child">Current Child</param>
 /// <param name="branchRoot">Original root of this branch</param>
 private void BuildAssignmentTree(AssignmentTreeViewItem root,
                                  ejsAssignment child, AssignmentTreeViewItem branchRoot)
 {
     if (root.Assignment.ExternalAssignmentId == child.ParentAssignmentId)
     {
         CommentedAssignmentTreeViewItem cat = new CommentedAssignmentTreeViewItem(child);
         cat.BranchRoot = branchRoot;
         if (child.IsAvailable)
         {
             cat.DefaultImage  = new BitmapImage(new Uri("pack://application:,,,/Stages/imgData/caTvS.png"));
             cat.SelectedImage = new BitmapImage(new Uri("pack://application:,,,/Stages/imgData/caTvD.png"));
         }
         else
         {
             cat.DefaultImage  = new BitmapImage(new Uri("pack://application:,,,/Stages/imgData/aNA.png"));
             cat.SelectedImage = new BitmapImage(new Uri("pack://application:,,,/Stages/imgData/aNA.png"));
         }
         root.Items.Add(cat);
         //Add up the total number of comments in this branch..
         branchRoot.Assignment.CommentCount += child.CommentCount;
     }
     else
     {
         foreach (AssignmentTreeViewItem childItem in root.Items)
         {
             this.BuildAssignmentTree(childItem, child, branchRoot);
         }
     }
 }
        private void RestoreAssignment(ejsAssignment assignment)
        {
            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.RestoreAssignment(this.CurrentUserToken, assignment);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                        e.Cancel = true;
                    }
                };

                bgw.RunWorkerAsync();

                this.RaiseAsyncOperationStartedEvent("Restoring Assignment on eJournalServer...");
            }
        }
Esempio n. 4
0
        public static void HideAssignment(ejsSessionToken sessionToken, ejsAssignment assignmentToHide)
        {
            EjsPublicServiceClient _client = null;

            try
            {
                _client = new EjsPublicServiceClient();
                _client.Endpoint.Address = new EndpointAddress(ejsBridgeManager.EjsAddress);
                _client.HideAssignment(sessionToken, assignmentToHide);
            }
            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();
                }
            }
        }
 public CommentedAssignmentTreeViewItem(ejsAssignment assignment)
     : base(assignment)
 {
     this._textTitle.Text  = assignment.OwnerName;
     this.TextDetails.Text =
         this._assignment.CreationDate.ToShortDateString() +
         " " + this._assignment.CreationDate.ToLongTimeString() +
         Application.Current.Resources["Str_Ui_LblComments"] as string + this._assignment.CommentCount.ToString();
 }
Esempio n. 6
0
 public CommentedAssignmentTreeViewItem(ejsAssignment assignment)
     : base(assignment)
 {
     this._textTitle.Text  = assignment.OwnerName;
     this.TextDetails.Text =
         this._assignment.CreationDate.ToShortDateString() +
         " " + this._assignment.CreationDate.ToLongTimeString() +
         " Comments: " + this._assignment.CommentCount.ToString();
 }
Esempio n. 7
0
        private void OnDeleteAssignment(object sender, RoutedEventArgs e)
        {
            if (this._tv_Assignments.SelectedItem != null)
            {
                AssignmentTreeViewItem selectedAss = this._tv_Assignments.SelectedItem as AssignmentTreeViewItem;
                if (selectedAss == null)
                {
                    return;
                }

                ejsAssignment assToDelete = selectedAss.Assignment;

                if (assToDelete.OwnerUserId != App._currentEjpStudent.Id)
                {
                    MessageBox.Show("他人のアサインメントは削除出来ません。", "エラー", MessageBoxButton.OK, MessageBoxImage.Stop);
                }
                else
                {
                    try
                    {
                        int selectedCoursItemId = this._cb_Courses.SelectedIndex;
                        if (MessageBox.Show("選択されたアサインメントを削除しますか?", "削除",
                                            MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                        {
                            EjsBridge.ejsBridgeManager.DeleteAssignment(
                                App._currentEjpStudent.SessionToken, assToDelete);
                            this.LoadDataFromEjs();

                            //Set the combobox to display the documents
                            //of the prev selected course in the list, if there are
                            //any courses in the list.
                            if (this._cb_Courses.Items.Count != 0)
                            {
                                this._cb_Courses.SelectedIndex = selectedCoursItemId;
                            }
                        }
                    }
                    catch (ApplicationException ex)
                    {
                        SiliconStudio.DebugManagers.DebugReporter.Report(
                            SiliconStudio.DebugManagers.MessageType.Error,
                            "eJournalPlus Client - EJS Open Assignment Window",
                            "Deleting Assignment from EJS Failed" +
                            "\nError: " + ex.Message);

                        MessageBox.Show("選択されたアサインメントは削除できません。", "エラー", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
            }
        }
        /// <summary>
        /// Tell EJS to merge all the comments and open the Assignment
        /// as a Commented Assignment.
        /// </summary>
        private void OnMergeCommentsAndOpen(object sender, RoutedEventArgs e)
        {
            if (this._tv_Assignments.SelectedItem != null)
            {
                if (this._tv_Assignments.SelectedItem is CommentedAssignmentTreeViewItem)
                {
                    return;
                }

                AssignmentTreeViewItem selectedAss = this._tv_Assignments.SelectedItem as AssignmentTreeViewItem;
                if (selectedAss == null)
                {
                    return;
                }

                this._assignmentToOpen = selectedAss.Assignment;

                if (this._assignmentToOpen != null)
                {
                    this._cancelled = false;
                    this._openSelectedAssignmentAsCommented = true;
                    this.MergeCommentsAndOpenAssignment     = true;

                    List <ejsAssignment> lsAT = new List <ejsAssignment>();

                    foreach (CommentedAssignmentTreeViewItem catvi in selectedAss.Items)
                    {
                        this.GetAllChildAssignmentsForParent(catvi, lsAT);
                        lsAT.Add(catvi.Assignment);
                    }

                    this.CommentedAssignmentsToMerge = lsAT.ToArray();

                    this.Close();
                }
                else
                {
                    MessageBox.Show(Application.Current.Resources["EX_AsgOpenFailed"] as string,          //Properties.Resources.EX_AsgOpenFailed,
                                    Application.Current.Resources["Str_ErrorTitle"] as string,            //Properties.Resources.Str_ErrorTitle,
                                    MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            else
            {
                this._cancelled = true;
                this.Close();
            }
        }
        private void OnDeleteAssignment(object sender, RoutedEventArgs e)
        {
            if (this._tv_Assignments.SelectedItem != null)
            {
                AssignmentTreeViewItem selectedAss = this._tv_Assignments.SelectedItem as AssignmentTreeViewItem;
                if (selectedAss == null)
                {
                    return;
                }

                ejsAssignment assToDelete = selectedAss.Assignment;

                if (assToDelete.OwnerUserId != App._currentEjpStudent.Id)
                {
                    MessageBox.Show(Application.Current.Resources["ERR_CannotDelOthersAsg"] as string,    //Properties.Resources.ERR_CannotDelOthersAsg,
                                    Application.Current.Resources["Str_ErrorTitle"] as string,            //Properties.Resources.Str_ErrorTitle,
                                    MessageBoxButton.OK, MessageBoxImage.Stop);
                }
                else
                {
                    try
                    {
                        int selectedCoursItemId = this._cb_Courses.SelectedIndex;
                        if (MessageBox.Show(Application.Current.Resources["Q_DelAsg"] as string, Application.Current.Resources["Str_WarnTitle"] as string,
                                            MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                        {
                            EjsBridge.ejsBridgeManager.HideAssignment(
                                App._currentEjpStudent.SessionToken, assToDelete);
                            this.LoadDataFromEjs();

                            //Set the combobox to display the documents
                            //of the prev selected course in the list, if there are
                            //any courses in the list.
                            if (this._cb_Courses.Items.Count != 0)
                            {
                                this._cb_Courses.SelectedIndex = selectedCoursItemId;
                            }
                        }
                    }
                    catch (ApplicationException)
                    {
                        MessageBox.Show(Application.Current.Resources["EX_AsgDelFailed"] as string,               //Properties.Resources.EX_AsgDelFailed,
                                        Application.Current.Resources["Str_ErrorTitle"] as string,                //Properties.Resources.Str_ErrorTitle,
                                        MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
            }
        }
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            ejsAssignment ass = value as ejsAssignment;

            if (ass == null)
            {
                throw new ApplicationException("Attempt to display non EJS Assignment Object in Assignment List.");
            }

            return(ass.Title +
                   " " +
                   "(" + ass.OwnerName +
                   " " +
                   " / " + ass.CreationDate.ToShortDateString() + " " + ass.CreationDate.ToLongTimeString() +
                   ")");
        }
Esempio n. 11
0
        private void OnOpenAssignmentAsCA(object sender, RoutedEventArgs e)
        {
            if (this._tv_Assignments.SelectedItem != null)
            {
                AssignmentTreeViewItem selectedAss = this._tv_Assignments.SelectedItem as AssignmentTreeViewItem;
                if (selectedAss == null)
                {
                    return;
                }

                //If this value is an empty GUID that means the assignment
                //was created with version 1 of EJP+EJP. Thus, it cannot
                //be opened as a Commented Assignment with this version of EJP.
                if (selectedAss.Assignment.ExternalAssignmentId == Guid.Empty)
                {
                    MessageBox.Show("\n\nThis assignment was created with an earlier version\n" +
                                    "of EJournal Plus, therefor it cannot be opened in \n" +
                                    "Comment Mode.\n\n" +
                                    "If you wish do upgrade this Assignment, first open it\n" +
                                    "in Normal Mode, then re-publish it to E Journal Server.\n" +
                                    "After this you can open the new Published version in \n" +
                                    "Comment Mode.", "Version Error", MessageBoxButton.OK, MessageBoxImage.Stop);
                    return;
                }

                this._assignmentToOpen = selectedAss.Assignment;
                if (this._assignmentToOpen != null)
                {
                    this._cancelled = false;
                    this._openSelectedAssignmentAsCommented = true;
                    this.Close();
                }
                else
                {
                    MessageBox.Show("選択されたアサインメントが開けません。", "エラー", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            else
            {
                this._cancelled = true;
                this.Close();
            }
        }
        private void OnOpenAssignment(object sender, RoutedEventArgs e)
        {
            if (this._tv_Assignments.SelectedItem != null)
            {
                AssignmentTreeViewItem selectedAss = this._tv_Assignments.SelectedItem as AssignmentTreeViewItem;
                if (selectedAss == null)
                {
                    return;
                }

                if (selectedAss is CommentedAssignmentTreeViewItem)
                {
                    if (
                        MessageBox.Show(Application.Current.Resources["Q_OpenAsComAsg"] as string,
                                        Application.Current.Resources["Str_WarnTitle"] as string, MessageBoxButton.YesNo, MessageBoxImage.Question)
                        == MessageBoxResult.No)
                    {
                        return;
                    }
                }

                this._assignmentToOpen = selectedAss.Assignment;

                if (this._assignmentToOpen != null)
                {
                    this._cancelled = false;
                    this._openSelectedAssignmentAsCommented = false;
                    this.Close();
                }
                else
                {
                    MessageBox.Show(Application.Current.Resources["EX_AsgOpenFailed"] as string,          //Properties.Resources.EX_AsgOpenFailed,
                                    Application.Current.Resources["Str_ErrorTitle"] as string,            //Properties.Resources.Str_ErrorTitle,
                                    MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            else
            {
                this._cancelled = true;
                this.Close();
            }
        }
Esempio n. 13
0
        private void OnOpenAssignment(object sender, RoutedEventArgs e)
        {
            if (this._tv_Assignments.SelectedItem != null)
            {
                AssignmentTreeViewItem selectedAss = this._tv_Assignments.SelectedItem as AssignmentTreeViewItem;
                if (selectedAss == null)
                {
                    return;
                }

                if (selectedAss is CommentedAssignmentTreeViewItem)
                {
                    if (
                        MessageBox.Show("選択したファイルにはコメントがあるため" +
                                        "\nコメントモードに開きます。\n\n" +
                                        "宜しいですか?", "Warning", MessageBoxButton.YesNo, MessageBoxImage.Question)
                        == MessageBoxResult.No)
                    {
                        return;
                    }
                }

                this._assignmentToOpen = selectedAss.Assignment;

                if (this._assignmentToOpen != null)
                {
                    this._cancelled = false;
                    this._openSelectedAssignmentAsCommented = false;
                    this.Close();
                }
                else
                {
                    MessageBox.Show("選択されたアサインメントが開けません。", "エラー", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            else
            {
                this._cancelled = true;
                this.Close();
            }
        }
        private void OnOpenAssignmentAsCA(object sender, RoutedEventArgs e)
        {
            if (this._tv_Assignments.SelectedItem != null)
            {
                AssignmentTreeViewItem selectedAss = this._tv_Assignments.SelectedItem as AssignmentTreeViewItem;
                if (selectedAss == null)
                {
                    return;
                }

                //If this value is an empty GUID that means the assignment
                //was created with version 1 of EJP+EJP. Thus, it cannot
                //be opened as a Commented Assignment with this version of EJP.
                if (selectedAss.Assignment.ExternalAssignmentId == Guid.Empty)
                {
                    MessageBox.Show(Application.Current.Resources["ERR_AsgOpenFailed_Version"] as string,        //Properties.Resources.ERR_AsgOpenFailed_Version,
                                    Application.Current.Resources["Str_VersionErrorTitle"] as string,            //Properties.Resources.Str_VersionErrorTitle,
                                    MessageBoxButton.OK, MessageBoxImage.Stop);
                    return;
                }

                this._assignmentToOpen = selectedAss.Assignment;
                if (this._assignmentToOpen != null)
                {
                    this._cancelled = false;
                    this._openSelectedAssignmentAsCommented = true;
                    this.Close();
                }
                else
                {
                    MessageBox.Show(Application.Current.Resources["EX_AsgOpenFailed"] as string,          //Properties.Resources.EX_AsgOpenFailed,
                                    Application.Current.Resources["Str_ErrorTitle"] as string,            //Properties.Resources.Str_ErrorTitle,
                                    MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            else
            {
                this._cancelled = true;
                this.Close();
            }
        }
 private void OnOpenAssignment(object sender, RoutedEventArgs e)
 {
     if (this._lv_Assignments.SelectedItem != null)
     {
         this._assignmentToOpen = this._lv_Assignments.SelectedItem as ejsAssignment;
         if (this._assignmentToOpen != null)
         {
             this._cancelled = false;
             this.Close();
         }
         else
         {
             MessageBox.Show("選択されたアサインメントが開けません。", "エラー", MessageBoxButton.OK, MessageBoxImage.Error);
         }
     }
     else
     {
         this._cancelled = true;
         this.Close();
     }
 }
Esempio n. 16
0
        public AssignmentTreeViewItem(ejsAssignment assignment)
        {
            //Give som space...
            this.Margin = new Thickness(0, 2, 0, 2);

            //Set the assignment
            this._assignment = assignment;

            //Build the visual
            StackPanel panel = new StackPanel();

            panel.Orientation = Orientation.Horizontal;
            this.Header       = panel;

            this._image = new Image();
            this._image.VerticalAlignment = VerticalAlignment.Center;
            this._image.Margin            = new Thickness(0, 0, 2, 0);
            panel.Children.Add(this._image);

            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._assignment.Title;
            this._textDetails.Text =
                " (" +
                this._assignment.OwnerName +
                " / " + this._assignment.CreationDate.ToShortDateString() +
                " " + this._assignment.CreationDate.ToLongTimeString() +
                ")";
        }
Esempio n. 17
0
        private void OnDeleteAssignment(object sender, RoutedEventArgs e)
        {
            if (this._lv_Assignments.SelectedItem != null)
            {
                ejsAssignment assToDelete = this._lv_Assignments.SelectedItem as ejsAssignment;
                if (assToDelete.OwnerUserId != App._currentEjpStudent.Id)
                {
                    MessageBox.Show("他人のアサインメントは削除出来ません。", "エラー", MessageBoxButton.OK, MessageBoxImage.Stop);
                }
                else
                {
                    try
                    {
                        int selectedCoursItemId = this._cb_Courses.SelectedIndex;
                        if (MessageBox.Show("選択されたアサインメントを削除しますか?", "削除",
                                            MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                        {
                            EjsBridge.ejsBridgeManager.HideAssignment(
                                App._currentEjpStudent.SessionToken, assToDelete);
                            this.LoadDataFromEjs();

                            //Set the combobox to display the documents
                            //of the prev selected course in the list, if there are
                            //any courses in the list.
                            if (this._cb_Courses.Items.Count != 0)
                            {
                                this._cb_Courses.SelectedIndex = selectedCoursItemId;
                            }
                        }
                    }
                    catch (ApplicationException)
                    {
                        MessageBox.Show("選択されたアサインメントは削除できません。", "エラー", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
            }
        }