1 | using System;
|
---|
2 | using System.Data.Entity.Infrastructure;
|
---|
3 | using System.Diagnostics;
|
---|
4 | using System.IO;
|
---|
5 | using System.Threading;
|
---|
6 | using HeuristicLab.Services.Optimization.Billing.DataAccess;
|
---|
7 | using HeuristicLab.Services.Optimization.Billing.Model;
|
---|
8 |
|
---|
9 | namespace HeuristicLab.Services.Optimization.Billing.Test {
|
---|
10 | class Program {
|
---|
11 | private static BillingEngine.BillingEngine billingEngine;
|
---|
12 | private static Thread billingEngineThread;
|
---|
13 |
|
---|
14 | static void Main(string[] args) {
|
---|
15 | string ddlScript;
|
---|
16 | using (var context = new BillingContext()) {
|
---|
17 | System.Data.Entity.Database.SetInitializer(new HeuristicLab.Services.Optimization.Billing.DataAccess.BillingContext.BillingContextInitiliazer());
|
---|
18 | ddlScript = (((IObjectContextAdapter)context).ObjectContext.CreateDatabaseScript());
|
---|
19 | }
|
---|
20 |
|
---|
21 | using (StreamWriter writer = new StreamWriter(@"..\..\DDLScript.sql")) {
|
---|
22 | writer.Write(ddlScript);
|
---|
23 | }
|
---|
24 |
|
---|
25 | //BillingService srv = new BillingService();
|
---|
26 | BillingDao dao = new BillingDao();
|
---|
27 | var products = dao.FindAllProducts();
|
---|
28 | foreach (Product p in products) {
|
---|
29 | Console.WriteLine(string.Format("{0}: {1}", p.ProductId, p.Name));
|
---|
30 | }
|
---|
31 |
|
---|
32 | // Start BillingEngine Service:
|
---|
33 | Trace.WriteLine("Starting BillingEngine ...");
|
---|
34 | try {
|
---|
35 | billingEngine = new BillingEngine.BillingEngine();
|
---|
36 | billingEngineThread = new Thread(billingEngine.Run);
|
---|
37 | billingEngineThread.IsBackground = true; //dont keep app alive
|
---|
38 | billingEngineThread.Start();
|
---|
39 | }
|
---|
40 | catch (Exception e) {
|
---|
41 | Trace.WriteLine("Error during BillingEngine startup: " + e.Message);
|
---|
42 | }
|
---|
43 |
|
---|
44 | Console.WriteLine("Press any key to exit...");
|
---|
45 | Console.ReadKey();
|
---|
46 | }
|
---|
47 | }
|
---|
48 | }
|
---|