├── .gitignore
├── DS.Web.UCenter.sln
├── README.md
└── src
└── DS.Web.UCenter
├── Api
├── IUcRequestArguments.cs
├── UcActions.cs
├── UcApiBase.cs
└── UcRequestArguments.cs
├── App.config
├── ClassDiagram.cd
├── Client
├── IUcClient.cs
├── UcClient.cs
├── UcClientBase.cs
└── UcModelName.cs
├── DS.Web.UCenter.csproj
├── Model
├── CollectionReceive
│ ├── UcApps.cs
│ ├── UcBadWords.cs
│ ├── UcCreditSettings.cs
│ ├── UcFeeds.cs
│ ├── UcFriends.cs
│ ├── UcHosts.cs
│ ├── UcPmList.cs
│ ├── UcPmView.cs
│ ├── UcTags.cs
│ └── UcUserProtecteds.cs
├── CollectionReturn
│ ├── UcCreditSettingReturns.cs
│ └── UcTagReturns.cs
├── IDictionaryExtension.cs
├── ItemReceive
│ ├── UcApp.cs
│ ├── UcBadWord.cs
│ ├── UcClientSetting.cs
│ ├── UcCreditSetting.cs
│ ├── UcFeed.cs
│ ├── UcFriend.cs
│ ├── UcHost.cs
│ ├── UcMailQueue.cs
│ ├── UcPm.cs
│ ├── UcPmBlacklsGet.cs
│ ├── UcPmCheckNew.cs
│ ├── UcPmSend.cs
│ ├── UcTag.cs
│ ├── UcUserCheckEmail.cs
│ ├── UcUserEdit.cs
│ ├── UcUserInfo.cs
│ ├── UcUserLogin.cs
│ ├── UcUserMerge.cs
│ ├── UcUserProtected.cs
│ └── UcUserRegister.cs
├── ItemReturn
│ ├── UcCreditSettingReturn.cs
│ └── UcTagReturn.cs
├── UcCollectionBase.cs
├── UcCollectionReceiveBase.cs
├── UcCollectionReturnBase.cs
├── UcEnums.cs
├── UcItemBase.cs
├── UcItemReceiveBase.cs
└── UcItemReturnBase.cs
├── Properties
└── AssemblyInfo.cs
├── UcConfig.cs
└── UcUtility.cs
/.gitignore:
--------------------------------------------------------------------------------
1 | # Build Folders (you can keep bin if you'd like, to store dlls and pdbs)
2 | bin
3 | obj
4 |
5 | # mstest test results
6 | TestResults
--------------------------------------------------------------------------------
/DS.Web.UCenter.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 11.00
3 | # Visual Studio 2010
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DS.Web.UCenter", "src\DS.Web.UCenter\DS.Web.UCenter.csproj", "{50E9578D-EF71-4E28-9BC3-D61E7E26C391}"
5 | EndProject
6 | Global
7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
8 | Debug|Any CPU = Debug|Any CPU
9 | Release|Any CPU = Release|Any CPU
10 | EndGlobalSection
11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
12 | {50E9578D-EF71-4E28-9BC3-D61E7E26C391}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
13 | {50E9578D-EF71-4E28-9BC3-D61E7E26C391}.Debug|Any CPU.Build.0 = Debug|Any CPU
14 | {50E9578D-EF71-4E28-9BC3-D61E7E26C391}.Release|Any CPU.ActiveCfg = Release|Any CPU
15 | {50E9578D-EF71-4E28-9BC3-D61E7E26C391}.Release|Any CPU.Build.0 = Release|Any CPU
16 | EndGlobalSection
17 | GlobalSection(SolutionProperties) = preSolution
18 | HideSolutionNode = FALSE
19 | EndGlobalSection
20 | EndGlobal
21 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | UCenter-API-For-DotNet
2 | ======================
3 |
4 | 目录:
5 |
6 | - 开篇
7 | - 通讯原理:UCenter API 与子站之间的通讯原理和单点登陆原理
8 | - 加密与解密:AuthCode详解 & AuthCode函数翻译过程中的注意点
9 | - 网站搭建: 康盛旗下网站 & Asp.net 网站搭建
10 | - MVC 网站下的用法:在 MVC 下的使用方法
11 |
12 |
--------------------------------------------------------------------------------
/src/DS.Web.UCenter/Api/IUcRequestArguments.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dozer47528/UCenter-API-For-DotNet/b42509c086e1cb18625f5b7ea9303b3b1e6919aa/src/DS.Web.UCenter/Api/IUcRequestArguments.cs
--------------------------------------------------------------------------------
/src/DS.Web.UCenter/Api/UcActions.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dozer47528/UCenter-API-For-DotNet/b42509c086e1cb18625f5b7ea9303b3b1e6919aa/src/DS.Web.UCenter/Api/UcActions.cs
--------------------------------------------------------------------------------
/src/DS.Web.UCenter/Api/UcApiBase.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Web;
3 | using System.Web.SessionState;
4 |
5 | namespace DS.Web.UCenter.Api
6 | {
7 | ///
8 | /// UcApi
9 | /// Dozer 版权所有
10 | /// 允许复制、修改,但请保留我的联系方式!
11 | /// http://www.dozer.cc
12 | /// mailto:dozer.cc@gmail.com
13 | ///
14 | public abstract class UcApiBase : IHttpHandler, IRequiresSessionState
15 | {
16 | ///
17 | ///
18 | ///
19 | public bool IsReusable
20 | {
21 | get { return false; }
22 | }
23 | ///
24 | ///
25 | ///
26 | ///
27 | public void ProcessRequest(HttpContext context)
28 | {
29 | Response = context.Response;
30 | Request = context.Request;
31 | Args = new UcRequestArguments(Request);
32 | if (!check()) return;
33 | switchAction();
34 | }
35 |
36 | #region 私有
37 | private HttpResponse Response { get; set; }
38 | private HttpRequest Request { get; set; }
39 | private IUcRequestArguments Args { get; set; }
40 | ///
41 | /// 检查合法性
42 | ///
43 | ///
44 | private bool check()
45 | {
46 | if (Args.IsInvalidRequest)
47 | {
48 | writeEnd("Invalid Request");
49 | }
50 | if (Args.IsAuthracationExpiried)
51 | {
52 | writeEnd("Authracation has expiried");
53 | }
54 | return true;
55 | }
56 | private void writeEnd(string msg)
57 | {
58 | Response.Write(msg);
59 | Response.End();
60 | }
61 | private void writeEnd(UcCollectionReturnBase msg)
62 | where T : UcItemReturnBase
63 | {
64 | writeEnd(msg.ToString());
65 | }
66 | private void writeEnd(ApiReturn result)
67 | {
68 | var msg = result == ApiReturn.Success ? UcConfig.ApiReturnSucceed : UcConfig.ApiReturnFailed;
69 | Response.Write(msg);
70 | Response.End();
71 | }
72 | private void writeForbidden()
73 | {
74 | writeEnd(UcConfig.ApiReturnForbidden);
75 | }
76 | private void switchAction()
77 | {
78 | if (Args.Action == UcActions.Test)
79 | {
80 | test();
81 | }
82 | else if (Args.Action == UcActions.DeleteUser)
83 | {
84 | deleteUser();
85 | }
86 | else if (Args.Action == UcActions.RenameUser)
87 | {
88 | renameUser();
89 | }
90 | else if (Args.Action == UcActions.GetTag)
91 | {
92 | getTag();
93 | }
94 | else if (Args.Action == UcActions.SynLogin)
95 | {
96 | synLogin();
97 | }
98 | else if (Args.Action == UcActions.SynLogout)
99 | {
100 | synLogout();
101 | }
102 | else if (Args.Action == UcActions.UpdatePw)
103 | {
104 | updatePw();
105 | }
106 | else if (Args.Action == UcActions.UpdateBadWords)
107 | {
108 | updateBadWords();
109 | }
110 | else if (Args.Action == UcActions.UpdateHosts)
111 | {
112 | updateHosts();
113 | }
114 | else if (Args.Action == UcActions.UpdateApps)
115 | {
116 | updateApps();
117 | }
118 | else if (Args.Action == UcActions.UpdateClient)
119 | {
120 | updateClient();
121 | }
122 | else if (Args.Action == UcActions.UpdateCredit)
123 | {
124 | updateCredit();
125 | }
126 | else if (Args.Action == UcActions.GetCreditSettings)
127 | {
128 | getCreditSettings();
129 | }
130 | else if (Args.Action == UcActions.GetCredit)
131 | {
132 | getCredit();
133 | }
134 | else if (Args.Action == UcActions.UpdateCreditSettings)
135 | {
136 | updateCreditSettings();
137 | }
138 | }
139 | #endregion
140 |
141 | #region API实现
142 | private void test()
143 | {
144 | writeEnd(UcConfig.ApiReturnSucceed);
145 | }
146 | private void deleteUser()
147 | {
148 | if (!UcConfig.ApiDeleteUser) writeForbidden();
149 | var ids = Args.QueryString["ids"];
150 | var idArray = new List();
151 | foreach (var id in ids.Split(','))
152 | {
153 | int idInt;
154 | if (int.TryParse(id, out idInt)) idArray.Add(idInt);
155 | }
156 | writeEnd(DeleteUser(idArray));
157 | }
158 | private void renameUser()
159 | {
160 | if (!UcConfig.ApiRenameUser) writeForbidden();
161 | int uid;
162 | int.TryParse(Args.QueryString["uid"], out uid);
163 | var oldusername = Args.QueryString["oldusername"];
164 | var newusername = Args.QueryString["newusername"];
165 | writeEnd(RenameUser(uid, oldusername, newusername));
166 | }
167 | private void getTag()
168 | {
169 | if (!UcConfig.ApiGetTag) writeForbidden();
170 | var tagName = Args.QueryString["id"];
171 | writeEnd(GetTag(tagName));
172 | }
173 | private void synLogin()
174 | {
175 | if (!UcConfig.ApiSynLogin) writeForbidden();
176 | Response.Headers.Add("P3P", "CP=\"CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR\"");
177 | int uid;
178 | int.TryParse(Args.QueryString["uid"], out uid);
179 | writeEnd(SynLogin(uid));
180 | }
181 | private void synLogout()
182 | {
183 | if (!UcConfig.ApiSynLogout) writeForbidden();
184 | Response.Headers.Add("P3P", "CP=\"CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR\"");
185 | writeEnd(SynLogout());
186 | }
187 | private void updatePw()
188 | {
189 | if (!UcConfig.ApiUpdatePw) writeForbidden();
190 | var username = Args.QueryString["username"];
191 | var password = Args.QueryString["password"];
192 | writeEnd(UpdatePw(username, password));
193 | }
194 | private void updateBadWords()
195 | {
196 | if (!UcConfig.ApiUpdateBadWords) writeForbidden();
197 | var badWords = new UcBadWords(Args.FormData);
198 | writeEnd(UpdateBadWords(badWords));
199 | }
200 | private void updateHosts()
201 | {
202 | if (!UcConfig.ApiUpdateHosts) writeForbidden();
203 | var hosts = new UcHosts(Args.FormData);
204 | writeEnd(UpdateHosts(hosts));
205 | }
206 | private void updateApps()
207 | {
208 | if (!UcConfig.ApiUpdateApps) writeForbidden();
209 | var apps = new UcApps(Args.FormData);
210 | writeEnd(UpdateApps(apps));
211 | }
212 | private void updateClient()
213 | {
214 | if (!UcConfig.ApiUpdateClient) writeForbidden();
215 | var client = new UcClientSetting(Args.FormData);
216 | writeEnd(UpdateClient(client));
217 | }
218 | private void updateCredit()
219 | {
220 | if (!UcConfig.ApiUpdateCredit) writeForbidden();
221 | int uid;
222 | int.TryParse(Args.QueryString["uid"], out uid);
223 | int credit;
224 | int.TryParse(Args.QueryString["credit"], out credit);
225 | int amount;
226 | int.TryParse(Args.QueryString["amount"], out amount);
227 | writeEnd(UpdateCredit(uid, credit, amount));
228 | }
229 | private void getCreditSettings()
230 | {
231 | if (!UcConfig.ApiGetCreditSettings) writeForbidden();
232 | writeEnd(GetCreditSettings());
233 | }
234 | private void getCredit()
235 | {
236 | if (!UcConfig.ApiGetCredit) writeForbidden();
237 | int uid;
238 | int.TryParse(Args.QueryString["uid"], out uid);
239 | int credit;
240 | int.TryParse(Args.QueryString["credit"], out credit);
241 | writeEnd(GetCredit(uid, credit));
242 | }
243 | private void updateCreditSettings()
244 | {
245 | if (!UcConfig.ApiUpdateCreditSettings) writeForbidden();
246 | var creditSettings = new UcCreditSettings(Args.FormData);
247 | writeEnd(UpdateCreditSettings(creditSettings));
248 | }
249 | #endregion
250 |
251 | #region 抽象方法
252 | ///
253 | /// 删除用户
254 | ///
255 | /// Uid
256 | ///
257 | public abstract ApiReturn DeleteUser(IEnumerable ids);
258 | ///
259 | /// 重命名
260 | ///
261 | /// Uid
262 | /// 旧用户名
263 | /// 新用户名
264 | ///
265 | public abstract ApiReturn RenameUser(int uid, string oldUserName, string newUserName);
266 | ///
267 | /// 得到标签
268 | ///
269 | /// 标签名
270 | ///
271 | public abstract UcTagReturns GetTag(string tagName);
272 | ///
273 | /// 同步登陆
274 | ///
275 | /// uid
276 | ///
277 | public abstract ApiReturn SynLogin(int uid);
278 | ///
279 | /// 同步登出
280 | ///
281 | ///
282 | public abstract ApiReturn SynLogout();
283 | ///
284 | /// 更新密码
285 | ///
286 | /// 用户名
287 | /// 密码
288 | ///
289 | public abstract ApiReturn UpdatePw(string userName, string passWord);
290 | ///
291 | /// 更新不良词汇
292 | ///
293 | /// 不良词汇
294 | ///
295 | public abstract ApiReturn UpdateBadWords(UcBadWords badWords);
296 | ///
297 | /// 更新Hosts
298 | ///
299 | /// Hosts
300 | ///
301 | public abstract ApiReturn UpdateHosts(UcHosts hosts);
302 | ///
303 | /// 更新App
304 | ///
305 | /// App
306 | ///
307 | public abstract ApiReturn UpdateApps(UcApps apps);
308 | ///
309 | /// 更新UCenter设置
310 | ///
311 | /// UCenter设置
312 | ///
313 | public abstract ApiReturn UpdateClient(UcClientSetting client);
314 | ///
315 | /// 更新用户积分
316 | ///
317 | /// Uid
318 | /// 积分编号
319 | /// 积分增减
320 | ///
321 | public abstract ApiReturn UpdateCredit(int uid, int credit, int amount);
322 | ///
323 | /// 得到积分设置
324 | ///
325 | ///
326 | public abstract UcCreditSettingReturns GetCreditSettings();
327 | ///
328 | /// 得到积分
329 | ///
330 | /// Uid
331 | /// 积分编号
332 | ///
333 | public abstract ApiReturn GetCredit(int uid, int credit);
334 | ///
335 | /// 更新积分设置
336 | ///
337 | /// 积分设置
338 | ///
339 | public abstract ApiReturn UpdateCreditSettings(UcCreditSettings creditSettings);
340 | #endregion
341 | }
342 |
343 | ///
344 | /// 返回类型
345 | ///
346 | public enum ApiReturn
347 | {
348 | ///
349 | /// 失败
350 | ///
351 | Failed,
352 | ///
353 | /// 成功
354 | ///
355 | Success,
356 | }
357 | }
358 |
359 |
--------------------------------------------------------------------------------
/src/DS.Web.UCenter/Api/UcRequestArguments.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dozer47528/UCenter-API-For-DotNet/b42509c086e1cb18625f5b7ea9303b3b1e6919aa/src/DS.Web.UCenter/Api/UcRequestArguments.cs
--------------------------------------------------------------------------------
/src/DS.Web.UCenter/App.config:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------
/src/DS.Web.UCenter/ClassDiagram.cd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | IAAAABAAEgCEiAAEgAAAAAABAAAAAQAAAAAACAAwEAQ=
7 | Api\UcActions.cs
8 |
9 |
10 |
11 |
12 |
13 | IAAAADCFFgDcgQAMgBAAAAABAgQAgYAIgCAQAgQkEAQ=
14 | Api\UcApiBase.cs
15 |
16 |
17 |
18 |
19 |
20 |
21 | AAAAAAAAAAAABAAAIAAgAAABAAAAAAAAAAAAAAAIAQQ=
22 | Api\UcRequestArguments.cs
23 |
24 |
25 |
26 |
27 |
28 |
29 | HAUJAAAgILgAAQRIAMUgAoICMiAkA1AACAiA4EAEgAA=
30 | Client\UcClient.cs
31 |
32 |
33 |
34 |
35 |
36 |
37 | AQQAAAAAAAAAgAEAAAACAAAAAAAACgIAAAAAAAAAEAA=
38 | Client\UcClientBase.cs
39 |
40 |
41 |
42 |
43 |
44 | AAIAAAAAEwIAAAAAAUAAAAAAETAAQAAAAAABABgAACA=
45 | Client\UcModelName.cs
46 |
47 |
48 |
49 |
50 |
51 | AAAAAAAAAACAAIAAEgBAgAEAAFAACAABAAAABAgAEAA=
52 | Client\UcModelName.cs
53 |
54 |
55 |
56 |
57 |
58 | AAAIAAAAAQAAAAAAAAAAAAAAABAACAAAAAAAAAgAAAA=
59 | Client\UcModelName.cs
60 |
61 |
62 |
63 |
64 |
65 | AAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAA=
66 | Client\UcModelName.cs
67 |
68 |
69 |
70 |
71 |
72 | AAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAgAAAA=
73 | Client\UcModelName.cs
74 |
75 |
76 |
77 |
78 |
79 | AAAIAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAgAAAA=
80 | Client\UcModelName.cs
81 |
82 |
83 |
84 |
85 |
86 | AAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAgAAAA=
87 | Client\UcModelName.cs
88 |
89 |
90 |
91 |
92 |
93 | AAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAA=
94 | Client\UcModelName.cs
95 |
96 |
97 |
98 |
99 |
100 | ACACAaoAgABIAAgAAAAIAAAABAAAQCACQgAAAAAAUAA=
101 | UcUtility.cs
102 |
103 |
104 |
105 |
106 |
107 | AAAAAAAJIQIgCCAAFSEiAAAEEBBAAAAghKCAQAAARhA=
108 | UcConfig.cs
109 |
110 |
111 |
112 |
113 |
114 | AAAAAAAAAAAACAAAAAAAAAAAABEAAAAAAAAAAAAAAAA=
115 | Model\CollectionReceive\UcApps.cs
116 |
117 |
118 |
119 |
120 |
121 | AAAAAAAAAAAACAAAAAAAAAAAABEAAAAAAAAAAAAAAAA=
122 | Model\CollectionReceive\UcBadWords.cs
123 |
124 |
125 |
126 |
127 |
128 | AAAAAAAAAAAACAAAAAAAAAAAABEAAAAAAAAAAAAAAAA=
129 | Model\CollectionReceive\UcCreditSettings.cs
130 |
131 |
132 |
133 |
134 |
135 | AAAAAAAAAAAACAAAAAAAAAAAABEAAAAAAQAAAAAAAAA=
136 | Model\CollectionReceive\UcFeeds.cs
137 |
138 |
139 |
140 |
141 |
142 | AAAAAAAAAAAACAAAAAAAAAAAABEAAAAAAAAAAAAAAAA=
143 | Model\CollectionReceive\UcFriends.cs
144 |
145 |
146 |
147 |
148 |
149 | AAAAAAAAAAAACAAAAAAAAAAAABEAAAAAAAAAAAAAAAA=
150 | Model\CollectionReceive\UcHosts.cs
151 |
152 |
153 |
154 |
155 |
156 | AAAAAAAAAAAACAAAAAAAAAQAABEAAAAAAAAAAAAAAAA=
157 | Model\CollectionReceive\UcPmList.cs
158 |
159 |
160 |
161 |
162 |
163 | AAAAAAAAAAAACAAAAAAAAAAAABEAAAAAAAAAAAAAAAA=
164 | Model\CollectionReceive\UcPmView.cs
165 |
166 |
167 |
168 |
169 |
170 | AAAAAAAAAAAACAAAAAAAAAAAABEAAAAAAQAAAAAAAAA=
171 | Model\CollectionReceive\UcTags.cs
172 |
173 |
174 |
175 |
176 |
177 | AAAAAAAAAAAACAAAAAAAAAAAABEAAAAAAAAAAAAAAAA=
178 | Model\CollectionReceive\UcUserProtecteds.cs
179 |
180 |
181 |
182 |
183 |
184 | AAAAAAAAAAAACAAAAAAAAAAAABAAACAAAAAAAAAAAAA=
185 | Model\CollectionReturn\UcCreditSettingReturns.cs
186 |
187 |
188 |
189 |
190 |
191 | AAAAAAAAAAAACAAAAAAAAAAAABAAACAAAAAAAAAACAA=
192 | Model\CollectionReturn\UcTagReturns.cs
193 |
194 |
195 |
196 |
197 |
198 | AACAAAggAAAAAAAAAAAABAAAAAAEAAAAAAAAAACAAAA=
199 | Model\IDictionaryExtension.cs
200 |
201 |
202 |
203 |
204 |
205 | AAAAABAAAAAAAAAABBQAAAwBAAEAEBAACAAAAAQAIAA=
206 | Model\ItemReceive\UcApp.cs
207 |
208 |
209 |
210 |
211 |
212 | AAACAAAAAAAAAAAAAAAAAQAAAAEIAAAAAAAAAAAAAAE=
213 | Model\ItemReceive\UcBadWord.cs
214 |
215 |
216 |
217 |
218 |
219 | AAQAgEIAgAAABAAAAAKAAgAAIAEAoEAAAADAEBAKBgA=
220 | Model\ItemReceive\UcClientSetting.cs
221 |
222 |
223 |
224 |
225 |
226 | AAAAAAAAAAAAAEAAIBAAAAAAAAEAACQAAAABAAAAAAA=
227 | Model\ItemReceive\UcCreditSetting.cs
228 |
229 |
230 |
231 |
232 |
233 | AAAAAAAAUAACAAAAABAAAAAwCAkABBAAAQAgAAUAAQA=
234 | Model\ItemReceive\UcFeed.cs
235 |
236 |
237 |
238 |
239 |
240 | AAAAAAAAAAAAAAAAADAAAAAAAAEBAAAAAQAAAAAAAAA=
241 | Model\ItemReceive\UcFriend.cs
242 |
243 |
244 |
245 |
246 |
247 | AAACAAAAAAAAAAAAAAAAAAAAAgEAAAAAAAAAAAAAIAA=
248 | Model\ItemReceive\UcHost.cs
249 |
250 |
251 |
252 |
253 |
254 | AAAAAAAAAAAAAAAAAAAAAAQAAAAgAAAAAAAAAAAAAAA=
255 | Model\ItemReceive\UcMailQueue.cs
256 |
257 |
258 |
259 |
260 |
261 | AAAAAIAAAAAAAAAAAIAAAAAAIAEAAAAAEEAAIAAAgQA=
262 | Model\ItemReceive\UcPm.cs
263 |
264 |
265 |
266 |
267 |
268 | AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAA=
269 | Model\ItemReceive\UcPmBlacklsGet.cs
270 |
271 |
272 |
273 |
274 |
275 | AAAQAAAAAIAAAAAQAAAAACAAAAEAAABAAABAAAACAAI=
276 | Model\ItemReceive\UcPmCheckNew.cs
277 |
278 |
279 |
280 |
281 |
282 | AAAAAIAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAA=
283 | Model\ItemReceive\UcPmSend.cs
284 |
285 |
286 |
287 |
288 |
289 | AAAAAAAAAAAAAAAABIAAAAAAAAEAAAAACAAAAAAAAAA=
290 | Model\ItemReceive\UcTag.cs
291 |
292 |
293 |
294 |
295 |
296 | AAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAA=
297 | Model\ItemReceive\UcUserCheckEmail.cs
298 |
299 |
300 |
301 |
302 |
303 | AAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAA=
304 | Model\ItemReceive\UcUserEdit.cs
305 |
306 |
307 |
308 |
309 |
310 | AAAAAAAAAAAAAAAAABAAAAAAAAEAAAAAAQAAAQAAAAA=
311 | Model\ItemReceive\UcUserInfo.cs
312 |
313 |
314 |
315 |
316 |
317 | AAAAAgAAAAAAAAAAABAAAAQAAAEAAAAAEQAAAQAAAAA=
318 | Model\ItemReceive\UcUserLogin.cs
319 |
320 |
321 |
322 |
323 |
324 | AAAAAAAAAAAAAAAAABAAAAQAAAAAAAAAAAAAAAAAAAA=
325 | Model\ItemReceive\UcUserMerge.cs
326 |
327 |
328 |
329 |
330 |
331 | AAAAAAAAAAAAAAAAABAAAAAAAAEAAAAAAQAAAAAAAAA=
332 | Model\ItemReceive\UcUserProtected.cs
333 |
334 |
335 |
336 |
337 |
338 | AAAAAAAAAAAAAAAAABAAAAQAAAAAAAAAAAAAAAAAAAA=
339 | Model\ItemReceive\UcUserRegister.cs
340 |
341 |
342 |
343 |
344 |
345 | AAAAAAAAAAAAAAAAAAAAAAAAAAAAACAQAAAAAAAACAA=
346 | Model\ItemReturn\UcCreditSettingReturn.cs
347 |
348 |
349 |
350 |
351 |
352 | AAAAAAAAAAAAAAAAgIAAAAAAAAAAADAACBAAAAAAAQA=
353 | Model\ItemReturn\UcTagReturn.cs
354 |
355 |
356 |
357 |
358 |
359 | AAAAAAAABAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAA=
360 | Model\UcCollectionBase.cs
361 |
362 |
363 |
364 |
365 |
366 | AgAAAAAAAAAAAAAAAAEAAAAAAAEAACAAAAAAQAAAAAA=
367 | Model\UcCollectionReceiveBase.cs
368 |
369 |
370 |
371 |
372 |
373 | AAAAAAAAAAAAAAAEAAAAIAAAQAAAACAAAAAAAAAAAAA=
374 | Model\UcCollectionReturnBase.cs
375 |
376 |
377 |
378 |
379 |
380 | AAAAAAAABAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAA=
381 | Model\UcItemBase.cs
382 |
383 |
384 |
385 |
386 |
387 | AAAAAAAAAAAAAAAAAAEAAAAAAgEAAAQAAAIAQAAAAAA=
388 | Model\UcItemReceiveBase.cs
389 |
390 |
391 |
392 |
393 |
394 | BAAAAAAAAAAAAAAEAAAAIABAAAAAACAAAAAAAAAAAAA=
395 | Model\UcItemReturnBase.cs
396 |
397 |
398 |
399 |
400 |
401 | AAAAAAAAAAAABAAAIAAAAAABAAAAAAAAAAAAAAAIAQQ=
402 | Api\IUcRequestArguments.cs
403 |
404 |
405 |
406 |
407 |
408 | HAUJAAAgILgAAQRIAMUgAoICMiAkAUAACACA4EAAgAA=
409 | Client\IUcClient.cs
410 |
411 |
412 |
413 |
414 |
415 | AAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAABAAAAAAAAA=
416 | Api\UcApiBase.cs
417 |
418 |
419 |
420 |
421 |
422 | AAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAA=
423 | UcUtility.cs
424 |
425 |
426 |
427 |
428 |
429 | AAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAQAAAQAAAAA=
430 | Model\UcEnums.cs
431 |
432 |
433 |
434 |
435 |
436 | AAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAQAAAAAAAAA=
437 | Model\UcEnums.cs
438 |
439 |
440 |
441 |
442 |
443 | AAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAQAAAAAAAAA=
444 | Model\UcEnums.cs
445 |
446 |
447 |
448 |
449 |
450 | AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAA=
451 | Model\UcEnums.cs
452 |
453 |
454 |
455 |
456 |
457 | AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAQAAA=
458 | Model\UcEnums.cs
459 |
460 |
461 |
462 |
463 |
464 | AAAQAAAAAAAAAAAQAAAAAAAAAAAAAAAAAABAAAAAAAA=
465 | Model\UcEnums.cs
466 |
467 |
468 |
469 |
470 |
471 | AAAAAAAAAAAAACAAAAAAAAAAAAAAAAAAABAAAAAAAAA=
472 | Model\UcEnums.cs
473 |
474 |
475 |
476 |
477 |
478 | AAAAAAAAAAAAAAAKAAAAAAAAAAAQAAAAAAAAAAAAAAA=
479 | Model\UcEnums.cs
480 |
481 |
482 |
483 |
484 |
485 | AAAAAAAAAgAAAAAAAAAYAAAAAAAAAAAAAgAAAAAAAQA=
486 | Model\UcEnums.cs
487 |
488 |
489 |
490 |
491 |
492 | AAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAIACAAAAAAI=
493 | Model\UcEnums.cs
494 |
495 |
496 |
497 |
498 |
499 | AAAAAAAAAAAAAAAAAAAAAAAAEgAAAAAAAAAABAAQAAA=
500 | Model\UcEnums.cs
501 |
502 |
503 |
504 |
505 |
506 | AAAAAAAAAAAAAAAAAAAAAAAAAgAAACAAAAAAACAAAAQ=
507 | Model\UcEnums.cs
508 |
509 |
510 |
511 |
512 |
513 | ACAAAAAAAIAAAAQAAAAAAAAAAgAAACAAAAAAACAgAAQ=
514 | Model\UcEnums.cs
515 |
516 |
517 |
518 |
519 |
520 | ACAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAACAEAAAA=
521 | Model\UcEnums.cs
522 |
523 |
524 |
525 |
526 |
527 | AAAAAAAAAAAAAAAAAAAAAAAAEgAAACAAAAAABCAQAAQ=
528 | Model\UcEnums.cs
529 |
530 |
531 |
532 |
533 |
534 | AAAAAAAQABAAAAAQAAAAAAABAgAAAAAAABAAAAAAAAA=
535 | Model\UcEnums.cs
536 |
537 |
538 |
539 |
540 |
541 | AAAAAQAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAAAAAA=
542 | Model\UcEnums.cs
543 |
544 |
545 |
546 |
547 |
548 | AAAAAAAAAAAAAAAACAAAAABAAAAAAAAAAAAQAAAAAAA=
549 | Model\UcEnums.cs
550 |
551 |
552 |
553 |
554 |
555 | AAAIAAAEAQAAAAAAAAAAAAAACBAAAAQACAAACAAAASg=
556 | Model\UcEnums.cs
557 |
558 |
559 |
560 |
--------------------------------------------------------------------------------
/src/DS.Web.UCenter/Client/IUcClient.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dozer47528/UCenter-API-For-DotNet/b42509c086e1cb18625f5b7ea9303b3b1e6919aa/src/DS.Web.UCenter/Client/IUcClient.cs
--------------------------------------------------------------------------------
/src/DS.Web.UCenter/Client/UcClient.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Text;
3 |
4 | namespace DS.Web.UCenter.Client
5 | {
6 | ///
7 | /// UCenter Client
8 | /// Dozer 版权所有
9 | /// 允许复制、修改,但请保留我的联系方式!
10 | /// http://www.dozer.cc
11 | /// mailto:dozer.cc@gmail.com
12 | ///
13 | public class UcClient : UcClientBase, IUcClient
14 | {
15 | #region UserModel
16 | ///
17 | /// 用户注册
18 | ///
19 | /// 用户名
20 | /// 密码
21 | /// Email
22 | /// 登陆问题
23 | /// 答案
24 | ///
25 | public UcUserRegister UserRegister(string userName, string passWord, string email, int questionId = 0, string answer = "")
26 | {
27 | var args = new Dictionary
28 | {
29 | {"username", userName},
30 | {"password", passWord},
31 | {"email", email},
32 | {"questionid", questionId.ToString()},
33 | {"answer", answer}
34 | };
35 | return new UcUserRegister(SendArgs(args, UcUserModelName.ModelName, UcUserModelName.ActionRegister));
36 | }
37 |
38 | ///
39 | /// 用户登陆
40 | ///
41 | /// 用户名/Uid/Email
42 | /// 密码
43 | /// 登录方式
44 | /// 需要登陆问题
45 | /// 问题ID
46 | /// 答案
47 | ///
48 | public UcUserLogin UserLogin(string userName, string passWord, LoginMethod loginMethod = LoginMethod.UserName, bool checkques = false, int questionId = 0, string answer = "")
49 | {
50 | var args = new Dictionary
51 | {
52 | {"username", userName},
53 | {"password", passWord},
54 | {"isuid", ((int) loginMethod).ToString()},
55 | {"checkques", checkques ? "1" : "0"},
56 | {"questionid", questionId.ToString()},
57 | {"answer", answer}
58 | };
59 | return new UcUserLogin(SendArgs(args, UcUserModelName.ModelName, UcUserModelName.ActionLogin));
60 | }
61 |
62 | ///
63 | /// 得到用户信息
64 | ///
65 | /// 用户名
66 | ///
67 | public UcUserInfo UserInfo(string userName)
68 | {
69 | return userInfo(userName,InfoMethod.UserName);
70 | }
71 |
72 | ///
73 | /// 得到用户信息
74 | ///
75 | /// Uid
76 | ///
77 | public UcUserInfo UserInfo(int uid)
78 | {
79 | return userInfo(uid.ToString(), InfoMethod.Uid);
80 | }
81 |
82 | ///
83 | /// 得到用户信息
84 | ///
85 | /// 用户名/Uid
86 | /// 查询方式
87 | ///
88 | private UcUserInfo userInfo(string userName, InfoMethod infoMethod)
89 | {
90 | var args = new Dictionary
91 | {
92 | {"username", userName},
93 | {"isuid", ((int) infoMethod).ToString()}
94 | };
95 | return new UcUserInfo(SendArgs(args, UcUserModelName.ModelName, UcUserModelName.ActionInfo));
96 | }
97 |
98 | ///
99 | /// 更新用户信息
100 | /// 更新资料需验证用户的原密码是否正确,除非指定 ignoreoldpw 为 1。
101 | /// 如果只修改 Email 不修改密码,可让 newpw 为空;
102 | /// 同理如果只修改密码不修改 Email,可让 email 为空。
103 | ///
104 | ///
105 | public UcUserEdit UserEdit(string userName, string oldPw, string newPw, string email, bool ignoreOldPw = false, int questionId = 0, string answer = "")
106 | {
107 | var args = new Dictionary
108 | {
109 | {"username", userName},
110 | {"oldpw", oldPw},
111 | {"newpw", newPw},
112 | {"email", email},
113 | {"ignoreoldpw", ignoreOldPw ? "1" : "0"},
114 | {"questionid", questionId.ToString()},
115 | {"answer", answer}
116 | };
117 | return new UcUserEdit(SendArgs(args, UcUserModelName.ModelName, UcUserModelName.ActionEdit));
118 | }
119 |
120 | ///
121 | /// 删除用户
122 | ///
123 | /// Uid
124 | ///
125 | public bool UserDelete(params int[] uid)
126 | {
127 | var args = new Dictionary();
128 | addArray(args, "uid", uid);
129 | return toBool(SendArgs(args, UcUserModelName.ModelName, UcUserModelName.ActionDelete));
130 | }
131 |
132 |
133 |
134 | ///
135 | /// 删除用户头像
136 | ///
137 | /// Uid
138 | public void UserDeleteAvatar(params int[] uid)
139 | {
140 | var args = new Dictionary();
141 | addArray(args, "uid", uid);
142 | SendArgs(args, UcUserModelName.ModelName, UcUserModelName.ActionDeleteAvatar);
143 | }
144 |
145 | ///
146 | /// 同步登陆
147 | ///
148 | /// Uid
149 | /// 同步登陆的 Html 代码
150 | public string UserSynlogin(int uid)
151 | {
152 | var args = new Dictionary
153 | {
154 | {"uid", uid.ToString()}
155 | };
156 | return SendArgs(args, UcUserModelName.ModelName, UcUserModelName.ActionSynLogin);
157 | }
158 |
159 | ///
160 | /// 同步登出
161 | ///
162 | /// 同步登出的 Html 代码
163 | public string UserSynLogout()
164 | {
165 | var args = new Dictionary();
166 | return SendArgs(args, UcUserModelName.ModelName, UcUserModelName.ActionSynLogout);
167 | }
168 |
169 | ///
170 | /// 检查 Email 格式
171 | ///
172 | /// Email
173 | ///
174 | public UcUserCheckEmail UserCheckEmail(string email)
175 | {
176 | var args = new Dictionary
177 | {
178 | {"email", email}
179 | };
180 | return new UcUserCheckEmail(SendArgs(args, UcUserModelName.ModelName, UcUserModelName.ActionCheckEmail));
181 | }
182 |
183 | ///
184 | /// 增加受保护用户
185 | ///
186 | /// 操作管理员
187 | /// 用户名
188 | ///
189 | public bool UserAddProtected(string admin, params string[] userName)
190 | {
191 | var args = new Dictionary
192 | {
193 | {"admin", admin}
194 | };
195 | addArray(args, "username", userName);
196 | return toBool(SendArgs(args, UcUserModelName.ModelName, UcUserModelName.ActionAddProtected));
197 | }
198 |
199 | ///
200 | /// 删除受保护用户
201 | ///
202 | /// 操作管理员
203 | /// 用户名
204 | ///
205 | public bool UserDeleteProtected(string admin, params string[] userName)
206 | {
207 | var args = new Dictionary
208 | {
209 | {"admin", admin}
210 | };
211 | addArray(args, "username", userName);
212 | return toBool(SendArgs(args, UcUserModelName.ModelName, UcUserModelName.ActionDeleteProtected));
213 | }
214 |
215 | ///
216 | /// 得到受保护用户
217 | ///
218 | ///
219 | public UcUserProtecteds UserGetProtected()
220 | {
221 | var args = new Dictionary();
222 | return new UcUserProtecteds(SendArgs(args, UcUserModelName.ModelName, UcUserModelName.ActionGetProtected));
223 | }
224 |
225 | ///
226 | /// 合并用户
227 | ///
228 | /// 老用户名
229 | /// 新用户名
230 | /// Uid
231 | /// 密码
232 | /// Email
233 | ///
234 | public UcUserMerge UserMerge(string oldUserName, string newUserName, int uid, string passWord, string email)
235 | {
236 | var args = new Dictionary
237 | {
238 | {"oldusername", oldUserName},
239 | {"newusername", newUserName},
240 | {"uid", uid.ToString()},
241 | {"password", passWord},
242 | {"email", email}
243 | };
244 | return new UcUserMerge(SendArgs(args, UcUserModelName.ModelName, UcUserModelName.ActionMerge));
245 | }
246 |
247 | ///
248 | /// 移除重名用户记录
249 | ///
250 | /// 用户名
251 | public void UserMergeRemove(string userName)
252 | {
253 | var args = new Dictionary
254 | {
255 | {"username", userName}
256 | };
257 | SendArgs(args, UcUserModelName.ModelName, UcUserModelName.ActionMergeRemove);
258 |
259 | }
260 |
261 | ///
262 | /// 得到用户积分
263 | ///
264 | /// 应用程序Id
265 | /// Uid
266 | /// 积分编号
267 | ///
268 | public int UserGetCredit(int appId, int uid, int credit)
269 | {
270 | int result;
271 | var args = new Dictionary
272 | {
273 | {"appid", appId.ToString()},
274 | {"uid", uid.ToString()},
275 | {"credit", credit.ToString()}
276 | };
277 | int.TryParse(SendArgs(args, UcUserModelName.ModelName, UcUserModelName.ActionGetCredit), out result);
278 | return result;
279 | }
280 | #endregion
281 |
282 | #region PmModel
283 | ///
284 | /// 检查新消息
285 | ///
286 | /// Uid
287 | ///
288 | public UcPmCheckNew PmCheckNew(int uid)
289 | {
290 | var args = new Dictionary
291 | {
292 | {"uid", uid.ToString()},
293 | {"more","3"}
294 | };
295 | return new UcPmCheckNew(SendArgs(args, UcPmModelName.ModelName, UcPmModelName.ActionCheckNew));
296 | }
297 |
298 | ///
299 | /// 发送短消息
300 | ///
301 | /// 发件人用户 ID,0 为系统消息
302 | /// 回复的消息 ID,0:发送新的短消息,大于 0:回复指定的短消息
303 | /// 消息标题
304 | /// 消息内容
305 | /// 收件人ID
306 | ///
307 | public UcPmSend PmSend(int fromUid, int replyPmId, string subject, string message, params int[] msgTo)
308 | {
309 | return pmSend(fromUid, string.Join(",", intToString(msgTo)), subject, message, replyPmId);
310 | }
311 |
312 | ///
313 | /// 发送短消息
314 | ///
315 | /// 发件人用户 ID,0 为系统消息
316 | /// 回复的消息 ID,0:发送新的短消息,大于 0:回复指定的短消息
317 | /// 消息标题
318 | /// 消息内容
319 | /// 收件人用户名
320 | ///
321 | public UcPmSend PmSend(int fromUid, int replyPmId, string subject, string message, params string[] msgTo)
322 | {
323 | return pmSend(fromUid, string.Join(",", msgTo), subject, message, replyPmId, SendMethod.UserName);
324 | }
325 |
326 | ///
327 | /// 发送短消息
328 | ///
329 | /// 发件人用户 ID,0 为系统消息
330 | /// 收件人用户名 / 用户 ID,多个用逗号分割,默认为ID
331 | /// 消息标题
332 | /// 消息内容
333 | /// 回复的消息 ID,0:(默认值) 发送新的短消息,大于 0:回复指定的短消息
334 | /// msgto 参数类型
335 | ///
336 | private UcPmSend pmSend(int fromUid, string msgTo, string subject, string message, int replyPmId = 0, SendMethod sendMethod = SendMethod.Uid)
337 | {
338 | var args = new Dictionary
339 | {
340 | {"fromuid", fromUid.ToString()},
341 | {"msgto",msgTo},
342 | {"subject",subject},
343 | {"message",message},
344 | {"replypid",replyPmId.ToString()},
345 | {"isusername",((int)sendMethod).ToString()}
346 | };
347 | return new UcPmSend(SendArgs(args, UcPmModelName.ModelName, UcPmModelName.ActionSend));
348 | }
349 |
350 | ///
351 | /// 删除短消息
352 | ///
353 | /// Uid
354 | /// 文件夹
355 | /// 短消息ID
356 | /// 删除的数量
357 | public int PmDelete(int uid, PmDeleteFolder folder, params int[] pmIds)
358 | {
359 | var args = new Dictionary
360 | {
361 | {"uid", uid.ToString()},
362 | {"folder",folder.ToString().ToLower()}
363 | };
364 | addArray(args, "pmids", pmIds);
365 | return toInt(SendArgs(args, UcPmModelName.ModelName, UcPmModelName.ActionDelete));
366 | }
367 |
368 | ///
369 | /// 删除会话
370 | ///
371 | /// 发件人
372 | /// 收件人
373 | /// 删除的数量
374 | public int PmDelete(int uid, params int[] toUids)
375 | {
376 | var args = new Dictionary
377 | {
378 | {"uid", uid.ToString()}
379 | };
380 | addArray(args, "touids", toUids);
381 | return toInt(SendArgs(args, UcPmModelName.ModelName, UcPmModelName.ActionDeleteUser));
382 | }
383 |
384 |
385 |
386 | ///
387 | /// 修改阅读状态
388 | ///
389 | /// 发件人
390 | /// 收件人
391 | /// 短消息ID
392 | /// 阅读状态
393 | public void PmReadStatus(int uid, int toUids, int pmIds = 0, ReadStatus readStatus = ReadStatus.Readed)
394 | {
395 | PmReadStatus(uid, new[] { toUids }, new[] { pmIds }, readStatus);
396 | }
397 |
398 |
399 | ///
400 | /// 修改阅读状态
401 | ///
402 | /// 发件人
403 | /// 收件人数组
404 | /// 短消息ID数组
405 | /// 阅读状态
406 | public void PmReadStatus(int uid, IEnumerable toUids, IEnumerable pmIds, ReadStatus readStatus = ReadStatus.Readed)
407 | {
408 | var args = new Dictionary
409 | {
410 | {"uid", uid.ToString()},
411 | {"status",((int)readStatus).ToString()}
412 | };
413 | addArray(args, "uids", toUids);
414 | addArray(args, "pmids", pmIds);
415 | SendArgs(args, UcPmModelName.ModelName, UcPmModelName.ActionReadStatus);
416 | }
417 |
418 |
419 | ///
420 | /// 获取短消息列表
421 | ///
422 | /// Uid
423 | /// 当前页编号,默认值 1
424 | /// 每页最大条目数,默认值 10
425 | /// 短消息所在的文件夹
426 | /// 过滤方式
427 | /// 截取短消息内容文字的长度,0 为不截取,默认值 0
428 | ///
429 | public UcPmList PmList(int uid, int page = 1, int pageSize = 10, PmReadFolder folder = PmReadFolder.NewBox, PmReadFilter filter = PmReadFilter.NewPm, int msgLen = 0)
430 | {
431 | var args = new Dictionary
432 | {
433 | {"uid", uid.ToString()},
434 | {"page", page.ToString()},
435 | {"pagesize", pageSize.ToString()},
436 | {"folder", folder.ToString().ToLower()},
437 | {"filter",filter.ToString().ToLower()},
438 | {"msglen", msgLen.ToString()}
439 | };
440 | return new UcPmList(SendArgs(args, UcPmModelName.ModelName, UcPmModelName.ActionList));
441 | }
442 |
443 |
444 | ///
445 | /// 获取短消息内容
446 | /// 本接口函数用于返回指定用户的指定消息 ID 的消息,返回的数据中包含针对这个消息的回复。
447 | /// 如果指定 touid 参数,那么短消息将列出所有 uid 和 touid 之间的短消息,daterange 可以指定返回消息的日期范围。
448 | ///
449 | /// Uid
450 | /// 短消息ID
451 | /// 收件人ID
452 | /// 日期范围
453 | ///
454 | public UcPmView PmView(int uid, int pmId, int toUid = 0, DateRange dateRange = DateRange.Today)
455 | {
456 | var args = new Dictionary
457 | {
458 | {"uid", uid.ToString()},
459 | {"pmid", pmId.ToString()},
460 | {"touid", toUid.ToString()},
461 | {"daterange", ((int)dateRange).ToString()}
462 | };
463 | return new UcPmView(SendArgs(args, UcPmModelName.ModelName, UcPmModelName.ActionView));
464 | }
465 |
466 | ///
467 | /// 获取单条短消息内容
468 | ///
469 | /// Uid
470 | /// 类型
471 | /// 短消息ID
472 | ///
473 | public UcPm PmViewNode(int uid, ViewType type = ViewType.Specified, int pmId = 0)
474 | {
475 | var args = new Dictionary
476 | {
477 | {"uid", uid.ToString()},
478 | {"type", ((int)type).ToString()},
479 | {"pmid", pmId.ToString()}
480 | };
481 | return new UcPm(SendArgs(args, UcPmModelName.ModelName, UcPmModelName.ActionViewNode));
482 | }
483 |
484 | ///
485 | /// 忽略未读消息提示
486 | ///
487 | /// Uid
488 | public void PmIgnore(int uid)
489 | {
490 | var args = new Dictionary
491 | {
492 | {"uid", uid.ToString()}
493 | };
494 | SendArgs(args, UcPmModelName.ModelName, UcPmModelName.ActionIgnore);
495 | }
496 |
497 |
498 |
499 | ///
500 | /// 得到黑名单
501 | ///
502 | /// Uid
503 | ///
504 | public UcPmBlacklsGet PmBlacklsGet(int uid)
505 | {
506 | var args = new Dictionary
507 | {
508 | {"uid", uid.ToString()}
509 | };
510 | return new UcPmBlacklsGet(SendArgs(args, UcPmModelName.ModelName, UcPmModelName.ActionBlacklsGet));
511 | }
512 |
513 |
514 | ///
515 | /// 设置黑名单为禁止所有人(清空原数据)
516 | ///
517 | /// Uid
518 | ///
519 | public bool PmBlacklsSetAll(int uid)
520 | {
521 | return PmBlacklsSet(uid, "{ALL}");
522 | }
523 |
524 | ///
525 | /// 设置黑名单(清空原数据)
526 | ///
527 | /// Uid
528 | /// 黑名单用户名
529 | ///
530 | public bool PmBlacklsSet(int uid, params string[] userName)
531 | {
532 | var args = new Dictionary
533 | {
534 | {"uid", uid.ToString()},
535 | {"username",string.Join(",",userName)}
536 | };
537 | return toBool(SendArgs(args, UcPmModelName.ModelName, UcPmModelName.ActionBlacklsSet));
538 | }
539 |
540 | ///
541 | /// 添加黑名单为禁止所有人
542 | ///
543 | /// Uid
544 | ///
545 | public bool PmBlacklsAddAll(int uid)
546 | {
547 | return PmBlacklsAdd(uid, "{ALL}");
548 | }
549 |
550 |
551 | ///
552 | /// 增加黑名单
553 | ///
554 | /// Uid
555 | /// 黑名单用户名
556 | ///
557 | public bool PmBlacklsAdd(int uid, params string[] userName)
558 | {
559 | var args = new Dictionary
560 | {
561 | {"uid", uid.ToString()}
562 | };
563 | addArray(args, "username", userName);
564 | return toBool(SendArgs(args, UcPmModelName.ModelName, UcPmModelName.ActionBlacklsAdd));
565 | }
566 |
567 | ///
568 | /// 删除黑名单中的禁止所有人
569 | ///
570 | /// Uid
571 | ///
572 | public void PmBlacklsDeleteAll(int uid)
573 | {
574 | PmBlacklsDelete(uid, "{ALL}");
575 | }
576 |
577 | ///
578 | /// 删除黑名单
579 | ///
580 | /// Uid
581 | /// 黑名单用户名
582 | public void PmBlacklsDelete(int uid, params string[] userName)
583 | {
584 | var args = new Dictionary
585 | {
586 | {"uid", uid.ToString()}
587 | };
588 | addArray(args, "username", userName);
589 | SendArgs(args, UcPmModelName.ModelName, UcPmModelName.ActionBlacklsDelete);
590 | }
591 | #endregion
592 |
593 | #region FriendMode
594 | ///
595 | /// 增加好友
596 | ///
597 | /// Uid
598 | /// 好友ID
599 | /// 备注
600 | ///
601 | public bool FriendAdd(int uid, int friendId, string comment = "")
602 | {
603 | var args = new Dictionary
604 | {
605 | {"uid", uid.ToString()},
606 | {"friendid", friendId.ToString()},
607 | {"comment", comment}
608 | };
609 | return toBool(SendArgs(args, UcFriendModelName.ModelName, UcFriendModelName.ActionAdd));
610 | }
611 |
612 | ///
613 | /// 删除好友
614 | ///
615 | /// Uid
616 | /// 好友ID
617 | ///
618 | public bool FriendDelete(int uid, params int[] friendIds)
619 | {
620 | var args = new Dictionary
621 | {
622 | {"uid", uid.ToString()}
623 | };
624 | addArray(args, "friendids", friendIds);
625 | return toBool(SendArgs(args, UcFriendModelName.ModelName, UcFriendModelName.ActionDelete));
626 | }
627 |
628 | ///
629 | /// 获取好友总数
630 | ///
631 | /// Uid
632 | /// 方向
633 | /// 好友数目
634 | public int FriendTotalNum(int uid, FriendDirection direction = FriendDirection.All)
635 | {
636 | var args = new Dictionary
637 | {
638 | {"uid", uid.ToString()},
639 | {"direction",((int)direction).ToString()}
640 | };
641 | return toInt(SendArgs(args, UcFriendModelName.ModelName, UcFriendModelName.ActionTotalNum));
642 | }
643 |
644 |
645 | ///
646 | /// 好友列表
647 | ///
648 | /// Uid
649 | /// 当前页编号
650 | /// 每页最大条目数
651 | /// 好友总数
652 | /// 方向
653 | ///
654 | public UcFriends FriendList(int uid, int page = 1, int pageSize = 10, int totalNum = 10, FriendDirection direction = FriendDirection.All)
655 | {
656 | var args = new Dictionary
657 | {
658 | {"uid", uid.ToString()},
659 | {"page", page.ToString()},
660 | {"pagesize", pageSize.ToString()},
661 | {"totalnum", totalNum.ToString()},
662 | {"direction",((int)direction).ToString()}
663 | };
664 | return new UcFriends(SendArgs(args, UcFriendModelName.ModelName, UcFriendModelName.ActionList));
665 | }
666 | #endregion
667 |
668 | #region CreditModel
669 | ///
670 | /// 积分兑换请求
671 | ///
672 | /// Uid
673 | /// 原积分
674 | /// 目标积分
675 | /// 目标应用ID
676 | /// 积分数额
677 | ///
678 | public bool CreditExchangeRequest(int uid, int from, int to, int toAppId, int amount)
679 | {
680 | var args = new Dictionary
681 | {
682 | {"uid", uid.ToString()},
683 | {"from", from.ToString()},
684 | {"to", to.ToString()},
685 | {"toappid", toAppId.ToString()},
686 | {"amount", amount.ToString()}
687 | };
688 | return toBool(SendArgs(args, UcCreditModelName.ModelName, UcCreditModelName.ActionExchangeRequest));
689 | }
690 | #endregion
691 |
692 | #region Avatar
693 |
694 | ///
695 | /// 修改头像
696 | ///
697 | ///Uid
698 | ///
699 | ///
700 | public string Avatar(int uid, AvatarType type = AvatarType.Virtual)
701 | {
702 | var args = new Dictionary
703 | {
704 | {"uid" ,uid.ToString()}
705 | };
706 | var input = GetInput(args);
707 | var movie = string.Format("{0}images/camera.swf?inajax=1&appid={1}&input={2}&agent={3}&ucapi={4}&avatartype={5}", UcConfig.UcApi, UcConfig.UcAppid, input, UcUtility.Md5(UcUtility.GetUserAgent()), UcUtility.PhpUrlEncode(UcConfig.UcApi.Replace("http://", "")), type.ToString().ToLower());
708 | return getFlashPlayerCode(movie);
709 | }
710 |
711 | ///
712 | /// 得到头像地址
713 | ///
714 | /// Uid
715 | /// 大小
716 | /// 类型
717 | ///
718 | public string AvatarUrl(int uid,AvatarSize size,AvatarType type = AvatarType.Virtual)
719 | {
720 | return string.Format("{0}avatar.php?uid={1}&type={2}&size={3}", UcConfig.UcApi, uid,
721 | type.ToString().ToLower(), size.ToString().ToLower());
722 | }
723 |
724 | ///
725 | /// 检查头像是否存在
726 | ///
727 | ///
728 | ///
729 | ///
730 | ///
731 | public bool AvatarCheck(int uid, AvatarSize size = AvatarSize.Middle, AvatarType type = AvatarType.Virtual)
732 | {
733 | var args = new Dictionary
734 | {
735 | {"uid", uid.ToString()},
736 | {"size", size.ToString().ToLower()},
737 | {"type", type.ToString().ToLower()},
738 | {"check_file_exists", "1"}
739 | };
740 | return toBool(SendGet(UcConfig.UcApi + "avatar.php", args));
741 | }
742 |
743 | #endregion
744 |
745 | #region TagModel
746 | ///
747 | /// 获取标签数据
748 | ///
749 | /// 标签名
750 | /// 应用程序ID对应的数量
751 | ///
752 | public UcTags TagGet(string tagName, IEnumerable> number)
753 | {
754 | var args = new Dictionary
755 | {
756 | {"tagname", tagName}
757 | };
758 | foreach (var n in number)
759 | {
760 | args.Add(n.Key, n.Value);
761 | }
762 | return new UcTags(SendArgs(args, UcTagModelName.ModelName, UcTagModelName.ActionGet));
763 | }
764 | #endregion
765 |
766 | #region FeedModel
767 | ///
768 | /// 添加事件
769 | ///
770 | /// 图标类型,如:thread、post、video、goods、reward、debate、blog、album、comment、wall、friend
771 | /// Uid
772 | /// 用户名
773 | /// 标题模板
774 | /// 标题数据数组
775 | /// 内容模板
776 | /// 模板数据
777 | /// 相同事件合并时用到的数据:特定的数组,只有两项:name、link,保留
778 | /// 保留
779 | /// 相关图片的 URL 和链接地址。一个图片地址,一个链接地址
780 | ///
781 | public int FeedAdd(FeedIcon icon, int uid, string userName, string titleTemplate, string titleData, string bodyTemplate, string bodyData, string bodyGeneral, string targetIds, params string[] images)
782 | {
783 | var args = new Dictionary
784 | {
785 | {"icon", icon.ToString().ToLower()},
786 | {"uid",uid.ToString()},
787 | {"username",userName},
788 | {"title_template",titleTemplate},
789 | {"title_data",titleData},
790 | {"body_template",bodyTemplate},
791 | {"body_data",bodyData},
792 | {"body_general",bodyGeneral},
793 | {"target_ids",targetIds}
794 | };
795 |
796 | var length = images.Length;
797 | if ( length% 2 == 0)
798 | {
799 | var url = new string[length/2];
800 | var link = new string[length / 2];
801 | for(var k=0;k
814 | /// 得到Feed
815 | ///
816 | /// 数量限制
817 | ///
818 | public UcFeeds FeedGet(int limit)
819 | {
820 | var args = new Dictionary
821 | {
822 | {"limit", limit.ToString()}
823 | };
824 | return new UcFeeds(SendArgs(args, UcFeedModelName.ModelName, UcFeedModelName.ActionGet));
825 | }
826 | #endregion
827 |
828 | #region AppModel
829 | ///
830 | /// 得到应用列表
831 | ///
832 | ///
833 | public UcApps AppList()
834 | {
835 | var args = new Dictionary();
836 | return new UcApps(SendArgs(args, UcAppModelName.ModelName, UcAppModelName.ActionList));
837 | }
838 | #endregion
839 |
840 | #region MailMode
841 |
842 | ///
843 | /// 添加邮件到队列
844 | ///
845 | /// 标题
846 | /// 内容
847 | /// Uid
848 | ///
849 | public UcMailQueue MailQueue(string subject, string message,params int[] uids)
850 | {
851 | return MailQueue(subject, message, "", "gbk", false, 1, uids, new string[0]);
852 | }
853 |
854 | ///
855 | /// 添加邮件到队列
856 | ///
857 | /// 标题
858 | /// 内容
859 | /// 目标email
860 | ///
861 | public UcMailQueue MailQueue(string subject, string message, params string[] emails)
862 | {
863 | return MailQueue(subject, message, "", "gbk", false, 1, new int[0], emails);
864 | }
865 |
866 | ///
867 | /// 添加邮件到队列
868 | ///
869 | /// 标题
870 | /// 内容
871 | /// Uid
872 | /// 目标email
873 | ///
874 | public UcMailQueue MailQueue(string subject, string message, int[] uids, string[] emails)
875 | {
876 | return MailQueue(subject, message, "", "gbk", false, 1, uids, emails);
877 | }
878 |
879 | ///
880 | /// 添加邮件到队列
881 | ///
882 | /// 标题
883 | /// 内容
884 | /// 发信人,可选参数,默认为空,uc后台设置的邮件来源作为发信人地址
885 | /// 邮件字符集,可选参数,默认为gbk
886 | /// 是否是html格式的邮件,可选参数,默认为FALSE,即文本邮件
887 | /// 邮件级别,可选参数,默认为1,数字大的优先发送,取值为0的时候立即发送,邮件不入队列
888 | /// Uid
889 | /// 目标email
890 | ///
891 | public UcMailQueue MailQueue(string subject,string message,string fromMail,string charset,bool htmlOn,int level,int[] uids,string[] emails)
892 | {
893 | var args = new Dictionary
894 | {
895 | {"uids", string.Join(",",intToString(uids))},
896 | {"emails", string.Join(",",emails)},
897 | {"subject",subject},
898 | {"message", message},
899 | {"frommail", fromMail},
900 | {"charset", charset},
901 | {"htmlon", htmlOn?"1":"0"},
902 | {"level", level.ToString()}
903 | };
904 | return new UcMailQueue(SendArgs(args, UcMailModelName.ModelName, UcMailModelName.ActionAdd));
905 | }
906 | #endregion
907 | #region 函数
908 | private string getFlashPlayerCode(string movie)
909 | {
910 | var sb = new StringBuilder();
911 | sb.AppendLine("");
921 | return string.Format(sb.ToString(), movie);
922 | }
923 |
924 |
925 | ///
926 | /// Int数组转换为String数组
927 | ///
928 | /// 数据
929 | ///
930 | private string[] intToString(int[] data)
931 | {
932 | var result = new string[data.Length];
933 | for (var k = 0; k < data.Length; k++)
934 | {
935 | result[k] = data[k].ToString();
936 | }
937 | return result;
938 | }
939 |
940 |
941 | ///
942 | /// 添加数组
943 | ///
944 | /// 参数结合
945 | /// Key
946 | /// Value
947 | private void addArray(IDictionary args, string key, IEnumerable value)
948 | {
949 | var index = 0;
950 | foreach (var v in value)
951 | {
952 | args.Add(string.Format("{0}[{1}]", key, index++), v.ToString());
953 | }
954 | }
955 |
956 | ///
957 | /// 添加数组
958 | ///
959 | /// 参数结合
960 | /// Key
961 | /// Value
962 | private void addArray(IDictionary args, string key, IEnumerable value)
963 | {
964 | var index = 0;
965 | foreach (var v in value)
966 | {
967 | args.Add(string.Format("{0}[{1}]", key, index++), v);
968 | }
969 | }
970 |
971 | ///
972 | /// 转到到Bool
973 | ///
974 | /// 判断为true的条件:大于0,或者为非空、非"false"的字符串
975 | ///
976 | private bool toBool(string input)
977 | {
978 | int result;
979 | if (int.TryParse(input, out result))
980 | {
981 | return result > 0 ? true : false;
982 | }
983 | if (input.ToLower() == "false" || string.IsNullOrEmpty(input)) return false;
984 | return true;
985 | }
986 |
987 | ///
988 | /// 转换到Int
989 | ///
990 | /// 原数据
991 | ///
992 | private int toInt(string input)
993 | {
994 | int result;
995 | int.TryParse(input, out result);
996 | return result;
997 | }
998 | #endregion
999 | }
1000 | }
--------------------------------------------------------------------------------
/src/DS.Web.UCenter/Client/UcClientBase.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.IO;
3 | using System.Net;
4 | using System.Text;
5 |
6 | namespace DS.Web.UCenter.Client
7 | {
8 | ///
9 | /// UCenter API
10 | /// Dozer 版权所有
11 | /// 允许复制、修改,但请保留我的联系方式!
12 | /// http://www.dozer.cc
13 | /// mailto:dozer.cc@gmail.com
14 | ///
15 | public abstract class UcClientBase
16 | {
17 | ///
18 | /// 得到加密后的input参数
19 | ///
20 | ///
21 | ///
22 | protected string GetInput(IDictionary args)
23 | {
24 | args.Add("agent", UcUtility.Md5(GetUserAgent()));
25 | args.Add("time", UcUtility.PhpTimeNow().ToString());
26 | return UcUtility.PhpUrlEncode((UcUtility.AuthCodeEncode(ArgsToString(args))));
27 | }
28 |
29 | ///
30 | /// 发送参数
31 | ///
32 | /// 参数
33 | /// Model
34 | /// Action
35 | ///
36 | protected string SendArgs(IDictionary args, string model, string action)
37 | {
38 |
39 | var input = GetInput(args);
40 | var api = new Dictionary
41 | {
42 | {"input",input },
43 | {"m", model},
44 | {"a", action},
45 | {"release", UcConfig.UcClientRelease},
46 | {"appid", UcConfig.UcAppid}
47 | };
48 |
49 | return SendPost(ArgsToString(api));
50 | }
51 |
52 | ///
53 | /// 对象转换成字符串
54 | ///
55 | /// Dictionary对象
56 | ///
57 | protected string ArgsToString(IEnumerable> args)
58 | {
59 | var sb = new StringBuilder();
60 | foreach (var item in args)
61 | {
62 | if (sb.Length != 0) sb.Append('&');
63 | sb.Append(string.Format("{0}={1}", item.Key, item.Value));
64 | }
65 | return sb.ToString();
66 | }
67 |
68 | ///
69 | /// 发送表单并得到返回的字符串数据
70 | ///
71 | ///
72 | ///
73 | protected string SendPost(string args)
74 | {
75 | var encoding = Encoding.GetEncoding(UcConfig.UcCharset);
76 | var data = encoding.GetBytes(args);
77 | var request = getPostRequest(data);
78 | return getStr(request).Trim();
79 | }
80 |
81 | ///
82 | /// 发送Get
83 | ///
84 | /// 地址
85 | /// 参数
86 | ///
87 | protected string SendGet(string url,IEnumerable> args)
88 | {
89 | var request = getGetRequest(url + "?" + ArgsToString(args));
90 | return getStr(request).Trim();
91 | }
92 |
93 | ///
94 | /// 处理Response对象,并得到字符串
95 | ///
96 | ///
97 | ///
98 | private string getStr(WebRequest request)
99 | {
100 | try
101 | {
102 | using (var response = (HttpWebResponse)request.GetResponse())
103 | {
104 | if (response == null || response.StatusCode != HttpStatusCode.OK) return "";
105 | using (var stream = response.GetResponseStream())
106 | {
107 | if (stream == null) return "";
108 | using (var reader = new StreamReader(stream, Encoding.GetEncoding(UcConfig.UcCharset)))
109 | {
110 | return reader.ReadToEnd();
111 | }
112 | }
113 | }
114 | }
115 | catch
116 | {
117 | return "";
118 | }
119 | }
120 |
121 | ///
122 | /// 得到Requset对象
123 | ///
124 | /// 地址
125 | ///
126 | private HttpWebRequest getGetRequest(string url)
127 | {
128 | var request = (HttpWebRequest)WebRequest.Create(url);
129 | request.UserAgent = GetUserAgent();
130 | request.Headers.Add(HttpRequestHeader.AcceptLanguage, "zh-cn");
131 | request.Method = "GET";
132 | return request;
133 | }
134 |
135 | ///
136 | /// 得到Requset对象
137 | ///
138 | /// POST数据
139 | ///
140 | private HttpWebRequest getPostRequest(byte[] data)
141 | {
142 | var request = (HttpWebRequest)WebRequest.Create(GetUrl());
143 | request.UserAgent = GetUserAgent();
144 | request.Headers.Add(HttpRequestHeader.AcceptLanguage, "zh-cn");
145 | request.Method = "POST";
146 | request.ContentType = "application/x-www-form-urlencoded";
147 | request.ContentLength = data.Length;
148 |
149 | var newStream = request.GetRequestStream();
150 | newStream.Write(data, 0, data.Length);
151 | newStream.Close();
152 |
153 | return request;
154 | }
155 |
156 | ///
157 | /// 得到 Url
158 | ///
159 | ///
160 | protected virtual string GetUrl()
161 | {
162 | return UcConfig.UcApi + "index.php";
163 | }
164 |
165 | ///
166 | /// 得到 UserAgent 字符串
167 | ///
168 | ///
169 | protected virtual string GetUserAgent()
170 | {
171 | return UcUtility.GetUserAgent();
172 | }
173 | }
174 | }
175 |
--------------------------------------------------------------------------------
/src/DS.Web.UCenter/Client/UcModelName.cs:
--------------------------------------------------------------------------------
1 | namespace DS.Web.UCenter.Client
2 | {
3 | ///
4 | /// Dozer 版权所有
5 | /// 允许复制、修改,但请保留我的联系方式!
6 | /// http://www.dozer.cc
7 | /// mailto:dozer.cc@gmail.com
8 | ///
9 | static internal class UcUserModelName
10 | {
11 | static public string ModelName { get { return "user"; } }
12 | static public string ActionRegister { get { return "register"; } }
13 | static public string ActionLogin { get { return "login"; } }
14 | static public string ActionInfo { get { return "get_user"; } }
15 | static public string ActionEdit { get { return "edit"; } }
16 | static public string ActionDelete { get { return "delete"; } }
17 | static public string ActionDeleteAvatar { get { return "deleteavatar"; } }
18 | static public string ActionSynLogin { get { return "synlogin"; } }
19 | static public string ActionSynLogout { get { return "synlogout"; } }
20 | static public string ActionCheckEmail { get { return "check_email"; } }
21 | static public string ActionAddProtected { get { return "addprotected"; } }
22 | static public string ActionDeleteProtected { get { return "deleteprotected"; } }
23 | static public string ActionGetProtected { get { return "getprotected"; } }
24 | static public string ActionMerge { get { return "merge"; } }
25 | static public string ActionMergeRemove { get { return "merge_remove"; } }
26 | static public string ActionGetCredit { get { return "getcredit"; } }
27 | }
28 |
29 | static internal class UcPmModelName
30 | {
31 | static public string ModelName { get { return "pm"; } }
32 | static public string ActionCheckNew { get { return "check_newpm"; } }
33 | static public string ActionSend { get { return "sendpm"; } }
34 | static public string ActionDelete { get { return "delete"; } }
35 | static public string ActionDeleteUser { get { return "deleteuser"; } }
36 | static public string ActionReadStatus { get { return "readstatus"; } }
37 | static public string ActionList { get { return "ls"; } }
38 | static public string ActionView { get { return "view"; } }
39 | static public string ActionViewNode { get { return "viewnode"; } }
40 | static public string ActionIgnore { get { return "ignore"; } }
41 | static public string ActionBlacklsGet { get { return "blackls_get"; } }
42 | static public string ActionBlacklsSet { get { return "blackls_set"; } }
43 | static public string ActionBlacklsAdd { get { return "blackls_add"; } }
44 | static public string ActionBlacklsDelete { get { return "blackls_delete"; } }
45 | }
46 |
47 | static internal class UcFriendModelName
48 | {
49 | static public string ModelName { get { return "friend"; } }
50 | static public string ActionAdd { get { return "add"; } }
51 | static public string ActionDelete { get { return "delete"; } }
52 | static public string ActionTotalNum { get { return "totalnum"; } }
53 | static public string ActionList { get { return "ls"; } }
54 | }
55 |
56 | static internal class UcCreditModelName
57 | {
58 | static public string ModelName { get { return "credit"; } }
59 | static public string ActionExchangeRequest { get { return "request"; } }
60 | }
61 |
62 | static internal class UcTagModelName
63 | {
64 | static public string ModelName { get { return "tag"; } }
65 | static public string ActionGet { get { return "gettag"; } }
66 | }
67 |
68 | static internal class UcFeedModelName
69 | {
70 | static public string ModelName { get { return "feed"; } }
71 | static public string ActionAdd { get { return "add"; } }
72 | static public string ActionGet { get { return "get"; } }
73 | }
74 |
75 | static internal class UcAppModelName
76 | {
77 | static public string ModelName { get { return "app"; } }
78 | static public string ActionList { get { return "ls"; } }
79 | }
80 |
81 | static internal class UcMailModelName
82 | {
83 | static public string ModelName { get { return "mail"; } }
84 | static public string ActionAdd { get { return "add"; } }
85 |
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/src/DS.Web.UCenter/DS.Web.UCenter.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | 8.0.30703
7 | 2.0
8 | {50E9578D-EF71-4E28-9BC3-D61E7E26C391}
9 | Library
10 | Properties
11 | DS.Web.UCenter
12 | DS.Web.UCenter
13 | v3.5
14 | 512
15 |
16 |
17 |
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 | bin\Debug\DS.Web.UCenter.XML
26 | false
27 |
28 |
29 | pdbonly
30 | true
31 | bin\Release\
32 | TRACE
33 | prompt
34 | 4
35 | bin\Release\DS.Web.UCenter.XML
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 | Designer
102 |
103 |
104 |
105 |
106 |
113 |
--------------------------------------------------------------------------------
/src/DS.Web.UCenter/Model/CollectionReceive/UcApps.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace DS.Web.UCenter
4 | {
5 | ///
6 | /// 应用程序集合
7 | ///
8 | public class UcApps : UcCollectionReceiveBase
9 | {
10 | ///
11 | /// 构造函数
12 | ///
13 | /// 数据
14 | public UcApps(string xml)
15 | : base(xml)
16 | {
17 | }
18 |
19 | private IList _items;
20 | ///
21 | /// 集合
22 | ///
23 | public IList Items { get { return _items ?? (_items = new List()); } }
24 |
25 | ///
26 | /// 设置属性
27 | ///
28 | protected override void SetProperty()
29 | {
30 | SetItems(Items);
31 | }
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/src/DS.Web.UCenter/Model/CollectionReceive/UcBadWords.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace DS.Web.UCenter
5 | {
6 | ///
7 | /// 不良词汇集合
8 | ///
9 | public class UcBadWords : UcCollectionReceiveBase
10 | {
11 | ///
12 | /// 构造函数
13 | ///
14 | /// 数据
15 | public UcBadWords(string xml)
16 | : base(xml)
17 | {
18 | }
19 |
20 | private IList _items;
21 | ///
22 | /// 集合
23 | ///
24 | public IList Items { get { return _items ?? (_items = new List()); } }
25 |
26 | ///
27 | /// 设置属性
28 | ///
29 | protected override void SetProperty()
30 | {
31 | SetItems(Items);
32 | }
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/src/DS.Web.UCenter/Model/CollectionReceive/UcCreditSettings.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace DS.Web.UCenter
5 | {
6 | ///
7 | /// 积分设置集合
8 | ///
9 | public class UcCreditSettings : UcCollectionReceiveBase
10 | {
11 | ///
12 | /// 构造函数
13 | ///
14 | /// 数据
15 | public UcCreditSettings(string xml)
16 | : base(xml)
17 | {
18 | }
19 |
20 | private IList _items;
21 | ///
22 | /// 集合
23 | ///
24 | public IList Items { get { return _items ?? (_items = new List()); } }
25 |
26 | ///
27 | /// 设置属性
28 | ///
29 | protected override void SetProperty()
30 | {
31 | SetItems(Items);
32 | }
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/src/DS.Web.UCenter/Model/CollectionReceive/UcFeeds.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Collections;
4 |
5 | namespace DS.Web.UCenter
6 | {
7 | ///
8 | /// Feed集合
9 | ///
10 | public class UcFeeds : UcCollectionReceiveBase
11 | {
12 | ///
13 | /// 构造函数
14 | ///
15 | /// 数据
16 | public UcFeeds(string xml)
17 | : base(xml)
18 | {
19 | }
20 |
21 | private IList _items;
22 | ///
23 | /// 集合
24 | ///
25 | public IList Items { get { return _items ?? (_items = new List()); } }
26 | ///
27 | /// 总数
28 | ///
29 | public int Type { get; private set; }
30 |
31 | ///
32 | /// 设置属性
33 | ///
34 | protected override void SetProperty()
35 | {
36 | SetItems(Items, Data);
37 | }
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/src/DS.Web.UCenter/Model/CollectionReceive/UcFriends.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Collections;
4 |
5 | namespace DS.Web.UCenter
6 | {
7 | ///
8 | /// 短消息集合
9 | ///
10 | public class UcFriends : UcCollectionReceiveBase
11 | {
12 | ///
13 | /// 构造函数
14 | ///
15 | /// 数据
16 | public UcFriends(string xml)
17 | : base(xml)
18 | {
19 | }
20 |
21 | private IList _items;
22 | ///
23 | /// 集合
24 | ///
25 | public IList Items { get { return _items ?? (_items = new List()); } }
26 |
27 | ///
28 | /// 设置属性
29 | ///
30 | protected override void SetProperty()
31 | {
32 | SetItems(Items, Data);
33 | }
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/src/DS.Web.UCenter/Model/CollectionReceive/UcHosts.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace DS.Web.UCenter
5 | {
6 | ///
7 | /// Host集合
8 | ///
9 | public class UcHosts : UcCollectionReceiveBase
10 | {
11 | ///
12 | /// 构造函数
13 | ///
14 | /// 数据
15 | public UcHosts(string xml)
16 | : base(xml)
17 | {
18 | }
19 |
20 | private IList _items;
21 | ///
22 | /// 集合
23 | ///
24 | public IList Items { get { return _items ?? (_items = new List()); } }
25 |
26 | ///
27 | /// 设置属性
28 | ///
29 | protected override void SetProperty()
30 | {
31 | SetItems(Items);
32 | }
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/src/DS.Web.UCenter/Model/CollectionReceive/UcPmList.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Collections;
4 |
5 | namespace DS.Web.UCenter
6 | {
7 | ///
8 | /// 短消息集合
9 | ///
10 | public class UcPmList : UcCollectionReceiveBase
11 | {
12 | ///
13 | /// 构造函数
14 | ///
15 | /// 数据
16 | public UcPmList(string xml)
17 | : base(xml)
18 | {
19 | }
20 |
21 | private IList _items;
22 | ///
23 | /// 集合
24 | ///
25 | public IList Items { get { return _items ?? (_items = new List()); } }
26 | ///
27 | /// 总数
28 | ///
29 | public int Count { get; private set; }
30 |
31 | ///
32 | /// 设置属性
33 | ///
34 | protected override void SetProperty()
35 | {
36 | SetItems(Items, (Hashtable)Data["data"]);
37 | Count = Data.GetInt("count");
38 | }
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/src/DS.Web.UCenter/Model/CollectionReceive/UcPmView.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Collections;
4 |
5 | namespace DS.Web.UCenter
6 | {
7 | ///
8 | /// 短消息集合
9 | ///
10 | public class UcPmView : UcCollectionReceiveBase
11 | {
12 | ///
13 | /// 构造函数
14 | ///
15 | /// 数据
16 | public UcPmView(string xml)
17 | : base(xml)
18 | {
19 | }
20 |
21 | private IList _items;
22 | ///
23 | /// 集合
24 | ///
25 | public IList Items { get { return _items ?? (_items = new List()); } }
26 |
27 |
28 | ///
29 | /// 设置属性
30 | ///
31 | protected override void SetProperty()
32 | {
33 | SetItems(Items, Data);
34 | }
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/src/DS.Web.UCenter/Model/CollectionReceive/UcTags.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Collections;
4 |
5 | namespace DS.Web.UCenter
6 | {
7 | ///
8 | /// 短消息集合
9 | ///
10 | public class UcTags : UcCollectionReceiveBase
11 | {
12 | ///
13 | /// 构造函数
14 | ///
15 | /// 数据
16 | public UcTags(string xml)
17 | : base(xml)
18 | {
19 | }
20 |
21 | private IList _items;
22 | ///
23 | /// 集合
24 | ///
25 | public IList Items { get { return _items ?? (_items = new List()); } }
26 | ///
27 | /// 总数
28 | ///
29 | public int Type { get; private set; }
30 |
31 | ///
32 | /// 设置属性
33 | ///
34 | protected override void SetProperty()
35 | {
36 | SetItems(Items, (Hashtable)Data["data"]);
37 | Type = Data.GetInt("type");
38 | }
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/src/DS.Web.UCenter/Model/CollectionReceive/UcUserProtecteds.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace DS.Web.UCenter
5 | {
6 | ///
7 | /// 受保护用户集合
8 | ///
9 | public class UcUserProtecteds : UcCollectionReceiveBase
10 | {
11 | ///
12 | /// 构造函数
13 | ///
14 | /// 数据
15 | public UcUserProtecteds(string xml)
16 | : base(xml)
17 | {
18 | }
19 |
20 | private IList _items;
21 | ///
22 | /// 集合
23 | ///
24 | public IList Items { get { return _items ?? (_items = new List()); } }
25 |
26 | ///
27 | /// 设置属性
28 | ///
29 | protected override void SetProperty()
30 | {
31 | SetItems(Items);
32 | }
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/src/DS.Web.UCenter/Model/CollectionReturn/UcCreditSettingReturns.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace DS.Web.UCenter
6 | {
7 | ///
8 | /// 积分设置集合
9 | ///
10 | public class UcCreditSettingReturns : UcCollectionReturnBase
11 | {
12 | ///
13 | /// 构造函数
14 | ///
15 | /// 集合
16 | public UcCreditSettingReturns(params UcCreditSettingReturn[] ucCreditSetting)
17 | {
18 | AddToList(Items, ucCreditSetting);
19 | }
20 |
21 | private IList _items;
22 | ///
23 | /// 集合
24 | ///
25 | public IList Items { get { return _items ?? (_items = new List()); } }
26 |
27 | ///
28 | /// 设置属性
29 | ///
30 | protected override void SetItems()
31 | {
32 | var index = 0;
33 | foreach(var item in Items)
34 | {
35 | Data.Add(index++, item);
36 | }
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/DS.Web.UCenter/Model/CollectionReturn/UcTagReturns.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace DS.Web.UCenter
6 | {
7 | ///
8 | /// Tag集合
9 | ///
10 | public class UcTagReturns : UcCollectionReturnBase
11 | {
12 | ///
13 | /// 构造函数
14 | ///
15 | /// Tag名字
16 | /// 集合
17 | public UcTagReturns(string tagName, params UcTagReturn[] ucTagReturn)
18 | {
19 | AddToList(Items, ucTagReturn);
20 | TagName = tagName;
21 | }
22 |
23 | private IList _items;
24 | ///
25 | /// 集合
26 | ///
27 | public IList Items { get { return _items ?? (_items = new List()); } }
28 | ///
29 | /// Tag名字
30 | ///
31 | public string TagName { get; set; }
32 |
33 | ///
34 | /// 设置属性
35 | ///
36 | protected override void SetItems()
37 | {
38 | Data.Add("0",TagName);
39 | var index = 1;
40 | foreach(var item in Items)
41 | {
42 | Data.Add(index++, item);
43 | }
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/DS.Web.UCenter/Model/IDictionaryExtension.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 |
4 | namespace DS.Web.UCenter
5 | {
6 | ///
7 | /// Dozer 版权所有
8 | /// 允许复制、修改,但请保留我的联系方式!
9 | /// http://www.dozer.cc
10 | /// mailto:dozer.cc@gmail.com
11 | ///
12 | static class DictionaryExtension
13 | {
14 |
15 | ///
16 | /// 得到Int
17 | ///
18 | ///
19 | ///
20 | ///
21 | static public int GetInt(this IDictionary data, string key)
22 | {
23 | var result = default(int);
24 | if (data != null) if (data.Contains(key)) int.TryParse(data[key].ToString(), out result);
25 | return result;
26 | }
27 |
28 |
29 | ///
30 | /// 得到String
31 | ///
32 | ///
33 | ///
34 | ///
35 | static public string GetString(this IDictionary data, string key)
36 | {
37 | var result = string.Empty;
38 | if (data != null) if (data.Contains(key)) result = data[key].ToString();
39 | return result;
40 | }
41 |
42 |
43 | ///
44 | /// 得到Bool
45 | ///
46 | ///
47 | ///
48 | ///
49 | ///
50 | static public bool GetBool(this IDictionary data, string key, string compare = "1")
51 | {
52 | var result = default(bool);
53 | if (data != null) if (data.Contains(key)) result = (data[key].ToString() == compare);
54 | return result;
55 | }
56 |
57 |
58 | ///
59 | /// 得到DateTime
60 | ///
61 | ///
62 | ///
63 | ///
64 | static public DateTime GetDateTime(this IDictionary data, string key)
65 | {
66 | var result = default(DateTime);
67 | if (data != null) if (data.Contains(key)) result = UcUtility.PhpTimeToDateTime(long.Parse(data[key].ToString()));
68 | return result;
69 | }
70 |
71 |
72 | ///
73 | /// 得到Double
74 | ///
75 | ///
76 | ///
77 | ///
78 | static public double GetDouble(this IDictionary data, string key)
79 | {
80 | var result = default(double);
81 | if (data != null) if (data.Contains(key)) double.TryParse(data[key].ToString(), out result);
82 | return result;
83 | }
84 |
85 |
86 | ///
87 | /// 得到Hashtable
88 | ///
89 | ///
90 | ///
91 | ///
92 | static public Hashtable GetHashtable(this IDictionary data, string key)
93 | {
94 | var result = default(Hashtable);
95 | if (data != null) if (data.Contains(key)) if (data[key] is Hashtable) result = (Hashtable)data[key];
96 | return result;
97 | }
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/src/DS.Web.UCenter/Model/ItemReceive/UcApp.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Xml;
4 | using System.Collections;
5 |
6 | namespace DS.Web.UCenter
7 | {
8 | ///
9 | /// 应用Model
10 | ///
11 | public class UcApp : UcItemReceiveBase
12 | {
13 | ///
14 | /// 构造函数
15 | ///
16 | /// 数据
17 | public UcApp(string xml)
18 | : base(xml)
19 | {}
20 | ///
21 | /// 构造函数
22 | ///
23 | /// 数据
24 | public UcApp(XmlNode xml)
25 | : base(xml)
26 | { }
27 |
28 | ///
29 | /// AppId
30 | ///
31 | public int AppId { get; set; }
32 | ///
33 | /// 类型
34 | ///
35 | public string TypeName { get; set; }
36 | ///
37 | /// 名称
38 | ///
39 | public string Name { get; set; }
40 | ///
41 | /// 地址
42 | ///
43 | public string Url { get; set; }
44 | ///
45 | /// Ip
46 | ///
47 | public string Ip { get; set; }
48 | ///
49 | /// 其他地址
50 | ///
51 | public string ViewProUrl { get; set; }
52 | ///
53 | /// 接口名称
54 | ///
55 | public string ApiFileName { get; set; }
56 | ///
57 | /// 字符集
58 | ///
59 | public string CharSet { get; set; }
60 | ///
61 | /// 是否同步登陆
62 | ///
63 | public bool SynLogin { get; set; }
64 | private IDictionary _extra;
65 | ///
66 | /// 附加信息
67 | ///
68 | public IDictionary Extra { get { return _extra ?? (_extra = new Dictionary()); } }
69 | ///
70 | /// 传输信息
71 | ///
72 | public string RecvNote { get; set; }
73 |
74 | ///
75 | /// 设置属性
76 | ///
77 | protected override void SetProperty()
78 | {
79 | AppId = Data.GetInt("appid");
80 | TypeName = Data.GetString("type");
81 | Name = Data.GetString("name");
82 | Url = Data.GetString("url");
83 | Ip = Data.GetString("ip");
84 | ViewProUrl = Data.GetString("viewprourl");
85 | ApiFileName = Data.GetString("apifilename");
86 | CharSet = Data.GetString("charset");
87 | SynLogin = Data.GetBool("synlogin");
88 | Extra.Add("apppath", Data.GetHashtable("extra").GetString("apppath"));
89 | RecvNote = Data.GetString("recvnote");
90 | CheckForSuccess("appid");
91 | }
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/src/DS.Web.UCenter/Model/ItemReceive/UcBadWord.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Xml;
3 |
4 | namespace DS.Web.UCenter
5 | {
6 | ///
7 | /// 不良词语Model
8 | ///
9 | public class UcBadWord : UcItemReceiveBase
10 | {
11 | ///
12 | /// 构造函数
13 | ///
14 | /// 数据
15 | public UcBadWord(string xml)
16 | : base(xml)
17 | { }
18 | ///
19 | /// 构造函数
20 | ///
21 | /// 数据
22 | public UcBadWord(XmlNode xml)
23 | : base(xml)
24 | { }
25 |
26 | ///
27 | /// Id
28 | ///
29 | public int Id { get; set; }
30 | ///
31 | /// 添加人
32 | ///
33 | public string Admin { get; set; }
34 | ///
35 | /// 查找字符串
36 | ///
37 | public string Find { get; set; }
38 | ///
39 | /// 替换字符串
40 | ///
41 | public string Replacement { get; set; }
42 |
43 | ///
44 | /// 设置属性
45 | ///
46 | protected override void SetProperty()
47 | {
48 | Id = Data.GetInt("id");
49 | Admin = Data.GetString("admin");
50 | Find = Data.GetString("find");
51 | Replacement = Data.GetString("replacement");
52 | CheckForSuccess("id");
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/src/DS.Web.UCenter/Model/ItemReceive/UcClientSetting.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Xml;
3 |
4 | namespace DS.Web.UCenter
5 | {
6 | ///
7 | /// 积分设置Model
8 | ///
9 | public class UcClientSetting : UcItemReceiveBase
10 | {
11 | ///
12 | /// 构造函数
13 | ///
14 | /// 数据
15 | public UcClientSetting(string xml)
16 | : base(xml)
17 | { }
18 | ///
19 | /// 构造函数
20 | ///
21 | /// 数据
22 | public UcClientSetting(XmlNode xml)
23 | : base(xml)
24 | { }
25 |
26 | ///
27 | ///
28 | ///
29 | public string AccessEmail { get; set; }
30 | ///
31 | ///
32 | ///
33 | public string CensorEmail { get; set; }
34 | ///
35 | ///
36 | ///
37 | public string CensoruserName { get; set; }
38 | ///
39 | /// 时间格式
40 | ///
41 | public string DateFormat { get; set; }
42 | ///
43 | ///
44 | ///
45 | public bool Doublee { get; set; }
46 | ///
47 | /// 时区(秒)
48 | ///
49 | public int TimeoffSet { get; set; }
50 | ///
51 | /// 每日短消息限制
52 | ///
53 | public int PmLimit1Day { get; set; }
54 | ///
55 | /// 短信间隔时间
56 | ///
57 | public int PmFloodCtrl { get; set; }
58 | ///
59 | /// 启用短消息中心
60 | ///
61 | public bool PmCenter { get; set; }
62 | ///
63 | /// 启用短信验证码
64 | ///
65 | public bool SendPmSeccode { get; set; }
66 | ///
67 | /// 发短消息最少注册天数
68 | ///
69 | public int PmSendRegDays { get; set; }
70 | ///
71 | /// 邮件来源地址
72 | ///
73 | public string MailDefault { get; set; }
74 | ///
75 | /// 邮件发送方式
76 | ///
77 | public string MailSend { get; set; }
78 | ///
79 | /// SMTP 服务器
80 | ///
81 | public string MailServer { get; set; }
82 | ///
83 | /// SMTP 端口
84 | ///
85 | public int MailPort { get; set; }
86 | ///
87 | /// SMTP 服务器要求身份验证
88 | ///
89 | public string MailAuth { get; set; }
90 | ///
91 | /// 发信人邮件地址
92 | ///
93 | public string MailFrom { get; set; }
94 | ///
95 | /// SMTP 身份验证用户名
96 | ///
97 | public string MailAuthUserName { get; set; }
98 | ///
99 | /// SMTP 身份验证密码
100 | ///
101 | public string MailAuthPassWord { get; set; }
102 | ///
103 | /// 邮件分隔符
104 | ///
105 | public string MailDelimiter { get; set; }
106 | ///
107 | /// 收件人地址中包含用户名
108 | ///
109 | public string MailUserName { get; set; }
110 | ///
111 | /// 屏蔽邮件发送中的全部错误提示
112 | ///
113 | public string MailSilent { get; set; }
114 | ///
115 | /// 12/24小时
116 | ///
117 | public string TimeFormat { get; set; }
118 |
119 | ///
120 | /// 设置属性
121 | ///
122 | protected override void SetProperty()
123 | {
124 | AccessEmail = Data.GetString("accessemail");
125 | CensorEmail = Data.GetString("censoremail");
126 | CensoruserName = Data.GetString("censorusername");
127 | DateFormat = Data.GetString("dateformat");
128 | Doublee = Data.GetBool("doublee");
129 | TimeoffSet = Data.GetInt("timeoffset");
130 | PmLimit1Day = Data.GetInt("pmlimit1day");
131 | PmFloodCtrl = Data.GetInt("pmfloodctrl");
132 | PmCenter = Data.GetBool("pmcenter");
133 | SendPmSeccode = Data.GetBool("sendpmseccode");
134 | PmSendRegDays = Data.GetInt("pmsendregdays");
135 | MailDefault = Data.GetString("maildefault");
136 | MailSend = Data.GetString("mailsend");
137 | MailServer = Data.GetString("mailserver");
138 | MailPort = Data.GetInt("mailport");
139 | MailAuth = Data.GetString("mailauth");
140 | MailFrom = Data.GetString("mailfrom");
141 | MailAuthUserName = Data.GetString("mailauth_username");
142 | MailAuthPassWord = Data.GetString("mailauth_password");
143 | MailDelimiter = Data.GetString("maildelimiter");
144 | MailUserName = Data.GetString("mailusername");
145 | MailSilent = Data.GetString("mailsilent");
146 | TimeFormat = Data.GetString("timeformat");
147 | }
148 | }
149 | }
150 |
--------------------------------------------------------------------------------
/src/DS.Web.UCenter/Model/ItemReceive/UcCreditSetting.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Xml;
3 |
4 | namespace DS.Web.UCenter
5 | {
6 | ///
7 | /// 积分设置Model
8 | ///
9 | public class UcCreditSetting : UcItemReceiveBase
10 | {
11 | ///
12 | /// 构造函数
13 | ///
14 | /// 数据
15 | public UcCreditSetting(string xml)
16 | : base(xml)
17 | { }
18 | ///
19 | /// 构造函数
20 | ///
21 | /// 数据
22 | public UcCreditSetting(XmlNode xml)
23 | : base(xml)
24 | { }
25 |
26 | ///
27 | /// 积分兑换的目标应用程序 ID
28 | ///
29 | public int AppIdDesc { get; set; }
30 | ///
31 | /// 积分兑换的目标积分编号
32 | ///
33 | public int CreditDesc { get; set; }
34 | ///
35 | /// 积分兑换的源积分编号
36 | ///
37 | public int CreditSrce { get; set; }
38 | ///
39 | /// 积分名称
40 | ///
41 | public string Title { get; set; }
42 | ///
43 | /// 积分单位
44 | ///
45 | public string Unit { get; set; }
46 | ///
47 | /// 积分兑换比率
48 | ///
49 | public double Ratio { get; set; }
50 |
51 | ///
52 | /// 设置属性
53 | ///
54 | protected override void SetProperty()
55 | {
56 | AppIdDesc = Data.GetInt("appiddesc");
57 | CreditDesc = Data.GetInt("creditdesc");
58 | CreditSrce = Data.GetInt("creditsrc");
59 | Title = Data.GetString("title");
60 | Unit = Data.GetString("unit");
61 | Ratio = Data.GetDouble("ratio");
62 | CheckForSuccess("appiddesc");
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/src/DS.Web.UCenter/Model/ItemReceive/UcFeed.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Xml;
4 |
5 | namespace DS.Web.UCenter
6 | {
7 | ///
8 | /// FeedModel
9 | ///
10 | public class UcFeed : UcItemReceiveBase
11 | {
12 | ///
13 | /// 构造函数
14 | ///
15 | /// 数据
16 | public UcFeed(string xml)
17 | : base(xml)
18 | {}
19 | ///
20 | /// 构造函数
21 | ///
22 | /// 数据
23 | public UcFeed(XmlNode xml)
24 | : base(xml)
25 | { }
26 |
27 | ///
28 | /// 事件的 ID
29 | ///
30 | public int FeedId { get; set; }
31 | ///
32 | /// 所在应用的 ID
33 | ///
34 | public int AppId { get; set; }
35 | ///
36 | /// 事件的图标 thread、poll、reward 等
37 | ///
38 | public FeedIcon Icon { get; set; }
39 | ///
40 | /// 事件的发起人的用户 ID
41 | ///
42 | public int Uid { get; set; }
43 | ///
44 | /// 发起人的用户名
45 | ///
46 | public string UserName { get; set; }
47 | ///
48 | /// 时间
49 | ///
50 | public DateTime Time { get; set; }
51 | ///
52 | /// 模板的 Hash 值,用来相同类型事件的合并,32位字符串,如:c95dbd9aa75862c841b627e1e9598fd5
53 | ///
54 | public string HashTemplate { get; set; }
55 | ///
56 | /// 数据的 Hash 值,用来相同类型事件的合并,32位字符串,如:c95dbd9aa75862c841b627e1e9598fd5
57 | ///
58 | public string HashData { get; set; }
59 | ///
60 | /// 标题模板
61 | ///
62 | public string TitleTemplate { get; set; }
63 | ///
64 | /// 标题数据
65 | ///
66 | public string TitleData { get; set; }
67 | ///
68 | /// 内容模板
69 | ///
70 | public string BodyTemplate { get; set; }
71 | ///
72 | /// 事件内容 HTML 格式,用 {xxx} 格式字符表示变量,如 {username}
73 | ///
74 | public string BodyData { get; set; }
75 | ///
76 | /// 保留
77 | ///
78 | public string BodyGeneral { get; set; }
79 | ///
80 | /// 图片链接对应图片地址
81 | ///
82 | private IDictionary _images;
83 | ///
84 | /// 图片链接对应图片地址
85 | ///
86 | public IDictionary Images { get { return _images ?? (_images = new Dictionary()); } }
87 | ///
88 | /// 设置属性
89 | ///
90 | protected override void SetProperty()
91 | {
92 | FeedId = Data.GetInt("feedid");
93 | AppId = Data.GetInt("appid");
94 | var icon = Data.GetString("icon");
95 | icon = icon[0].ToString().ToUpper() + icon.Substring(1);
96 | Icon = (FeedIcon) Enum.Parse(typeof (FeedIcon), icon);
97 | Uid = Data.GetInt("uid");
98 | UserName = Data.GetString("username");
99 | Time = Data.GetDateTime("dateline");
100 | HashTemplate = Data.GetString("hash_template");
101 | HashData = Data.GetString("hash_data");
102 | TitleTemplate= Data.GetString("title_template");
103 | TitleData = Data.GetString("title_data");
104 | BodyTemplate = Data.GetString("body_template");
105 | BodyData = Data.GetString("body_data");
106 | BodyGeneral = Data.GetString("body_general");
107 | GetImages();
108 |
109 | CheckForSuccess("feedid");
110 | }
111 |
112 | ///
113 | /// 设置图片
114 | ///
115 | private void GetImages()
116 | {
117 | var index = 1;
118 | while (true)
119 | {
120 | var url = Data.GetString("image_" + index);
121 | var link = Data.GetString("image_" + index++ + "_link");
122 | if (string.IsNullOrEmpty(url) || string.IsNullOrEmpty(link)) break;
123 | Images.Add(url, link);
124 | }
125 | }
126 | }
127 | }
128 |
--------------------------------------------------------------------------------
/src/DS.Web.UCenter/Model/ItemReceive/UcFriend.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Xml;
3 |
4 | namespace DS.Web.UCenter
5 | {
6 | ///
7 | /// 好友Model
8 | ///
9 | public class UcFriend : UcItemReceiveBase
10 | {
11 | ///
12 | /// 构造函数
13 | ///
14 | /// 数据
15 | public UcFriend(string xml)
16 | : base(xml)
17 | {}
18 | ///
19 | /// 构造函数
20 | ///
21 | /// 数据
22 | public UcFriend(XmlNode xml)
23 | : base(xml)
24 | {}
25 |
26 | ///
27 | /// 用户 ID
28 | ///
29 | public int Uid { get; set; }
30 | ///
31 | /// 好友用户 ID
32 | ///
33 | public int FriendId { get; set; }
34 | ///
35 | /// 方向
36 | ///
37 | public FriendDirection Direction { get; set; }
38 | ///
39 | /// 好友用户名
40 | ///
41 | public string UserName { get; set; }
42 |
43 | ///
44 | /// 设置属性
45 | ///
46 | protected override void SetProperty()
47 | {
48 | Uid = Data.GetInt("uid");
49 | FriendId = Data.GetInt("friendid");
50 | Direction = (FriendDirection)Data.GetInt("direction");
51 | UserName = Data.GetString("username");
52 | CheckForSuccess("uid", "friendid");
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/src/DS.Web.UCenter/Model/ItemReceive/UcHost.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Xml;
3 |
4 | namespace DS.Web.UCenter
5 | {
6 | ///
7 | /// HostModel
8 | ///
9 | public class UcHost : UcItemReceiveBase
10 | {
11 | ///
12 | /// 构造函数
13 | ///
14 | /// 数据
15 | public UcHost(string xml)
16 | : base(xml)
17 | { }
18 | ///
19 | /// 构造函数
20 | ///
21 | /// 数据
22 | public UcHost(XmlNode xml)
23 | : base(xml)
24 | { }
25 |
26 | ///
27 | /// Id
28 | ///
29 | public int Id { get; set; }
30 | ///
31 | /// 域名
32 | ///
33 | public string Domain { get; set; }
34 | ///
35 | /// Ip
36 | ///
37 | public string Ip { get; set; }
38 |
39 | ///
40 | /// 设置属性
41 | ///
42 | protected override void SetProperty()
43 | {
44 | Id = Data.GetInt("id");
45 | Domain = Data.GetString("domain");
46 | Ip = Data.GetString("ip");
47 | CheckForSuccess("id");
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/DS.Web.UCenter/Model/ItemReceive/UcMailQueue.cs:
--------------------------------------------------------------------------------
1 | using DS.Web.UCenter.Client;
2 |
3 | namespace DS.Web.UCenter
4 | {
5 | ///
6 | /// 邮件Model
7 | ///
8 | public class UcMailQueue
9 | {
10 | ///
11 | /// 修改结果
12 | ///
13 | public bool Result { get; private set; }
14 | ///
15 | /// 邮件Id
16 | ///
17 | public int MailId { get; private set; }
18 |
19 | ///
20 | /// 构造函数
21 | ///
22 | /// 数据
23 | public UcMailQueue(string xml)
24 | {
25 | int result;
26 | Result = false;
27 | if (!int.TryParse(xml, out result)) return;
28 | MailId = result;
29 | Result = true;
30 | }
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/src/DS.Web.UCenter/Model/ItemReceive/UcPm.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Xml;
3 |
4 | namespace DS.Web.UCenter
5 | {
6 | ///
7 | /// 短消息Model
8 | ///
9 | public class UcPm : UcItemReceiveBase
10 | {
11 | ///
12 | /// 构造函数
13 | ///
14 | /// 数据
15 | public UcPm(string xml)
16 | : base(xml)
17 | {}
18 | ///
19 | /// 构造函数
20 | ///
21 | /// 数据
22 | public UcPm(XmlNode xml)
23 | : base(xml)
24 | { }
25 |
26 | ///
27 | /// 短消息Id
28 | ///
29 | public int PmId { get; set; }
30 | ///
31 | /// 发件人
32 | ///
33 | public string MsgFrom { get; set; }
34 | ///
35 | /// 发件人Id
36 | ///
37 | public int MsgFromId { get; set; }
38 | ///
39 | /// 收件人Id
40 | ///
41 | public int MsgToId { get; set; }
42 | ///
43 | /// 是否未读
44 | ///
45 | public bool IsNew{ get; set; }
46 | ///
47 | /// 主题
48 | ///
49 | public string Subject { get; set; }
50 | ///
51 | /// 时间
52 | ///
53 | public DateTime Time { get; set; }
54 | ///
55 | /// 消息
56 | ///
57 | public string Message { get; set; }
58 |
59 | ///
60 | /// 设置属性
61 | ///
62 | protected override void SetProperty()
63 | {
64 | PmId = Data.GetInt("pmid");
65 | MsgFrom = Data.GetString("msgfrom");
66 | MsgFromId = Data.GetInt("msgfromid");
67 | MsgToId = Data.GetInt("msgtoid");
68 | IsNew = Data.GetBool("new");
69 | Subject = Data.GetString("subject");
70 | Time = Data.GetDateTime("dateline");
71 | Message = Data.GetString("message");
72 | CheckForSuccess("pmid");
73 | }
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/src/DS.Web.UCenter/Model/ItemReceive/UcPmBlacklsGet.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace DS.Web.UCenter
6 | {
7 | ///
8 | /// 黑名单Model
9 | ///
10 | public class UcPmBlacklsGet
11 | {
12 | ///
13 | /// 黑名单
14 | ///
15 | public string[] DeleteNumber { get; private set; }
16 |
17 | ///
18 | /// 构造函数
19 | ///
20 | /// 数据
21 | public UcPmBlacklsGet(string xml)
22 | {
23 | DeleteNumber = xml.Split(',');
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/DS.Web.UCenter/Model/ItemReceive/UcPmCheckNew.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Xml;
3 |
4 | namespace DS.Web.UCenter
5 | {
6 | ///
7 | /// 检查邮件 Model
8 | ///
9 | public class UcPmCheckNew:UcItemReceiveBase
10 | {
11 | ///
12 | /// 构造函数
13 | ///
14 | /// 数据
15 | public UcPmCheckNew(string xml)
16 | : base(xml)
17 | {}
18 | ///
19 | /// 构造函数
20 | ///
21 | /// 数据
22 | public UcPmCheckNew(XmlNode xml)
23 | : base(xml)
24 | { }
25 |
26 | ///
27 | /// 未读消息数
28 | ///
29 | public int NewPm { get; set; }
30 | ///
31 | /// 私人消息数
32 | ///
33 | public int NewProvatePm { get; set; }
34 | ///
35 | /// 公共消息数
36 | ///
37 | public int AnnouncePm { get; set; }
38 | ///
39 | /// 系统消息数
40 | ///
41 | public int SystemPm { get; set; }
42 | ///
43 | /// 最后消息时间
44 | ///
45 | public DateTime LastDate { get; set; }
46 | ///
47 | /// 最后消息发件人 ID
48 | ///
49 | public int LastMsgFromId { get; set; }
50 | ///
51 | /// 最后消息发件人用户名
52 | ///
53 | public string LastMsgFrom { get; set; }
54 | ///
55 | /// 最后消息内容
56 | ///
57 | public string LastMsg { get; set; }
58 |
59 | ///
60 | /// 设置属性
61 | ///
62 | protected override void SetProperty()
63 | {
64 | NewPm = Data.GetInt("newpm");
65 | NewProvatePm = Data.GetInt("newprivatepm");
66 | AnnouncePm = Data.GetInt("announcepm");
67 | SystemPm = Data.GetInt("systempm");
68 | LastDate = Data.GetDateTime("lastdate");
69 | LastMsgFromId = Data.GetInt("lastmsgfromid");
70 | LastMsgFrom = Data.GetString("lastmsgfrom");
71 | LastMsg = Data.GetString("lastmsg");
72 | CheckForSuccess("newpm");
73 | }
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/src/DS.Web.UCenter/Model/ItemReceive/UcPmSend.cs:
--------------------------------------------------------------------------------
1 | namespace DS.Web.UCenter
2 | {
3 | ///
4 | /// 短信发送Model
5 | ///
6 | public class UcPmSend
7 | {
8 | ///
9 | /// 短信Id
10 | ///
11 | public int PmId { get; private set; }
12 |
13 | ///
14 | /// 发送结果
15 | ///
16 | public PmSendResult Result
17 | {
18 | get { return PmId > 0 ? PmSendResult.Success : (PmSendResult)PmId; }
19 | }
20 |
21 | ///
22 | /// 构造函数
23 | ///
24 | /// 数据
25 | public UcPmSend(string xml)
26 | {
27 | var result = 0;
28 | int.TryParse(xml, out result);
29 | PmId = result;
30 | }
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/src/DS.Web.UCenter/Model/ItemReceive/UcTag.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 | using System.Xml;
3 |
4 | namespace DS.Web.UCenter
5 | {
6 | ///
7 | /// TagModel
8 | ///
9 | public class UcTag : UcItemReceiveBase
10 | {
11 | ///
12 | /// 构造函数
13 | ///
14 | /// 数据
15 | public UcTag(string xml)
16 | : base(xml)
17 | {}
18 | ///
19 | /// 构造函数
20 | ///
21 | /// 数据
22 | public UcTag(XmlNode xml)
23 | : base(xml)
24 | { }
25 |
26 | ///
27 | /// URL
28 | ///
29 | public string Url { get; set; }
30 | ///
31 | /// 标题
32 | ///
33 | public string Subject { get; set; }
34 | ///
35 | /// 扩展数据
36 | ///
37 | public IDictionary Extra { get; set; }
38 |
39 | ///
40 | /// 设置属性
41 | ///
42 | protected override void SetProperty()
43 | {
44 | Url = Data.GetString("url");
45 | Subject = Data.GetString("subject");
46 | Extra = Data.GetHashtable("extra");
47 | CheckForSuccess("url");
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/DS.Web.UCenter/Model/ItemReceive/UcUserCheckEmail.cs:
--------------------------------------------------------------------------------
1 | using System.Xml;
2 |
3 | namespace DS.Web.UCenter
4 | {
5 | ///
6 | /// 检查右键Model
7 | ///
8 | public class UcUserCheckEmail
9 | {
10 | ///
11 | /// 检查结果
12 | ///
13 | public UserCheckEmailResult Result { get;private set; }
14 | ///
15 | /// 构造函数
16 | ///
17 | /// 数据
18 | public UcUserCheckEmail(string xml)
19 | {
20 | var result = 0;
21 | int.TryParse(xml, out result);
22 | Result = (UserCheckEmailResult)result;
23 | }
24 | }
25 |
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/src/DS.Web.UCenter/Model/ItemReceive/UcUserEdit.cs:
--------------------------------------------------------------------------------
1 | using DS.Web.UCenter.Client;
2 |
3 | namespace DS.Web.UCenter
4 | {
5 | ///
6 | /// 用户修改Model
7 | ///
8 | public class UcUserEdit
9 | {
10 | ///
11 | /// 修改结果
12 | ///
13 | public UserEditResult Result { get; private set; }
14 |
15 | ///
16 | /// 构造函数
17 | ///
18 | /// 数据
19 | public UcUserEdit(string xml)
20 | {
21 | var result = 0;
22 | int.TryParse(xml, out result);
23 | Result = (UserEditResult)result;
24 | }
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/src/DS.Web.UCenter/Model/ItemReceive/UcUserInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Xml;
2 |
3 | namespace DS.Web.UCenter
4 | {
5 | ///
6 | /// 用户信息Model
7 | ///
8 | public class UcUserInfo:UcItemReceiveBase
9 | {
10 | ///
11 | /// 构造函数
12 | ///
13 | /// 数据
14 | public UcUserInfo(string xml)
15 | : base(xml)
16 | { }
17 | ///
18 | /// 构造函数
19 | ///
20 | /// 数据
21 | public UcUserInfo(XmlNode xml)
22 | : base(xml)
23 | { }
24 |
25 | ///
26 | /// Uid
27 | ///
28 | public int Uid { get; set; }
29 | ///
30 | /// 用户名
31 | ///
32 | public string UserName { get; set; }
33 | ///
34 | /// 邮箱
35 | ///
36 | public string Mail { get; set; }
37 |
38 | ///
39 | /// 设置属性
40 | ///
41 | protected override void SetProperty()
42 | {
43 | Uid = Data.GetInt("0");
44 | UserName = Data.GetString("1");
45 | Mail = Data.GetString("2");
46 | CheckForSuccess("0");
47 | }
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/src/DS.Web.UCenter/Model/ItemReceive/UcUserLogin.cs:
--------------------------------------------------------------------------------
1 | using System.Xml;
2 |
3 | namespace DS.Web.UCenter
4 | {
5 | ///
6 | /// 用户登陆Model
7 | ///
8 | public class UcUserLogin:UcItemReceiveBase
9 | {
10 | ///
11 | /// 构造函数
12 | ///
13 | /// 数据
14 | public UcUserLogin(string xml)
15 | : base(xml)
16 | { }
17 | ///
18 | /// 构造函数
19 | ///
20 | /// 数据
21 | public UcUserLogin(XmlNode xml)
22 | : base(xml)
23 | { }
24 |
25 | ///
26 | /// Uid
27 | ///
28 | public int Uid { get; set; }
29 | ///
30 | /// 用户名
31 | ///
32 | public string UserName { get; set; }
33 | ///
34 | /// 密码
35 | ///
36 | public string PassWord { get; set; }
37 | ///
38 | /// 邮箱
39 | ///
40 | public string Mail { get; set; }
41 | ///
42 | /// 是否有重复的名称
43 | ///
44 | public bool HasSameName { get; set; }
45 | ///
46 | /// 登陆结果
47 | ///
48 | public LoginResult Result
49 | {
50 | get { return Uid > 0 ? LoginResult.Success : (LoginResult) Uid; }
51 | }
52 |
53 | ///
54 | /// 设置属性
55 | ///
56 | protected override void SetProperty()
57 | {
58 | Uid = Data.GetInt("0");
59 | UserName = Data.GetString("1");
60 | PassWord = Data.GetString("2");
61 | Mail = Data.GetString("3");
62 | HasSameName = Data.GetBool("4");
63 | CheckForSuccess("0");
64 | }
65 | }
66 |
67 | }
68 |
--------------------------------------------------------------------------------
/src/DS.Web.UCenter/Model/ItemReceive/UcUserMerge.cs:
--------------------------------------------------------------------------------
1 | using DS.Web.UCenter.Client;
2 |
3 | namespace DS.Web.UCenter
4 | {
5 | ///
6 | /// 用户合并Model
7 | ///
8 | public class UcUserMerge
9 | {
10 | ///
11 | /// Uid
12 | ///
13 | public int Uid { get; private set; }
14 | ///
15 | /// 合并结果
16 | ///
17 | public UserMergeResult Result
18 | {
19 | get { return Uid > 0 ? UserMergeResult.Success : (UserMergeResult)Uid; }
20 | }
21 | ///
22 | /// 构造函数
23 | ///
24 | /// 数据
25 | public UcUserMerge(string xml)
26 | {
27 | var result = 0;
28 | int.TryParse(xml, out result);
29 | Uid = result;
30 | }
31 | }
32 |
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/src/DS.Web.UCenter/Model/ItemReceive/UcUserProtected.cs:
--------------------------------------------------------------------------------
1 | using System.Xml;
2 |
3 | namespace DS.Web.UCenter
4 | {
5 | ///
6 | /// 受保护用户Model
7 | ///
8 | public class UcUserProtected : UcItemReceiveBase
9 | {
10 | ///
11 | /// 构造函数
12 | ///
13 | /// 数据
14 | public UcUserProtected(string xml)
15 | : base(xml)
16 | { }
17 | ///
18 | /// 构造函数
19 | ///
20 | /// 数据
21 | public UcUserProtected(XmlNode xml)
22 | : base(xml)
23 | { }
24 |
25 | ///
26 | /// Uid
27 | ///
28 | public int Uid { get; set; }
29 | ///
30 | /// 用户名
31 | ///
32 | public string UserName { get; set; }
33 |
34 | ///
35 | /// 设置属性
36 | ///
37 | protected override void SetProperty()
38 | {
39 | Uid = Data.GetInt("uid");
40 | UserName = Data.GetString("username");
41 | CheckForSuccess("uid");
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/DS.Web.UCenter/Model/ItemReceive/UcUserRegister.cs:
--------------------------------------------------------------------------------
1 | namespace DS.Web.UCenter
2 | {
3 | ///
4 | /// 用户注册Model
5 | ///
6 | public class UcUserRegister
7 | {
8 | ///
9 | /// Uid
10 | ///
11 | public int Uid { get;private set; }
12 | ///
13 | /// 注册结果
14 | ///
15 | public RegisterResult Result
16 | {
17 | get { return Uid > 0 ? RegisterResult.Success : (RegisterResult)Uid; }
18 | }
19 | ///
20 | /// 构造函数
21 | ///
22 | /// 数据
23 | public UcUserRegister(string xml)
24 | {
25 | var result = 0;
26 | int.TryParse(xml, out result);
27 | Uid = result;
28 | }
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/src/DS.Web.UCenter/Model/ItemReturn/UcCreditSettingReturn.cs:
--------------------------------------------------------------------------------
1 | namespace DS.Web.UCenter
2 | {
3 | ///
4 | /// 积分设置Model
5 | ///
6 | public class UcCreditSettingReturn:UcItemReturnBase
7 | {
8 | ///
9 | /// 积分名字
10 | ///
11 | public string CreditName { get; set; }
12 | ///
13 | /// 积分单位
14 | ///
15 | public string CreditUnit { get; set; }
16 |
17 | ///
18 | /// 构造函数
19 | ///
20 | /// 积分名字
21 | /// 积分单位
22 | public UcCreditSettingReturn(string creditName, string creditUnit)
23 | {
24 | CreditName = creditName;
25 | CreditUnit = creditUnit;
26 | }
27 |
28 | ///
29 | /// 设置属性
30 | ///
31 | protected override void SetItems()
32 | {
33 | Data.Add("0", CreditName);
34 | Data.Add("1", CreditUnit);
35 | }
36 |
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/DS.Web.UCenter/Model/ItemReturn/UcTagReturn.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace DS.Web.UCenter
4 | {
5 | ///
6 | /// TagModel
7 | ///
8 | public class UcTagReturn : UcItemReturnBase
9 | {
10 | ///
11 | /// 主题
12 | ///
13 | public string Subject { get; set; }
14 | ///
15 | /// 作者ID
16 | ///
17 | public int AuthorId { get; set; }
18 | ///
19 | /// 作者
20 | ///
21 | public string Author { get; set; }
22 | ///
23 | /// 时间
24 | ///
25 | public DateTime Time { get; set; }
26 | ///
27 | /// 地址
28 | ///
29 | public string Url { get; set; }
30 | ///
31 | /// 图片
32 | ///
33 | public string Image { get; set; }
34 |
35 | ///
36 | /// 构造函数
37 | ///
38 | /// 主题
39 | /// 作者ID
40 | /// 作者
41 | /// 时间
42 | /// 地址
43 | /// 图片
44 | public UcTagReturn(string subject, int authorid, string author, DateTime time, string url, string image)
45 | {
46 | Subject = subject;
47 | AuthorId = authorid;
48 | Author = author;
49 | Time = time;
50 | Url = url;
51 | Image = image;
52 | }
53 |
54 | ///
55 | /// 设置属性
56 | ///
57 | protected override void SetItems()
58 | {
59 | Data.Add("name", Subject);
60 | Data.Add("uid", AuthorId);
61 | Data.Add("username", Author);
62 | Data.Add("dateline", Time);
63 | Data.Add("url", Url);
64 | Data.Add("image", Image);
65 | }
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/src/DS.Web.UCenter/Model/UcCollectionBase.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 |
3 | namespace DS.Web.UCenter
4 | {
5 | ///
6 | /// 集合基类
7 | ///
8 | public abstract class UcCollectionBase
9 | {
10 | private IDictionary _data;
11 | ///
12 | /// 数据
13 | ///
14 | protected IDictionary Data
15 | {
16 | get { return _data ?? (_data = new Hashtable()); }
17 | set { _data = value; }
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/DS.Web.UCenter/Model/UcCollectionReceiveBase.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Collections.Generic;
4 | using System.Xml;
5 |
6 | namespace DS.Web.UCenter
7 | {
8 | ///
9 | /// 集合基类
10 | /// Dozer 版权所有
11 | /// 允许复制、修改,但请保留我的联系方式!
12 | /// http://www.dozer.cc
13 | /// mailto:dozer.cc@gmail.com
14 | ///
15 | /// 项目
16 | /// 基类
17 | public abstract class UcCollectionReceiveBase : UcCollectionBase
18 | where T : UcItemReceiveBase
19 | where TThis : UcCollectionReceiveBase
20 | {
21 | ///
22 | /// 构造函数
23 | ///
24 | /// 数据
25 | protected UcCollectionReceiveBase(string xml)
26 | {
27 | initialize(xml);
28 | }
29 |
30 | ///
31 | /// 初始化
32 | ///
33 | /// 数据
34 | private void initialize(string xml)
35 | {
36 | try
37 | {
38 | unSerialize(xml);
39 | }
40 | catch { }
41 | finally
42 | {
43 | SetProperty();
44 | }
45 | }
46 |
47 |
48 | ///
49 | /// 反序列化
50 | ///
51 | /// XML
52 | ///
53 | private void unSerialize(string xml)
54 | {
55 | var document = new XmlDocument();
56 | document.LoadXml(xml);
57 | if (document.DocumentElement == null) throw new XmlException("这不是一个Xml文档");
58 | var data = new Hashtable();
59 | unSerialize(data, document.DocumentElement);
60 | foreach (DictionaryEntry root in data)
61 | {
62 | if (root.Value is Hashtable)
63 | {
64 | Data = (Hashtable)root.Value;
65 | break;
66 | }
67 | }
68 | }
69 |
70 | ///
71 | /// 反序列化
72 | ///
73 | ///
74 | ///
75 | private void unSerialize(IDictionary data, XmlNode node)
76 | {
77 | if (!node.FirstChild.HasChildNodes)
78 | {
79 | var key = getId(node);
80 | data.Add(key, node.InnerText);
81 | }
82 | else
83 | {
84 | var item = (T)Activator.CreateInstance(typeof(T), node);
85 | var key = getId(node);
86 | if (item.Success)
87 | {
88 | data.Add(key, item);
89 | }
90 | else
91 | {
92 | var dic = new Hashtable();
93 | data.Add(key, dic);
94 | foreach (XmlNode n in node.ChildNodes)
95 | {
96 | unSerialize(dic, n);
97 | }
98 | }
99 | }
100 | }
101 |
102 | private string getId(XmlNode node)
103 | {
104 | return node.Attributes != null ? node.Attributes["id"].Value : Guid.NewGuid().ToString();
105 | }
106 |
107 |
108 | ///
109 | /// 设置属性
110 | ///
111 | protected virtual void SetProperty() { }
112 |
113 | ///
114 | /// 设置项目
115 | ///
116 | ///
117 | protected void SetItems(IList list)
118 | {
119 | SetItems(list, Data);
120 | }
121 |
122 | ///
123 | /// 设置项目
124 | ///
125 | ///
126 | ///
127 | protected void SetItems(IList list, IDictionary data)
128 | {
129 | if (data == null) return;
130 | foreach (DictionaryEntry entry in data)
131 | {
132 | if (!(entry.Value is T)) continue;
133 | var item = (T)entry.Value;
134 | if (item.Success) list.Add(item);
135 | }
136 | }
137 | }
138 | }
139 |
--------------------------------------------------------------------------------
/src/DS.Web.UCenter/Model/UcCollectionReturnBase.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 | using System.Text;
3 | using System.Collections.Generic;
4 |
5 | namespace DS.Web.UCenter
6 | {
7 | ///
8 | /// 集合基类
9 | /// Dozer 版权所有
10 | /// 允许复制、修改,但请保留我的联系方式!
11 | /// http://www.dozer.cc
12 | /// mailto:dozer.cc@gmail.com
13 | ///
14 | /// 项目
15 | public abstract class UcCollectionReturnBase :UcCollectionBase
16 | where T:UcItemReturnBase
17 | {
18 | ///
19 | /// 序列化
20 | ///
21 | /// 是否输出HTML
22 | /// 是否为根目录
23 | ///
24 | private string serialize(bool htmlOn = true, bool isRoot = true)
25 | {
26 | var sb = new StringBuilder();
27 | if (isRoot)
28 | {
29 | sb.AppendLine("");
30 | sb.AppendLine("");
31 | }
32 | foreach (DictionaryEntry entry in Data)
33 | {
34 | sb.AppendFormat(htmlOn ? " \r\n" : "- {1}
\r\n", entry.Key, ((T)entry.Value).ToString(false));
35 | }
36 | if (isRoot)
37 | {
38 | sb.AppendLine("");
39 | }
40 | return sb.ToString();
41 | }
42 |
43 | #region 输出
44 | ///
45 | /// 序列化输出
46 | ///
47 | ///
48 | public override string ToString()
49 | {
50 | return ToString(true);
51 | }
52 | ///
53 | /// 序列化输出
54 | ///
55 | ///
56 | ///
57 | public string ToString(bool isRoot)
58 | {
59 | SetItems();
60 | return serialize(false, isRoot);
61 | }
62 | #endregion
63 |
64 | ///
65 | /// 设置属性
66 | ///
67 | protected abstract void SetItems();
68 |
69 | ///
70 | /// 加入List
71 | ///
72 | ///
73 | ///
74 | protected void AddToList(IList list,IEnumerable array)
75 | {
76 | foreach(var item in array)
77 | {
78 | list.Add(item);
79 | }
80 | }
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/src/DS.Web.UCenter/Model/UcEnums.cs:
--------------------------------------------------------------------------------
1 | namespace DS.Web.UCenter
2 | {
3 | ///
4 | /// 登录方式
5 | ///
6 | public enum LoginMethod
7 | {
8 | ///
9 | /// 使用用户名
10 | ///
11 | UserName = 0,
12 | ///
13 | /// 使用Uid
14 | ///
15 | Uid = 1,
16 | ///
17 | /// 使用邮箱
18 | ///
19 | Mail = 2,
20 | }
21 |
22 | ///
23 | /// 查询方式
24 | ///
25 | public enum InfoMethod
26 | {
27 | ///
28 | /// 使用用户名
29 | ///
30 | UserName = 0,
31 | ///
32 | /// 使用Uid
33 | ///
34 | Uid = 1,
35 | }
36 |
37 | ///
38 | /// 发送方式
39 | ///
40 | public enum SendMethod
41 | {
42 | ///
43 | /// Uid
44 | ///
45 | Uid= 0,
46 | ///
47 | /// 用户名
48 | ///
49 | UserName = 1,
50 | }
51 |
52 | ///
53 | /// 短消息文件夹
54 | ///
55 | public enum PmDeleteFolder
56 | {
57 | ///
58 | /// 发件箱
59 | ///
60 | InBox,
61 | ///
62 | /// 收件箱
63 | ///
64 | OutBox,
65 | }
66 |
67 | ///
68 | /// 短消息文件夹
69 | ///
70 | public enum PmReadFolder
71 | {
72 | ///
73 | /// 新建项
74 | ///
75 | NewBox,
76 | ///
77 | /// 发件箱
78 | ///
79 | InBox,
80 | ///
81 | /// 收件箱
82 | ///
83 | OutBox,
84 | }
85 |
86 | ///
87 | /// 短消息过滤器
88 | ///
89 | public enum PmReadFilter
90 | {
91 | ///
92 | /// 未读消息,folder 为 inbox 和 outbox 时使用
93 | ///
94 | NewPm,
95 | ///
96 | /// 系统消息,folder 为 inbox 时使用
97 | ///
98 | SystemPm,
99 | ///
100 | /// 公共消息,folder 为 inbox 时使用
101 | ///
102 | AnnouncePm,
103 | }
104 |
105 |
106 | ///
107 | /// 阅读状态
108 | ///
109 | public enum ReadStatus
110 | {
111 | ///
112 | /// 已读
113 | ///
114 | Readed = 0,
115 | ///
116 | /// 未读
117 | ///
118 | New = 1,
119 | }
120 |
121 | ///
122 | /// 消息的类型
123 | ///
124 | public enum ViewType
125 | {
126 | ///
127 | /// 获取指定单条消息
128 | ///
129 | Specified =0,
130 | ///
131 | /// 获取指定用户发的最后单条消息
132 | ///
133 | LastOutput =1,
134 | ///
135 | /// 获取指定用户收的最后单条消息
136 | ///
137 | LastInput =2,
138 | }
139 |
140 | ///
141 | /// 日期范围
142 | ///
143 | public enum DateRange
144 | {
145 | ///
146 | /// 今天
147 | ///
148 | Today = 1,
149 | ///
150 | /// 昨天
151 | ///
152 | Yestarday = 2,
153 | ///
154 | /// 前天
155 | ///
156 | TheDayBeforeYesterday = 3,
157 | ///
158 | /// 上周
159 | ///
160 | LastWeek = 4,
161 | ///
162 | /// 更早
163 | ///
164 | Earlier = 5,
165 | }
166 |
167 | ///
168 | /// 好友方向
169 | ///
170 | public enum FriendDirection
171 | {
172 | ///
173 | /// 指定用户的全部好友
174 | ///
175 | All = 0,
176 | ///
177 | /// 正向,指定用户添加的好友,但没被对方添加
178 | ///
179 | Forward =1,
180 | ///
181 | /// 反向,指定用户被哪些用户添加为好友,但没被对方添加
182 | ///
183 | Reverse =2,
184 | ///
185 | /// 双向,互相添加为好友
186 | ///
187 | Both =3,
188 | }
189 |
190 |
191 | ///
192 | /// 合并结果
193 | ///
194 | public enum UserMergeResult
195 | {
196 | ///
197 | /// 返回用户 ID,表示用户注册成功
198 | ///
199 | Success = 0,
200 | ///
201 | /// 用户名不合法
202 | ///
203 | UserNameIllegal = -1,
204 | ///
205 | /// 包含不允许注册的词语
206 | ///
207 | ContainsInvalidWords = -2,
208 | ///
209 | /// 用户名已经存在
210 | ///
211 | UserNameExists = -3,
212 | }
213 |
214 | ///
215 | /// 邮箱检查结果
216 | ///
217 | public enum UserCheckEmailResult
218 | {
219 | ///
220 | /// Email 正确
221 | ///
222 | Success = 1,
223 | ///
224 | /// Email 格式有误
225 | ///
226 | IncorrectEmailFormat = -4,
227 | ///
228 | /// Email 不允许注册
229 | ///
230 | EmailNotAllowed = -5,
231 | ///
232 | /// 该 Email 已经被注册
233 | ///
234 | EmailHasBeenRegistered = -6,
235 | }
236 |
237 |
238 | ///
239 | /// 修改结果
240 | ///
241 | public enum UserEditResult
242 | {
243 | ///
244 | /// 更新成功
245 | ///
246 | Success = 1,
247 | ///
248 | /// 没有做任何修改
249 | ///
250 | DoNotEdited = 0,
251 | ///
252 | /// 旧密码错误
253 | ///
254 | PassWordError = -1,
255 | ///
256 | /// Email 格式有误
257 | ///
258 | IncorrectEmailFormat = -4,
259 | ///
260 | /// Email 不允许注册
261 | ///
262 | EmailNotAllowed = -5,
263 | ///
264 | /// 该 Email 已经被注册
265 | ///
266 | EmailHasBeenRegistered = -6,
267 | ///
268 | /// 没有做任何修改
269 | ///
270 | EditedNothing = -7,
271 | ///
272 | /// 该用户受保护无权限更改
273 | ///
274 | UserIsProtected = -8,
275 | }
276 |
277 |
278 | ///
279 | /// 登陆结果
280 | ///
281 | public enum LoginResult
282 | {
283 | ///
284 | /// 返回用户 ID,表示用户登录成功
285 | ///
286 | Success = 0,
287 | ///
288 | /// 用户不存在,或者被删除
289 | ///
290 | NotExist = -1,
291 | ///
292 | /// 密码错
293 | ///
294 | PassWordError = -2,
295 | ///
296 | /// 安全提问错
297 | ///
298 | QuestionError = -3,
299 | }
300 |
301 |
302 | ///
303 | /// 注册结果
304 | ///
305 | public enum RegisterResult
306 | {
307 | ///
308 | /// 返回用户 ID,表示用户注册成功
309 | ///
310 | Success = 0,
311 | ///
312 | /// 用户名不合法
313 | ///
314 | UserNameIllegal = -1,
315 | ///
316 | /// 包含不允许注册的词语
317 | ///
318 | ContainsInvalidWords = -2,
319 | ///
320 | /// 用户名已经存在
321 | ///
322 | UserNameExists = -3,
323 | ///
324 | /// Email 格式有误
325 | ///
326 | IncorrectEmailFormat = -4,
327 | ///
328 | /// Email 不允许注册
329 | ///
330 | EmailNotAllowed = -5,
331 | ///
332 | /// 该 Email 已经被注册
333 | ///
334 | EmailHasBeenRegistered = -6,
335 | }
336 |
337 |
338 | ///
339 | /// 短信发送结果
340 | ///
341 | public enum PmSendResult
342 | {
343 | ///
344 | /// 发送成功
345 | ///
346 | Success = 1,
347 | ///
348 | /// 发送失败
349 | ///
350 | Failed = 0,
351 | ///
352 | /// 超出了24小时最大允许发送短消息数目
353 | ///
354 | BeyondMaxNumber = -1,
355 | ///
356 | /// 不满足两次发送短消息最短间隔
357 | ///
358 | SendTooFast = -2,
359 | ///
360 | /// 不能给非好友批量发送短消息
361 | ///
362 | CanNotBatchSendMsg = -3,
363 | ///
364 | /// 目前还不能使用发送短消息功能(注册多少日后才可以使用发短消息限制)
365 | ///
366 | CanNotSendNow = -4,
367 | }
368 |
369 | ///
370 | /// 头像类型
371 | ///
372 | public enum AvatarType
373 | {
374 | ///
375 | /// 虚拟头像
376 | ///
377 | Virtual,
378 | ///
379 | /// 真实头像
380 | ///
381 | Real,
382 | }
383 |
384 |
385 | ///
386 | /// 头像大小
387 | ///
388 | public enum AvatarSize
389 | {
390 | ///
391 | /// 大
392 | ///
393 | Big,
394 | ///
395 | /// 中
396 | ///
397 | Middle,
398 | ///
399 | /// 小
400 | ///
401 | Small,
402 | }
403 |
404 | ///
405 | /// 图标
406 | ///
407 | public enum FeedIcon
408 | {
409 | ///
410 | ///
411 | ///
412 | Thread,
413 | ///
414 | ///
415 | ///
416 | Post,
417 | ///
418 | ///
419 | ///
420 | Video,
421 | ///
422 | ///
423 | ///
424 | Goods,
425 | ///
426 | ///
427 | ///
428 | Reward,
429 | ///
430 | ///
431 | ///
432 | Debate,
433 | ///
434 | ///
435 | ///
436 | Blog,
437 | ///
438 | ///
439 | ///
440 | Album,
441 | ///
442 | ///
443 | ///
444 | Comment,
445 | ///
446 | ///
447 | ///
448 | Wall,
449 | ///
450 | ///
451 | ///
452 | Friend,
453 | }
454 | }
--------------------------------------------------------------------------------
/src/DS.Web.UCenter/Model/UcItemBase.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 |
3 | namespace DS.Web.UCenter
4 | {
5 | ///
6 | /// 项目基类
7 | /// Dozer 版权所有
8 | /// 允许复制、修改,但请保留我的联系方式!
9 | /// http://www.dozer.cc
10 | /// mailto:dozer.cc@gmail.com
11 | ///
12 | public abstract class UcItemBase
13 | {
14 | private IDictionary _data;
15 | ///
16 | /// 数据
17 | ///
18 | protected IDictionary Data
19 | {
20 | get { return _data ?? (_data = new Hashtable()); }
21 | set { _data = value; }
22 | }
23 | }
24 | }
--------------------------------------------------------------------------------
/src/DS.Web.UCenter/Model/UcItemReceiveBase.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 | using System.Xml;
3 |
4 | namespace DS.Web.UCenter
5 | {
6 | ///
7 | /// 项目基类
8 | /// Dozer 版权所有
9 | /// 允许复制、修改,但请保留我的联系方式!
10 | /// http://www.dozer.cc
11 | /// mailto:dozer.cc@gmail.com
12 | ///
13 | ///
14 | public abstract class UcItemReceiveBase : UcItemBase
15 | where T : UcItemReceiveBase
16 | {
17 | ///
18 | /// 是否成功
19 | ///
20 | public bool Success { get; private set; }
21 |
22 | ///
23 | /// 构造函数
24 | ///
25 | /// 数据
26 | protected UcItemReceiveBase(string xml)
27 | {
28 | initialize(xml);
29 | }
30 |
31 | ///
32 | /// 构造函数
33 | ///
34 | /// 数据
35 | protected UcItemReceiveBase(XmlNode xml)
36 | {
37 | initialize(xml);
38 | }
39 |
40 | ///
41 | /// 初始化
42 | ///
43 | /// 参数
44 | private void initialize(string xml)
45 | {
46 | try
47 | {
48 | unSerialize(xml);
49 | Success = true;
50 | }
51 | catch
52 | {
53 | Success = false;
54 | }
55 | finally
56 | {
57 | SetProperty();
58 | }
59 | }
60 | ///
61 | /// 初始化
62 | ///
63 | /// 数据
64 | private void initialize(XmlNode xml)
65 | {
66 | try
67 | {
68 | getItems(xml);
69 | Success = true;
70 | }
71 | catch
72 | {
73 | Success = false;
74 | }
75 | finally
76 | {
77 | SetProperty();
78 | }
79 | }
80 |
81 | ///
82 | /// 得到UCenter项目
83 | ///
84 | /// 节点
85 | private void getItems(XmlNode node)
86 | {
87 | foreach (XmlNode xn in node.ChildNodes)
88 | {
89 | if (xn.Attributes != null) Data.Add(xn.Attributes["id"].Value, xn.InnerText);
90 | }
91 | }
92 |
93 | ///
94 | /// 反序列化
95 | ///
96 | /// XML
97 | /// 根目录
98 | ///
99 | private void unSerialize(string xml, string rootNodeName = "root")
100 | {
101 | var document = new XmlDocument();
102 | document.LoadXml(xml);
103 | var node = document.SelectSingleNode(rootNodeName);
104 | getItems(node);
105 | }
106 |
107 | ///
108 | /// 设置属性
109 | ///
110 | protected abstract void SetProperty();
111 |
112 | ///
113 | /// 检查是否成功
114 | ///
115 | /// 必要的参数
116 | protected void CheckForSuccess(params string[] keys)
117 | {
118 | if (keys.Any(key => !Data.Contains(key))) Success = false;
119 | }
120 | }
121 | }
--------------------------------------------------------------------------------
/src/DS.Web.UCenter/Model/UcItemReturnBase.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 | using System.Text;
3 |
4 | namespace DS.Web.UCenter
5 | {
6 | ///
7 | /// 集合基类
8 | /// Dozer 版权所有
9 | /// 允许复制、修改,但请保留我的联系方式!
10 | /// http://www.dozer.cc
11 | /// mailto:dozer.cc@gmail.com
12 | ///
13 | public abstract class UcItemReturnBase : UcItemBase
14 | {
15 | ///
16 | /// 序列化
17 | ///
18 | ///
19 | ///
20 | ///
21 | private string serialize(bool htmlOn = true, bool isRoot = true)
22 | {
23 | return serialize(Data,htmlOn,isRoot);
24 | }
25 |
26 | ///
27 | /// 序列化
28 | ///
29 | /// 需要序列化的对象
30 | /// 是否输出HTML
31 | /// 是否为根目录
32 | ///
33 | private string serialize(IDictionary item,bool htmlOn = true, bool isRoot = true)
34 | {
35 | var sb = new StringBuilder();
36 | getHeader(isRoot, sb);
37 |
38 | foreach (DictionaryEntry entry in item)
39 | {
40 | if (entry.Value is Hashtable)
41 | {
42 | sb.AppendLine("- ");
43 | sb.AppendLine(serialize((Hashtable)entry.Value, htmlOn, false ));
44 | sb.AppendLine("
");
45 | }
46 | else
47 | {
48 | sb.AppendFormat(htmlOn ? " \r\n" : "- {1}
\r\n", entry.Key, entry.Value);
49 | }
50 | }
51 |
52 | getFooter(isRoot, sb);
53 |
54 | return sb.ToString();
55 | }
56 |
57 | private void getFooter(bool isRoot, StringBuilder sb)
58 | {
59 | if (isRoot)
60 | {
61 | sb.AppendLine("");
62 | }
63 | }
64 |
65 | private void getHeader(bool isRoot, StringBuilder sb)
66 | {
67 | if (!isRoot) return;
68 | sb.AppendLine("");
69 | sb.AppendLine("");
70 | }
71 |
72 | #region 输出
73 | ///
74 | /// 序列化输出
75 | ///
76 | ///
77 | public override string ToString()
78 | {
79 | return ToString(true);
80 | }
81 | ///
82 | /// 序列化输出
83 | ///
84 | ///
85 | ///
86 | public virtual string ToString(bool isRoot)
87 | {
88 | SetItems();
89 | return serialize(true, isRoot);
90 | }
91 | #endregion
92 |
93 | ///
94 | /// 设置属性
95 | ///
96 | protected abstract void SetItems();
97 | }
98 | }
--------------------------------------------------------------------------------
/src/DS.Web.UCenter/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的常规信息通过以下
6 | // 特性集控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("DS.Web.UCenter")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Microsoft")]
12 | [assembly: AssemblyProduct("DS.Web.UCenter")]
13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2011")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // 将 ComVisible 设置为 false 使此程序集中的类型
18 | // 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型,
19 | // 则将该类型上的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("a9418c19-6df1-462e-932c-765708414cf7")]
24 |
25 | // 程序集的版本信息由下面四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 内部版本号
30 | // 修订号
31 | //
32 | // 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值,
33 | // 方法是按如下所示使用“*”:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/src/DS.Web.UCenter/UcConfig.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dozer47528/UCenter-API-For-DotNet/b42509c086e1cb18625f5b7ea9303b3b1e6919aa/src/DS.Web.UCenter/UcConfig.cs
--------------------------------------------------------------------------------
/src/DS.Web.UCenter/UcUtility.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dozer47528/UCenter-API-For-DotNet/b42509c086e1cb18625f5b7ea9303b3b1e6919aa/src/DS.Web.UCenter/UcUtility.cs
--------------------------------------------------------------------------------