/// -----------------------------------------------------------------------------
        /// <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);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 项的集合转字符串
        /// </summary>
        /// <param name="ContentItem"></param>
        /// <returns></returns>
        public String ItemEntityToString(DNNGo_LayerGallery_Content ContentItem)
        {
            String ItemXml = String.Empty;

            if (ContentItem != null && ContentItem.ID > 0)
            {
                QueryParam qp          = new QueryParam();
                int        RecordCount = 0;
                qp.Where.Add(new SearchParam(DNNGo_LayerGallery_Item._.ContentID, ContentItem.ID, SearchType.Equal));
                List <DNNGo_LayerGallery_Item> list = DNNGo_LayerGallery_Item.FindAll(qp, out RecordCount);
                if (list != null && list.Count > 0)
                {
                    List <GalleryItemEntity> ItemList = new List <GalleryItemEntity>();
                    foreach (DNNGo_LayerGallery_Item item in list)
                    {
                        ItemList.Add(EntityToXml(item));
                    }
                    XmlFormat xf = new XmlFormat(MapPath(String.Format("{0}Resource/xml/ItemEntity.xml", ModulePath)));
                    ItemXml = xf.ToXml <GalleryItemEntity>(ItemList);
                }
            }
            return(ItemXml);
        }
Exemplo n.º 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);
            }
        }