/// <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, } }, }; }
/// <summary> /// Initializes a new instance of the ArcGisServerLoginViewModel class. /// </summary> /// <param name="server">The server to provide 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> public ArcGisServerLoginViewModel( AgsServer server, IMessenger messenger, IWorkingStatusController workingStatusController) { Debug.Assert(server != null); Debug.Assert(messenger != null); Debug.Assert(workingStatusController != null); _server = server; _server.StateChanged += _ServerStateChanged; this.LicenseState = server.State; this.RegisterHeader( AgsServerState.Unauthorized, App.Current.GetString("LoginToServerString", _server.Title)); _messenger = messenger; _workingStatusController = workingStatusController; var licensePageCommands = new LicensePageCommands() { CreateAccount = null, RecoverCredentials = null, UpgradeLicense = null, }; this.LoginState = new LoginStateViewModel( licensePageCommands, _ExecuteLogin); var licenseInfoText = EnumerableEx.Return(ApplyStyle(new FlowDocument( new Paragraph() { Inlines = { new Run(App.Current.GetString("LoggedToServerString", _server.Title)), new Run(NEW_LINE), new Run(_server.Description) }, } ))); this.ConnectedState = new ConnectedStateViewModel( licensePageCommands, licenseInfoText) { SwitchUserCommand = new DelegateCommand( _ => this.LicenseState = AgsServerState.Unauthorized), }; var connectionFailureInfo = ApplyStyle(new FlowDocument( new Paragraph( new Run(App.Current.GetString( "ServerIsUnavailableString", _server.Title) ) ) )); this.NotConnectedState = new NotConnectedStateViewModel() { ConnectionFailureInfo = connectionFailureInfo, }; }