Skip to content

Commit 5671fed

Browse files
author
Ethan Hann
committed
Merge branch 'develop'
2 parents 18f9abd + 96e4bc4 commit 5671fed

37 files changed

+267
-87
lines changed

IntegrationEngine.Client/EndpointName.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ public class EndpointName
88
public static string SimpleTrigger = "SimpleTrigger";
99
public static string JobType = "JobType";
1010
public static string TimeZone = "TimeZone";
11+
public static string HealthStatus = "HealthStatus";
1112
}
1213
}
1314

IntegrationEngine.Client/InEngineClient.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System;
1+
using InEngineTimeZone = IntegrationEngine.Model.TimeZone;
2+
using System;
23
using System.Collections.Generic;
34
using System.Linq;
45
using IntegrationEngine.Model;
@@ -107,11 +108,11 @@ public SimpleTrigger DeleteSimpleTrigger(string id)
107108
#endregion
108109

109110
#region TimeZone
110-
public IList<TimeZone> GetTimeZones()
111+
public IList<InEngineTimeZone> GetTimeZones()
111112
{
112113
var request = new RestRequest(EndpointName.TimeZone, Method.GET);
113114
var result = RestClient.Execute(request);
114-
return JsonConvert.DeserializeObject<IList<TimeZone>>(result.Content);
115+
return JsonConvert.DeserializeObject<IList<InEngineTimeZone>>(result.Content);
115116
}
116117
#endregion
117118

@@ -123,6 +124,15 @@ public IList<string> GetJobTypes()
123124
return JsonConvert.DeserializeObject<IList<string>>(result.Content);
124125
}
125126
#endregion
127+
128+
#region HealthStatus
129+
public HealthStatus GetHealthStatus()
130+
{
131+
var request = new RestRequest(EndpointName.HealthStatus, Method.GET);
132+
var result = RestClient.Execute(request);
133+
return JsonConvert.DeserializeObject<HealthStatus>(result.Content);
134+
}
135+
#endregion
126136
}
127137
}
128138

IntegrationEngine.Core/Mail/IMailClient.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ public interface IMailClient
88
MailConfiguration MailConfiguration { get; set; }
99
SmtpClient SmtpClient { get; set; }
1010
void Send(MailMessage mailMessage);
11+
bool IsServerAvailable();
1112
}
1213
}
1314

IntegrationEngine.Core/Mail/MailClient.cs

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
using IntegrationEngine.Core.Configuration;
33
using System;
44
using System.Net.Mail;
5+
using System.Net.Sockets;
6+
using System.IO;
57

68
namespace IntegrationEngine.Core.Mail
79
{
@@ -22,11 +24,11 @@ public MailClient (ILog log) : this()
2224
public void Send(MailMessage mailMessage)
2325
{
2426
ConfigureSmtpClient();
25-
try
27+
try
2628
{
2729
SmtpClient.Send(mailMessage);
2830
}
29-
catch (Exception exception)
31+
catch (Exception exception)
3032
{
3133
Log.Error(exception);
3234
}
@@ -39,6 +41,36 @@ void ConfigureSmtpClient()
3941
SmtpClient.Host = MailConfiguration.HostName;
4042
SmtpClient.Port = MailConfiguration.Port;
4143
}
44+
45+
public bool IsServerAvailable()
46+
{
47+
try
48+
{
49+
using (var client = new TcpClient())
50+
{
51+
client.Connect(MailConfiguration.HostName, MailConfiguration.Port);
52+
using (var stream = client.GetStream())
53+
{
54+
using (var writer = new StreamWriter(stream))
55+
using (var reader = new StreamReader(stream))
56+
{
57+
writer.WriteLine("EHLO " + MailConfiguration.HostName);
58+
writer.Flush();
59+
var response = reader.ReadLine();
60+
Log.Debug(x => x("Mail server status: {0}", response));
61+
if (response != null)
62+
return true;
63+
}
64+
}
65+
}
66+
}
67+
catch(SocketException exception)
68+
{
69+
Log.Error(exception);
70+
return false;
71+
}
72+
return false;
73+
}
4274
}
4375
}
4476

IntegrationEngine.Core/Storage/ESRepository.cs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using IntegrationEngine.Model;
1+
using Common.Logging;
2+
using IntegrationEngine.Model;
23
using Nest;
34
using System;
45
using System.Collections.Generic;
@@ -8,7 +9,8 @@ namespace IntegrationEngine.Core.Storage
89
{
910
public class ESRepository<T> : IRepository<T> where T : class, IHasStringId
1011
{
11-
public ElasticClient ElasticClient{ get; set; }
12+
public IElasticClient ElasticClient { get; set; }
13+
public ILog Log { get; set; }
1214

1315
public ESRepository()
1416
{
@@ -73,6 +75,19 @@ public void Dispose()
7375
{
7476
throw new NotImplementedException();
7577
}
78+
79+
public bool IsServerAvailable()
80+
{
81+
try
82+
{
83+
return ElasticClient.Ping(new PingRequest()).ConnectionStatus.Success;
84+
}
85+
catch(Exception exception)
86+
{
87+
Log.Error(exception);
88+
return false;
89+
}
90+
}
7691
}
7792
}
7893

IntegrationEngine.Core/Storage/IRepository.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@ public interface IRepository<T> where T : class
1818
bool Exists(object id);
1919
void SetState(T value, EntityState entityState);
2020
void Dispose();
21+
bool IsServerAvailable();
2122
}
2223
}

IntegrationEngine.Core/Storage/Repository.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,10 @@ public void Dispose()
6969
{
7070
db.Dispose();
7171
}
72+
73+
public bool IsServerAvailable()
74+
{
75+
throw new NotImplementedException();
76+
}
7277
}
7378
}

IntegrationEngine.Model.net40/IHasStateId.cs

Lines changed: 0 additions & 13 deletions
This file was deleted.

IntegrationEngine.Model.net40/IntegrationEngine.Model.net40.csproj

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
<Compile Include="..\IntegrationEngine.Model\ISimpleTrigger.cs">
5353
<Link>ISimpleTrigger.cs</Link>
5454
</Compile>
55-
<Compile Include="IHasStateId.cs" />
5655
<Compile Include="Properties\AssemblyInfo.cs" />
5756
<Compile Include="..\IntegrationEngine.Model\SimpleTrigger.cs">
5857
<Link>SimpleTrigger.cs</Link>
@@ -63,6 +62,18 @@
6362
<Compile Include="..\IntegrationEngine.Model\IIntegrationJobTrigger.cs">
6463
<Link>IIntegrationJobTrigger.cs</Link>
6564
</Compile>
65+
<Compile Include="..\IntegrationEngine.Model\ITimeZone.cs">
66+
<Link>ITimeZone.cs</Link>
67+
</Compile>
68+
<Compile Include="..\IntegrationEngine.Model\TimeZone.cs">
69+
<Link>TimeZone.cs</Link>
70+
</Compile>
71+
<Compile Include="..\IntegrationEngine.Model\HealthStatus.cs">
72+
<Link>HealthStatus.cs</Link>
73+
</Compile>
74+
<Compile Include="..\IntegrationEngine.Model\IHealthStatus.cs">
75+
<Link>IHealthStatus.cs</Link>
76+
</Compile>
6677
</ItemGroup>
6778
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
6879
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

IntegrationEngine.Model/CronTrigger.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,9 @@ public class CronTrigger : ICronTrigger
99
public string CronExpressionString { get; set; }
1010
public string TimeZoneId { get; set; }
1111
public int StateId { get; set; }
12+
13+
public string CronExpressionDescription { get { throw new NotImplementedException(); } }
14+
public TimeZoneInfo TimeZoneInfo { get { throw new NotImplementedException(); } }
15+
public string StateDescription { get { throw new NotImplementedException(); } }
1216
}
1317
}

0 commit comments

Comments
 (0)