-
Notifications
You must be signed in to change notification settings - Fork 0
/
Setting_ManagerItem.ascx.cs
834 lines (617 loc) · 28.5 KB
/
Setting_ManagerItem.ascx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Globalization;
using System.Text;
using DotNetNuke.Services.Localization;
using DotNetNuke.Entities.Tabs;
using DotNetNuke.Common.Utilities;
using System.Threading;
using System.Web.UI.HtmlControls;
namespace DNNGo.Modules.DNNGalleryPro
{
public partial class Setting_ManagerItem : BaseModule
{
#region "属性"
/// <Description>
/// 项编号
/// </Description>
public Int32 SliderID = WebHelper.GetIntParam(HttpContext.Current.Request, "ID", 0);
private DNNGo_DNNGalleryPro_Slider _SliderItem;
/// <Description>
/// 文章项
/// </Description>
public DNNGo_DNNGalleryPro_Slider SliderItem
{
get
{
if (!(_SliderItem != null && _SliderItem.ID > 0))
{
if (SliderID > 0)
_SliderItem = DNNGo_DNNGalleryPro_Slider.FindByKeyForEdit(SliderID);
else
_SliderItem = new DNNGo_DNNGalleryPro_Slider();
}
return _SliderItem;
}
}
private List<KeyValueEntity> _ItemSettings;
/// <Description>
/// 封装的参数集合
/// </Description>
public List<KeyValueEntity> ItemSettings
{
get
{
if (!(_ItemSettings != null && _ItemSettings.Count > 0))
{
if (SliderItem != null && SliderItem.ID > 0 && !String.IsNullOrEmpty(SliderItem.Options))
{
try
{
_ItemSettings = ConvertTo.Deserialize<List<KeyValueEntity>>(SliderItem.Options);
}
catch
{
_ItemSettings = new List<KeyValueEntity>();
}
}
else
_ItemSettings = new List<KeyValueEntity>();
}
return _ItemSettings;
}
}
public String PostLayerResource(String _Token)
{
return String.Format("{0}Resource_Service.aspx?ModuleId={1}&PortalId={2}&TabId={3}&SliderID={4}&Token={5}&LayerID=", ModulePath, ModuleId, PortalId, TabId, SliderID,_Token);
}
/// <Description>
/// 提示操作类
/// </Description>
MessageTips mTips = new MessageTips();
#endregion
#region "事件"
/// <Description>
/// 页面加载
/// </Description>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//绑定页面项
BindPageItem();
// 绑定方案项
BindDataItem();
}
//绑定设置参数到页面
BindGroupsToPage("Left");
BindGroupsToPage("Right");
}
/// <Description>
/// 更新文章
/// </Description>
protected void cmdPublish_Click(object sender, EventArgs e)
{
try
{
// 设置方案项
DNNGo_DNNGalleryPro_Slider Article = new DNNGo_DNNGalleryPro_Slider();
Int32 SaveResult = SaveDataItem(-1, ref Article);
if (SaveResult > 0)
{
mTips.LoadMessage("SaveSliderSuccess", EnumTips.Success, this);
if (SliderID == 0)
{
Response.Redirect(xUrl("ID", Article.ID.ToString(), "AddNew"), false);
}
else
{
Response.Redirect(xUrl("ManagerList"), false);
}
}
else
{
mTips.IsPostBack = false;
mTips.LoadMessage("SaveSliderError", EnumTips.Success, this, new String[] { "" });
}
}
catch (Exception ex)
{
ProcessModuleLoadException(ex);
}
}
/// <summary>
/// 保存草稿
/// </summary>
protected void cmdSaveDraft_Click(object sender, EventArgs e)
{
try
{
Int32 ArticleStatus = (Int32)EnumStatus.Hidden;
DNNGo_DNNGalleryPro_Slider Article = new DNNGo_DNNGalleryPro_Slider();
Int32 SaveResult = SaveDataItem(ArticleStatus, ref Article);
if (SaveResult >0)
{
mTips.LoadMessage("SaveSliderSuccess", EnumTips.Success, this, new String[] { "" });
Response.Redirect(xUrl("ID", Article.ID.ToString(), "AddNew"), false);
}
else
{
mTips.IsPostBack = false;
mTips.LoadMessage("SaveSliderError", EnumTips.Success, this, new String[] { "" });
}
}
catch (Exception ex)
{
ProcessModuleLoadException(ex);
}
}
/// <Description>
/// 取消
/// </Description>
protected void cmdCancel_Click(object sender, EventArgs e)
{
try
{
Response.Redirect(xUrl("ManagerList"), false);
}
catch (Exception ex)
{
ProcessModuleLoadException(ex);
}
}
protected void RepeaterOptions_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
SettingEntity ThemeSetting = e.Item.DataItem as SettingEntity;
if (ThemeSetting != null && !String.IsNullOrEmpty(ThemeSetting.Name))
{
Boolean IsRightLayout = !String.IsNullOrEmpty(ThemeSetting.Layout) && ThemeSetting.Layout.IndexOf("Right", StringComparison.CurrentCultureIgnoreCase) >= 0;
KeyValueEntity KeyValue = ItemSettings.Find(r1 => r1.Key == ThemeSetting.Name);
if (KeyValue != null && !String.IsNullOrEmpty(KeyValue.Key))
{
ThemeSetting.DefaultValue = KeyValue.Value.ToString();
}
//构造输入控件
PlaceHolder ThemePH = e.Item.FindControl("ThemePH") as PlaceHolder;
#region "创建控件"
ControlHelper ctl = new ControlHelper(this);
ThemePH.Controls.Add((Control)ctl.ViewControl(ThemeSetting));
#endregion
Literal liTitle = e.Item.FindControl("liTitle") as Literal;
liTitle.Text = String.Format("<label class=\"col-sm-{2} control-label\" for=\"{1}\">{0}:</label>", !String.IsNullOrEmpty(ThemeSetting.Alias) ? ThemeSetting.Alias : ThemeSetting.Name, ctl.ViewControlID(ThemeSetting), IsRightLayout ? 3 : 2);
if (!String.IsNullOrEmpty(ThemeSetting.Description))
{
Literal liHelp = e.Item.FindControl("liHelp") as Literal;
liHelp.Text = String.Format("<span class=\"help-block\"><i class=\"fa fa-info-circle\"></i> {0}</span>", ThemeSetting.Description);
}
}
}
}
/// <Description>
/// 分组绑定事件
/// </Description>
protected void RepeaterGroup_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
Repeater RepeaterOptions = e.Item.FindControl("RepeaterOptions") as Repeater;
KeyValueEntity GroupItem = e.Item.DataItem as KeyValueEntity;
int OptionCount = 0;
BindOptionsToPage(RepeaterOptions, GroupItem.Key, out OptionCount);
if (OptionCount == 0)
{
e.Item.Visible = false;
}
}
}
#endregion
#region "方法"
/// <Description>
/// 绑定页面项
/// </Description>
private void BindPageItem()
{
EffectDBEntity EffectDB = Setting_EffectDB;
hlAddGroups.NavigateUrl = xUrl("Groups");
hlAddGroups.Attributes.Add("onclick", String.Format("return confirm('{0}');", Localization.GetString("hlAddGroups.Confirm", this.LocalResourceFile)));
divGroups.Visible = EffectDB.Groups;
divCustomModels.Visible = EffectDB.CustomModels;
divNumbers.Visible = EffectDB.Downloads;
//增加权限用户
DotNetNuke.Security.Roles.RoleController rc = new DotNetNuke.Security.Roles.RoleController();
WebHelper.BindList(cblPermissionsRoles, rc.GetPortalRoles(PortalId), "RoleName", "RoleName");
//构造增加按钮
if (EffectDB.Layers && SliderID > 0)
{
liTitle_Layers.Text = String.Format("{0} List", EffectDB.LayerName);
StringBuilder AddNewBuilder = new StringBuilder();
//通用按钮
AddNewBuilder.Append(AddNewLayerHtml(""));
if (!String.IsNullOrEmpty(EffectDB.LayerType))
{
List<String> AddNewList = Common.GetList(EffectDB.LayerType);
foreach (String AddNew in AddNewList)
{
if (!String.IsNullOrEmpty(AddNew))
{
AddNewBuilder.Append(AddNewLayerHtml(AddNew));
}
}
}
liAddNewLink_List.Text = AddNewBuilder.ToString();
div_Layers.Visible = true;
}
else
{
div_Layers.Visible = false;
}
////插入用户按钮的连接
//hlCreateUser.NavigateUrl = String.Format("{0}Resource_UserList.aspx?ModuleId={1}&PortalId={2}&UserId={3}&HomeDirectory={4}&TB_iframe=true&keepThis=true&height=400&width=600", ModulePath, ModuleId, PortalId, UserId, HttpUtility.UrlEncode(PortalSettings.HomeDirectory));
//绑定状态代码
WebHelper.BindList(ddlArticleStatus, typeof(EnumStatus));
}
/// <summary>
/// 增加Layer按钮
/// </summary>
/// <param name="AddNew"></param>
/// <returns></returns>
public String AddNewLayerHtml(String AddNew)
{
StringBuilder AddNewBuilder = new StringBuilder();
String AddNewText = String.IsNullOrEmpty(AddNew) ? "" : String.Format(" [{0}]", AddNew);
String data_href = String.Format("data-href=\"{0}Resource_Item.aspx?ModuleId={1}&PortalId={2}&TabId={3}&SliderID={4}&LayerType={5}\"", ModulePath, ModuleId, PortalId, TabId, SliderID, AddNew);
AddNewBuilder.AppendFormat("<a href=\"#AddLayer_Modal\" {0} class=\"add_Layer btn btn-xs btn-bricky tooltips\" data-placement=\"top\" data-toggle=\"modal\" data-original-title=\"Add New {1} {2}\"><i class='fa fa-plus'></i> Add New {1} {2}</a>", data_href, Setting_EffectDB.LayerName, AddNewText);
AddNewBuilder.AppendLine(" ");
return AddNewBuilder.ToString();
}
/// <Description>
/// 绑定数据项
/// </Description>
private void BindDataItem()
{
DNNGo_DNNGalleryPro_Slider Article = SliderItem;
//验证文章是否存在
if (SliderID > 0 && (Article == null || SliderID != Article.ID))
{
//需要给出提示,载入文章错误
mTips.LoadMessage("LoadingGalleryError", EnumTips.Error, this, new String[] { "" });
Response.Redirect(xUrl("ManagerList"), false);
}
if (Article == null) Article = new DNNGo_DNNGalleryPro_Slider();
if (divGroups.Visible) BindTreeGroups(Article);
cbPermissionsAllUsers.Checked = Article.Per_AllUsers == 0 ? true : false;
//List<String> Per_Roles = Common.GetList(Article.Per_Roles, "|");
WebHelper.SelectedListMultiByValue(cblPermissionsRoles, Article.Per_Roles);
//文章状态
liArticleStatus.Text = EnumHelper.GetEnumTextVal(Article.Status, typeof(EnumStatus));
WebHelper.SelectedListByValue(ddlArticleStatus, Article.Status);//管理员看到的文章状态
//发布时间和结束时间
if (SliderID > 0 && Article != null && Article.ID > 0)
{
liStartDateTime.Text = Article.StartTime.ToString("MM/dd/yyyy hh:mm tt", new CultureInfo("en-US", false));//Thread.CurrentThread.CurrentCulture
liDisableDateTime.Text = Article.EndTime.ToString("MM/dd/yyyy hh:mm tt", new CultureInfo("en-US", false));//Thread.CurrentThread.CurrentCulture
}
txtStartDate.Text = Article.StartTime.ToString("MM/dd/yyyy", new CultureInfo("en-US", false));
txtStartTime.Text = Article.StartTime.ToString("hh:mm tt", new CultureInfo("en-US", false));
txtDisableDate.Text = Article.EndTime.ToString("MM/dd/yyyy", new CultureInfo("en-US", false));
txtDisableTime.Text = Article.EndTime.ToString("hh:mm tt", new CultureInfo("en-US", false));
txtHeatNumber.Text = Article.Heats.ToString();
txtDownloadNumber.Text = Article.Clicks.ToString();
}
/// <Description>
/// 保存文章
/// </Description>
/// <param name="ArticleStatus">文章状态(为-1的时候取选项的值)</param>
private Int32 SaveDataItem(Int32 ArticleStatus, ref DNNGo_DNNGalleryPro_Slider Article)
{
int ResultArticle = 0;
Article = SliderItem;
//数字更新
Article.Heats = WebHelper.GetIntParam(Request, txtHeatNumber.UniqueID, 0);
Article.Clicks = WebHelper.GetIntParam(Request, txtDownloadNumber.UniqueID, 0);
//权限
Article.Per_AllUsers = cbPermissionsAllUsers.Checked ? 0 : 1;
String textStr, idStr = String.Empty;
WebHelper.GetSelected(cblPermissionsRoles,out textStr,out idStr);
Article.Per_Roles = idStr;
//文章的发布状态
Article.Status = Convert.ToInt32(ddlArticleStatus.Items[ddlArticleStatus.SelectedIndex].Value);
//设置属性
SetItemSettings(ref Article);
Article.Extension = SetExtensionSettings();
//更新项
Article.LastIP = WebHelper.UserHost;
Article.LastTime = xUserTime.UtcTime();
Article.LastUser = UserId;
//发布状态和时间
DateTime oTime = xUserTime.LocalTime();
string[] expectedFormats = { "G", "g", "f", "F" };
string StartDate = WebHelper.GetStringParam(Request, txtStartDate.UniqueID, oTime.ToString("MM/dd/yyyy"));
string StartTime = WebHelper.GetStringParam(Request, txtStartTime.UniqueID, oTime.ToString("hh:mm tt"));
if (DateTime.TryParseExact(String.Format("{0} {1}", StartDate, StartTime), "MM/dd/yyyy hh:mm tt", new CultureInfo("en-US", false), DateTimeStyles.AllowWhiteSpaces, out oTime))
{
if (oTime.Second == 0) oTime = oTime.AddSeconds(DateTime.Now.Second);//补秒
Article.StartTime = oTime;
}
//发布状态和时间
DateTime EndTime = xUserTime.LocalTime().AddYears(10);
string DisableDate = WebHelper.GetStringParam(Request, txtDisableDate.UniqueID, EndTime.ToString("MM/dd/yyyy"));
string DisableTime = WebHelper.GetStringParam(Request, txtDisableTime.UniqueID, EndTime.ToString("hh:mm tt"));
if (DateTime.TryParseExact(String.Format("{0} {1}", DisableDate, DisableTime), "MM/dd/yyyy hh:mm tt", new CultureInfo("en-US", false), DateTimeStyles.AllowWhiteSpaces, out EndTime))
{
if (EndTime.Second == 0) EndTime = EndTime.AddSeconds(DateTime.Now.Second);//补秒
Article.EndTime = EndTime;
}
//创建用户改为可以选择
//Article.CreateUser = WebHelper.GetIntParam(Request, txtCreateUser.UniqueID, UserId);
if (ArticleStatus == -1)//如果没有指定状态就取控件的
{
Article.Status = WebHelper.GetIntParam(Request, ddlArticleStatus.UniqueID, (Int32)EnumStatus.Activated);
}
else
{
Article.Status = ArticleStatus;
}
if (Article.ID > 0)
{
//更新
ResultArticle = Article.Update();
}
else
{
//新增
Article.CreateTime = xUserTime.UtcTime();
Article.CreateUser = UserId;
Article.ModuleId = ModuleId;
Article.PortalId = PortalId;
QueryParam Sqp = new QueryParam();
Sqp.ReturnFields = Sqp.Orderfld = DNNGo_DNNGalleryPro_Slider._.Sort;
Sqp.OrderType = 1;
Sqp.Where.Add(new SearchParam(DNNGo_DNNGalleryPro_Slider._.ModuleId, ModuleId, SearchType.Equal));
Article.Sort = Convert.ToInt32(DNNGo_DNNGalleryPro_Slider.FindScalar(Sqp)) + 2;
Article.ID = ResultArticle = Article.Insert();
}
if (ResultArticle > 0)
{
if (divGroups.Visible)
{
//更新分类项
String Categorys = WebHelper.GetStringParam(Request, String.Format("post$groups${0}", ModuleId), "");
ManagedThreadPool.QueueUserWorkItem(new WaitCallback(ThreadUpdateGroups), new KeyValueEntity(Article.ID.ToString(), Categorys));
}
////操作成功
//mTips.LoadMessage("SaveArticleSuccess", EnumTips.Success, this, new String[] { Article.Title });
////操作成功需要跳转到首页
//Response.Redirect(xUrl("Posts"));
}
else
{
//mTips.IsPostBack = false;
////操作失败
//mTips.LoadMessage("SaveArticleError", EnumTips.Success, this, new String[] { Article.Title });
////操作失败就留在本页面
}
return ResultArticle;
}
/// <Description>
/// 绑定树分类
/// </Description>
private void BindTreeGroups(DNNGo_DNNGalleryPro_Slider Article)
{
List<Int32> SelectList = new List<Int32>();
StringBuilder select = new StringBuilder();
if (Article != null && Article.ID > 0)
{
//填充分类的关系
List<DNNGo_DNNGalleryPro_Slider_Group> Relationships = DNNGo_DNNGalleryPro_Slider_Group.FindAllByArticleID(Article.ID);
foreach (DNNGo_DNNGalleryPro_Slider_Group Groups in Relationships)
{
SelectList.Add(Groups.GroupID);
select.AppendFormat("{0},", Groups.GroupID);
}
}
//绑定所有分类到页面
QueryParam qp = new QueryParam();
qp.Orderfld = DNNGo_DNNGalleryPro_Group._.Sort;
qp.OrderType = 0;
int RecordCount = 0;
qp.Where.Add(new SearchParam(DNNGo_DNNGalleryPro_Group._.ModuleId, ModuleId, SearchType.Equal));
List<DNNGo_DNNGalleryPro_Group> lst = DNNGo_DNNGalleryPro_Group.FindAll(qp, out RecordCount);
//拼接顶级分类的方法
StringBuilder sb = new StringBuilder();
sb.Append("<div id=\"Groups-all\" class=\"tabs-panel\">");
String ttString = CreateGroupsJson(lst, 0, SelectList);
if (!String.IsNullOrEmpty(ttString))
{
sb.Append(ttString);
}
sb.Append("</div>");
liGroups.Text = sb.ToString();
}
/// <Description>
/// 拼接分类的JSon数据
/// </Description>
/// <param name="lst">分类列表</param>
/// <param name="ParentID">上级编号</param>
/// <returns>Json数据</returns>
private String CreateGroupsJson(List<DNNGo_DNNGalleryPro_Group> lst, Int32 ParentID, List<Int32> SelectList)
{
//筛选数据并排列
QueryParam qp = new QueryParam();
qp.Orderfld = DNNGo_DNNGalleryPro_Group._.Sort;
qp.OrderType = 0;
qp.Where.Add(new SearchParam(DNNGo_DNNGalleryPro_Group._.ModuleId, ModuleId, SearchType.Equal));
int RecordCount = 0;
List<DNNGo_DNNGalleryPro_Group> TempList = DNNGo_DNNGalleryPro_Group.FindAll(qp, out RecordCount);
//TempList = TempList.Sort(DNNGo_DNNGalleryPro_Group._.Sort, false);
//取出数据进行拼接
StringBuilder sb = new StringBuilder();
if (ParentID == 0)
sb.Append("<ul id=\"Groupschecklist\" class=\"Categories_list list:Groups Groupschecklist form-no-clear\">");
else
sb.Append("<ul class=\"children\">");
foreach (DNNGo_DNNGalleryPro_Group Groups in TempList)
{
sb.AppendFormat("<li id=\"Groups-{0}\">", Groups.ID);
sb.Append("<label class=\"checkbox-inline selectit\">");
sb.AppendFormat("<input value=\"{0}\" class=\"square-green\" type=\"checkbox\" name=\"{1}\" id=\"post_groups_{2}\" {4} />{3}</label>",
Groups.ID,
String.Format("post$groups${0}", ModuleId),
String.Format("post_groups_{0}", ModuleId),
Groups.Name,
SelectList.Contains(Groups.ID) ? "checked=\"checked\"" : "");
//String ttString = CreateGroupsJson(lst, Groups.ID, SelectList);
//if (!String.IsNullOrEmpty(ttString))
//{
// sb.Append(ttString);
//}
sb.Append("</li>");
}
sb.Append("</ul>");
if (TempList.Count > 0)
return sb.ToString();
else
return String.Empty;
}
/// <Description>
/// 绑定选项分组框到页面
/// </Description>
private void BindGroupsToPage(String Layout)
{
Repeater RepeaterGroup = FindControl(String.Format("RepeaterGroup_{0}", Layout)) as Repeater;
HtmlGenericControl divOptions = FindControl(String.Format("divOptions_{0}", Layout)) as HtmlGenericControl;
if (RepeaterGroup != null && divOptions != null)
{
//获取效果参数
List<SettingEntity> ItemSettingDB = Setting_SliderSettingDB.FindAll(r=>r.Layout == Layout);
if (Layout != "Right")
{
ItemSettingDB = Setting_SliderSettingDB.FindAll(r => r.Layout != "Right");
}
if (ItemSettingDB != null && ItemSettingDB.Count > 0)
{
List<KeyValueEntity> Items = new List<KeyValueEntity>();
foreach (SettingEntity ItemSetting in ItemSettingDB)
{
if (!Items.Exists(r1 => r1.Key == ItemSetting.Group))
{
Items.Add(new KeyValueEntity(ItemSetting.Group, ""));
}
}
if (Items != null && Items.Count > 0)
{
//绑定参数项
RepeaterGroup.DataSource = Items;
RepeaterGroup.DataBind();
}
divOptions.Visible = true;
}
}
}
/// <Description>
/// 绑定选项集合到页面
/// </Description>
private void BindOptionsToPage(Repeater RepeaterOptions, String Group, out int OptionCount)
{
OptionCount = 0;
//获取效果参数
List<SettingEntity> ItemSettingDB = Setting_SliderSettingDB;
if (ItemSettingDB != null && ItemSettingDB.Count > 0)
{
ItemSettingDB = ItemSettingDB.FindAll(r1 => r1.Group == Group);
OptionCount = ItemSettingDB.Count;
//绑定参数项
RepeaterOptions.DataSource = ItemSettingDB;
RepeaterOptions.DataBind();
}
}
/// <Description>
/// 拼接数据项的设置参数
/// </Description>
/// <returns></returns>
public void SetItemSettings(ref DNNGo_DNNGalleryPro_Slider Article)
{
//获取效果参数
List<SettingEntity> ItemSettingDB = Setting_SliderSettingDB;
List<KeyValueEntity> list = new List<KeyValueEntity>();
if (ItemSettingDB != null && ItemSettingDB.Count > 0)
{
ControlHelper ControlItem = new ControlHelper(ModuleId);
foreach (SettingEntity ri in ItemSettingDB)
{
KeyValueEntity item = new KeyValueEntity();
item.Key = ri.Name;
item.Value = ControlHelper.GetWebFormValue(ri, this);
list.Add(item);
}
}
Article.Options = ConvertTo.Serialize<List<KeyValueEntity>>(list);
if (list.Exists(r => r.Key == "Attribute1"))
{
KeyValueEntity Attribute1 = list.Find(r => r.Key == "Attribute1");
Int32 Attribute1_Value = 0;
if (int.TryParse(Attribute1.Value.ToString(), out Attribute1_Value))
{
Article.Attribute1 = Attribute1_Value;
}
}
if (list.Exists(r => r.Key == "Attribute2"))
{
KeyValueEntity Attribute2 = list.Find(r => r.Key == "Attribute2");
Article.Attribute2 = Attribute2.Value.ToString();
}
if (list.Exists(r => r.Key == "Title"))
{
KeyValueEntity TitleEntity = list.Find(r => r.Key == "Title");
Article.Title = TitleEntity.Value.ToString();
}
}
/// <summary>
/// 拼接扩展数据项的设置参数
/// </summary>
/// <returns></returns>
public String SetExtensionSettings()
{
List<KeyValueEntity> list = new List<KeyValueEntity>();
String Names = Request.Form[String.Format("Model$Name${0}", ModuleId)];
String Values = Request.Form[String.Format("Model$Value${0}", ModuleId)];
if (!String.IsNullOrEmpty(Names) && !String.IsNullOrEmpty(Values))
{
List<String> NameList = Common.GetList(Names,",");
List<String> ValueList = Common.GetList(Values,",");
for (Int32 i = 0; i < NameList.Count && i < ValueList.Count; i++)
{
KeyValueEntity kv = new KeyValueEntity();
if (!String.IsNullOrEmpty(NameList[i]))
{
kv.Key = NameList[i];
kv.Value = ValueList[i];
list.Add(kv);
}
}
}
return ConvertTo.Serialize<List<KeyValueEntity>>(list);
}
#endregion
#region "异步执行需要调用的方法"
/// <Description>
/// 利用线程执行更新文章分类关系的方法
/// </Description>
/// <param name="Article"></param>
public void ThreadUpdateGroups(object KeyValue)
{
KeyValueEntity KeyValueItem = KeyValue as KeyValueEntity;
if (KeyValueItem != null && !String.IsNullOrEmpty(KeyValueItem.Key))
{
DNNGo_DNNGalleryPro_Slider_Group.Update(int.Parse(KeyValueItem.Key), KeyValueItem.Value.ToString());
}
}
#endregion
}
}