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