示例#1
0
        public void ProjectsAndTeams_Projects_RenameTeamProject_Success()
        {
            // arrange
            TeamProjects projects = new TeamProjects(_configuration);
            string       name     = System.Guid.NewGuid().ToString().ToLower().Substring(0, 30);

            // act
            //create the project
            OperationReference createResult = projects.CreateTeamProject(name);

            //TODO: Instead of sleep, monitor the status ("online")
            System.Threading.Thread.Sleep(5000);

            //get the project so we can get the id
            TeamProjectReference getResult = projects.GetTeamProjectWithCapabilities(name);

            //rename the project
            OperationReference renameResult = projects.RenameTeamProject(getResult.Id, "Vandelay Scrum Project");

            //TODO: keep checking the operation untill it failed or is done

            // assert
            Assert.AreNotEqual(createResult.Status, OperationStatus.Failed);
            Assert.AreNotEqual(renameResult.Status, OperationStatus.Failed);
        }
示例#2
0
        /// <summary>Indicates whether the current object is equal to another object of the same type.</summary>
        /// <param name="other">An object to compare with this object.</param>
        /// <returns>true if the current object is equal to the <paramref name="other">other</paramref> parameter; otherwise, false.</returns>
        public virtual bool Equals(Link other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            if (!OperationReference.Equals(other.OperationReference))
            {
                return(false);
            }
            if (!StringComparer.Ordinal.Equals(OperationIdentifier, other.OperationIdentifier))
            {
                return(false);
            }
            if (!StringComparer.Ordinal.Equals(Description, other.Description))
            {
                return(false);
            }
            if (!Server.NullableEquals(other.Server))
            {
                return(false);
            }

            return(true);
        }
示例#3
0
        public void ProjectsAndTeams_Projects_ChangeTeamProjectDescription_Success()
        {
            // arrange
            TeamProjects projects = new TeamProjects(_configuration);
            string       name     = System.Guid.NewGuid().ToString().ToLower().Substring(0, 30);

            // act
            //create project
            OperationReference createResult = projects.CreateTeamProject(name);

            //TODO: Instead of sleep, monitor the status ("online")
            System.Threading.Thread.Sleep(5000);

            //get the project we just created so we can get the id
            TeamProjectReference getResult = projects.GetTeamProjectWithCapabilities(name);

            //change project desription
            OperationReference updateResult = projects.ChangeTeamProjectDescription(getResult.Id, "This is my new project description");

            //TODO: keep checking the operation untill it failed or is done

            // assert
            Assert.AreNotEqual(createResult.Status, OperationStatus.Failed);
            Assert.AreNotEqual(updateResult.Status, OperationStatus.Failed);
        }
示例#4
0
        public async Task <Result> GetResult(OperationReference reference)
        {
            var response = await IDEAGateway.Request(JsonConvert.SerializeObject(reference, IDEAGateway.JsonSerializerSettings), "result");

            if (response != "null")
            {
                var result = JsonConvert.DeserializeObject <Result>(response, IDEAGateway.JsonSerializerSettings);
                return(result);
            }
            return(null);
        }
示例#5
0
        public void ProjectsAndTeams_Projects_CreateTeamProject_Success()
        {
            // arrange
            TeamProjects projects = new TeamProjects(_configuration);
            string       name     = System.Guid.NewGuid().ToString().ToLower().Substring(0, 30);

            // act
            OperationReference result = projects.CreateTeamProject(name);

            // assert
            Assert.AreNotEqual(result.Status, OperationStatus.Failed);
        }
        public async Task <OperationStatus> AddTagsAsync(IEnumerable <AddExtendedQueryTagEntry> entries, CancellationToken cancellationToken = default)
        {
            EnsureArg.IsNotNull(entries, nameof(entries));
            foreach (AddExtendedQueryTagEntry entry in entries)
            {
                _tags.Add(entry.Path);
            }

            DicomWebResponse <OperationReference> response = await _dicomWebClient.AddExtendedQueryTagAsync(entries, cancellationToken);

            OperationReference operation = await response.GetValueAsync();

            return(await GetOperationStatusRetryPolicy.ExecuteAsync(async() =>
            {
                var operationStatus = await _dicomWebClient.GetOperationStatusAsync(operation.Id);
                return await operationStatus.GetValueAsync();
            }));
        }
示例#7
0
        /// <summary>Serves as the default hash function.</summary>
        /// <returns>A hash code for the current object.</returns>
        public override int GetHashCode()
        {
            unchecked
            {
                var hc = 21L;

                hc = hc * 17 + OperationReference.GetHashCode();
                if (OperationIdentifier != null)
                {
                    hc = hc * 17 + StringComparer.Ordinal.GetHashCode(OperationIdentifier);
                }
                if (Description != null)
                {
                    hc = hc * 17 + StringComparer.Ordinal.GetHashCode(Description);
                }
                if (Server != null)
                {
                    hc = hc * 17 + Server.GetHashCode();
                }

                return(((int)(hc >> 32)) ^ (int)hc);
            }
        }
示例#8
0
        private async void run()
        {
            try
            {
                var response = await IDEAGateway.Request(JsonConvert.SerializeObject(OperationParameters, IDEAGateway.JsonSerializerSettings), "operation");

                OperationReference = JsonConvert.DeserializeObject <OperationReference>(response, IDEAGateway.JsonSerializerSettings);

                var resultCommand = new ResultCommand();

                // starting looping for updates
                while (_isRunning)
                {
                    var result = await resultCommand.GetResult(OperationReference);

                    if (result != null)
                    {
                        FireJobUpdated(new JobEventArgs {
                            Result = result, ResultExecutionId = _executionId
                        });

                        if (result.Progress >= 1.0)
                        {
                            _isRunning = false;
                            FireJobCompleted(new JobEventArgs {
                                Result = result, ResultExecutionId = _executionId
                            });
                        }
                    }
                    await Task.Delay(_throttle);
                }
            }
            catch (Exception exc)
            {
                ErrorHandler.HandleError(exc.Message);
            }
        }
        internal async Task <TeamProject> CreateProject(string projectName, string projectDescription = "", string processName = "Scrum")
        {
            Logger.Log(LogLevel.Warning, $"Project '{projectName}' does not exist.");
            Console.WriteLine("Would you like to create one? (Y/N)");
            var answer = Console.ReadKey();

            if (answer.KeyChar != 'Y' && answer.KeyChar != 'y')
            {
                return(null);
            }

            Logger.Log(LogLevel.Info, $"Creating project '{projectName}'.");

            // Setup version control properties
            Dictionary <string, string> versionControlProperties = new Dictionary <string, string>
            {
                [TeamProjectCapabilitiesConstants.VersionControlCapabilityAttributeName] = SourceControlTypes.Git.ToString()
            };

            // Setup process properties
            ProcessHttpClient processClient = RestConnection.GetClient <ProcessHttpClient>();
            Guid processId = processClient.GetProcessesAsync().Result.Find(process => { return(process.Name.Equals(processName, StringComparison.InvariantCultureIgnoreCase)); }).Id;

            Dictionary <string, string> processProperaties = new Dictionary <string, string>
            {
                [TeamProjectCapabilitiesConstants.ProcessTemplateCapabilityTemplateTypeIdAttributeName] = processId.ToString()
            };

            // Construct capabilities dictionary
            Dictionary <string, Dictionary <string, string> > capabilities = new Dictionary <string, Dictionary <string, string> >
            {
                [TeamProjectCapabilitiesConstants.VersionControlCapabilityName]  = versionControlProperties,
                [TeamProjectCapabilitiesConstants.ProcessTemplateCapabilityName] = processProperaties
            };

            // Construct object containing properties needed for creating the project
            TeamProject projectCreateParameters = new TeamProject()
            {
                Name         = projectName,
                Description  = projectDescription,
                Capabilities = capabilities
            };

            // Get a client
            ProjectHttpClient projectClient = RestConnection.GetClient <ProjectHttpClient>();

            TeamProject project = null;

            try
            {
                Logger.Log(LogLevel.Info, "Queuing project creation...");

                // Queue the project creation operation
                // This returns an operation object that can be used to check the status of the creation
                OperationReference operation = await projectClient.QueueCreateProject(projectCreateParameters);

                // Check the operation status every 5 seconds (for up to 30 seconds)
                Operation completedOperation = WaitForLongRunningOperation(operation.Id, 5, 30).Result;

                // Check if the operation succeeded (the project was created) or failed
                if (completedOperation.Status == OperationStatus.Succeeded)
                {
                    // Get the full details about the newly created project
                    project = projectClient.GetProject(
                        projectCreateParameters.Name,
                        includeCapabilities: true,
                        includeHistory: true).Result;

                    Logger.Log(LogLevel.Info, $"Project created (ID: {project.Id})");
                }
                else
                {
                    Logger.Log(LogLevel.Error, "Project creation operation failed: " + completedOperation.ResultMessage);
                }
            }
            catch (Exception ex)
            {
                Logger.Log(ex, "Exception during create project.", LogLevel.Critical);
            }

            return(project);
        }
示例#10
0
        public TeamProject CreateProject()
        {
            string projectName        = "Sample project " + Guid.NewGuid();
            string projectDescription = "Short description for my new project";
            string processName        = "Agile";

            // Setup version control properties
            Dictionary <string, string> versionControlProperties = new Dictionary <string, string>();

            versionControlProperties[TeamProjectCapabilitiesConstants.VersionControlCapabilityAttributeName] =
                SourceControlTypes.Git.ToString();

            // Setup process properties
            ProcessHttpClient processClient = Context.Connection.GetClient <ProcessHttpClient>();
            Guid processId = processClient.GetProcessesAsync().Result.Find(process => { return(process.Name.Equals(processName, StringComparison.InvariantCultureIgnoreCase)); }).Id;

            Dictionary <string, string> processProperaties = new Dictionary <string, string>();

            processProperaties[TeamProjectCapabilitiesConstants.ProcessTemplateCapabilityTemplateTypeIdAttributeName] =
                processId.ToString();

            // Construct capabilities dictionary
            Dictionary <string, Dictionary <string, string> > capabilities = new Dictionary <string, Dictionary <string, string> >();

            capabilities[TeamProjectCapabilitiesConstants.VersionControlCapabilityName] =
                versionControlProperties;
            capabilities[TeamProjectCapabilitiesConstants.ProcessTemplateCapabilityName] =
                processProperaties;

            // Construct object containing properties needed for creating the project
            TeamProject projectCreateParameters = new TeamProject()
            {
                Name         = projectName,
                Description  = projectDescription,
                Capabilities = capabilities
            };

            // Get a client
            VssConnection     connection    = Context.Connection;
            ProjectHttpClient projectClient = connection.GetClient <ProjectHttpClient>();

            TeamProject project = null;

            try
            {
                Console.WriteLine("Queuing project creation...");

                // Queue the project creation operation
                // This returns an operation object that can be used to check the status of the creation
                OperationReference operation = projectClient.QueueCreateProject(projectCreateParameters).Result;

                ClientSampleHttpLogger.SetSuppressOutput(Context, true);

                // Check the operation status every 5 seconds (for up to 30 seconds)
                Operation completedOperation = WaitForLongRunningOperation(operation.Id, 5, 30).Result;

                // Check if the operation succeeded (the project was created) or failed
                if (completedOperation.Status == OperationStatus.Succeeded)
                {
                    // Get the full details about the newly created project
                    project = projectClient.GetProject(
                        projectCreateParameters.Name,
                        includeCapabilities: true,
                        includeHistory: true).Result;

                    Console.WriteLine();
                    Console.WriteLine("Project created (ID: {0})", project.Id);

                    // Save the newly created project (other sample methods will use it)
                    Context.SetValue <TeamProject>("$newProject", project);
                }
                else
                {
                    Console.WriteLine("Project creation operation failed: " + completedOperation.ResultMessage);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception during create project: ", ex.Message);
            }

            return(project);
        }
 public AddExtendedQueryTagResponse(OperationReference operationReference)
 {
     Operation = EnsureArg.IsNotNull(operationReference);
 }
示例#12
0
        public async Task <ProjectAdo> CreateProject(ProjectAdo projectAdoCreate)
        {
            VssConnection connection = null;
            ProjectAdo    result     = null;

            try
            {
                string projectName        = projectAdoCreate.Name;
                string projectDescription = projectAdoCreate.Description;
                string processName        = projectAdoCreate.ProcessName ?? "Agile";
                var    organization       = projectAdoCreate.Organization;
                string url = $"https://dev.azure.com/{organization}";

                // Setup version control properties
                Dictionary <string, string> versionControlProperties = new();
                versionControlProperties[TeamProjectCapabilitiesConstants.VersionControlCapabilityAttributeName] =
                    SourceControlTypes.Git.ToString();

                if (_adoConfig.UsePta)
                {
                    connection = new VssConnection(new Uri(url), new VssBasicCredential(string.Empty, _adoConfig.AdoPersonalAccessToken));
                }
                else
                {
                    //connection = new VssConnection(new Uri(url), new VssCredentials(true));
                    connection = new VssConnection(new Uri(url), new VssClientCredentials(true));
                }

                //var scope = "vso.project_manage";
                //var token = await _tokenAcquisition.GetAccessTokenForAppAsync(scope);
                //var accessTokenCredential = new VssOAuthAccessTokenCredential(token);
                //connection = new VssConnection(new Uri(url), accessTokenCredential);

                // Setup process properties
                Guid?processId = null;
                var  process   = await _processAdoServices.GetAdoProcesByName(organization, processName);

                processId = process?.Id;

                Dictionary <string, string> processProperaties = new();
                processProperaties[TeamProjectCapabilitiesConstants.ProcessTemplateCapabilityTemplateTypeIdAttributeName] =
                    processId.ToString();

                // Construct capabilities dictionary
                Dictionary <string, Dictionary <string, string> > capabilities = new();
                capabilities[TeamProjectCapabilitiesConstants.VersionControlCapabilityName] =
                    versionControlProperties;
                capabilities[TeamProjectCapabilitiesConstants.ProcessTemplateCapabilityName] =
                    processProperaties;

                // Construct object containing properties needed for creating the project
                TeamProject projectCreateParameters = new()
                {
                    Name         = projectName,
                    Description  = projectDescription + " 'Created via CSRO Web Portal'",
                    Capabilities = capabilities,
                    //State = ProjectState.CreatePending //only from UI
                };

                // Get a client
                ProjectHttpClient projectClient = connection.GetClient <ProjectHttpClient>();
                _logger?.LogDebug("Queuing project creation...");

                // Queue the project creation operation
                // This returns an operation object that can be used to check the status of the creation
                OperationReference operation = await projectClient.QueueCreateProject(projectCreateParameters).ConfigureAwait(false);

                //ClientSampleHttpLogger.SetSuppressOutput(Context, true);

                // Check the operation status every 5 seconds (for up to 30 seconds)
                Operation completedOperation = await WaitForLongRunningOperation(connection, operation.Id, 2, 30).ConfigureAwait(false);

                // Check if the operation succeeded (the project was created) or failed
                if (completedOperation.Status == OperationStatus.Succeeded)
                {
                    // Get the full details about the newly created project
                    var project = await projectClient.GetProject(
                        projectCreateParameters.Name,
                        includeCapabilities : true,
                        includeHistory : true);

                    _logger?.LogDebug("Project created (ID: {0})", project.Id);

                    result = _mapper.Map <ProjectAdo>(project);
                    result.Organization = organization;
                    result.ProcessName  = processName;

                    //original props
                    result.Id         = projectAdoCreate.Id;
                    result.RowVersion = projectAdoCreate.RowVersion;
                    result.CreatedAt  = projectAdoCreate.CreatedAt;
                    result.CreatedBy  = projectAdoCreate.CreatedBy;
                    result.ModifiedAt = projectAdoCreate.ModifiedAt;
                    result.ModifiedBy = projectAdoCreate.ModifiedBy;
                    result.IsDeleted  = projectAdoCreate.IsDeleted;

                    //projectAdoCreate.Description = project.Description;
                    //projectAdoCreate.AdoId = project.Id;
                    //projectAdoCreate.Url = project.Url;
                    //projectAdoCreate.State = project.State;
                    //projectAdoCreate.Visibility = project.Visibility;
                    //return projectAdoCreate;
                }
                else
                {
                    _logger?.LogError("Project creation operation failed: " + completedOperation.ResultMessage);
                }
            }
            catch (Exception ex)
            {
                //Console.WriteLine("Exception during create project: ", ex.Message);
                throw;
            }
            finally
            {
                connection?.Dispose();
            }
            return(result);
        }