public void EditConnection(int selectedIndex, Action <int> openWizard)
        {
            if (selectedIndex != -1 && selectedIndex <= Servers.Count)
            {
                var selectedServer   = Servers[selectedIndex];
                var environmentModel = selectedServer.EnvironmentModel;
                if (environmentModel != null && environmentModel.Connection != null)
                {
                    var serverUri = environmentModel.Connection.AppServerUri;
                    var auth      = environmentModel.Connection.AuthenticationType;
                    openWizard(selectedIndex);
                    var updatedServer = _environmentRepository.All().FirstOrDefault(e => e.ID == environmentModel.ID);
                    if (updatedServer != null && (!serverUri.Equals(updatedServer.Connection.AppServerUri) || auth != updatedServer.Connection.AuthenticationType))
                    {
                        if (ConnectedStatusChanged != null)
                        {
                            ConnectedStatusChanged(this, new ConnectionStatusChangedEventArg(ConnectionEnumerations.ConnectedState.Busy, environmentModel.ID, false));
                        }

                        if (selectedServer.IsConnected)
                        {
                            _studioResourceRepository.Disconnect(environmentModel.ID);
                        }
                        selectedServer.EnvironmentModel = updatedServer;
                        _studioResourceRepository.Load(environmentModel.ID, _asyncWorker, ResourcesLoadedHandler);
                    }
                }
            }
        }
Esempio n. 2
0
 void OnNetworkStateChanged(object sender, NetworkStateEventArgs e)
 {
     RaiseNetworkStateChanged(e.ToState == NetworkState.Online || e.ToState == NetworkState.Connecting);
     if (e.ToState == NetworkState.Connecting || e.ToState == NetworkState.Offline)
     {
         _studioRepo.Disconnect(ID);
         if (AuthorizationService != null)
         {
             AuthorizationService.PermissionsChanged -= OnAuthorizationServicePermissionsChanged;
         }
     }
     if (e.ToState == NetworkState.Online)
     {
         if (AuthorizationService == null)
         {
             AuthorizationService = CreateAuthorizationService(Connection);
             AuthorizationService.PermissionsChanged += OnAuthorizationServicePermissionsChanged;
             OnAuthorizationServicePermissionsChanged(null, new EventArgs());
         }
     }
 }