/// <summary> /// Converts an array of project versions from webservice proxy type to this type. /// </summary> /// <param name="projectVersionDataArray">Project version data array.</param> /// <returns>An array of project versions in this type.</returns> internal static ProjectVersion[] ConvertArray(MantisConnectWebservice.ProjectVersionData[] projectVersionDataArray) { if (projectVersionDataArray == null) { return null; } ProjectVersion[] projectVersions = new ProjectVersion[projectVersionDataArray.Length]; for (int i = 0; i < projectVersionDataArray.Length; ++i) { projectVersions[i] = new ProjectVersion(projectVersionDataArray[i]); } return projectVersions; }
/// <summary> /// Adds a project version and sets the id on the supplied project version instance. /// </summary> /// <param name="version">The new project version details.</param> /// <returns>The version id of the added project version.</returns> public int ProjectVersionAdd(ProjectVersion version) { ValidateProjectId(version.ProjectId); if (version.Id != 0) { throw new ArgumentException("Version already has a version id"); } if (version.Name == null) { throw new ArgumentNullException("version.Name"); } if (version.Description == null) { throw new ArgumentNullException("version.Description"); } version.Id = Convert.ToInt32(this.mc.mc_project_version_add( this.session.Username, this.session.Password, version.ToWebservice())); return version.Id; }
/// <summary> /// Updates the project version data. /// </summary> /// <param name="version">The project version with the approriate id.</param> /// <exception cref="ArgumentOutOfRangeException">Version id or project id is invalid.</exception> public void ProjectVersionUpdate(ProjectVersion version) { ValidateProjectVersionId(version.Id); ValidateProjectId(version.ProjectId); if (version.Name == null) { throw new ArgumentNullException("version.Name"); } if (version.Description == null) { throw new ArgumentNullException("version.Description"); } this.mc.mc_project_version_update( this.session.Username, this.session.Password, version.Id.ToString(), version.ToWebservice()); }
static private void UpdateVersionsOfProject(Session ASession, int AProjectID, string AVersionReleased, string AVersionDev, string AVersionNext) { DateTime DateReleased = DateTime.Today; Console.WriteLine(AProjectID.ToString() + " " + AVersionReleased); ProjectVersion[] ProjectVersions = ASession.Request.ProjectGetVersions(AProjectID); foreach (var element in ProjectVersions) { if (element.Name == AVersionReleased) { element.IsReleased = true; element.DateOrder = DateReleased; element.Description = ""; ASession.Request.ProjectVersionUpdate(element); } else if (element.Name == AVersionDev) { AVersionDev = string.Empty; } else if (element.Name == AVersionNext) { AVersionNext = string.Empty; } } // add a new development version if (AVersionDev != string.Empty) { Console.WriteLine("adding version " + AVersionDev); ProjectVersion v = new ProjectVersion(); v.ProjectId = AProjectID; v.IsReleased = false; v.Name = AVersionDev; v.DateOrder = new DateTime(DateReleased.Year, DateReleased.Month, DateReleased.Day, 0, 1, 0); v.Description = "for fixing development bugs"; ASession.Request.ProjectVersionAdd(v); } // add a new future release version if (AVersionNext != string.Empty) { Console.WriteLine("adding version " + AVersionNext); ProjectVersion v = new ProjectVersion(); v.ProjectId = AProjectID; v.IsReleased = false; v.Name = AVersionNext; v.DateOrder = DateReleased.AddMonths(1); v.Description = "next planned release"; ASession.Request.ProjectVersionAdd(v); } }