public async Task InitializeSchedulerAndStartAsync() { _scheduler.Start(); var options = _optionsDataAccess.Load(); var generalOptions = _generalOptionsDataAccess.LoadOptions(); await _scheduler.SetOptions(options, generalOptions); if (generalOptions.TriggerSyncAfterSendReceive) { s_logger.Info("Triggering sync after startup"); EnsureSynchronizationContext(); SynchronizeInitial(); } }
private void PermanentStatusesViewModel_OptionsRequesting(object sender, OptionsEventArgs e) { e.Options = _optionsDataAccess.Load(); }
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 Options LoadOrNull() { var options = _optionsDataAccess.Load(); return(options.FirstOrDefault(o => o.Id == _profileId)); }
private Options CreateDefaultOptions(string profileName, string outlookFolderName) { var options = _optionsDataAccess.Load().Single(o => o.Name == profileName); return(CreateDefaultOptions(options, outlookFolderName)); }
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); }