public void ShowOptionsNoThrow() { try { var options = _optionsDataAccess.LoadOptions(); Options[] newOptions; GeneralOptions generalOptions = _generalOptionsDataAccess.LoadOptions(); if (OptionsForm.EditOptions( _session, options, out newOptions, GetProfileDataDirectory, generalOptions.FixInvalidSettings, generalOptions.DisplayAllProfilesAsGeneric)) { _optionsDataAccess.SaveOptions(newOptions); _scheduler.SetOptions(newOptions, generalOptions.CheckIfOnline); DeleteEntityChachesForChangedProfiles(options, newOptions); var changedOptions = CreateChangePairs(options, newOptions); SwitchCategories(changedOptions); } } catch (Exception x) { ExceptionHandler.Instance.HandleException(x, s_logger); } }
public async Task Initialize() { var options = _optionsDataAccess.LoadOptions(); var generalOptions = _generalOptionsDataAccess.LoadOptions(); await _scheduler.SetOptions(options, generalOptions); }
public void ShowOptions(Guid?initialVisibleProfile = null) { if (_currentVisibleOptionsFormOrNull == null) { var options = _optionsDataAccess.LoadOptions(); GeneralOptions generalOptions = _generalOptionsDataAccess.LoadOptions(); try { var newOptions = ShowWpfOptions(initialVisibleProfile, generalOptions, options); if (newOptions != null) { ApplyNewOptions(options, newOptions, generalOptions); } } finally { _currentVisibleOptionsFormOrNull = null; } } else { _currentVisibleOptionsFormOrNull.BringToFront(); if (initialVisibleProfile.HasValue) { _currentVisibleOptionsFormOrNull.ShowProfile(initialVisibleProfile.Value); } } }
public async Task InitializeSchedulerAndStart() { _scheduler.Start(); var options = _optionsDataAccess.LoadOptions(); var generalOptions = _generalOptionsDataAccess.LoadOptions(); await _scheduler.SetOptions(options, generalOptions); if (generalOptions.TriggerSyncAfterSendReceive) { s_logger.Info("Triggering sync after startup"); EnsureSynchronizationContext(); SynchronizeNowAsync(); } }
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 ComponentContainer (Application application) { try { XmlConfigurator.Configure(); _itemChangeWatcher = new OutlookItemChangeWatcher (application.Inspectors); _itemChangeWatcher.ItemSavedOrDeleted += ItemChangeWatcherItemSavedOrDeleted; _session = application.Session; s_logger.Info ("Startup..."); EnsureSynchronizationContext(); _applicationDataDirectory = Path.Combine (Environment.GetFolderPath (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"]), TimeSpan.Parse (ConfigurationManager.AppSettings["calDavReadWriteTimeout"])); _scheduler = new Scheduler (synchronizerFactory, EnsureSynchronizationContext); _scheduler.SetOptions (_optionsDataAccess.LoadOptions()); _updateChecker = new UpdateChecker (new AvailableVersionService(), () => _optionsDataAccess.IgnoreUpdatesTilVersion); _updateChecker.NewerVersionFound += UpdateChecker_NewerVersionFound; _updateChecker.IsEnabled = _optionsDataAccess.ShouldCheckForNewerVersions; } catch (Exception x) { ExceptionHandler.Instance.LogException (x, s_logger); throw; } s_logger.Info ("Startup finnished"); }
public void ShowOptionsNoThrow() { try { var options = _optionsDataAccess.LoadOptions(); var shouldCheckForNewerVersions = ShouldCheckForNewerVersions; if (OptionsForm.EditOptions(_session, options, out options, shouldCheckForNewerVersions, out shouldCheckForNewerVersions)) { _optionsDataAccess.SaveOptions(options); ShouldCheckForNewerVersions = shouldCheckForNewerVersions; _scheduler.SetOptions(options); } } catch (Exception x) { ExceptionHandler.Instance.HandleException(x, s_logger); } }
public ComponentContainer(NameSpace session) { try { XmlConfigurator.Configure(); _session = session; s_logger.Info("Startup..."); EnsureSynchronizationContext(); var applicationDataDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "CalDavSynchronizer"); _optionsDataAccess = new OptionsDataAccess( Path.Combine( applicationDataDirectory, GetOrCreateConfigFileName(applicationDataDirectory, _session.CurrentProfileName) )); var synchronizerFactory = new SynchronizerFactory( applicationDataDirectory, new TotalProgressFactory( new ProgressFormFactory(), int.Parse(ConfigurationManager.AppSettings["loadOperationThresholdForProgressDisplay"]), ExceptionHandler.Instance), _session, TimeSpan.Parse(ConfigurationManager.AppSettings["calDavConnectTimeout"]), TimeSpan.Parse(ConfigurationManager.AppSettings["calDavReadWriteTimeout"])); _scheduler = new Scheduler(synchronizerFactory, EnsureSynchronizationContext); _scheduler.SetOptions(_optionsDataAccess.LoadOptions()); _updateChecker = new UpdateChecker(new AvailableVersionService()); _updateChecker.NewerVersionFound += UpdateChecker_NewerVersionFound; _updateChecker.IsEnabled = _optionsDataAccess.ShouldCheckForNewerVersions; } catch (Exception x) { ExceptionHandler.Instance.LogException(x, s_logger); throw; } s_logger.Info("Startup finnished"); }
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; } } } }