Пример #1
0
        /// <summary>
        /// Resets this instance.
        /// </summary>
        private void Reset()
        {
            IsAddReportOpen = Visibility.Collapsed;
            Title           = string.Empty;

            Audiences.Single(a => a.Value == (int)Audience.Professionals).IsSelected = true;
            Audiences.Where(a => a.Value != (int)Audience.Professionals).ForEach(a => a.IsSelected = false);
        }
Пример #2
0
 private void CutOffStaticLimitations(string subject, LessonType type)
 {
     if (type == LessonType.Lecture)
     {
         Audiences = Audiences.Where(x => _lectureAudiences.Contains(x)).ToList();
         Teachers  = new List <string> {
             _subjectLecturer[subject]
         };
     }
 }
Пример #3
0
        /// <summary>
        /// Called when save is clicked to save the report changes.
        /// </summary>
        protected override async void OnSave()
        {
            base.OnSave();

            if (HasErrors)
            {
                return;
            }

            if (!(Audiences[1].IsSelected || Audiences[2].IsSelected))
            {
                MessageBox.Show(
                    "Please enter a report type, report name, and recommended audience(s) to add a new report.");
                return;
            }

            try
            {
                var errorOccurred   = false;
                var progressService = new ProgressService();

                progressService.SetProgress("Creating report", 0, false, true);

                //await Task.Delay(500);

                var operationComplete = await progressService.Execute(() =>
                {
                    //Get all selected enum values but the default/non-selected value of zero "0"
                    var selectedAudiences =
                        Audiences.Where(a => a.IsSelected && a.Value != 0).Select(a => a.Enum).ToList();
                    //.Aggregate<AudienceModel, uint>(0, (current, a) => current + (uint)a.Value);
                    var factory  = new ReportManifestFactory();
                    var manifest = factory.InstalledManifests.FirstOrDefault(x => x.Name == ReportType);
                    var report   = new Report(manifest)
                    {
                        Name = Title
                    };                                                  //, Audiences = selectedAudiences.ToList()
                    AddNewItemCommand.Execute(report);
                },
                                                                      opResult =>
                {
                    progressService.SetProgress("Completed", 100, true, false);
                    if (opResult.Status && opResult.Exception != null)
                    {
                        errorOccurred = true;
                        LogEntityError(opResult.Exception.GetBaseException(), typeof(Report), Title);
                    }
                    else
                    {
                        errorOccurred = false;
                    }
                }, new CancellationToken());

                if (operationComplete && !errorOccurred)
                {
                    OnLoad();
                    Notify(String.Format("New report {0} has been added", Title));
                }
            }
            catch (Exception exc)
            {
                LogEntityError(exc, typeof(Report), Title);
            }
            finally
            {
                Reset();
            }
        }