Esempio n. 1
0
        /// <summary>
        /// Layer列表的HTML生成
        /// </summary>
        public void PushLayerListHtml()
        {
            Int32 SliderID = WebHelper.GetIntParam(Request, "SliderID", 0);

            if (SliderID > 0)
            {
                QueryParam qp = new QueryParam();
                qp.Orderfld  = DNNGo_DNNGalleryPro_Layer._.Sort;
                qp.OrderType = 0;
                qp.PageIndex = WebHelper.GetIntParam(Request, "PageIndex", 1);
                qp.PageSize  = WebHelper.GetIntParam(Request, "PageSize", Int32.MaxValue);

                Int32 LayerID = WebHelper.GetIntParam(Request, "LayerID", 0);
                if (LayerID > 0)
                {
                    qp.Where.Add(new SearchParam(DNNGo_DNNGalleryPro_Layer._.ID, LayerID, SearchType.Equal));
                }

                qp.Where.Add(new SearchParam(DNNGo_DNNGalleryPro_Layer._.SliderID, SliderID, SearchType.Equal));


                int RecordCount = 0;
                List <DNNGo_DNNGalleryPro_Layer> LayerList = DNNGo_DNNGalleryPro_Layer.FindAll(qp, out RecordCount);

                Dictionary <String, Object> jsonLayers = new Dictionary <string, Object>();

                TemplateFormat xf = new TemplateFormat();


                foreach (var LayerItem in LayerList)
                {
                    int index = LayerList.IndexOf(LayerItem); //index 为索引值

                    Dictionary <String, Object> jsonLayer = new Dictionary <String, Object>();

                    jsonLayer.Add("ID", LayerItem.ID);
                    jsonLayer.Add("Sort", LayerItem.Sort);
                    jsonLayer.Add("CreateTime", LayerItem.CreateTime);
                    jsonLayer.Add("Status", LayerItem.Status == 1 ? "checked=\"checked\"" : "");
                    jsonLayer.Add("Title", WebHelper.leftx(xf.ViewLayerSettingT <String>(LayerItem, "Title", ""), 30, "..."));


                    String LayerType = xf.ViewLayerSettingT <String>(LayerItem, "LayerType", "");
                    jsonLayer.Add("LayerType", String.IsNullOrEmpty(LayerType) ? "Common" : LayerType);

                    jsonLayer.Add("Edit", String.Format("{0}Resource_Item.aspx?ModuleId={1}&PortalId={2}&TabId={3}&SliderID={4}&LayerID={5}&LayerType={6}", ModulePath, ModuleId, PortalId, TabId, SliderID, LayerItem.ID, LayerType));



                    String Thumbnail = xf.ViewLayerSettingT <String>(LayerItem, "Thumbnail", "");
                    if (String.IsNullOrEmpty(Thumbnail))
                    {
                        Thumbnail = xf.ViewLayerSettingT <String>(LayerItem, "Picture", "");
                    }

                    if (!String.IsNullOrEmpty(Thumbnail))
                    {
                        jsonLayer.Add("Thumbnail", String.Format("<img style=\"border-width:0px; max-height:60px;max-width:80px;\"  src=\"{0}\" onError=\"this.src='{1}Resource/images/no_image.png'\"  /> ", ViewLinkUrl(Thumbnail), ModulePath));
                    }
                    else
                    {
                        jsonLayer.Add("Thumbnail", "");
                    }
                    jsonLayers.Add((10000 - index).ToString(), jsonLayer);
                }

                //转换数据为json
                JavaScriptSerializer jsSerializer = new JavaScriptSerializer();
                Response.Clear();
                Response.Write(jsSerializer.Serialize(jsonLayers));
                Response.End();
            }
        }
Esempio n. 2
0
        /// <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();
        }