markus / ConvertService / ServiceBase / Markus.Service.ConvertProcess / Program.cs @ a0341bef
이력 | 보기 | 이력해설 | 다운로드 (4.71 KB)
1 |
using log4net; |
---|---|
2 |
using Markus.Message; |
3 |
using Markus.Service.Extensions; |
4 |
using Markus.Service.Helper; |
5 |
using System; |
6 |
using System.Collections.Generic; |
7 |
using System.Linq; |
8 |
using System.ServiceModel; |
9 |
using System.Text; |
10 |
using System.Threading.Tasks; |
11 |
using System.Web.Script.Serialization; |
12 |
using System.Windows.Forms; |
13 |
using static Markus.Service.Extensions.Encrypt; |
14 |
using ConvertPlugin = Markus.Service.Convert.Plugin; |
15 |
|
16 |
namespace Markus.Service.ConvertProcess |
17 |
{ |
18 |
class Convert |
19 |
{ |
20 |
protected static ILog logger; |
21 |
protected static Service.Convert.ConvertService convert; |
22 |
|
23 |
private static ProcessContext convetContext; |
24 |
|
25 |
[MTAThread] |
26 |
static void Main(string[] args) |
27 |
{ |
28 |
try |
29 |
{ |
30 |
logger = LogManager.GetLogger(typeof(Convert)); |
31 |
//#if DEBUG |
32 |
// args = new[] { "11cb3ebc-2323-3b12-1a3e-87a783579ec3", "9gW0LjBVZwt3Z5opwby84cqlTB9oEZzLWBpFJ6LmRo0DArLL680d3EWmRT2gQ5E6gqNSmuC7Jse/4JZPXR9srb1NGnt3B4682sQAX6bfd412bdc+3pqI+ZySkvfAuiaESFWWYlEpDTUahE2mGpenD+JIA3lLBR5DNtdTlpYMHiI8/TiciIizUNbFKy7Ubp4dJ1QvBsNA+r5TcKvuSZIykLTaxAvIfC9T31wYSG9d24vkm3cj2NdzWIKNoYGj9wCREoaakyKANyTumVSlfTFclizlZACANPopOOmpb+FG4f7kGEn0tMCAKPo8Vx1muRLDXM/pVfOUAsisXWHfc/A7Vxfx/xQuVQX55SZWxOGPtdNXFiyfXnBIE0MANMnYthnxzbp2ZqYEXvJlClMrcRCLpUQ/SDVOvvhaTmU4FfyKaKVMTZ6yMlbqqSvYZr9R7NN+UW+h2ghsfJhx3y+GNIRpqHVriP/C6mc3hV72mDAAe+00uV4DlvO78qMCaX0xIXj0VjQHiEA2ePcpZRxFcVf6luE1n37OVFecv89cxl3Tk+fD7MjIJYvuy3U8WySDm1XqDlO1PX/yz/xDhtjHIXnkxK+upqoVr+W5Sd9uRN+JGsGP3AkGbWg01sQOe1T63om3gPIjMtCPrkhjSdQRED/mpJumeR85j/2uBIkkBbXWVJQs8tG+Engcd6+zCyoNJ8tf2+GBozzjXIPHCze57i9kWrtp4scfop8aAlaUsexC3C3msu3ZP9+LaLrqtcGTvO9XXhSld/B2pB3fF1r/PPESJCKavStakkwH80ak2FvY/p9bsf/jB9TDTXHuinTq52fNlT0SUFwMZvDcit7qODlRtLuwfODyZbPqx6bu2Eh4o/2+AQ4a9lvSfUGXJY88Q+JycNXEvJv0A5WQBdtjkdBFt6I0Lc8y8Vme8x7RDE76UwfOrsaEOdBh1oo9dg60eWp7t3QSRSOh5gDV3jfwqPVRkdSLUPujX6VRKCNkYclUtQcfd/vPQFEIyXaeRYHcJa5AVCNLFcoAg4Lp8BxXuNvxtg==" }; |
33 |
//#endif |
34 |
if (args.Length == 2) |
35 |
{ |
36 |
string ConvertID = args[0]; |
37 |
|
38 |
convetContext = ObjectToBytesStringConvert.BytesStringToObject<ProcessContext>(AESEncrypter.Decrypt(args[1])); |
39 |
|
40 |
convert = new Service.Convert.ConvertService(convetContext); |
41 |
|
42 |
var convertFile = convert.SetFileAsync(); |
43 |
convertFile.Wait(); |
44 |
|
45 |
if(convertFile.Result.StatusCode != StatusCodeType.Completed) |
46 |
{ |
47 |
logger.Error($"Markus.Service.ConvertProcess Error ConvertId : {convetContext.ConvertID}"); |
48 |
} |
49 |
else |
50 |
{ |
51 |
var pluginPath = System.IO.Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, "Plugin"); |
52 |
var plugins = GenericPluginLoader<ConvertPlugin.IPlugin>.LoadPlugins(pluginPath); |
53 |
var config = ConfigHelper.AppConfig("Plugin.ini"); |
54 |
|
55 |
if(plugins != null) |
56 |
{ |
57 |
foreach (var item in plugins) |
58 |
{ |
59 |
Dictionary<string, object> parameters = new Dictionary<string, object>(); |
60 |
|
61 |
var sections = config.Sections.Where(x=>x.SectionName == item.Name); |
62 |
|
63 |
if (sections.Count() > 0) |
64 |
{ |
65 |
foreach (var param in sections.First().Keys) |
66 |
{ |
67 |
parameters.Add(param.Name, param.Content); |
68 |
} |
69 |
} |
70 |
|
71 |
var result = item.Do(convetContext.ConvertID, parameters); |
72 |
|
73 |
if(!result) |
74 |
{ |
75 |
logger.Error($"Markus.Service.ConvertProcess Error ConvertId : {convetContext.ConvertID} PlugIn Error : ",new Exception(item.Exception.ToString())); |
76 |
} |
77 |
} |
78 |
} |
79 |
else |
80 |
{ |
81 |
logger.Error($"Markus.Service.ConvertProcess Error Plugin Directory {pluginPath}"); |
82 |
} |
83 |
} |
84 |
} |
85 |
} |
86 |
catch (Exception ex) |
87 |
{ |
88 |
logger.Error($"Markus.Service.ConvertProcess Error ConvertId : {convetContext.ConvertID}", ex); |
89 |
} |
90 |
finally |
91 |
{ |
92 |
convert?.Dispose(); |
93 |
GC.Collect(); |
94 |
GC.WaitForPendingFinalizers(); |
95 |
GC.Collect(); |
96 |
|
97 |
Application.Exit(); |
98 |
} |
99 |
} |
100 |
} |
101 |
} |