markus / ConvertService / ServiceBase / Markus.Service.Convert / Plugin.cs @ 504c5aa1
이력 | 보기 | 이력해설 | 다운로드 (1.72 KB)
1 | db0d3db3 | taeseongkim | using Markus.Service.Extensions; |
---|---|---|---|
2 | using Markus.Service.Helper; |
||
3 | using System; |
||
4 | using System.Collections.Generic; |
||
5 | using System.Linq; |
||
6 | using System.Text; |
||
7 | using System.Threading.Tasks; |
||
8 | using Markus.Service.Convert.Plugin; |
||
9 | using log4net; |
||
10 | |||
11 | namespace Markus.Service |
||
12 | { |
||
13 | public static class PluginService |
||
14 | { |
||
15 | private const string ConfigFileName = "Plugin.ini"; |
||
16 | private const string BasePath = "Plugin"; |
||
17 | |||
18 | public static bool Run(string ConvertID) |
||
19 | { |
||
20 | bool result = false; |
||
21 | |||
22 | var pluginPath = System.IO.Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, BasePath); |
||
23 | var plugins = GenericPluginLoader<IPlugin>.LoadPlugins(pluginPath); |
||
24 | var config = ConfigHelper.AppConfig(ConfigFileName); |
||
25 | |||
26 | if (plugins != null) |
||
27 | { |
||
28 | foreach (var item in plugins) |
||
29 | { |
||
30 | Dictionary<string, object> parameters = new Dictionary<string, object>(); |
||
31 | |||
32 | var sections = config.Sections.Where(x => x.SectionName == item.Name); |
||
33 | |||
34 | if (sections.Count() > 0) |
||
35 | { |
||
36 | foreach (var param in sections.First().Keys) |
||
37 | { |
||
38 | parameters.Add(param.Name, param.Content); |
||
39 | } |
||
40 | } |
||
41 | |||
42 | var pluginResult = item.Do(ConvertID, parameters); |
||
43 | |||
44 | if (!pluginResult) |
||
45 | { |
||
46 | |||
47 | throw new Exception($"Markus.Service.ConvertProcess Error ConvertId : {ConvertID} PlugIn Error : ", new Exception(item.Exception.ToString())); |
||
48 | } |
||
49 | } |
||
50 | } |
||
51 | |||
52 | return result; |
||
53 | } |
||
54 | |||
55 | } |
||
56 | } |