public void GetJSON()
        {
            if (JsonType.IndexOf("Settings", StringComparison.CurrentCultureIgnoreCase) >= 0)
            {
                List <KeyValueEntity>       DefaultSettings = GetDefaultSettings();
                Dictionary <String, object> DictsSettings   = new Dictionary <string, object>();


                foreach (KeyValueEntity kvEntity in DefaultSettings)
                {
                    String SettingName = String.Format("Global_{0}", kvEntity.Key);
                    if (Settings.ContainsKey(SettingName))
                    {
                        DictsSettings.Add(kvEntity.Key, Settings[SettingName]);
                    }
                    else
                    {
                        DictsSettings.Add(kvEntity.Key, kvEntity.Value);
                    }
                }

                Response.Write(jsSerializer.Serialize(DictsSettings));
            }
            else
            {
                List <DNNGo_LayerGallery_Content> Sliders = DNNGo_LayerGallery_Content.FindAll(this);

                Dictionary <String, object> DictsSliders = new Dictionary <string, object>();


                for (int i = 0; i < Sliders.Count; i++)
                {
                    DNNGo_LayerGallery_Content Slider = Sliders[i];

                    Dictionary <String, object> Slider_Options = jsSerializer.DeserializeObject(Slider.Options) as Dictionary <String, object>;

                    SetDicts(ref Slider_Options, "id", Slider.ID);
                    SetDicts(ref Slider_Options, "sort", i + 1);
                    SetDicts(ref Slider_Options, "StartTime", Slider.StartTime.ToString("MM/dd/yyyy HH:mm", new CultureInfo("en-US", false)));
                    SetDicts(ref Slider_Options, "EndTime", Slider.EndTime.ToString("MM/dd/yyyy HH:mm", new CultureInfo("en-US", false)));
                    //SetDicts(ref Slider_Options, "StartTime", Slider.StartTime);
                    //SetDicts(ref Slider_Options, "EndTime", Slider.EndTime);

                    //增加layers的定义
                    Dictionary <String, object> Layer_Options = GetLayerItems(Slider);
                    if (Layer_Options != null && Layer_Options.Count > 0)
                    {
                        Slider_Options.Add("layers", Layer_Options);
                    }

                    DictsSliders.Add(String.Format("slide_{0}", Slider.ID), Slider_Options);
                }

                Response.Write(jsSerializer.Serialize(DictsSliders));

                //Response.Write(System.IO.File.ReadAllText(Server.MapPath(String.Format("{0}Resource/templates/data.html", ModulePath))));
            }
        }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// ExportModule implements the IPortable ExportModule Interface
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <param name="ModuleID">The Id of the module to be exported</param>
        /// <history>
        /// </history>
        /// -----------------------------------------------------------------------------

        public string ExportModule(int ModuleID)
        {
            string strXML = String.Empty;

            ImportExportHelper ieHelper = new ImportExportHelper();

            ieHelper.ModuleID = ModuleID;
            ieHelper.UserId   = 1;

            //查询字段的数据,填充待导出的XML实体
            QueryParam qp = new QueryParam();

            qp.OrderType = 0;
            Int32 RecordCount = 0;

            qp.Where.Add(new SearchParam("ModuleId", ModuleID, SearchType.Equal));
            List <DNNGo_LayerGallery_Content> ArticleList = DNNGo_LayerGallery_Content.FindAll(qp, out RecordCount);

            if (ArticleList != null && ArticleList.Count > 0)
            {
                List <GalleryContentEntity>  xmlContentList = new List <GalleryContentEntity>();
                List <GallerySettingsEntity> xmlSettingList = new List <GallerySettingsEntity>();


                //查询出所有的配置项
                if (ieHelper.Settings != null && ieHelper.Settings.Count > 0)
                {
                    List <KeyValueEntity> DefaultSettings = ieHelper.GetDefaultSettings();

                    foreach (KeyValueEntity kv in DefaultSettings)
                    {
                        String key = String.Format("Global_{0}", kv.Key);
                        if (!xmlSettingList.Exists(r1 => r1.SettingName == key) && ieHelper.Settings[key] != null)
                        {
                            xmlSettingList.Add(new GallerySettingsEntity(key, Convert.ToString(ieHelper.Settings[key])));
                        }
                    }
                }

                foreach (DNNGo_LayerGallery_Content ContentItem in ArticleList)
                {
                    xmlContentList.Add(ieHelper.EntityToXml(ContentItem));
                }



                XmlFormat xf = new XmlFormat(HttpContext.Current.Server.MapPath(String.Format("{0}Resource/xml/Entity.xml", ieHelper.ModulePath)));
                strXML = xf.ToXml <GalleryContentEntity>(xmlContentList, xmlSettingList);
            }
            else
            {
            }

            return(strXML);
        }
Exemple #3
0
        /// <summary>
        /// 导出数据到XML
        /// </summary>
        protected void cmdExportToXml_Click(object sender, EventArgs e)
        {
            try
            {
                //查询字段的数据,填充待导出的XML实体
                QueryParam qp = new QueryParam();
                qp.OrderType = 0;
                Int32 RecordCount = 0;
                qp.Where.Add(new SearchParam("ModuleId", ModuleId, SearchType.Equal));
                List <DNNGo_LayerGallery_Content> ArticleList = DNNGo_LayerGallery_Content.FindAll(qp, out RecordCount);

                if (ArticleList != null && ArticleList.Count > 0)
                {
                    List <GalleryContentEntity>  xmlContentList = new List <GalleryContentEntity>();
                    List <GallerySettingsEntity> xmlSettingList = new List <GallerySettingsEntity>();

                    ImportExportHelper ieHelper = new ImportExportHelper();
                    ieHelper.ModuleID = ModuleId;
                    ieHelper.UserId   = UserId;

                    //查询出所有的配置项
                    if (Settings != null && Settings.Count > 0)
                    {
                        List <KeyValueEntity> DefaultSettings = GetDefaultSettings();

                        foreach (KeyValueEntity kv in DefaultSettings)
                        {
                            String key = String.Format("Global_{0}", kv.Key);
                            if (!xmlSettingList.Exists(r1 => r1.SettingName == key) && Settings[key] != null)
                            {
                                xmlSettingList.Add(new GallerySettingsEntity(key, Convert.ToString(Settings[key])));
                            }
                        }
                    }


                    foreach (DNNGo_LayerGallery_Content ContentItem in ArticleList)
                    {
                        xmlContentList.Add(EntityToXml(ContentItem));
                    }



                    XmlFormat xf = new XmlFormat(MapPath(String.Format("{0}Resource/xml/Entity.xml", ModulePath)));
                    //将字段列表转换成XML的实体
                    String XmlContent  = xf.ToXml <GalleryContentEntity>(xmlContentList, xmlSettingList);
                    String XmlFilePath = FileSystemUtils.SaveXmlToFile(String.Format("ContentListEntity_{0}_{1}.xml", ModuleId, xUserTime.UtcTime().ToString("yyyyMMddHHmmssffff")), XmlContent, this);
                    FileSystemUtils.DownloadFile(XmlFilePath, "ContentListEntity.xml");
                }
                else
                {
                    //没有可导出的文章条目
                    mTips.IsPostBack = true;
                    mTips.LoadMessage("ExportContentError", EnumTips.Success, this, new String[] { "" });
                }
            }
            catch (Exception ex)
            {
                DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, ex);
            }
        }
        /// <summary>
        /// 绑定数据项到前台
        /// </summary>
        public void BindDataItem(EffectDBEntity EffectDB)
        {
            List <DNNGo_LayerGallery_Content> DataList = new List <DNNGo_LayerGallery_Content>();
            Hashtable      Puts = new Hashtable();
            TemplateFormat xf   = new TemplateFormat(this);

            xf.PhContent = PhContent;

            //读取需要载入的参数
            QueryParam qp          = new QueryParam();
            int        RecordCount = 0;

            qp.Where.Add(new SearchParam(DNNGo_LayerGallery_Content._.ModuleId, Settings_ModuleID, SearchType.Equal));
            qp.Where.Add(new SearchParam(DNNGo_LayerGallery_Content._.Status, (Int32)EnumStatus.Published, SearchType.Equal));
            qp.Where.Add(new SearchParam(DNNGo_LayerGallery_Content._.StartTime, xUserTime.UtcTime(), SearchType.LtEqual));
            qp.Where.Add(new SearchParam(DNNGo_LayerGallery_Content._.EndTime, xUserTime.UtcTime(), SearchType.GtEqual));
            qp.OrderType = 0;


            if (EffectDB.Pager)//传入分页的数量
            {
                qp.PageSize  = (Int32)xf.ViewXmlSetting("PageSize", 9999);
                qp.PageSize  = qp.PageSize <= 0 ? 9999 : qp.PageSize;
                qp.PageIndex = PageIndex;
            }



            if (Settings_Sortby == (Int32)EnumSortby.Name)
            {
                qp.Orderfld = DNNGo_LayerGallery_Content._.Title;
                DataList    = DNNGo_LayerGallery_Content.FindAll(qp, out RecordCount);
            }
            else if (Settings_Sortby == (Int32)EnumSortby.Name_Desc)
            {
                qp.OrderType = 1;
                qp.Orderfld  = DNNGo_LayerGallery_Content._.Title;
                DataList     = DNNGo_LayerGallery_Content.FindAll(qp, out RecordCount);
            }
            else if (Settings_Sortby == (Int32)EnumSortby.Time)
            {
                qp.Orderfld = DNNGo_LayerGallery_Content._.StartTime;
                DataList    = DNNGo_LayerGallery_Content.FindAll(qp, out RecordCount);
            }
            else if (Settings_Sortby == (Int32)EnumSortby.Time_Desc)
            {
                qp.OrderType = 1;
                qp.Orderfld  = DNNGo_LayerGallery_Content._.StartTime;
                DataList     = DNNGo_LayerGallery_Content.FindAll(qp, out RecordCount);
            }
            else if (Settings_Sortby == (Int32)EnumSortby.Random)
            {
                qp.Orderfld = " newid() ";
                DataList    = DNNGo_LayerGallery_Content.FindRandomAll(qp, out RecordCount);
            }
            else
            {
                qp.Orderfld = DNNGo_LayerGallery_Content._.Sort;
                DataList    = DNNGo_LayerGallery_Content.FindAll(qp, out RecordCount);
            }

            List <DNNGo_LayerGallery_Content> tList = new List <DNNGo_LayerGallery_Content>();

            //查看需要过滤掉非激活的选项
            foreach (var content in DataList)
            {
                String Activate = Convert.ToString(xf.GetValue(xf.ViewDicts(content), "activate", "on"));
                if (String.IsNullOrEmpty(Activate) || Activate.ToLower() == "on")
                {
                    tList.Add(content);
                }
            }



            Puts.Add("DataList", tList);
            Puts.Add("EffectName", Settings_EffectName);
            Puts.Add("ThemeName", Settings_EffectThemeName);


            //加载LayerList
            Puts.Add("LayerList", GetLayerList());



            if (EffectDB.Pager && RecordCount > qp.PageSize)
            {
                Puts.Add("Pager", new Pager(qp.PageIndex, qp.PageSize, ModuleId, RecordCount, EnumPageType.DnnURL).CreateHtml());//分页
            }
            else
            {
                Puts.Add("Pager", "");
            }

            String HtmlContent = ViewTemplate(EffectDB, "Effect.html", Puts, xf);


            //#if RELEASE  //Release状态下需要格式化HTML代码
            HtmlContent = CodeDeal.DealCode(HtmlContent);    //格式化HTML
            //#endif
            liContent.Text = HtmlContent;
        }