public ExchangeSettingsViewModel(IWorkbook workbook, INavigationService navigationService, IMessageBoxService messageBoxService, ISynchronizationManager synchronizationManager, ITrackingManager trackingManager) : base(workbook, navigationService, messageBoxService, synchronizationManager, trackingManager) { if (!this.Settings.HasValue(ExchangeSettings.ExchangeVersion)) { this.Settings.SetValue(ExchangeSettings.ExchangeVersion, ExchangeServerVersion.ExchangeOffice365); } if (!string.IsNullOrEmpty(this.ServerUri)) { this.ServerUri = this.ServerUri.GetUriCompatibleString(); } this.exchangeVersion = ExchangeServerVersionHelper.GetString(this.Settings.GetValue <ExchangeServerVersion>(ExchangeSettings.ExchangeVersion)); this.syncFlaggedItems = this.Settings.GetValue <bool>(ExchangeSettings.ExchangeSyncFlaggedItems); this.UpdateSSLUsage(); }
protected override async void CheckSettingsExecute() { this.Settings.SetValue(ExchangeSettings.ExchangeVersion, ExchangeServerVersionHelper.GetEnum(this.exchangeVersion)); this.Settings.SetValue(ExchangeSettings.ExchangeSyncFlaggedItems, this.syncFlaggedItems); if (string.IsNullOrEmpty(this.Domain) && !string.IsNullOrEmpty(this.Email)) { // try to use the email address to find out what the domain is string[] emailComponents = this.Email.Split('@'); if (emailComponents.Length > 1) { this.Domain = emailComponents[1]; } } if (!string.IsNullOrEmpty(this.ServerUri)) { this.ServerUri = this.ServerUri.GetUriCompatibleString(); if (!this.ServerUri.StartsWith(HttpPrefix) && !this.ServerUri.StartsWith(HttpsPrefix)) { // http prefix is missing add it if (this.UseSSL) { this.ServerUri = HttpsPrefix + this.ServerUri; } else { this.ServerUri = HttpPrefix + this.ServerUri; } } } if (string.IsNullOrEmpty(this.Username) && !string.IsNullOrEmpty(this.Email)) { // if the username is empty while the email is not // use the email as the username this.Username = this.Email; } using (this.ExecuteBusyAction(ExchangeResources.Exchange_CheckingCredentials)) { SynchronizationService synchronizationService = SynchronizationService.ExchangeEws; ISynchronizationProvider provider = this.SynchronizationManager.GetProvider(synchronizationService); bool result = false; if (provider != null) { provider.OperationFailed += this.ProviderOnOperationFailed; result = await provider.CheckLoginAsync(); provider.OperationFailed -= this.ProviderOnOperationFailed; } // notify potential changes to the server uri this.RaisePropertyChanged("ServerUri"); this.UpdateSSLUsage(); if (result) { this.SynchronizationManager.Metadata.Reset(); this.SynchronizationManager.ActiveService = synchronizationService; await this.HandleGoodSettings(); } } }