-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bfc2b55
commit 04c31bf
Showing
14 changed files
with
224 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
IntegrationConnectors/src/IntegrationConnectors.TeamCity/Converters/DateTimeConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Text.Json.Serialization; | ||
using System.Text.Json; | ||
using System.Threading.Tasks; | ||
using System.Globalization; | ||
|
||
namespace IntegrationConnectors.TeamCity.Converters | ||
{ | ||
public class DateTimeConverter : JsonConverter<DateTime> | ||
{ | ||
public override DateTime Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) | ||
{ | ||
CultureInfo provider = CultureInfo.InvariantCulture; | ||
var str = reader.GetString(); | ||
str = str.Replace("+0000", string.Empty); | ||
var date = DateTime.ParseExact(str, "yyyyMMddTHHmmss", provider); | ||
return TimeZone.CurrentTimeZone.ToLocalTime(date); | ||
} | ||
|
||
public override void Write(Utf8JsonWriter writer, DateTime value, JsonSerializerOptions options) | ||
{ | ||
writer.WriteStringValue(value.ToString()); | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...rationConnectors/src/IntegrationConnectors.TeamCity/IntegrationConnectors.TeamCity.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\IntegrationConnectors.Common\IntegrationConnectors.Common.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
17 changes: 17 additions & 0 deletions
17
IntegrationConnectors/src/IntegrationConnectors.TeamCity/Model/TeamCityBuild.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
namespace IntegrationConnectors.TeamCity.Model | ||
{ | ||
public class TeamCityBuild | ||
{ | ||
public int Id { get; set; } | ||
public string BuildTypeId { get; set; } | ||
public string Number { get; set; } | ||
public string Status { get; set; } | ||
public string State { get; set; } | ||
public string BranchName { get; set; } | ||
public bool DefaultBranch { get; set; } | ||
public string Href { get; set; } | ||
public string WebUrl { get; set; } | ||
public DateTime FinishOnAgentDate { get; set; } | ||
public bool Customized { get; set; } | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
IntegrationConnectors/src/IntegrationConnectors.TeamCity/Model/TeamCityBuilds.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace IntegrationConnectors.TeamCity.Model | ||
{ | ||
public class TeamCityBuilds | ||
{ | ||
public int Count { get; set; } | ||
public string Href { get; set; } | ||
[JsonPropertyName("build")] | ||
public TeamCityBuild[] Builds { get; set; } | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
IntegrationConnectors/src/IntegrationConnectors.TeamCity/Model/TeamCityCodeChange.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
namespace IntegrationConnectors.TeamCity.Model | ||
{ | ||
public class TeamCityCodeChange | ||
{ | ||
public int Id { get; set; } | ||
public string Version { get; set; } | ||
public string Username { get; set; } | ||
public string Date { get; set; } | ||
public string Href { get; set; } | ||
public string WebUrl { get; set; } | ||
public string Comment { get; set; } | ||
public TeamCityCodeChangeFiles Files { get; set; } | ||
public TeamCityCodeChangeVcsrootinstance VcsRootInstance { get; set; } | ||
public TeamCityCodeChangeCommiter Commiter { get; set; } | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
IntegrationConnectors/src/IntegrationConnectors.TeamCity/Model/TeamCityCodeChangeCommiter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace IntegrationConnectors.TeamCity.Model | ||
{ | ||
public class TeamCityCodeChangeCommiter | ||
{ | ||
public string VcsUsername { get; set; } | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
IntegrationConnectors/src/IntegrationConnectors.TeamCity/Model/TeamCityCodeChangeFiles.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace IntegrationConnectors.TeamCity.Model | ||
{ | ||
public class TeamCityCodeChangeFiles | ||
{ | ||
public int Count { get; set; } | ||
public object[] File { get; set; } | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...nConnectors/src/IntegrationConnectors.TeamCity/Model/TeamCityCodeChangeVcsrootinstance.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace IntegrationConnectors.TeamCity.Model | ||
{ | ||
public class TeamCityCodeChangeVcsrootinstance | ||
{ | ||
public string Id { get; set; } | ||
public string Vcsrootid { get; set; } | ||
public string Name { get; set; } | ||
public string Href { get; set; } | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
IntegrationConnectors/src/IntegrationConnectors.TeamCity/Model/TeamCityCodeChanges.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace IntegrationConnectors.TeamCity.Model | ||
{ | ||
public class TeamCityCodeChanges | ||
{ | ||
[JsonPropertyName("change")] | ||
public TeamCityCodeChange[] Changes { get; set; } | ||
public string Href { get; set; } | ||
public int Count { get; set; } | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
IntegrationConnectors/src/IntegrationConnectors.TeamCity/TeamCityConnector.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using System.Text.Json; | ||
using IntegrationConnectors.Common; | ||
using IntegrationConnectors.TeamCity.Converters; | ||
using IntegrationConnectors.TeamCity.Model; | ||
|
||
namespace IntegrationConnectors.JIRA | ||
{ | ||
|
||
public class TeamCityConnector : HttpConnector | ||
{ | ||
public TeamCityConnector(string baseUrl, string apiKey, AuthenticationType authType) : base(baseUrl, apiKey, authType) | ||
{ | ||
} | ||
|
||
public async Task<List<TeamCityCodeChange>> GetBuildChanges(int buildId) | ||
{ | ||
JsonSerializerOptions options = new JsonSerializerOptions() { PropertyNameCaseInsensitive = true }; | ||
options.Converters.Add(new DateTimeConverter()); | ||
|
||
|
||
var response = await GetAsync($"{_url}/app/rest/changes?locator=build:(id:{buildId})"); | ||
var teamcityCodeChanges = JsonSerializer.Deserialize<TeamCityCodeChanges>(response, options); | ||
return teamcityCodeChanges?.Changes.ToList(); | ||
} | ||
|
||
public async Task<List<TeamCityBuild>> GetBuilds() | ||
{ | ||
JsonSerializerOptions options = new JsonSerializerOptions() { PropertyNameCaseInsensitive = true }; | ||
options.Converters.Add(new DateTimeConverter()); | ||
|
||
|
||
var response = await GetAsync($"{_url}/app/rest/builds?locator=count:100,start:0"); | ||
var teamcityBuilds = JsonSerializer.Deserialize<TeamCityBuilds>(response, options); | ||
return teamcityBuilds?.Builds.ToList(); | ||
} | ||
|
||
public async Task<TeamCityCodeChange> GetChange(int changeId) | ||
{ | ||
JsonSerializerOptions options = new JsonSerializerOptions() { PropertyNameCaseInsensitive = true }; | ||
options.Converters.Add(new DateTimeConverter()); | ||
|
||
var response = await GetAsync($"{_url}/app/rest/changes/{changeId}"); | ||
var teamCityCodeChange = JsonSerializer.Deserialize<TeamCityCodeChange>(response, options); | ||
return teamCityCodeChange; | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
Tools/ConnectionDropOutTester/ConnectionDropOutTester.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System.Net.NetworkInformation; | ||
|
||
for (int i = 0; i < 200; i++) | ||
{ | ||
PingServer("google.com"); | ||
Thread.Sleep(1000); | ||
} | ||
|
||
void PingServer(string hostName) | ||
{ | ||
try | ||
{ | ||
var pinger = new Ping(); | ||
pinger.Send(hostName); | ||
Console.ForegroundColor = ConsoleColor.Green; | ||
Console.WriteLine($"{DateTime.Now.ToString("HH:mm:ss")} PING: {hostName} OK"); | ||
} | ||
catch (Exception) | ||
{ | ||
Console.ForegroundColor = ConsoleColor.Red; | ||
Console.WriteLine($"{DateTime.Now.ToString("HH:mm:ss")} PING: {hostName} Failed"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters