/// <summary> /// 拼接数据项的设置参数 /// </summary> /// <returns></returns> public String SetItemSettings() { //获取效果参数 List <SettingEntity> ItemSettingDB = Setting_CategorySettingDB; 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); } } return(ConvertTo.Serialize <List <KeyValueEntity> >(list)); }
/// <summary> /// 保存需要提示的内容 /// </summary> public void Put() { if (!String.IsNullOrEmpty(_Content)) { //将当前的内容序列化到个人缓存 String s = ConvertTo.Serialize <MessageTips>((MessageTips)this); //如果有Session的话需要先清除 if (HttpContext.Current.Session[SessionName()] != null) { HttpContext.Current.Session.Remove(SessionName()); } //增加当前序列化的内容到Session HttpContext.Current.Session.Add(SessionName(), s); } //跳转 if (!String.IsNullOrEmpty(_GoUrl)) { HttpContext.Current.Response.Redirect(_GoUrl, true); } }
/// <summary> /// 读取数据项参数 /// </summary> /// <param name="DataItem">数据项</param> /// <param name="Name">参数名</param> /// <param name="DefaultValue">默认值</param> /// <returns></returns> public static object ViewCategorySettingByStatic(DNNGo_DNNGalleryProGame_Group DataItem, String Name, object DefaultValue) { object o = DefaultValue; if (DataItem != null && DataItem.ID > 0 && !String.IsNullOrEmpty(DataItem.Options)) { try { List <KeyValueEntity> ItemSettings = ConvertTo.Deserialize <List <KeyValueEntity> >(DataItem.Options); KeyValueEntity KeyValue = ItemSettings.Find(r1 => r1.Key.ToLower() == Name.ToLower()); if (KeyValue != null && !String.IsNullOrEmpty(KeyValue.Key)) { o = KeyValue.Value; } } catch { } } return(o); }
/// <summary> /// Gets the date time param. /// </summary> /// <param name="request">The request.</param> /// <param name="paramName">Name of the param.</param> /// <param name="errorReturn">The error return.</param> /// <returns>The param value.</returns> public static DateTime GetDateTimeParam(System.Web.HttpRequest request, string paramName, DateTime errorReturn) { string retStr = request.Form[paramName]; if (retStr == null) { retStr = request.QueryString[paramName]; } if (retStr == null || retStr.Trim() == string.Empty) { return(errorReturn); } try { return((DateTime)ConvertTo.FormatValue(retStr, typeof(DateTime))); } catch { return(errorReturn); } }
/// <Description> /// 拼接数据项的设置参数 /// </Description> /// <returns></returns> public String SetItemSettings() { //获取效果参数 List <SettingEntity> LayerSettingDB = Setting_LayerSettingDB; List <KeyValueEntity> list = new List <KeyValueEntity>(); if (LayerSettingDB != null && LayerSettingDB.Count > 0) { ControlHelper ControlItem = new ControlHelper(this); foreach (SettingEntity ri in LayerSettingDB) { KeyValueEntity item = new KeyValueEntity(); item.Key = ri.Name; item.Value = ControlHelper.GetWebFormValue(ri, this); list.Add(item); } } //添加层的类型 list.Add(new KeyValueEntity("LayerType", LayerType)); return(ConvertTo.Serialize <List <KeyValueEntity> >(list)); }
/// <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)); }
/// <summary> /// 读取XML参数 /// </summary> /// <param name="Name">参数名</param> /// <param name="DefaultValue">默认值</param> /// <returns></returns> public object ViewXmlSetting(String Name, object DefaultValue) { String SettingKey = EffectSettingsFormat(Settings_EffectName, Name); return(DNNGalleryProGame_Settings[SettingKey] != null?ConvertTo.FormatValue(DNNGalleryProGame_Settings[SettingKey].ToString(), DefaultValue.GetType()) : DefaultValue); }
/// <Description> /// 拼接数据项的设置参数 /// </Description> /// <returns></returns> public void SetItemSettings(ref DNNGo_DNNGalleryProGame_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); } } 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(); } String FriendlyUrl = String.Empty; if (list.Exists(r => r.Key == "FriendlyUrl")) { KeyValueEntity TitleEntity = list.Find(r => r.Key == "FriendlyUrl"); FriendlyUrl = TitleEntity.Value.ToString(); if (String.IsNullOrEmpty(FriendlyUrl) && !String.IsNullOrEmpty(Article.Title)) { FriendlyUrl = Common.FriendlySlug(Article.Title); } Article.FriendlyUrl = FriendlyUrl; TitleEntity.Value = FriendlyUrl; list[list.FindIndex(r => r.Key == "FriendlyUrl")] = TitleEntity; } Article.Options = ConvertTo.Serialize <List <KeyValueEntity> >(list); }
/// <summary> /// 列表行绑定 /// </summary> protected void gvArticleList_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { //还原出数据 DNNGo_DNNGalleryProGame_Slider Article = e.Row.DataItem as DNNGo_DNNGalleryProGame_Slider; if (Article != null && Article.ID > 0) { HyperLink hlEdit = e.Row.FindControl("hlEdit") as HyperLink; HyperLink hlMobileEdit = e.Row.FindControl("hlMobileEdit") as HyperLink; LinkButton btnRemove = e.Row.FindControl("btnRemove") as LinkButton; LinkButton btnMobileRemove = e.Row.FindControl("btnMobileRemove") as LinkButton; //移动分类按钮 LinkButton lbSortUp = e.Row.FindControl("lbSortUp") as LinkButton; LinkButton lbSortDown = e.Row.FindControl("lbSortDown") as LinkButton; LinkButton lbMobileSortUp = e.Row.FindControl("lbMobileSortUp") as LinkButton; LinkButton lbMobileSortDown = e.Row.FindControl("lbMobileSortDown") as LinkButton; lbSortUp.CommandArgument = lbSortDown.CommandArgument = lbMobileSortUp.CommandArgument = lbMobileSortDown.CommandArgument = Article.ID.ToString(); //设置按钮的CommandArgument btnRemove.CommandArgument = btnMobileRemove.CommandArgument = Article.ID.ToString(); //设置删除按钮的提示 if (Article.Status == (Int32)EnumStatus.RecycleBin) { btnRemove.Attributes.Add("onClick", "javascript:return confirm('" + Localization.GetString("DeleteItem") + "');"); btnMobileRemove.Attributes.Add("onClick", "javascript:return confirm('" + Localization.GetString("DeleteItem") + "');"); } else { btnRemove.Attributes.Add("onClick", "javascript:return confirm('" + ViewResourceText("DeleteRecycleItem", "Are you sure to move it to recycle bin?") + "');"); btnMobileRemove.Attributes.Add("onClick", "javascript:return confirm('" + ViewResourceText("DeleteRecycleItem", "Are you sure to move it to recycle bin?") + "');"); } hlEdit.NavigateUrl = hlMobileEdit.NavigateUrl = xUrl("ID", Article.ID.ToString(), "AddNew"); //文章状态 e.Row.Cells[7].Text = EnumHelper.GetEnumTextVal(Article.Status, typeof(EnumStatus)); //格式化2种时间为短日期格式 e.Row.Cells[5].Text = Article.StartTime.ToShortDateString(); e.Row.Cells[6].Text = Article.EndTime.ToShortDateString(); //显示分组 if (Setting_EffectDB.Groups) { e.Row.Cells[4].Text = DNNGo_DNNGalleryProGame_Group.FindGroupsBySliderID(Article.ID); } if (!String.IsNullOrEmpty(Article.Options)) { if (gvArticleList.Columns[1].Visible || gvArticleList.Columns[2].Visible) { List <KeyValueEntity> kvList = new List <KeyValueEntity>(); try { kvList = ConvertTo.Deserialize <List <KeyValueEntity> >(Article.Options); } catch { } if (kvList != null && kvList.Count > 0) { if (kvList.Exists(r => r.Key == "Title")) { KeyValueEntity rowEntity = kvList.Find(r => r.Key == "Title"); if (rowEntity != null && !String.IsNullOrEmpty(rowEntity.Key)) { e.Row.Cells[2].Text = Convert.ToString(rowEntity.Value); } } TemplateFormat tf = new TemplateFormat(this); Image imgPicture = e.Row.FindControl("imgPicture") as Image; if (kvList.Exists(r => r.Key == "Thumbnails")) { KeyValueEntity rowEntity = kvList.Find(r => r.Key == "Thumbnails"); if (rowEntity != null && !String.IsNullOrEmpty(rowEntity.Key)) { imgPicture.ImageUrl = tf.ViewLinkUrl(Convert.ToString(rowEntity.Value)); } } else if (kvList.Exists(r => r.Key == "Picture")) { KeyValueEntity rowEntity = kvList.Find(r => r.Key == "Picture"); if (rowEntity != null && !String.IsNullOrEmpty(rowEntity.Key)) { imgPicture.ImageUrl = tf.ViewLinkUrl(Convert.ToString(rowEntity.Value)); } } else { imgPicture.Visible = false; } } } } } } }
/// <summary> /// 创建文章自定义模型的JSON信息 /// </summary> public void PushCustomModels() { Dictionary <String, Object> jsonCustomModels = new Dictionary <String, Object>(); //读取出该事件的信息 Int32 SliderID = WebHelper.GetIntParam(HttpContext.Current.Request, "SliderID", 0); if (SliderID > 0) { DNNGo_DNNGalleryProGame_Slider EventItem = DNNGo_DNNGalleryProGame_Slider.FindByKeyForEdit(SliderID); if (EventItem != null && EventItem.ID > 0 && !String.IsNullOrEmpty(EventItem.Extension)) { //取出扩展项 List <KeyValueEntity> ExtensionSettings = ConvertTo.Deserialize <List <KeyValueEntity> >(EventItem.Extension); foreach (KeyValueEntity k in ExtensionSettings) { if (!jsonCustomModels.ContainsKey(k.Key)) { Dictionary <String, Object> jsonItem = new Dictionary <String, Object>(); jsonItem.Add("Name", k.Key); jsonItem.Add("Value", k.Value); jsonItem.Add("Index", jsonCustomModels.Count); jsonCustomModels.Add(jsonCustomModels.Count.ToString(), jsonItem); } } } } //提取预设值的自定义模型 String CustomModels = ViewXmlSettingT <String>("CustomModels", ""); if (!String.IsNullOrEmpty(CustomModels)) { //提取共用属性名 List <String> ExtensionKeys = Common.GetList(CustomModels, "\r\n");; foreach (String k in ExtensionKeys) { if (!String.IsNullOrEmpty(k) && !jsonCustomModels.ContainsKey(k)) { Dictionary <String, Object> jsonItem = new Dictionary <String, Object>(); jsonItem.Add("Name", k); jsonItem.Add("Value", ""); jsonItem.Add("Index", jsonCustomModels.Count); jsonCustomModels.Add(jsonCustomModels.Count.ToString(), jsonItem); } } } Dictionary <String, Object> jsonNull = new Dictionary <String, Object>(); jsonNull.Add("Name", ""); jsonNull.Add("Value", ""); jsonNull.Add("Index", jsonCustomModels.Count); jsonCustomModels.Add(jsonCustomModels.Count.ToString(), jsonNull); //转换数据为json JavaScriptSerializer jsSerializer = new JavaScriptSerializer(); Response.Clear(); Response.Write(jsSerializer.Serialize(jsonCustomModels)); Response.End(); }
/// <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_DNNGalleryProGame_Slider._.ModuleId, Settings_ModuleID, SearchType.Equal)); qp.Where.Add(new SearchParam(DNNGo_DNNGalleryProGame_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_DNNGalleryProGame_Slider._.ID, DNNGo_DNNGalleryProGame_Slider_Group.BuilderArticleIDs(Search_GroupID), SearchType.In)); } int RecordCount = 0; List <DNNGo_DNNGalleryProGame_Slider> SliderList = new List <DNNGo_DNNGalleryProGame_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_DNNGalleryProGame_Slider._.StartTime; SliderList = DNNGo_DNNGalleryProGame_Slider.FindAll(qp, out RecordCount); } else if (Sortby == (Int32)EnumSortby.Time_Desc) { qp.OrderType = 1; qp.Orderfld = DNNGo_DNNGalleryProGame_Slider._.StartTime; SliderList = DNNGo_DNNGalleryProGame_Slider.FindAll(qp, out RecordCount); } else if (Sortby == (Int32)EnumSortby.Title) { qp.Orderfld = DNNGo_DNNGalleryProGame_Slider._.Title; SliderList = DNNGo_DNNGalleryProGame_Slider.FindAll(qp, out RecordCount); } else if (Sortby == (Int32)EnumSortby.Title_Desc) { qp.OrderType = 1; qp.Orderfld = DNNGo_DNNGalleryProGame_Slider._.Title; SliderList = DNNGo_DNNGalleryProGame_Slider.FindAll(qp, out RecordCount); } else if (Sortby == (Int32)EnumSortby.Random) { qp.Orderfld = " newid() "; SliderList = DNNGo_DNNGalleryProGame_Slider.FindRandomAll(qp, out RecordCount); } else { qp.Orderfld = DNNGo_DNNGalleryProGame_Slider._.Sort; SliderList = DNNGo_DNNGalleryProGame_Slider.FindAll(qp, out RecordCount); } if (qp.Pages < qp.PageIndex) //索引数大于总页面数时不返回记录 { SliderList = new List <DNNGo_DNNGalleryProGame_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_DNNGalleryProGame_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(); }