Skip to content

Commit fece785

Browse files
committed
Merge branch 'develop' of https://github.com/ethanhann/InEngine.NET into develop
2 parents d4a920b + 43b4d01 commit fece785

File tree

10 files changed

+199
-69
lines changed

10 files changed

+199
-69
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System.ComponentModel;
2+
using System.Configuration.Install;
3+
using System.ServiceProcess;
4+
5+
6+
namespace IntegrationEngine.ConsoleHost
7+
{
8+
[RunInstaller(true)]
9+
public class InEngineServerInstaller : Installer
10+
{
11+
public InEngineServerInstaller()
12+
{
13+
var serviceProcessInstaller = new ServiceProcessInstaller();
14+
serviceProcessInstaller.Account = ServiceAccount.LocalSystem;
15+
serviceProcessInstaller.Username = null;
16+
serviceProcessInstaller.Password = null;
17+
Installers.Add(serviceProcessInstaller);
18+
19+
var serviceInstaller = new ServiceInstaller();
20+
serviceInstaller.DisplayName = "InEngine.NET Server";
21+
serviceInstaller.StartType = ServiceStartMode.Automatic;
22+
serviceInstaller.ServiceName = Program.ServiceName;
23+
Installers.Add(serviceInstaller);
24+
}
25+
}
26+
}

IntegrationEngine.ConsoleHost/IntegrationEngine.ConsoleHost.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,16 @@
6464
<Reference Include="RazorEngine">
6565
<HintPath>..\packages\RazorEngine.3.5.0\lib\net45\RazorEngine.dll</HintPath>
6666
</Reference>
67+
<Reference Include="System.Configuration.Install" />
68+
<Reference Include="System.ServiceProcess" />
6769
<Reference Include="System.Web.Razor">
6870
<HintPath>..\packages\Microsoft.AspNet.Razor.3.2.2\lib\net45\System.Web.Razor.dll</HintPath>
6971
</Reference>
7072
</ItemGroup>
7173
<ItemGroup>
74+
<Compile Include="InEngineServerInstaller.cs">
75+
<SubType>Component</SubType>
76+
</Compile>
7277
<Compile Include="IntegrationJobs\SampleSqlReport\SampleReport.cs" />
7378
<Compile Include="IntegrationJobs\SampleSqlReport\SampleDatum.cs" />
7479
<Compile Include="IntegrationJobs\SampleSqlReport\SampleSqlReportJob.cs" />
Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,59 @@
11
using System;
2+
using System.IO;
23
using System.Reflection;
4+
using System.ServiceProcess;
35

46
namespace IntegrationEngine.ConsoleHost
57
{
6-
public class MainClass
8+
public class Program
79
{
10+
public const string ServiceName = "InEngine.NET Server";
11+
public static EngineHost EngineHosts { get; set; }
812
public static void Main(string[] args)
913
{
10-
(new EngineHost(typeof(MainClass).Assembly)).Initialize();
14+
if (!Environment.UserInteractive)
15+
{
16+
// Set current working directory as services use the system directory by default.
17+
Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);
18+
using (var service = new Service())
19+
ServiceBase.Run(service);
20+
}
21+
else
22+
{
23+
Start(args);
24+
Console.WriteLine("Press any key to stop...");
25+
Console.ReadLine();
26+
Stop();
27+
}
28+
}
29+
30+
private static void Start(string[] args)
31+
{
32+
EngineHosts = new EngineHost(typeof(Program).Assembly);
33+
EngineHosts.Initialize();
34+
}
35+
36+
private static void Stop()
37+
{
38+
EngineHosts.Dispose();
39+
}
40+
41+
public class Service : ServiceBase
42+
{
43+
public Service()
44+
{
45+
ServiceName = Program.ServiceName;
46+
}
47+
48+
protected override void OnStart(string[] args)
49+
{
50+
Program.Start(args);
51+
}
52+
53+
protected override void OnStop()
54+
{
55+
Program.Stop();
56+
}
1157
}
1258
}
1359
}

IntegrationEngine.sln

Lines changed: 43 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 2012
3+
# Visual Studio 2013
44
VisualStudioVersion = 12.0.31101.0
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IntegrationEngine", "IntegrationEngine\IntegrationEngine.csproj", "{7D49353D-A68C-4ACA-A6A5-40B1C314C30E}"
@@ -49,36 +49,6 @@ Global
4949
Release|x86 = Release|x86
5050
EndGlobalSection
5151
GlobalSection(ProjectConfigurationPlatforms) = postSolution
52-
{0B499FE4-0BDB-4080-BCB7-F8D4CE54A4FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
53-
{0B499FE4-0BDB-4080-BCB7-F8D4CE54A4FF}.Debug|Any CPU.Build.0 = Debug|Any CPU
54-
{0B499FE4-0BDB-4080-BCB7-F8D4CE54A4FF}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
55-
{0B499FE4-0BDB-4080-BCB7-F8D4CE54A4FF}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
56-
{0B499FE4-0BDB-4080-BCB7-F8D4CE54A4FF}.Debug|x86.ActiveCfg = Debug|Any CPU
57-
{0B499FE4-0BDB-4080-BCB7-F8D4CE54A4FF}.Release|Any CPU.ActiveCfg = Release|Any CPU
58-
{0B499FE4-0BDB-4080-BCB7-F8D4CE54A4FF}.Release|Any CPU.Build.0 = Release|Any CPU
59-
{0B499FE4-0BDB-4080-BCB7-F8D4CE54A4FF}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
60-
{0B499FE4-0BDB-4080-BCB7-F8D4CE54A4FF}.Release|Mixed Platforms.Build.0 = Release|Any CPU
61-
{0B499FE4-0BDB-4080-BCB7-F8D4CE54A4FF}.Release|x86.ActiveCfg = Release|Any CPU
62-
{3F3794D7-4078-4D26-954C-7864173EDD86}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
63-
{3F3794D7-4078-4D26-954C-7864173EDD86}.Debug|Any CPU.Build.0 = Debug|Any CPU
64-
{3F3794D7-4078-4D26-954C-7864173EDD86}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
65-
{3F3794D7-4078-4D26-954C-7864173EDD86}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
66-
{3F3794D7-4078-4D26-954C-7864173EDD86}.Debug|x86.ActiveCfg = Debug|Any CPU
67-
{3F3794D7-4078-4D26-954C-7864173EDD86}.Release|Any CPU.ActiveCfg = Release|Any CPU
68-
{3F3794D7-4078-4D26-954C-7864173EDD86}.Release|Any CPU.Build.0 = Release|Any CPU
69-
{3F3794D7-4078-4D26-954C-7864173EDD86}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
70-
{3F3794D7-4078-4D26-954C-7864173EDD86}.Release|Mixed Platforms.Build.0 = Release|Any CPU
71-
{3F3794D7-4078-4D26-954C-7864173EDD86}.Release|x86.ActiveCfg = Release|Any CPU
72-
{46DB723B-F767-4F5A-A1DA-53A6CF13704B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
73-
{46DB723B-F767-4F5A-A1DA-53A6CF13704B}.Debug|Any CPU.Build.0 = Debug|Any CPU
74-
{46DB723B-F767-4F5A-A1DA-53A6CF13704B}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
75-
{46DB723B-F767-4F5A-A1DA-53A6CF13704B}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
76-
{46DB723B-F767-4F5A-A1DA-53A6CF13704B}.Debug|x86.ActiveCfg = Debug|Any CPU
77-
{46DB723B-F767-4F5A-A1DA-53A6CF13704B}.Release|Any CPU.ActiveCfg = Release|Any CPU
78-
{46DB723B-F767-4F5A-A1DA-53A6CF13704B}.Release|Any CPU.Build.0 = Release|Any CPU
79-
{46DB723B-F767-4F5A-A1DA-53A6CF13704B}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
80-
{46DB723B-F767-4F5A-A1DA-53A6CF13704B}.Release|Mixed Platforms.Build.0 = Release|Any CPU
81-
{46DB723B-F767-4F5A-A1DA-53A6CF13704B}.Release|x86.ActiveCfg = Release|Any CPU
8252
{7D49353D-A68C-4ACA-A6A5-40B1C314C30E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
8353
{7D49353D-A68C-4ACA-A6A5-40B1C314C30E}.Debug|Any CPU.Build.0 = Debug|Any CPU
8454
{7D49353D-A68C-4ACA-A6A5-40B1C314C30E}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
@@ -90,16 +60,6 @@ Global
9060
{7D49353D-A68C-4ACA-A6A5-40B1C314C30E}.Release|Mixed Platforms.Build.0 = Release|x86
9161
{7D49353D-A68C-4ACA-A6A5-40B1C314C30E}.Release|x86.ActiveCfg = Release|x86
9262
{7D49353D-A68C-4ACA-A6A5-40B1C314C30E}.Release|x86.Build.0 = Release|x86
93-
{BBF7B784-DF72-4561-92B9-4021B5F7D8E3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
94-
{BBF7B784-DF72-4561-92B9-4021B5F7D8E3}.Debug|Any CPU.Build.0 = Debug|Any CPU
95-
{BBF7B784-DF72-4561-92B9-4021B5F7D8E3}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
96-
{BBF7B784-DF72-4561-92B9-4021B5F7D8E3}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
97-
{BBF7B784-DF72-4561-92B9-4021B5F7D8E3}.Debug|x86.ActiveCfg = Debug|Any CPU
98-
{BBF7B784-DF72-4561-92B9-4021B5F7D8E3}.Release|Any CPU.ActiveCfg = Release|Any CPU
99-
{BBF7B784-DF72-4561-92B9-4021B5F7D8E3}.Release|Any CPU.Build.0 = Release|Any CPU
100-
{BBF7B784-DF72-4561-92B9-4021B5F7D8E3}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
101-
{BBF7B784-DF72-4561-92B9-4021B5F7D8E3}.Release|Mixed Platforms.Build.0 = Release|Any CPU
102-
{BBF7B784-DF72-4561-92B9-4021B5F7D8E3}.Release|x86.ActiveCfg = Release|Any CPU
10363
{C273AE91-E13F-4443-8D01-9C97016AB4AC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
10464
{C273AE91-E13F-4443-8D01-9C97016AB4AC}.Debug|Any CPU.Build.0 = Debug|Any CPU
10565
{C273AE91-E13F-4443-8D01-9C97016AB4AC}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
@@ -111,6 +71,26 @@ Global
11171
{C273AE91-E13F-4443-8D01-9C97016AB4AC}.Release|Mixed Platforms.Build.0 = Release|x86
11272
{C273AE91-E13F-4443-8D01-9C97016AB4AC}.Release|x86.ActiveCfg = Release|x86
11373
{C273AE91-E13F-4443-8D01-9C97016AB4AC}.Release|x86.Build.0 = Release|x86
74+
{3F3794D7-4078-4D26-954C-7864173EDD86}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
75+
{3F3794D7-4078-4D26-954C-7864173EDD86}.Debug|Any CPU.Build.0 = Debug|Any CPU
76+
{3F3794D7-4078-4D26-954C-7864173EDD86}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
77+
{3F3794D7-4078-4D26-954C-7864173EDD86}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
78+
{3F3794D7-4078-4D26-954C-7864173EDD86}.Debug|x86.ActiveCfg = Debug|Any CPU
79+
{3F3794D7-4078-4D26-954C-7864173EDD86}.Release|Any CPU.ActiveCfg = Release|Any CPU
80+
{3F3794D7-4078-4D26-954C-7864173EDD86}.Release|Any CPU.Build.0 = Release|Any CPU
81+
{3F3794D7-4078-4D26-954C-7864173EDD86}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
82+
{3F3794D7-4078-4D26-954C-7864173EDD86}.Release|Mixed Platforms.Build.0 = Release|Any CPU
83+
{3F3794D7-4078-4D26-954C-7864173EDD86}.Release|x86.ActiveCfg = Release|Any CPU
84+
{0B499FE4-0BDB-4080-BCB7-F8D4CE54A4FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
85+
{0B499FE4-0BDB-4080-BCB7-F8D4CE54A4FF}.Debug|Any CPU.Build.0 = Debug|Any CPU
86+
{0B499FE4-0BDB-4080-BCB7-F8D4CE54A4FF}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
87+
{0B499FE4-0BDB-4080-BCB7-F8D4CE54A4FF}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
88+
{0B499FE4-0BDB-4080-BCB7-F8D4CE54A4FF}.Debug|x86.ActiveCfg = Debug|Any CPU
89+
{0B499FE4-0BDB-4080-BCB7-F8D4CE54A4FF}.Release|Any CPU.ActiveCfg = Release|Any CPU
90+
{0B499FE4-0BDB-4080-BCB7-F8D4CE54A4FF}.Release|Any CPU.Build.0 = Release|Any CPU
91+
{0B499FE4-0BDB-4080-BCB7-F8D4CE54A4FF}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
92+
{0B499FE4-0BDB-4080-BCB7-F8D4CE54A4FF}.Release|Mixed Platforms.Build.0 = Release|Any CPU
93+
{0B499FE4-0BDB-4080-BCB7-F8D4CE54A4FF}.Release|x86.ActiveCfg = Release|Any CPU
11494
{DFCD19CE-A96A-4B19-8CF1-9CAC560E7F42}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
11595
{DFCD19CE-A96A-4B19-8CF1-9CAC560E7F42}.Debug|Any CPU.Build.0 = Debug|Any CPU
11696
{DFCD19CE-A96A-4B19-8CF1-9CAC560E7F42}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
@@ -143,6 +123,26 @@ Global
143123
{F3FCB706-F0DD-46C1-B121-785757FAE9B9}.Release|Mixed Platforms.Build.0 = Release|Any CPU
144124
{F3FCB706-F0DD-46C1-B121-785757FAE9B9}.Release|x86.ActiveCfg = Release|Any CPU
145125
{F3FCB706-F0DD-46C1-B121-785757FAE9B9}.Release|x86.Build.0 = Release|Any CPU
126+
{BBF7B784-DF72-4561-92B9-4021B5F7D8E3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
127+
{BBF7B784-DF72-4561-92B9-4021B5F7D8E3}.Debug|Any CPU.Build.0 = Debug|Any CPU
128+
{BBF7B784-DF72-4561-92B9-4021B5F7D8E3}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
129+
{BBF7B784-DF72-4561-92B9-4021B5F7D8E3}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
130+
{BBF7B784-DF72-4561-92B9-4021B5F7D8E3}.Debug|x86.ActiveCfg = Debug|Any CPU
131+
{BBF7B784-DF72-4561-92B9-4021B5F7D8E3}.Release|Any CPU.ActiveCfg = Release|Any CPU
132+
{BBF7B784-DF72-4561-92B9-4021B5F7D8E3}.Release|Any CPU.Build.0 = Release|Any CPU
133+
{BBF7B784-DF72-4561-92B9-4021B5F7D8E3}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
134+
{BBF7B784-DF72-4561-92B9-4021B5F7D8E3}.Release|Mixed Platforms.Build.0 = Release|Any CPU
135+
{BBF7B784-DF72-4561-92B9-4021B5F7D8E3}.Release|x86.ActiveCfg = Release|Any CPU
136+
{46DB723B-F767-4F5A-A1DA-53A6CF13704B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
137+
{46DB723B-F767-4F5A-A1DA-53A6CF13704B}.Debug|Any CPU.Build.0 = Debug|Any CPU
138+
{46DB723B-F767-4F5A-A1DA-53A6CF13704B}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
139+
{46DB723B-F767-4F5A-A1DA-53A6CF13704B}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
140+
{46DB723B-F767-4F5A-A1DA-53A6CF13704B}.Debug|x86.ActiveCfg = Debug|Any CPU
141+
{46DB723B-F767-4F5A-A1DA-53A6CF13704B}.Release|Any CPU.ActiveCfg = Release|Any CPU
142+
{46DB723B-F767-4F5A-A1DA-53A6CF13704B}.Release|Any CPU.Build.0 = Release|Any CPU
143+
{46DB723B-F767-4F5A-A1DA-53A6CF13704B}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
144+
{46DB723B-F767-4F5A-A1DA-53A6CF13704B}.Release|Mixed Platforms.Build.0 = Release|Any CPU
145+
{46DB723B-F767-4F5A-A1DA-53A6CF13704B}.Release|x86.ActiveCfg = Release|Any CPU
146146
{F999051E-B715-4AB9-A3B2-0D91A896A2C2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
147147
{F999051E-B715-4AB9-A3B2-0D91A896A2C2}.Debug|Any CPU.Build.0 = Debug|Any CPU
148148
{F999051E-B715-4AB9-A3B2-0D91A896A2C2}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
@@ -154,12 +154,10 @@ Global
154154
{F999051E-B715-4AB9-A3B2-0D91A896A2C2}.Release|Mixed Platforms.Build.0 = Release|Any CPU
155155
{F999051E-B715-4AB9-A3B2-0D91A896A2C2}.Release|x86.ActiveCfg = Release|Any CPU
156156
EndGlobalSection
157-
GlobalSection(NestedProjects) = preSolution
157+
GlobalSection(SolutionProperties) = preSolution
158+
HideSolutionNode = FALSE
158159
EndGlobalSection
159160
GlobalSection(MonoDevelopProperties) = preSolution
160161
StartupItem = IntegrationEngine.ConsoleHost\IntegrationEngine.ConsoleHost.csproj
161162
EndGlobalSection
162-
GlobalSection(SolutionProperties) = preSolution
163-
HideSolutionNode = FALSE
164-
EndGlobalSection
165163
EndGlobal

IntegrationEngine/EngineHost.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace IntegrationEngine
77
{
8-
public class EngineHost
8+
public class EngineHost : IDisposable
99
{
1010
EngineHostConfiguration _engineConfiguration;
1111
public IList<Assembly> AssembliesWithJobs { get; set; }
@@ -15,10 +15,10 @@ public EngineHost(params Assembly[] assembliesWithJobs)
1515
AssembliesWithJobs = assembliesWithJobs.ToList();
1616
}
1717

18-
~EngineHost()
18+
public void Dispose()
1919
{
20-
if (_engineConfiguration == null)
21-
_engineConfiguration.Shutdown();
20+
if (_engineConfiguration != null)
21+
_engineConfiguration.Dispose();
2222
}
2323

2424
public void Initialize()

IntegrationEngine/EngineHostConfiguration.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
namespace IntegrationEngine
2222
{
23-
public class EngineHostConfiguration
23+
public class EngineHostConfiguration : IDisposable
2424
{
2525
public IUnityContainer Container { get; set; }
2626
public EngineConfiguration Configuration { get; set; }
@@ -113,6 +113,7 @@ public void SetupMessageQueueListener()
113113
IntegrationEngineContext = Container.Resolve<IntegrationEngineContext>(),
114114
ElasticClient = Container.Resolve<IElasticClient>(),
115115
};
116+
Container.RegisterInstance<IMessageQueueListener>(rabbitMqListener);
116117
rabbitMqListener.Listen();
117118
}
118119

@@ -176,10 +177,12 @@ public void SetupElasticClient()
176177
});
177178
}
178179

179-
public void Shutdown()
180+
public void Dispose()
180181
{
181182
var engineScheduler = Container.Resolve<IEngineScheduler>();
182183
engineScheduler.Shutdown();
184+
var messageQueueListener = Container.Resolve<IMessageQueueListener>();
185+
messageQueueListener.Dispose();
183186
}
184187
}
185188
}

IntegrationEngine/MessageQueue/IMessageQueueListener.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace IntegrationEngine.MessageQueue
88
{
9-
public interface IMessageQueueListener
9+
public interface IMessageQueueListener : IDisposable
1010
{
1111
void Listen();
1212
}

IntegrationEngine/MessageQueue/MsmqListener.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ public void Listen()
5454
}
5555
}
5656

57+
public void Dispose()
58+
{
59+
throw new NotImplementedException();
60+
}
5761
T AutoWireJob<T>(T job, Type type)
5862
{
5963
if (type.GetInterface(typeof(IMailJob).Name) != null)

0 commit comments

Comments
 (0)