예제 #1
0
        private void Timer_Elapsed(object _)
        {
            try
            {
                var maxAge = MaxAge;

                foreach (var reportName in _reportRepository.GetAvailableReports())
                {
                    if (DateTime.UtcNow - reportName.StartTime > maxAge)
                    {
                        try
                        {
                            _reportRepository.DeleteReport(reportName);
                        }
                        catch (Exception x)
                        {
                            s_logger.Error(null, x);
                        }
                    }
                }
            }
            catch (Exception x)
            {
                s_logger.Error(null, x);
            }
        }
        public ReportsViewModel(
            ISynchronizationReportRepository reportRepository,
            Dictionary <Guid, string> currentProfileNamesById, IReportsViewModelParent parent)
        {
            _reportRepository        = reportRepository;
            _currentProfileNamesById = currentProfileNamesById;
            _parent = parent;
            _deleteSelectedCommand = new DelegateCommand(DeleteSelected, _ => _reports.Any(r => r.IsSelected));
            _saveSelectedCommand   = new DelegateCommand(SaveSelected, _ => _reports.Any(r => r.IsSelected));

            foreach (var reportName in reportRepository.GetAvailableReports())
            {
                AddReportViewModel(reportName);
            }

            // Regarding to race conditions it doesn't matter when the handler is added
            // since everything happens in the ui thread
            _reportRepository.ReportAdded += ReportRepository_ReportAdded;

            _reportsCollectionViewSource        = new CollectionViewSource();
            _reportsCollectionViewSource.Source = _reports;
            _reportsCollectionViewSource.SortDescriptions.Add(new SortDescription(nameof(ReportViewModel.StartTime), ListSortDirection.Descending));
            Reports = _reportsCollectionViewSource.View;

            if (_reports.Count > 0)
            {
                _reports[0].IsSelected = true;
            }
        }
    public ReportsViewModel (
        ISynchronizationReportRepository reportRepository,
        Dictionary<Guid, string> currentProfileNamesById)
    {
      _reportRepository = reportRepository;
      _currentProfileNamesById = currentProfileNamesById;
      _deleteSelectedCommand = new DelegateCommand (DeleteSelected, _ => Reports.Any (r => r.IsSelected));
      _saveSelectedCommand = new DelegateCommand (SaveSelected, _ => Reports.Any (r => r.IsSelected));

      foreach (var reportName in reportRepository.GetAvailableReports())
        AddReportViewModel (reportName);

      // Regarding to race conditions it doesn't matter when the handler is added
      // since everything happens in the ui thread
      _reportRepository.ReportAdded += ReportRepository_ReportAdded;

      if (Reports.Count > 0)
        Reports[0].IsSelected = true;
    }
        public ReportsViewModel(
            ISynchronizationReportRepository reportRepository,
            Dictionary <Guid, string> currentProfileNamesById)
        {
            _reportRepository        = reportRepository;
            _currentProfileNamesById = currentProfileNamesById;
            _deleteSelectedCommand   = new DelegateCommand(DeleteSelected, _ => Reports.Any(r => r.IsSelected));
            _saveSelectedCommand     = new DelegateCommand(SaveSelected, _ => Reports.Any(r => r.IsSelected));

            foreach (var reportName in reportRepository.GetAvailableReports())
            {
                AddReportViewModel(reportName);
            }

            // Regarding to race conditions it doesn't matter when the handler is added
            // since everything happens in the ui thread
            _reportRepository.ReportAdded += ReportRepository_ReportAdded;

            if (Reports.Count > 0)
            {
                Reports[0].IsSelected = true;
            }
        }
 public IReadOnlyList <SynchronizationReportName> GetAvailableReports()
 {
     return(_inner.GetAvailableReports());
 }