/// <summary> /// Initializes a new instance of the LicensePageModel class. /// </summary> /// <param name="servers">Collection of servers to provide separate /// authentication for.</param> /// <param name="messenger">The messenger object to be used for /// notifications.</param> /// <param name="workingStatusController">The object to be used for /// managing application working status.</param> /// <param name="uriNavigator">The reference to the object to be used /// for navigating to URI's.</param> public LicensePageModel( IEnumerable<AgsServer> servers, IMessenger messenger, IWorkingStatusController workingStatusController, IUriNavigator uriNavigator, ILicenseManager licenseManager) { Debug.Assert(servers != null); Debug.Assert(servers.All(server => server != null)); Debug.Assert(messenger != null); Debug.Assert(workingStatusController != null); Debug.Assert(licenseManager != null); _licenseManager = licenseManager; _licenseExpirationChecker = _licenseManager.LicenseExpirationChecker; var items = new ObservableCollection<LoginViewModelBase>(); var licensingViewModel = new LicensingViewModel( messenger, workingStatusController, uriNavigator, licenseManager); this.RequiresExpirationWarning = licensingViewModel.RequiresExpirationWarning; licensingViewModel.PropertyChanged += delegate { this.RequiresExpirationWarning = licensingViewModel.RequiresExpirationWarning; _UpdateCompletedState(); }; items.Add(licensingViewModel); _servers = servers.ToList(); foreach (var server in _servers) { items.Add(new ArcGisServerLoginViewModel( server, messenger, workingStatusController)); server.StateChanged += delegate { _UpdateCompletedState(); }; } this.LoginViewModels = new ReadOnlyObservableCollection<LoginViewModelBase>(items); _UpdateCompletedState(); _UpdateLoggedInState(); foreach (var vm in this.LoginViewModels) { vm.LoginState.LoginViewHost = this; vm.PropertyChanged += delegate { _UpdateLoggedInState(); }; } }
/// <summary> /// Initializes a new instance of the LicensingViewModel class. /// </summary> /// <param name="messenger">The messenger object to be used for /// notifications.</param> /// <param name="workingStatusController">The object to be used for /// managing application working status.</param> /// <param name="uriNavigator">The reference to the object to be used /// for navigating to URI's.</param> /// <param name="licenseManager">The reference to the license manager /// object.</param> public LicensingViewModel( IMessenger messenger, IWorkingStatusController workingStatusController, IUriNavigator uriNavigator, ILicenseManager licenseManager) { Debug.Assert(messenger != null); Debug.Assert(workingStatusController != null); Debug.Assert(uriNavigator != null); Debug.Assert(licenseManager != null); _licenseManager = licenseManager; _licenseExpirationChecker = licenseManager.LicenseExpirationChecker; _messenger = messenger; _workingStatusController = workingStatusController; _uriNavigator = uriNavigator; _licensePageCommands = new LicensePageCommands() { CreateAccount = _CreateUrlNavigationCommand( _licenseManager.LicenseComponent.CreateAccountURL, _uriNavigator), RecoverCredentials = _CreateUrlNavigationCommand( _licenseManager.LicenseComponent.RecoverCredentialsURL, _uriNavigator), UpgradeLicense = _CreateUrlNavigationCommand( _licenseManager.LicenseComponent.UpgradeLicenseURL, _uriNavigator), }; this.LicenseActivationStatus = _licenseManager.LicenseActivationStatus; this.LicenseState = this.LicenseActivationStatus == LicenseActivationStatus.Activated ? AgsServerState.Authorized : AgsServerState.Unauthorized; _UpdateExpirationWarningDisplayState(); foreach (var item in EnumHelpers.GetValues<AgsServerState>()) { this.RegisterHeader( item, _licenseManager.LicenseComponent.LoginPrompt); } _CreateLoginState(); _CreateConnectedState(); _CreateNotConnectedState(); this.LicensingNotes = _CreateLicensingNotes( _licenseManager.LicenseComponent.LicensingNotes); this.TroubleshootingNotes = _CreateTroubleshootingNotes( _licenseManager.LicenseComponent.TroubleshootingNotes); _stateFactories = new Dictionary<LicenseActivationStatus, Func<LicenseActivationViewState>>() { { LicenseActivationStatus.None, () => new LicenseActivationViewState { LoginViewState = this.LoginState, InformationViewState = (object)null, } }, { LicenseActivationStatus.Activated, () => new LicenseActivationViewState { LoginViewState = this.ConnectedState, InformationViewState = _CreateActivatedState(), } }, { LicenseActivationStatus.Expired, () => new LicenseActivationViewState { LoginViewState = this.LoginState, InformationViewState = _CreateExpiredState(), } }, { LicenseActivationStatus.WrongCredentials, () => new LicenseActivationViewState { LoginViewState = this.LoginState, InformationViewState = _CreateWrongCredentialsState(), } }, { LicenseActivationStatus.NoSubscription, () => new LicenseActivationViewState { LoginViewState = this.LoginState, InformationViewState = _CreateNoSubscriptionState(), } }, { LicenseActivationStatus.Failed, () => new LicenseActivationViewState { LoginViewState = this.NotConnectedState, InformationViewState = (object)null, } }, }; }