Exemplo n.º 1
0
 public override async Task Invoke(IStepExecutionContext context = null)
 {
     var reportModels = reporterRepository.GetAll();
     await Task.Run(() => Parallel.ForEach(reportModels, async(r, i) =>
     {
         var options  = reporterRepository.LoadOptions(r.Id.ToString(), r.EntityType);
         var reporter = reporters.FirstOrDefault(rt => rt.Id == r.ReporterId);
         reporter.SetOptions(options.Select(o => new OptionItem {
             Name = o.Key, Value = o.Value
         }));
         reporter.SetReportModel(r);
         await reporter.Queue();
     }));
 }
        private void OnRefreshReporters(RefreshReporterListEventArgument obj)
        {
            Reporters = new ObservableCollection <ReporterModel>(reporterRepository.GetAll());
            var selectedId = obj.SelectedReporterId;

            if (obj.SelectedReporterId == Guid.Empty)
            {
                var firstConnection = Reporters.FirstOrDefault();
                selectedId = firstConnection?.Id ?? Guid.Empty;
            }
            if (selectedId != Guid.Empty)
            {
                eventAggregator.GetEvent <SelectReporterEvent>().Publish(new SelectReporterEventArgument
                {
                    ReporterId = selectedId
                });
            }
        }
        public UCRepoterListViewViewModel(
            ReporterRepository reporterRepository,
            IEventAggregator eventAggregator)
        {
            this.reporterRepository = reporterRepository;
            this.eventAggregator    = eventAggregator;
            Reporters = new ObservableCollection <ReporterModel>(reporterRepository.GetAll());
            eventAggregator.GetEvent <RefreshReporterListEvent>().Subscribe(OnRefreshReporters);
            var firstConection = Reporters.FirstOrDefault();

            if (firstConection != null)
            {
                eventAggregator.GetEvent <SelectReporterEvent>().Publish(new SelectReporterEventArgument
                {
                    ReporterId = firstConection.Id
                });
            }
        }