private static bool GetFileResponse(BuildDoc buildDoc, ConfigFileData data) { bool newCopy = false; var url = teamCityUrl + RepositoryDownloadAll + data.BuildTypeId + Slash + buildDoc.Id + IdArtifactsZip; var bytesProcessed = 0; var response = ResponseHelper.GetWebResponse(url); _downloadPath = DownloadArtifactsDirectory + BackSlash + Build + buildDoc.Id + ZipExtension; if (!File.Exists(_downloadPath)) { FileHelper.DeleteOldZips(); var stream = response.GetResponseStream(); var localStream = File.Create(_downloadPath); byte[] buffer = new byte[_131072MBs]; var bytesRead = 0; do { bytesRead = stream.Read(buffer, 0, buffer.Length); localStream.Write(buffer, 0, bytesRead); bytesProcessed += bytesRead; }while (bytesRead > 0); localStream.Dispose(); stream.Dispose(); newCopy = true; } Console.WriteLine(DownloadComplete); return(newCopy); }
private ConfigFileData WriteConfigFile() { var data = new ConfigFileData(); if (!Directory.Exists(StringConstants.DownloadArtifactsDirectory)) { Directory.CreateDirectory(StringConstants.DownloadArtifactsDirectory); } Console.WriteLine(StringConstants.EnterTeamCityBuildUrl); var teamcityURL = Console.ReadLine(); Console.WriteLine(StringConstants.EnterTeamCityProjectPrompt); var projectId = Console.ReadLine(); var stringBuilder = new StringBuilder(); stringBuilder.Append(teamcityURL); stringBuilder.Append(Environment.NewLine); stringBuilder.Append(projectId); data.Url = teamcityURL; data.ProjectId = projectId; data.BuildTypeId = teamcityURL.Substring(teamcityURL.LastIndexOf("=") + 1); File.WriteAllText(FileLocation, stringBuilder.ToString()); return(data); }
private static XmlNodeList GetBuilds(ConfigFileData data) { var url = BaseUrl + Projects + data.ProjectId + BuildTypesId + data.BuildTypeId + BuildsStatusSuccess; var xmlDocument = XmlHelper.GetXml(url); var builds = xmlDocument.GetElementsByTagName(Build); return(builds); }
public ConfigFileData ReadConfigFile() { ConfigFileData data = new ConfigFileData(); if (File.Exists(FileLocation)) { List <string> lines = new List <string>(); string line; StreamReader file = new StreamReader(FileLocation); while ((line = file.ReadLine()) != null) { lines.Add(line); } data.Url = lines.First(); data.ProjectId = lines[1]; data.BuildTypeId = data.Url.Substring(data.Url.IndexOf("=") + 1); } else { data = WriteConfigFile(); } return(data); }