markus / ConvertService / ServiceBase / Markus.Service.Convert / DownloadPlugin.cs @ 43e1d368
이력 | 보기 | 이력해설 | 다운로드 (1.72 KB)
1 |
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 |
|
10 |
namespace Markus.Service |
11 |
{ |
12 |
public static class DownloadPluginService |
13 |
{ |
14 |
private const string BasePath = "DownloadPlugin"; |
15 |
|
16 |
public static bool Download(string PdfFileFullPath, string SaveDirectory, ref string DownloadFilePath) |
17 |
{ |
18 |
bool result = false; |
19 |
string error = ""; |
20 |
var baseDir = new System.IO.DirectoryInfo(AppDomain.CurrentDomain.SetupInformation.ApplicationBase).Parent.FullName; |
21 |
var pluginPath = System.IO.Path.Combine(baseDir, BasePath); |
22 |
Console.WriteLine(pluginPath); |
23 |
|
24 |
var plugins = GenericPluginLoader<IDownloadPlugin>.LoadPlugins(pluginPath); |
25 |
|
26 |
if (plugins != null) |
27 |
{ |
28 |
foreach (var item in plugins) |
29 |
{ |
30 |
if (item.Do(PdfFileFullPath, SaveDirectory, ref DownloadFilePath)) |
31 |
{ |
32 |
result = true; |
33 |
break; |
34 |
} |
35 |
else |
36 |
{ |
37 |
var msg = $" not working {item.Name} {item.Exception}"; |
38 |
Console.WriteLine(msg); |
39 |
error += msg; |
40 |
} |
41 |
} |
42 |
|
43 |
if (!result) |
44 |
{ |
45 |
throw new Exception("download plugin Error : " + error); |
46 |
} |
47 |
} |
48 |
else |
49 |
{ |
50 |
throw new Exception("plugins is null"); |
51 |
} |
52 |
|
53 |
return result; |
54 |
} |
55 |
|
56 |
} |
57 |
} |