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 Scheduler( ISynchronizerFactory synchronizerFactory, ISynchronizationReportRepository synchronizationReportRepository, Action ensureSynchronizationContext) { if (synchronizerFactory == null) { throw new ArgumentNullException("synchronizerFactory"); } if (ensureSynchronizationContext == null) { throw new ArgumentNullException("ensureSynchronizationContext"); } if (synchronizationReportRepository == null) { throw new ArgumentNullException("synchronizationReportRepository"); } _synchronizationReportRepository = synchronizationReportRepository; _synchronizerFactory = synchronizerFactory; _ensureSynchronizationContext = ensureSynchronizationContext; _synchronizationTimer.Tick += _synchronizationTimer_Tick; _synchronizationTimer.Interval = (int)_timerInterval.TotalMilliseconds; _synchronizationTimer.Start(); }
public ComponentContainer(Application application) { _uiService = new UiService(); _generalOptionsDataAccess = new GeneralOptionsDataAccess(); var generalOptions = _generalOptionsDataAccess.LoadOptions(); FrameworkElement.LanguageProperty.OverrideMetadata( typeof(FrameworkElement), new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag))); ConfigureServicePointManager(generalOptions); ConfigureLogLevel(generalOptions.EnableDebugLog); _itemChangeWatcher = new OutlookItemChangeWatcher(application.Inspectors); _itemChangeWatcher.ItemSavedOrDeleted += ItemChangeWatcherItemSavedOrDeleted; _session = application.Session; s_logger.Info("Startup..."); EnsureSynchronizationContext(); _applicationDataDirectory = Path.Combine( Environment.GetFolderPath( generalOptions.StoreAppDataInRoamingFolder ? Environment.SpecialFolder.ApplicationData : Environment.SpecialFolder.LocalApplicationData), "CalDavSynchronizer"); _optionsDataAccess = new OptionsDataAccess( Path.Combine( _applicationDataDirectory, GetOrCreateConfigFileName(_applicationDataDirectory, _session.CurrentProfileName) )); var synchronizerFactory = new SynchronizerFactory( GetProfileDataDirectory, new TotalProgressFactory( new ProgressFormFactory(), int.Parse(ConfigurationManager.AppSettings["loadOperationThresholdForProgressDisplay"]), ExceptionHandler.Instance), _session, TimeSpan.Parse(ConfigurationManager.AppSettings["calDavConnectTimeout"])); _synchronizationReportRepository = CreateSynchronizationReportRepository(); _filteringSynchronizationReportRepository = new FilteringSynchronizationReportRepositoryWrapper(_synchronizationReportRepository); UpdateGeneralOptionDependencies(generalOptions); _filteringSynchronizationReportRepository.ReportAdded += _synchronizationReportRepository_ReportAdded; _scheduler = new Scheduler( synchronizerFactory, _filteringSynchronizationReportRepository, EnsureSynchronizationContext); _scheduler.SetOptions(_optionsDataAccess.LoadOptions(), generalOptions.CheckIfOnline); _updateChecker = new UpdateChecker(new AvailableVersionService(), () => _generalOptionsDataAccess.IgnoreUpdatesTilVersion); _updateChecker.NewerVersionFound += UpdateChecker_NewerVersionFound; _updateChecker.IsEnabled = generalOptions.ShouldCheckForNewerVersions; _reportGarbageCollection = new ReportGarbageCollection(_synchronizationReportRepository, TimeSpan.FromDays(generalOptions.MaxReportAgeInDays)); }
public ReportGarbageCollection(ISynchronizationReportRepository reportRepository, TimeSpan maxAge) { _reportRepository = reportRepository; MaxAge = maxAge; _timer = new Timer(Timer_Elapsed); Thread.MemoryBarrier(); _timer.Change(TimeSpan.FromMinutes(1), TimeSpan.FromDays(1)); }
public SynchronizationProfileRunner ( ISynchronizerFactory synchronizerFactory, ISynchronizationReportRepository synchronizationReportRepository) { _synchronizerFactory = synchronizerFactory; _synchronizationReportRepository = synchronizationReportRepository; // Set to min, to ensure that it runs on the first run after startup _lastRun = DateTime.MinValue; }
public ReportGarbageCollection (ISynchronizationReportRepository reportRepository, TimeSpan maxAge) { _reportRepository = reportRepository; MaxAge = maxAge; _timer = new Timer (Timer_Elapsed); Thread.MemoryBarrier(); _timer.Change (TimeSpan.FromMinutes (1), TimeSpan.FromDays (1)); }
public SynchronizationProfileRunner( ISynchronizerFactory synchronizerFactory, ISynchronizationReportRepository synchronizationReportRepository) { _synchronizerFactory = synchronizerFactory; _synchronizationReportRepository = synchronizationReportRepository; // Set to min, to ensure that it runs on the first run after startup _lastRun = DateTime.MinValue; }
public ReportViewModel(ReportProxy reportProxy, ISynchronizationReportRepository reportRepository, IReportViewModelParent parent) { _reportRepository = reportRepository; _parent = parent; _reportProxy = reportProxy; OpenAEntityCommand = new DelegateCommand(parameter => { OpenAEntity((EntitySynchronizationReport)parameter); }); OpenBEntityCommand = new DelegateCommand(parameter => { OpenBEntity((EntitySynchronizationReport)parameter); }); OpenEntityWithLoadErrorCommand = new DelegateCommand(parameter => { OpenEntityWithLoadError((LoadError)parameter); }); }
public ReportViewModel (ReportProxy reportProxy, ISynchronizationReportRepository reportRepository, IReportViewModelParent parent) { _reportRepository = reportRepository; _parent = parent; _reportProxy = reportProxy; OpenAEntityCommand = new DelegateCommand (parameter => { OpenAEntity ((EntitySynchronizationReport) parameter); }); OpenBEntityCommand = new DelegateCommand (parameter => { OpenBEntity ((EntitySynchronizationReport) parameter); }); OpenEntityWithLoadErrorCommand = new DelegateCommand (parameter => { OpenEntityWithLoadError ((LoadError) parameter); }); }
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 Scheduler ( ISynchronizerFactory synchronizerFactory, ISynchronizationReportRepository synchronizationReportRepository, Action ensureSynchronizationContext) { if (synchronizerFactory == null) throw new ArgumentNullException ("synchronizerFactory"); if (ensureSynchronizationContext == null) throw new ArgumentNullException ("ensureSynchronizationContext"); if (synchronizationReportRepository == null) throw new ArgumentNullException ("synchronizationReportRepository"); _synchronizationReportRepository = synchronizationReportRepository; _synchronizerFactory = synchronizerFactory; _ensureSynchronizationContext = ensureSynchronizationContext; _synchronizationTimer.Tick += _synchronizationTimer_Tick; _synchronizationTimer.Interval = (int) _timerInterval.TotalMilliseconds; _synchronizationTimer.Start(); }
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 ComponentContainer(Application application) { s_logger.Info("Startup..."); _generalOptionsDataAccess = new GeneralOptionsDataAccess(); _synchronizationStatus = new SynchronizationStatus(); var generalOptions = _generalOptionsDataAccess.LoadOptions(); _daslFilterProvider = new DaslFilterProvider(generalOptions.IncludeCustomMessageClasses); FrameworkElement.LanguageProperty.OverrideMetadata( typeof(FrameworkElement), new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag))); ConfigureServicePointManager(generalOptions); ConfigureLogLevel(generalOptions.EnableDebugLog); _session = application.Session; _outlookAccountPasswordProvider = string.IsNullOrEmpty(_session.CurrentProfileName) ? NullOutlookAccountPasswordProvider.Instance : new OutlookAccountPasswordProvider(_session.CurrentProfileName, application.Version); _globalTimeZoneCache = new GlobalTimeZoneCache(); EnsureSynchronizationContext(); _applicationDataDirectory = Path.Combine( Environment.GetFolderPath( generalOptions.StoreAppDataInRoamingFolder ? Environment.SpecialFolder.ApplicationData : Environment.SpecialFolder.LocalApplicationData), "CalDavSynchronizer"); _optionsDataAccess = new OptionsDataAccess( Path.Combine( _applicationDataDirectory, GetOrCreateConfigFileName(_applicationDataDirectory, _session.CurrentProfileName) )); _synchronizerFactory = new SynchronizerFactory( GetProfileDataDirectory, new TotalProgressFactory( new ProgressFormFactory(), int.Parse(ConfigurationManager.AppSettings["loadOperationThresholdForProgressDisplay"]), ExceptionHandler.Instance), _session, _daslFilterProvider, _outlookAccountPasswordProvider, _globalTimeZoneCache); _synchronizationReportRepository = CreateSynchronizationReportRepository(); UpdateGeneralOptionDependencies(generalOptions); _scheduler = new Scheduler( _synchronizerFactory, this, EnsureSynchronizationContext, new FolderChangeWatcherFactory( _session), _synchronizationStatus); var options = _optionsDataAccess.LoadOptions(); EnsureCacheCompatibility(options); _profileStatusesViewModel = new ProfileStatusesViewModel(this); _profileStatusesViewModel.EnsureProfilesDisplayed(options); _availableVersionService = new AvailableVersionService(); _updateChecker = new UpdateChecker(_availableVersionService, () => _generalOptionsDataAccess.IgnoreUpdatesTilVersion); _updateChecker.NewerVersionFound += UpdateChecker_NewerVersionFound; _updateChecker.IsEnabled = generalOptions.ShouldCheckForNewerVersions; _reportGarbageCollection = new ReportGarbageCollection(_synchronizationReportRepository, TimeSpan.FromDays(generalOptions.MaxReportAgeInDays)); _trayNotifier = generalOptions.EnableTrayIcon ? new TrayNotifier(this) : NullTrayNotifer.Instance; _uiService = new UiService(_profileStatusesViewModel); using (var syncObjects = GenericComObjectWrapper.Create(_session.SyncObjects)) { if (syncObjects.Inner != null && syncObjects.Inner.Count > 0) { _syncObject = syncObjects.Inner[1]; if (generalOptions.TriggerSyncAfterSendReceive) { _syncObject.SyncEnd += _sync_SyncEnd; } } } }
public FilteringSynchronizationReportRepositoryWrapper(ISynchronizationReportRepository inner) { _inner = inner; }
public ReportViewModel(ReportProxy reportProxy, ISynchronizationReportRepository reportRepository) { _reportRepository = reportRepository; _reportProxy = reportProxy; }
public FilteringSynchronizationReportRepositoryWrapper (ISynchronizationReportRepository inner) { _inner = inner; }
public ComponentContainer(Application application, IGeneralOptionsDataAccess generalOptionsDataAccess, IComWrapperFactory comWrapperFactory, IExceptionHandlingStrategy exceptionHandlingStrategy) { if (application == null) { throw new ArgumentNullException(nameof(application)); } if (generalOptionsDataAccess == null) { throw new ArgumentNullException(nameof(generalOptionsDataAccess)); } if (comWrapperFactory == null) { throw new ArgumentNullException(nameof(comWrapperFactory)); } s_logger.Info("Startup..."); s_logger.Info($"Version: {Assembly.GetExecutingAssembly().GetName().Version}"); s_logger.Info($"Operating system: {Environment.OSVersion}"); _profileTypeRegistry = ProfileTypeRegistry.Instance; if (GeneralOptionsDataAccess.WpfRenderModeSoftwareOnly) { RenderOptions.ProcessRenderMode = System.Windows.Interop.RenderMode.SoftwareOnly; } _generalOptionsDataAccess = generalOptionsDataAccess; _synchronizationStatus = new SynchronizationStatus(); var generalOptions = _generalOptionsDataAccess.LoadOptions(); _daslFilterProvider = new DaslFilterProvider(generalOptions.IncludeCustomMessageClasses); SetWpfLocale(generalOptions.CultureName); ConfigureServicePointManager(generalOptions); ConfigureLogLevel(generalOptions.EnableDebugLog); _session = application.Session; _outlookAccountPasswordProvider = string.IsNullOrEmpty(_session.CurrentProfileName) ? NullOutlookAccountPasswordProvider.Instance : new OutlookAccountPasswordProvider(_session.CurrentProfileName, application.Version); _globalTimeZoneCache = new GlobalTimeZoneCache(); var applicationDataDirectoryBase = Path.Combine( Environment.GetFolderPath( generalOptions.StoreAppDataInRoamingFolder ? Environment.SpecialFolder.ApplicationData : Environment.SpecialFolder.LocalApplicationData), "CalDavSynchronizer"); string optionsFilePath; (_applicationDataDirectory, optionsFilePath) = GetOrCreateDataDirectory(applicationDataDirectoryBase, _session.CurrentProfileName); _optionsDataAccess = new OptionsDataAccess(optionsFilePath); _uiService = new UiService(); var options = _optionsDataAccess.Load(); _permanentStatusesViewModel = new PermanentStatusesViewModel(_uiService, this, options); _permanentStatusesViewModel.OptionsRequesting += PermanentStatusesViewModel_OptionsRequesting; _queryFolderStrategyWrapper = new OutlookFolderStrategyWrapper(QueryOutlookFolderByRequestingItemStrategy.Instance); _totalProgressFactory = new TotalProgressFactory( _uiService, generalOptions.ShowProgressBar, generalOptions.ThresholdForProgressDisplay, ExceptionHandler.Instance); _outlookSession = new OutlookSession(_session); _synchronizerFactory = new SynchronizerFactory( GetProfileDataDirectory, _totalProgressFactory, _outlookSession, _daslFilterProvider, _outlookAccountPasswordProvider, _globalTimeZoneCache, _queryFolderStrategyWrapper, exceptionHandlingStrategy, comWrapperFactory, _optionsDataAccess, _profileTypeRegistry); _synchronizationReportRepository = CreateSynchronizationReportRepository(); UpdateGeneralOptionDependencies(generalOptions); _scheduler = new Scheduler( _synchronizerFactory, this, EnsureSynchronizationContext, new FolderChangeWatcherFactory( _session), _synchronizationStatus); EnsureCacheCompatibility(options); _availableVersionService = new AvailableVersionService(); _updateChecker = new UpdateChecker(_availableVersionService, () => _generalOptionsDataAccess.IgnoreUpdatesTilVersion); _updateChecker.NewerVersionFound += UpdateChecker_NewerVersionFound; _updateChecker.IsEnabled = generalOptions.ShouldCheckForNewerVersions; _reportGarbageCollection = new ReportGarbageCollection(_synchronizationReportRepository, TimeSpan.FromDays(generalOptions.MaxReportAgeInDays)); _trayNotifier = generalOptions.EnableTrayIcon ? new TrayNotifier(this) : NullTrayNotifer.Instance; try { using (var syncObjects = GenericComObjectWrapper.Create(_session.SyncObjects)) { if (syncObjects.Inner != null && syncObjects.Inner.Count > 0) { _syncObject = syncObjects.Inner[1]; if (generalOptions.TriggerSyncAfterSendReceive) { _syncObject.SyncEnd += SyncObject_SyncEnd; } } } } catch (COMException ex) { s_logger.Error("Can't access SyncObjects", ex); } _oneTimeTaskRunner = new OneTimeTaskRunner(_outlookSession); DDayICalWorkaround.DDayICalCustomization.InitializeNoThrow(); }
public ReportViewModel (ReportProxy reportProxy, ISynchronizationReportRepository reportRepository) { _reportRepository = reportRepository; _reportProxy = reportProxy; }
public ComponentContainer(Application application) { s_logger.Info("Startup..."); if (GeneralOptionsDataAccess.WpfRenderModeSoftwareOnly) { RenderOptions.ProcessRenderMode = System.Windows.Interop.RenderMode.SoftwareOnly; } _generalOptionsDataAccess = new GeneralOptionsDataAccess(); _synchronizationStatus = new SynchronizationStatus(); var generalOptions = _generalOptionsDataAccess.LoadOptions(); _daslFilterProvider = new DaslFilterProvider(generalOptions.IncludeCustomMessageClasses); SetWpfLocale(); ConfigureServicePointManager(generalOptions); ConfigureLogLevel(generalOptions.EnableDebugLog); _session = application.Session; _outlookAccountPasswordProvider = string.IsNullOrEmpty(_session.CurrentProfileName) ? NullOutlookAccountPasswordProvider.Instance : new OutlookAccountPasswordProvider(_session.CurrentProfileName, application.Version); _globalTimeZoneCache = new GlobalTimeZoneCache(); EnsureSynchronizationContext(); _applicationDataDirectory = Path.Combine( Environment.GetFolderPath( generalOptions.StoreAppDataInRoamingFolder ? Environment.SpecialFolder.ApplicationData : Environment.SpecialFolder.LocalApplicationData), "CalDavSynchronizer"); _optionsDataAccess = new OptionsDataAccess( Path.Combine( _applicationDataDirectory, GetOrCreateConfigFileName(_applicationDataDirectory, _session.CurrentProfileName) )); _profileStatusesViewModel = new ProfileStatusesViewModel(this); _uiService = new UiService(_profileStatusesViewModel); _queryFolderStrategyWrapper = new OutlookFolderStrategyWrapper(QueryOutlookFolderByRequestingItemStrategy.Instance); _totalProgressFactory = new TotalProgressFactory( _uiService, generalOptions.ShowProgressBar, generalOptions.ThresholdForProgressDisplay, ExceptionHandler.Instance); _synchronizerFactory = new SynchronizerFactory( GetProfileDataDirectory, _totalProgressFactory, _session, _daslFilterProvider, _outlookAccountPasswordProvider, _globalTimeZoneCache, _queryFolderStrategyWrapper); _synchronizationReportRepository = CreateSynchronizationReportRepository(); UpdateGeneralOptionDependencies(generalOptions); _scheduler = new Scheduler( _synchronizerFactory, this, EnsureSynchronizationContext, new FolderChangeWatcherFactory( _session), _synchronizationStatus); var options = _optionsDataAccess.Load(); EnsureCacheCompatibility(options); _profileStatusesViewModel.EnsureProfilesDisplayed(options); _availableVersionService = new AvailableVersionService(); _updateChecker = new UpdateChecker(_availableVersionService, () => _generalOptionsDataAccess.IgnoreUpdatesTilVersion); _updateChecker.NewerVersionFound += UpdateChecker_NewerVersionFound; _updateChecker.IsEnabled = generalOptions.ShouldCheckForNewerVersions; _reportGarbageCollection = new ReportGarbageCollection(_synchronizationReportRepository, TimeSpan.FromDays(generalOptions.MaxReportAgeInDays)); _trayNotifier = generalOptions.EnableTrayIcon ? new TrayNotifier(this) : NullTrayNotifer.Instance; try { using (var syncObjects = GenericComObjectWrapper.Create(_session.SyncObjects)) { if (syncObjects.Inner != null && syncObjects.Inner.Count > 0) { _syncObject = syncObjects.Inner[1]; if (generalOptions.TriggerSyncAfterSendReceive) { _syncObject.SyncEnd += SyncObject_SyncEnd; } } } } catch (COMException ex) { s_logger.Error("Can't access SyncObjects", ex); } _categorySwitcher = new CategorySwitcher(_session, _daslFilterProvider, _queryFolderStrategyWrapper); }