public ExplorerViewModel(IShellViewModel shellViewModel, Microsoft.Practices.Prism.PubSubEvents.IEventAggregator aggregator, bool shouldUpdateActiveEnvironment, Action <IExplorerItemViewModel> selectAction = null, bool loadLocalHost = true)
        {
            if (shellViewModel == null)
            {
                throw new ArgumentNullException(nameof(shellViewModel));
            }
            var localhostEnvironment = CreateEnvironmentFromServer(shellViewModel.LocalhostServer, shellViewModel);

            _shellViewModel = shellViewModel;
            _selectAction   = selectAction;
            localhostEnvironment.SelectAction = selectAction ?? (a => { });
            localhostEnvironment.IsSelected   = true;
            // ReSharper disable VirtualMemberCallInContructor
            Environments = new ObservableCollection <IEnvironmentViewModel> {
                localhostEnvironment
            };
            if (loadLocalHost)
#pragma warning disable 4014
            {
                LoadEnvironment(localhostEnvironment);
            }
#pragma warning restore 4014

            ConnectControlViewModel = new ConnectControlViewModel(shellViewModel.LocalhostServer, aggregator);
            ConnectControlViewModel.ShouldUpdateActiveEnvironment = shouldUpdateActiveEnvironment;
            ShowConnectControl = true;
            ConnectControlViewModel.ServerConnected            += ServerConnected;
            ConnectControlViewModel.ServerDisconnected         += ServerDisconnected;
            ConnectControlViewModel.ServerHasDisconnected      += ServerDisconnectDetected;
            ConnectControlViewModel.ServerReConnected          += ServerReConnected;
            ConnectControlViewModel.SelectedEnvironmentChanged += ConnectControlViewModelOnSelectedEnvironmentChanged;
        }
        public DeploySourceExplorerViewModel(IShellViewModel shellViewModel, Microsoft.Practices.Prism.PubSubEvents.IEventAggregator aggregator, IDeployStatsViewerViewModel statsArea, IEnvironmentViewModel selectedEnvironment)
        {
            if (shellViewModel == null)
            {
                throw new ArgumentNullException(nameof(shellViewModel));
            }
            var localhostEnvironment = CreateEnvironmentFromServer(shellViewModel.LocalhostServer, shellViewModel);

            _shellViewModel = shellViewModel;
            _selectAction   = SelectAction;
            _selectedEnv    = selectedEnvironment;

            Environments = new ObservableCollection <IEnvironmentViewModel> {
                localhostEnvironment
            };
            LoadLocalHostEnvironment(localhostEnvironment);
            ConnectControlViewModel = new ConnectControlViewModel(_shellViewModel.LocalhostServer, aggregator, _shellViewModel.ExplorerViewModel.ConnectControlViewModel.Servers);

            ShowConnectControl = true;
            ConnectControlViewModel.ServerDisconnected += ServerDisconnected;
            _statsArea = statsArea;
            foreach (var environmentViewModel in _environments)
            {
                environmentViewModel.SelectAction = SelectAction;
            }

            if (ConnectControlViewModel.SelectedConnection != null && !ConnectControlViewModel.SelectedConnection.IsLocalHost)
            {
                UpdateItemForDeploy(ConnectControlViewModel.SelectedConnection.EnvironmentID);
            }
            IsRefreshing       = false;
            ShowConnectControl = false;
            RefreshCommand     = new Microsoft.Practices.Prism.Commands.DelegateCommand(() => RefreshEnvironment(SelectedEnvironment.ResourceId));
            ConnectControlViewModel.SelectedEnvironmentChanged += ConnectControlSelectedExplorerEnvironmentChanged;
            ConnectControlViewModel.ServerConnected            += (sender, server) =>
            {
                IsDeployLoading = true;
                ServerConnectedAsync(server).ContinueWith(t =>
                {
                    IsDeployLoading = false;
                }, TaskContinuationOptions.ExecuteSynchronously);
            };
            IsDeploy = true;
        }
        public MergeServiceViewModel(IShellViewModel shellViewModel, Microsoft.Practices.Prism.PubSubEvents.IEventAggregator aggregator, IExplorerItemViewModel selectedResource, IMergeView mergeView, IServer selectedServer)
        {
            if (shellViewModel == null)
            {
                throw new ArgumentNullException(nameof(shellViewModel));
            }
            var localhostEnvironment = CreateEnvironmentFromServer(shellViewModel.LocalhostServer, shellViewModel);

            localhostEnvironment.Children = shellViewModel.ExplorerViewModel?.Environments[0].Children;
            _shellViewModel   = shellViewModel;
            _selectedResource = selectedResource;

            ResourceToMerge = _selectedResource.IsVersion ? _selectedResource.Parent.ResourceName : _selectedResource.ResourceName;

            _view = mergeView;

            Environments = new ObservableCollection <IEnvironmentViewModel> {
                localhostEnvironment
            };

            MergeConnectControlViewModel = new ConnectControlViewModel(_shellViewModel.LocalhostServer, aggregator, _shellViewModel.ExplorerViewModel.ConnectControlViewModel.Servers)
            {
                SelectedConnection = selectedServer
            };

            LoadVersions(selectedResource.Server);
            ShowConnectControl = true;
            MergeConnectControlViewModel.CanEditServer       = false;
            MergeConnectControlViewModel.CanCreateServer     = false;
            MergeConnectControlViewModel.ServerConnected    += async(sender, server) => { await ServerConnectedAsync(server).ConfigureAwait(false); };
            MergeConnectControlViewModel.ServerDisconnected += ServerDisconnected;

            ShowConnectControl = false;
            IsRefreshing       = false;
            RefreshCommand     = new DelegateCommand(() => RefreshEnvironment(SelectedEnvironment.ResourceId).ConfigureAwait(false));
            CancelCommand      = new DelegateCommand(Cancel);
            MergeCommand       = new DelegateCommand(Merge, CanMerge);

            MergeConnectControlViewModel.SelectedEnvironmentChanged += async(sender, id) =>
            {
                await MergeExplorerViewModelSelectedEnvironmentChangedAsync(sender).ConfigureAwait(false);
            };
        }
        public DeploySourceExplorerViewModel(IShellViewModel shellViewModel, Microsoft.Practices.Prism.PubSubEvents.IEventAggregator aggregator, IDeployStatsViewerViewModel statsArea)
        {
            if (shellViewModel == null)
            {
                throw new ArgumentNullException(nameof(shellViewModel));
            }
            var localhostEnvironment = CreateEnvironmentFromServer(shellViewModel.LocalhostServer, shellViewModel);

            _shellViewModel = shellViewModel;
            _selectAction   = SelectAction;
            // ReSharper disable once VirtualMemberCallInContructor
            Environments = new ObservableCollection <IEnvironmentViewModel> {
                localhostEnvironment
            };
            // ReSharper disable once VirtualMemberCallInContructor
            LoadEnvironment(localhostEnvironment);

            ConnectControlViewModel = new ConnectControlViewModel(_shellViewModel.LocalhostServer, aggregator, _shellViewModel.ExplorerViewModel.ConnectControlViewModel.Servers);

            ShowConnectControl = true;
            ConnectControlViewModel.ServerConnected    += async(sender, server) => { await ServerConnected(sender, server); };
            ConnectControlViewModel.ServerDisconnected += ServerDisconnected;
            _statsArea = statsArea;
            foreach (var environmentViewModel in _environments)
            {
                environmentViewModel.SelectAction = SelectAction;
            }

            if (ConnectControlViewModel.SelectedConnection != null)
            {
                UpdateItemForDeploy(ConnectControlViewModel.SelectedConnection.EnvironmentID);
            }
            IsRefreshing       = false;
            ShowConnectControl = false;
            RefreshCommand     = new Microsoft.Practices.Prism.Commands.DelegateCommand(() => RefreshEnvironment(SelectedEnvironment.ResourceId));
            ConnectControlViewModel.SelectedEnvironmentChanged += async(sender, id) =>
            {
                await DeploySourceExplorerViewModelSelectedEnvironmentChanged(sender, id);
            };
            IsDeploy = true;
        }
 public DeploySourceExplorerViewModel(IShellViewModel shellViewModel, Microsoft.Practices.Prism.PubSubEvents.IEventAggregator aggregator, IDeployStatsViewerViewModel statsArea)
     : this(shellViewModel, aggregator, statsArea, null)
 {
 }
        /// <exception cref="Exception">A delegate callback throws an exception.</exception>
        public ManageComPluginSourceViewModel(IManageComPluginSourceModel updateManager, Microsoft.Practices.Prism.PubSubEvents.IEventAggregator aggregator, IAsyncWorker asyncWorker)
            : base("ComPluginSource")
        {
            VerifyArgument.IsNotNull("asyncWorker", asyncWorker);
            VerifyArgument.IsNotNull("updateManager", updateManager);
            VerifyArgument.IsNotNull("aggregator", aggregator);
            _updateManager = updateManager;
            AsyncWorker = asyncWorker;
            HeaderText = Resources.Languages.Core.ComPluginSourceNewHeaderLabel;
            Header = Resources.Languages.Core.ComPluginSourceNewHeaderLabel;
            OkCommand = new DelegateCommand(Save, CanSave);
            CancelCommand = new DelegateCommand(() => CloseAction.Invoke());
            ClearSearchTextCommand = new DelegateCommand(() => SearchTerm = "");
            RefreshCommand = new DelegateCommand(() => PerformLoadAll());

            _warewolfserverName = updateManager.ServerName;
            if (Application.Current != null)
            {
                if (Application.Current.Dispatcher != null)
                {
                    DispatcherAction = Application.Current.Dispatcher.Invoke;
                }
            }
        }
 public ManageComPluginSourceViewModel(IManageComPluginSourceModel updateManager, Microsoft.Practices.Prism.PubSubEvents.IEventAggregator aggregator, IComPluginSource pluginSource, IAsyncWorker asyncWorker, Action<System.Action> dispatcherAction)
     : this(updateManager, aggregator, asyncWorker)
 {
     VerifyArgument.IsNotNull("comPluginSource", pluginSource);
     DispatcherAction = dispatcherAction;
     _pluginSource = pluginSource;
     SetupHeaderTextFromExisting();
     PerformLoadAll(() => FromModel(_pluginSource));
     Item = ToModel();
 }
 /// <exception cref="Exception">A delegate callback throws an exception.</exception>
 public ManageComPluginSourceViewModel(IManageComPluginSourceModel updateManager, Microsoft.Practices.Prism.PubSubEvents.IEventAggregator aggregator, IComPluginSource pluginSource, IAsyncWorker asyncWorker)
     : this(updateManager, aggregator, asyncWorker)
 {
     VerifyArgument.IsNotNull("compluginSource", pluginSource);
     asyncWorker.Start(() =>
     {
         IsLoading = true;
         var comPluginSource = updateManager.FetchSource(pluginSource.Id);
         List<DllListingModel> names = updateManager.GetComDllListings(null)?.Select(input => new DllListingModel(updateManager, input)).ToList();
         return new Tuple<IComPluginSource, List<DllListingModel>>(comPluginSource, names);
     }, tuple =>
     {
         if (tuple.Item2 != null)
         {
             _originalDllListings = new AsyncObservableCollection<IDllListingModel>(tuple.Item2);
             DllListings = _originalDllListings;
         }
         _pluginSource = tuple.Item1;
         _pluginSource.ResourcePath = pluginSource.ResourcePath;
         SetupHeaderTextFromExisting();
         FromModel(_pluginSource);
         Item = ToModel();
         IsLoading = false;
     });
 }
 public ManageComPluginSourceViewModel(IManageComPluginSourceModel updateManager, Task<IRequestServiceNameViewModel> requestServiceNameViewModel, Microsoft.Practices.Prism.PubSubEvents.IEventAggregator aggregator, IAsyncWorker asyncWorker, Action<Action> dispatcherAction)
     : this(updateManager, aggregator, asyncWorker)
 {
     DispatcherAction = dispatcherAction;
     VerifyArgument.IsNotNull("requestServiceNameViewModel", requestServiceNameViewModel);
     PerformLoadAll();
     _requestServiceNameViewModel = requestServiceNameViewModel;
     Item = ToModel();
 }
 public DeployDestinationViewModelForTesting(IShellViewModel shellViewModel, Microsoft.Practices.Prism.PubSubEvents.IEventAggregator aggregator)
     : base(shellViewModel, aggregator)
 {
 }
Exemple #11
0
 public DeploySourceExplorerViewModelForTesting(IShellViewModel shellViewModel, Microsoft.Practices.Prism.PubSubEvents.IEventAggregator aggregator, IDeployStatsViewerViewModel statsArea)
     : base(shellViewModel, aggregator, statsArea)
 {
     // ReSharper disable once VirtualMemberCallInContructor
     SelectedItems = new List <IExplorerTreeItem>();
 }
 public DeploySourceExplorerViewModelForTesting(IShellViewModel shellViewModel, Microsoft.Practices.Prism.PubSubEvents.IEventAggregator aggregator, IDeployStatsViewerViewModel statsArea)
     : base(shellViewModel, aggregator, statsArea)
 {
     SelectedItems = new List <IExplorerTreeItem>();
 }