UEditorActionCollection.cs
4.68 KB
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
using Microsoft.AspNetCore.Http;
using System;
using System.Collections.Generic;
using UEditorNetCore.Handlers;
namespace UEditorNetCore
{
public class UEditorActionCollection : Dictionary<string, Action<HttpContext>>
{
public UEditorActionCollection()
{
Add("config", ConfigAction);
Add("uploadimage", UploadImageAction);
Add("uploadscrawl", UploadScrawlAction);
Add("uploadvideo", UploadVideoAction);
Add("uploadfile", UploadFileAction);
Add("listimage", ListImageAction);
Add("listfile", ListFileAction);
Add("catchimage", CatchImageAction);
}
public new UEditorActionCollection Add(string action, Action<HttpContext> handler)
{
if (ContainsKey(action))
this[action] = handler;
else
base.Add(action, handler);
return this;
}
public new UEditorActionCollection Remove(string action)
{
base.Remove(action);
return this;
}
private void ConfigAction(HttpContext context)
{
new ConfigHandler(context).Process();
}
private void UploadImageAction(HttpContext context)
{
new UploadHandler(context, new UploadConfig()
{
AllowExtensions = Config.GetStringList("imageAllowFiles"),
PathFormat = Config.GetString("imagePathFormat"),
SaveAbsolutePath = Config.GetString("imageSaveAbsolutePath"),
FtpUpload = Config.GetValue<bool>("imageFtpUpload"),
FtpAccount = Consts.ImgFtpServer.account,
FtpPwd = Consts.ImgFtpServer.pwd,
FtpIp = Consts.ImgFtpServer.ip,
SizeLimit = Config.GetInt("imageMaxSize"),
UploadFieldName = Config.GetString("imageFieldName")
}).Process();
}
private void UploadScrawlAction(HttpContext context)
{
new UploadHandler(context, new UploadConfig()
{
AllowExtensions = new string[] { ".png" },
PathFormat = Config.GetString("scrawlPathFormat"),
SizeLimit = Config.GetInt("scrawlMaxSize"),
UploadFieldName = Config.GetString("scrawlFieldName"),
FtpUpload = Config.GetValue<bool>("scrawlFtpUpload"),
FtpAccount = Consts.ImgFtpServer.account,
FtpPwd = Consts.ImgFtpServer.pwd,
FtpIp = Consts.ImgFtpServer.ip,
Base64 = true,
Base64Filename = "scrawl.png"
}).Process();
}
private void UploadVideoAction(HttpContext context)
{
new UploadHandler(context, new UploadConfig()
{
AllowExtensions = Config.GetStringList("videoAllowFiles"),
PathFormat = Config.GetString("videoPathFormat"),
SizeLimit = Config.GetInt("videoMaxSize"),
FtpUpload = Config.GetValue<bool>("videoFtpUpload"),
FtpAccount = Consts.ImgFtpServer.account,
FtpPwd = Consts.ImgFtpServer.pwd,
FtpIp = Consts.ImgFtpServer.ip,
UploadFieldName = Config.GetString("videoFieldName")
}).Process();
}
private void UploadFileAction(HttpContext context)
{
new UploadHandler(context, new UploadConfig()
{
AllowExtensions = Config.GetStringList("fileAllowFiles"),
PathFormat = Config.GetString("filePathFormat"),
SizeLimit = Config.GetInt("fileMaxSize"),
FtpUpload = Config.GetValue<bool>("fileFtpUpload"),
FtpAccount = Consts.ImgFtpServer.account,
FtpPwd = Consts.ImgFtpServer.pwd,
FtpIp = Consts.ImgFtpServer.ip,
UploadFieldName = Config.GetString("fileFieldName")
}).Process();
}
private void ListImageAction(HttpContext context)
{
new ListFileManager(
context,
Config.GetString("imageManagerListPath"),
Config.GetStringList("imageManagerAllowFiles"))
.Process();
}
private void ListFileAction(HttpContext context)
{
new ListFileManager(
context,
Config.GetString("fileManagerListPath"),
Config.GetStringList("fileManagerAllowFiles"))
.Process();
}
private void CatchImageAction(HttpContext context)
{
new CrawlerHandler(context).Process();
}
}
}