-
Notifications
You must be signed in to change notification settings - Fork 0
/
SpoolPadProgram.cs
81 lines (63 loc) · 1.82 KB
/
SpoolPadProgram.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
using System;
using System.Data;
using System.Data.SqlClient;
using Common.Logging;
using Equisetum2.Common.Helpers;
using Equisetum2.NHibernate;
using Gtk;
using it.jodan.SpoolPad.BaseClasses;
using it.jodan.SpoolPad.BaseClasses.Configuration;
using it.jodan.SpoolPad.Helpers;
namespace it.jodan.SpoolPad {
public class SpoolPadProgram {
public const string APP_NAME = "SpoolPad 1.0";
//static readonly ILog _log = LogManager.GetLogger(typeof(SpoolPadProgram));
static ILog _log;
public static void Main( string[] args ) {
try{
_log = LogManager.GetCurrentClassLogger();
}catch(Exception ex ){
Console.WriteLine(ex.Message);
}
_log.InfoFormat("{0} ready to serve.", APP_NAME);
// BATCH
if (args.Length > 0) {
CodeRunner codeRunner = new CodeRunner();
try {
string padFile = args[0];
_log.InfoFormat("File argument: {0}", padFile);
// load configuration
PadConfig padConfig = new PadConfig();
if (!padConfig.Load(padFile)) {
_log.ErrorFormat("Error loading pad file!");
return;
}
// setup single factory (fast calls optimization)
if (padConfig.DataContext.Enabled) {
CustomConfiguration cfg = ServiceHelper.GetService<CustomConfiguration>();
cfg.FactoryRebuildOnTheFly = bool.FalseString;
cfg.IsConfigured = true;
}
// run
codeRunner.Build(padConfig);
codeRunner.Run();
} catch (Exception ex) {
_log.ErrorFormat(ex.Message);
} finally {
codeRunner.Release();
}
} else {
// GUI
try {
Application.Init();
SpoolPadWindow win = new SpoolPadWindow();
win.Show();
Application.Run();
} catch (Exception ex) {
MessageHelper.ShowError(ex);
}
}
_log.Info("SpoolPad goes to sleep.");
}
}
}