/// <summary> /// 绑定查询的方法 /// </summary> private List <SearchParam> BindSearch() { List <SearchParam> Where = new List <SearchParam>(); Where.Add(new SearchParam("ModuleId", Settings_ModuleID, SearchType.Equal)); //筛选文章的状态 if (ArticleStatus >= 0) { Where.Add(new SearchParam(DNNGo_DNNGalleryPro_Slider._.Status, ArticleStatus, SearchType.Equal)); } if (GroupID > 0) { String ArticleIDs = DNNGo_DNNGalleryPro_Slider_Group.FindArticleIDsByCategoryIDs(GroupID.ToString()); if (!String.IsNullOrEmpty(ArticleIDs)) { Where.Add(new SearchParam(DNNGo_DNNGalleryPro_Slider._.ID, ArticleIDs, SearchType.In)); } else { Where.Add(new SearchParam(DNNGo_DNNGalleryPro_Slider._.ID, 0, SearchType.Equal)); } } //Where.Add(new SearchParam(DNNGo_DNNGalleryPro_Slider._.t, ArticleStatus, SearchType.Equal)); return(Where); }
/// <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()); } }
/// <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(); }
/// <summary> /// 绑定查询的方法 /// </summary> private QueryParam BindSearch(QueryParam qp) { qp.Where.Add(new SearchParam(DNNGo_DNNGalleryPro_Slider._.ModuleId, Settings_ModuleID, SearchType.Equal)); qp.Where.Add(new SearchParam(DNNGo_DNNGalleryPro_Slider._.Status, (Int32)EnumStatus.Activated, SearchType.Equal)); if (FilterStartTime) { qp.Where.Add(new SearchParam(DNNGo_DNNGalleryPro_Slider._.StartTime, xUserTime.UtcTime(), SearchType.LtEqual)); } if (FilterEndTime) { qp.Where.Add(new SearchParam(DNNGo_DNNGalleryPro_Slider._.EndTime, xUserTime.UtcTime(), SearchType.GtEqual)); } if (GroupID > 0) { String ArticleIDs = DNNGo_DNNGalleryPro_Slider_Group.FindArticleIDsByCategoryIDs(GroupID.ToString()); if (!String.IsNullOrEmpty(ArticleIDs)) { qp.Where.Add(new SearchParam(DNNGo_DNNGalleryPro_Slider._.ID, ArticleIDs, SearchType.In)); } } if (Attribute1 >= 0) { qp.Where.Add(new SearchParam(DNNGo_DNNGalleryPro_Slider._.Attribute1, Attribute1, SearchType.Equal)); } if (!String.IsNullOrEmpty(Attribute2)) { qp.Where.Add(new SearchParam(DNNGo_DNNGalleryPro_Slider._.Attribute2, Attribute2, SearchType.Equal)); } //需要根据条件来查找相应的权限 if (UserId > 0) { if (!UserInfo.IsSuperUser)//超级管理员不限制 { qp.WhereSql.Append(" ( "); //公开的 qp.WhereSql.Append(new SearchParam(DNNGo_DNNGalleryPro_Slider._.Per_AllUsers, 0, SearchType.Equal).ToSql()); //有角色的 if (UserInfo.Roles != null && UserInfo.Roles.Length > 0) { qp.WhereSql.Append(" OR "); qp.WhereSql.Append(" ( "); Int32 RoleIndex = 0; foreach (var r in UserInfo.Roles) { if (RoleIndex > 0) { qp.WhereSql.Append(" OR "); } qp.WhereSql.Append(new SearchParam(DNNGo_DNNGalleryPro_Slider._.Per_Roles, String.Format(",{0},", r), SearchType.Like).ToSql()); //qp.WhereSql.Append(" OR "); //qp.WhereSql.Append(new SearchParam(DNNGo_DNNGalleryPro_Slider._.Per_Roles, r, SearchType.Like).ToSql()); RoleIndex++; } qp.WhereSql.Append(" ) "); } qp.WhereSql.Append(" ) "); } } else { qp.Where.Add(new SearchParam(DNNGo_DNNGalleryPro_Slider._.Per_AllUsers, 0, SearchType.Equal)); } return(qp); }
/// <summary> /// 导入数据 /// </summary> /// <param name="XmlContent"></param> /// <returns></returns> public Int32 Import(Stream XmlContent) { //插入成功的数量 Int32 InsertResult = 0; if (XmlContent != null && XmlContent.Length > 0) { //将XML转换为实体 XmlFormat xf = new XmlFormat(); xf.XmlDoc.Load(XmlContent); List <XmlSliserEntity> XmlContentList = xf.ToList <XmlSliserEntity>(); List <GallerySettingsEntity> XmlSettingList = xf.ToList <GallerySettingsEntity>(); List <GalleryGroupEntity> XmlGroupList = xf.ToList <GalleryGroupEntity>(); //插入分组的记录 foreach (GalleryGroupEntity XmlGroupItem in XmlGroupList) { QueryParam qp = new QueryParam(); qp.Where.Add(new SearchParam(DNNGo_DNNGalleryPro_Group._.ModuleId, ModuleID, SearchType.Equal)); qp.Where.Add(new SearchParam(DNNGo_DNNGalleryPro_Group._.Name, XmlGroupItem.Name, SearchType.Equal)); if (DNNGo_DNNGalleryPro_Group.FindCount(qp) == 0) { DNNGo_DNNGalleryPro_Group ContentItem = new DNNGo_DNNGalleryPro_Group(); ContentItem.Name = XmlGroupItem.Name; ContentItem.Description = XmlGroupItem.Description; ContentItem.QuoteCount = Convert.ToInt32(XmlGroupItem.QuoteCount); ContentItem.Sort = Convert.ToInt32(XmlGroupItem.Sort); ContentItem.ModuleId = ModuleID; ContentItem.PortalId = DNNGalleryPro_PortalSettings.PortalId; ContentItem.Insert(); } } //插入内容的记录 foreach (XmlSliserEntity XmlContentItem in XmlContentList) { DNNGo_DNNGalleryPro_Slider ContentItem = XmlToEntity(XmlContentItem); ContentItem.ID = ContentItem.Insert(); if (ContentItem.ID > 0) { InsertResult++; ImportLayers(ContentItem, Common.XmlDecode(XmlContentItem.Layers)); //插入分组 DNNGo_DNNGalleryPro_Slider_Group.InsertItem(ContentItem, XmlContentItem.Groups); } } //移除掉部分设置 XmlSettingList.RemoveAll(r => r.SettingName == "DNNGalleryPro_CopyOfOtherModule"); XmlSettingList.RemoveAll(r => r.SettingName == "DNNGalleryPro_CopyOfPortal"); XmlSettingList.RemoveAll(r => r.SettingName == "DNNGalleryPro_TabID"); XmlSettingList.RemoveAll(r => r.SettingName == "DNNGalleryPro_ModuleID"); //插入设置的记录 foreach (GallerySettingsEntity XmlSettingItem in XmlSettingList) { UpdateModuleSetting(ModuleID, XmlSettingItem.SettingName, XmlSettingItem.SettingValue); } } return(InsertResult); }
/// <summary> /// Layer列表的HTML生成 /// </summary> public void PushAjaxSliders() { EffectDBEntity EffectDB = Setting_EffectDB; QueryParam qp = new QueryParam(); qp.OrderType = 0; qp.PageIndex = WebHelper.GetIntParam(Request, "PageIndex", 2); if (qp.PageIndex <= 1) { qp.PageSize = WebHelper.GetIntParam(Request, "FirstScreen", 10); if (qp.PageSize <= 0) { qp.PageSize = WebHelper.GetIntParam(Request, "LoadDisplay", 10); } } else { qp.PageSize = WebHelper.GetIntParam(Request, "LoadDisplay", 10); qp.FirstScreen = WebHelper.GetIntParam(Request, "FirstScreen", 10); } qp.Where.Add(new SearchParam(DNNGo_DNNGalleryPro_Slider._.ModuleId, Settings_ModuleID, SearchType.Equal)); qp.Where.Add(new SearchParam(DNNGo_DNNGalleryPro_Slider._.Status, (Int32)EnumStatus.Activated, SearchType.Equal)); Int32 Search_GroupID = WebHelper.GetIntParam(HttpContext.Current.Request, "GroupID", 0); if (Search_GroupID > 0) { qp.Where.Add(new SearchParam(DNNGo_DNNGalleryPro_Slider._.ID, DNNGo_DNNGalleryPro_Slider_Group.BuilderArticleIDs(Search_GroupID), SearchType.In)); } int RecordCount = 0; List <DNNGo_DNNGalleryPro_Slider> SliderList = new List <DNNGo_DNNGalleryPro_Slider>(); Int32 Sortby = Settings_Sortby; String Orderfld = WebHelper.GetStringParam(Request, "Order", ""); Int32 OrderType = WebHelper.GetIntParam(Request, "OrderBy", -1); if (!String.IsNullOrEmpty(Orderfld)) { if (Orderfld.ToLower() == "title") { Sortby = OrderType == 1 ? (Int32)EnumSortby.Title_Desc : (Int32)EnumSortby.Title; } else if (Orderfld.ToLower() == "starttime") { Sortby = OrderType == 1 ? (Int32)EnumSortby.Time_Desc : (Int32)EnumSortby.Time; } } if (Sortby == (Int32)EnumSortby.Time) { qp.Orderfld = DNNGo_DNNGalleryPro_Slider._.StartTime; SliderList = DNNGo_DNNGalleryPro_Slider.FindAll(qp, out RecordCount); } else if (Sortby == (Int32)EnumSortby.Time_Desc) { qp.OrderType = 1; qp.Orderfld = DNNGo_DNNGalleryPro_Slider._.StartTime; SliderList = DNNGo_DNNGalleryPro_Slider.FindAll(qp, out RecordCount); } else if (Sortby == (Int32)EnumSortby.Title) { qp.Orderfld = DNNGo_DNNGalleryPro_Slider._.Title; SliderList = DNNGo_DNNGalleryPro_Slider.FindAll(qp, out RecordCount); } else if (Sortby == (Int32)EnumSortby.Title_Desc) { qp.OrderType = 1; qp.Orderfld = DNNGo_DNNGalleryPro_Slider._.Title; SliderList = DNNGo_DNNGalleryPro_Slider.FindAll(qp, out RecordCount); } else if (Sortby == (Int32)EnumSortby.Random) { qp.Orderfld = " newid() "; SliderList = DNNGo_DNNGalleryPro_Slider.FindRandomAll(qp, out RecordCount); } else { qp.Orderfld = DNNGo_DNNGalleryPro_Slider._.Sort; SliderList = DNNGo_DNNGalleryPro_Slider.FindAll(qp, out RecordCount); } if (qp.Pages < qp.PageIndex) //索引数大于总页面数时不返回记录 { SliderList = new List <DNNGo_DNNGalleryPro_Slider>(); } Dictionary <String, Object> jsonSliders = new Dictionary <string, Object>(); TemplateFormat xf = new TemplateFormat(); foreach (var SliderItem in SliderList) { int index = SliderList.IndexOf(SliderItem); //index 为索引值 Dictionary <String, Object> jsonSlider = new Dictionary <String, Object>(); jsonSlider.Add("ID", SliderItem.ID); jsonSlider.Add("Sort", SliderItem.Sort); jsonSlider.Add("CreateTime", SliderItem.CreateTime); jsonSlider.Add("StartTime", SliderItem.StartTime); jsonSlider.Add("EndTime", SliderItem.EndTime); jsonSlider.Add("CreateTimeUS", SliderItem.CreateTime.ToString("MM/dd/yyy HH:mm:ss")); jsonSlider.Add("StartTimeUS", SliderItem.StartTime.ToString("MM/dd/yyy HH:mm:ss")); jsonSlider.Add("EndTimeUS", SliderItem.EndTime.ToString("MM/dd/yyy HH:mm:ss")); jsonSlider.Add("Status", SliderItem.Status == 1 ? "checked=\"checked\"" : ""); jsonSlider.Add("Pages", qp.Pages); foreach (var SliderSetting in Setting_SliderSettingDB) { String SliderName = SliderSetting.Name; String SliderValue = xf.ViewSliderSettingT <String>(SliderItem, SliderName, SliderSetting.DefaultValue); if (SliderSetting.ControlType == EnumControlType.Urls.ToString()) { jsonSlider.Add(SliderName, ViewLinkUrl(SliderValue, false)); } else { jsonSlider.Add(SliderName, SliderValue); } } //加载分组 if (EffectDB.Groups) { jsonSlider.Add("Groups", xf.ToGroups(SliderItem)); } //取出Layers数据 if (EffectDB.Layers) { Dictionary <String, Object> jsonLayers = new Dictionary <String, Object>(); List <DNNGo_DNNGalleryPro_Layer> LayerList = SliderItem.LayerList; if (LayerList != null && LayerList.Count > 0) { foreach (var Layer in LayerList) { int indexLayer = LayerList.IndexOf(Layer); Dictionary <String, Object> jsonLayer = new Dictionary <String, Object>(); foreach (var LayerSetting in Setting_LayerSettingDB) { String LayerName = LayerSetting.Name; String LayerValue = xf.ViewLayerSettingT <String>(Layer, LayerName, LayerSetting.DefaultValue); if (LayerSetting.ControlType == EnumControlType.Urls.ToString()) { jsonLayer.Add(LayerName, ViewLinkUrl(LayerValue, false)); } else { jsonLayer.Add(LayerName, LayerValue); } } jsonLayer.Add("ID", Layer.ID); jsonLayer.Add("Sort", Layer.Sort); jsonLayer.Add("Clicks", Layer.Clicks); jsonLayer.Add("Views", Layer.Views); jsonLayer.Add("Heats", Layer.Heats); jsonLayer.Add("CreateTime", Layer.CreateTime); jsonLayers.Add((10000 - indexLayer).ToString(), jsonLayer); } } jsonSlider.Add("Layers", jsonLayers); } //取出扩展项 Dictionary <String, Object> jsonExtension = new Dictionary <String, Object>(); if (!String.IsNullOrEmpty(SliderItem.Extension)) { List <KeyValueEntity> ExtensionSettings = ConvertTo.Deserialize <List <KeyValueEntity> >(SliderItem.Extension); foreach (KeyValueEntity kv in ExtensionSettings) { if (!jsonExtension.ContainsKey(kv.Key)) { jsonExtension.Add(kv.Key, kv.Value); } } } jsonSlider.Add("Extensions", jsonExtension); jsonSliders.Add(index.ToString(), jsonSlider); } //转换数据为json JavaScriptSerializer jsSerializer = new JavaScriptSerializer(); Response.Clear(); Response.Write(jsSerializer.Serialize(jsonSliders)); Response.End(); }