Exemplo n.º 1
0
        /// <summary>Initializes a new instance of the <see cref="StopBuildCommand"/> class.</summary>
        /// <param name="buildAdapter">The build adapter.</param>
        /// <param name="buildInformation">The build information.</param>
        public StopBuildCommand(BuildAdapter buildAdapter, BuildInformation buildInformation)
        {
            buildExplorer = BuildExplorerFactory.CreateBuildExplorer(buildInformation.TfsVersion);
            buildAdapter.PropertyChanged += buildAdapter_PropertyChanged;

            this.buildAdapter     = buildAdapter;
            this.buildInformation = buildInformation;
        }
Exemplo n.º 2
0
        /// <summary>Defines the method to be called when the command is invoked.</summary>
        /// <param name="parameter">Data used by the command.  If the command does not require data to be passed, this object can be set to null.</param>
        public async void Execute(object parameter)
        {
            var passwordBox = parameter as PasswordBox;

            if (passwordBox != null && !string.IsNullOrEmpty(passwordBox.Password))
            {
                buildServerAdapter.CryptedPassword = crypter.Encrypt(passwordBox.Password);
            }

            var buildServer = new BuildServer
            {
                DomainName    = buildServerAdapter.Domain,
                Login         = buildServerAdapter.Login,
                PasswordBytes = buildServerAdapter.CryptedPassword,
                Url           = buildServerAdapter.TfsUrl
            };

            busy = true;
            OnCanExecuteChanged();
            buildServerAdapter.ConnectionProgress = "Connecting to TFS server...";
            var buildExplorer = BuildExplorerFactory.CreateBuildExplorer(buildServerAdapter.TfsVersion);
            var result        = await buildExplorer.GetBuildDefinitions(buildServer);

            buildServerAdapter.ConnectionProgress = "Propagating results ...";

            buildServerAdapter.BuildDefinitionResults.Clear();
            foreach (var buildResult in result.BuildDefinitions.OrderBy(x => x.Name))
            {
                var id = buildResult.Id;
                buildResult.Selected = buildServerAdapter.BuildDefinitions.Any(x => x.Id == id);
                buildServerAdapter.BuildDefinitionResults.Add(buildResult);
            }

            buildServerAdapter.ProjectNames.Clear();
            buildServerAdapter.ProjectNames.Add(BuildServerAdapter.AllString);
            foreach (var projectName in result.BuildDefinitions.Select(x => x.ProjectName).Distinct().OrderBy(x => x))
            {
                buildServerAdapter.ProjectNames.Add(projectName);
            }

            buildServerAdapter.SelectedProjectName = BuildServerAdapter.AllString;
            buildServerAdapter.ConnectionProgress  = result.Message;

            busy = false;
            OnCanExecuteChanged();
        }
Exemplo n.º 3
0
      /// <summary>Initializes a new instance of the <see cref="BuildAdapter"/> class.</summary>
      /// <param name="mainWindowViewModel">The main window view model.</param>
      /// <param name="buildInformation">The build information.</param>
      /// <param name="isPinedView">if set to <c>true</c> [is pined view].</param>
      internal BuildAdapter(MainWindowViewModel mainWindowViewModel, BuildInformation buildInformation, bool isPinedView)
      {
         BuildInformation = buildInformation;
         this.mainWindowViewModel = mainWindowViewModel;
         this.isPinedView = isPinedView;
         buildExplorer = BuildExplorerFactory.CreateBuildExplorer(buildInformation.TfsVersion);

         OpenBrowserCommand = new RelayCommand(OpenBrowser);
         StopBuildCommand = new StopBuildCommand(this, buildInformation);
         RequestBuildCommand = new RequestBuildCommand(this, buildInformation);
         RunningBuildErrorDetails = new ObservableCollection<string>();
         Tags = new ObservableCollection<string>(buildInformation.Tags ?? new string[0]);

         if (!isPinedView)
         {
            PinBuildCommand = new PinBuildCommand(mainWindowViewModel, buildInformation);
         }

         var buildDefinition = MonitorSettingsContainer.BuildServers.SelectMany(x => x.BuildDefinitions).FirstOrDefault(x => x.Id == buildInformation.BuildDefinitionId);
         if (PinBuildCommand != null && buildDefinition != null && buildDefinition.IsPined)
         {
            PinBuildCommand.Execute(null);
         }
      }