Ejemplo n.º 1
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// ImportModule implements the IPortable ImportModule Interface
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <param name="ModuleID">The ID of the Module being imported</param>
        /// <param name="Content">The Content being imported</param>
        /// <param name="Version">The Version of the Module Content being imported</param>
        /// <param name="UserID">The UserID of the User importing the Content</param>
        /// <history>
        /// </history>
        /// -----------------------------------------------------------------------------

        public void ImportModule(int ModuleID, string Content, string Version, int UserId)
        {
            //先清除原有的字段列表
            QueryParam qp          = new QueryParam();
            Int32      RecordCount = 0;

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

            foreach (DNNGo_PowerForms_Field fieldItem in fieldList)
            {
                fieldItem.Delete();
            }


            ImportExportHelper ieHelper = new ImportExportHelper();

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

            if (!String.IsNullOrEmpty(Content))
            {
                //将XML转换为实体
                XmlFormat xf = new XmlFormat();
                xf.XmlDoc.LoadXml(Content);
                List <FieldEntity>           XmlFieldList   = xf.ToList <FieldEntity>();
                List <GallerySettingsEntity> XmlSettingList = xf.ToList <GallerySettingsEntity>();

                Int32 InsertResult = 0;
                foreach (FieldEntity XmlField in XmlFieldList)
                {
                    DNNGo_PowerForms_Field FieldItem = ieHelper.XmlToEntity(XmlField);

                    FieldItem.CreateUser = UserId;
                    FieldItem.CreateTime = DateTime.Now;

                    FieldItem.LastIP   = WebHelper.UserHost;
                    FieldItem.LastTime = DateTime.Now;
                    FieldItem.LastUser = UserId;

                    if (FieldItem.Insert() > 0)
                    {
                        InsertResult++;
                    }
                }

                //插入设置的记录
                foreach (GallerySettingsEntity XmlSettingItem in XmlSettingList)
                {
                    if (!String.IsNullOrEmpty(XmlSettingItem.SettingName) && !String.IsNullOrEmpty(XmlSettingItem.SettingValue))
                    {
                        ieHelper.UpdateModuleSetting(XmlSettingItem.SettingName, XmlSettingItem.SettingValue);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        /// -----------------------------------------------------------------------------
        /// <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;

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

            qp.Orderfld  = DNNGo_PowerForms_Field._.Sort;
            qp.OrderType = 0;
            qp.Where.Add(new SearchParam("ModuleId", ModuleID, SearchType.Equal));
            List <DNNGo_PowerForms_Field> fieldList      = DNNGo_PowerForms_Field.FindAll(qp, out RecordCount);
            List <FieldEntity>            xmlFieldList   = new List <FieldEntity>();
            List <GallerySettingsEntity>  xmlSettingList = new List <GallerySettingsEntity>();

            foreach (DNNGo_PowerForms_Field fieldItem in fieldList)
            {
                xmlFieldList.Add(ieHelper.EntityToXml(fieldItem));
            }

            if (xmlFieldList != null && xmlFieldList.Count > 0)
            {
                //查询出所有的配置项
                List <SettingEntity> EffectSettingDB = ieHelper.Setting_EffectSettingDB;
                if (EffectSettingDB != null && EffectSettingDB.Count > 0)
                {
                    foreach (SettingEntity SettingItem in EffectSettingDB)
                    {
                        String SettingValue = ieHelper.ViewXmlSetting(SettingItem.Name, SettingItem.DefaultValue).ToString();
                        xmlSettingList.Add(new GallerySettingsEntity(ieHelper.EffectSettingsFormat(ieHelper.Settings_EffectName, SettingItem.Name), SettingValue));
                    }

                    foreach (String key in ieHelper.PowerForms_Settings.Keys)
                    {
                        if (!xmlSettingList.Exists(r1 => r1.SettingName == key) && key.IndexOf("Gallery") != 0)
                        {
                            xmlSettingList.Add(new GallerySettingsEntity(key, Convert.ToString(ieHelper.PowerForms_Settings[key])));
                        }
                    }
                }


                XmlFormat xf = new XmlFormat(HttpContext.Current.Server.MapPath(String.Format("{0}Resource/xml/FieldEntity.xml", "~/DesktopModules/DNNGo_PowerForms/")));
                strXML = xf.ToXml <FieldEntity>(xmlFieldList, xmlSettingList);
            }
            else
            {
            }

            return(strXML);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 绑定列表
        /// </summary>
        private void BindDataList()
        {
            QueryParam qp = new QueryParam();

            qp.OrderType = OrderType;
            if (!String.IsNullOrEmpty(Orderfld))
            {
                qp.Orderfld = Orderfld;
            }
            else
            {
                qp.Orderfld = DNNGo_PowerForms_Field._.Sort;
            }

            #region "分页的一系列代码"


            int RecordCount = 0;
            int pagesize    = qp.PageSize = 10;
            qp.PageIndex = PageIndex;


            #endregion

            //查询的方法
            qp.Where = BindSearch();

            List <DNNGo_PowerForms_Field> Fields = DNNGo_PowerForms_Field.FindAll(qp, out RecordCount);
            qp.RecordCount      = RecordCount;
            RecordPages         = qp.Pages;
            lblRecordCount.Text = String.Format("{0} {2} / {1} {3}", RecordCount, RecordPages, ViewResourceText("Title_Items", "Items"), ViewResourceText("Title_Pages", "Pages"));

            hlAllFields.Text       = String.Format("{1} ({0})", DNNGo_PowerForms_Field.FindCountByStatus(ModuleId, -1), ViewResourceText("hlAllFields", "All"));
            hlActivationField.Text = String.Format("{1} ({0})", DNNGo_PowerForms_Field.FindCountByStatus(ModuleId, (Int32)EnumStatus.Activation), ViewResourceText("hlActivationField", "Activation"));
            hlHideField.Text       = String.Format("{1} ({0})", DNNGo_PowerForms_Field.FindCountByStatus(ModuleId, (Int32)EnumStatus.Hide), ViewResourceText("hlHideField", "Hide"));



            //ctlPagingControl.TotalRecords = RecordCount;

            //if (RecordCount <= pagesize)
            //{
            //    ctlPagingControl.Visible = false;

            //}

            gvFieldList.DataSource = Fields;
            gvFieldList.DataBind();
            BindGridViewEmpty <DNNGo_PowerForms_Field>(gvFieldList, new DNNGo_PowerForms_Field());
            gvFieldList.Columns[7].Visible = false;                  //屏蔽排序的列
            gvFieldList.Columns[2].Visible = Setting_EffectDB.Group; //分组展现
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 导出数据到XML
        /// </summary>
        protected void cmdExportToXml_Click(object sender, EventArgs e)
        {
            ImportExportHelper ieHelper = new ImportExportHelper();

            ieHelper.ModuleID = ModuleId;

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

            qp.Orderfld  = DNNGo_PowerForms_Field._.Sort;
            qp.OrderType = 0;
            qp.Where.Add(new SearchParam("ModuleId", ModuleId, SearchType.Equal));
            List <DNNGo_PowerForms_Field> fieldList      = DNNGo_PowerForms_Field.FindAll(qp, out RecordCount);
            List <FieldEntity>            xmlFieldList   = new List <FieldEntity>();
            List <GallerySettingsEntity>  xmlSettingList = new List <GallerySettingsEntity>();

            foreach (DNNGo_PowerForms_Field fieldItem in fieldList)
            {
                xmlFieldList.Add(ieHelper.EntityToXml(fieldItem));
            }

            //查询出所有的配置项
            List <SettingEntity> EffectSettingDB = ieHelper.Setting_EffectSettingDB;

            if (EffectSettingDB != null && EffectSettingDB.Count > 0)
            {
                foreach (SettingEntity SettingItem in EffectSettingDB)
                {
                    String SettingValue = ieHelper.ViewXmlSetting(SettingItem.Name, SettingItem.DefaultValue).ToString();
                    xmlSettingList.Add(new GallerySettingsEntity(ieHelper.EffectSettingsFormat(ieHelper.Settings_EffectName, SettingItem.Name), SettingValue));
                }

                foreach (String key in ieHelper.PowerForms_Settings.Keys)
                {
                    if (!xmlSettingList.Exists(r1 => r1.SettingName == key) && key.IndexOf("Gallery") != 0)
                    {
                        xmlSettingList.Add(new GallerySettingsEntity(key, Convert.ToString(ieHelper.PowerForms_Settings[key])));
                    }
                }
            }

            XmlFormat xf = new XmlFormat(MapPath(String.Format("{0}Resource/xml/FieldEntity.xml", ModulePath)));
            //将字段列表转换成XML的实体
            String XmlContent  = xf.ToXml <FieldEntity>(xmlFieldList, xmlSettingList);
            String XmlFilePath = FileSystemUtils.SaveXmlToFile(String.Format("FieldListEntity_{0}_{1}.xml", ModuleId, xUserTime.UtcTime().ToString("yyyyMMddHHmmssffff")), XmlContent, this);

            FileSystemUtils.DownloadFile(XmlFilePath, "FieldListEntity.xml");
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 从XML导入数据
        /// </summary>
        protected void cmdImportFormXml_Click(object sender, EventArgs e)
        {
            try
            {
                HttpPostedFile hpfile = fuImportFormXml.PostedFile;

                if (hpfile.ContentLength > 0)
                {
                    if (Path.GetExtension(hpfile.FileName).IndexOf(".xml", StringComparison.CurrentCultureIgnoreCase) >= 0)
                    {
                        ImportExportHelper ieHelper = new ImportExportHelper();
                        ieHelper.ModuleID = ModuleId;
                        ieHelper.UserId   = UserId;

                        //先清除原有的字段列表
                        QueryParam qp          = new QueryParam();
                        Int32      RecordCount = 0;
                        qp.Where.Add(new SearchParam("ModuleId", ModuleId, SearchType.Equal));
                        List <DNNGo_PowerForms_Field> fieldList = DNNGo_PowerForms_Field.FindAll(qp, out RecordCount);
                        foreach (DNNGo_PowerForms_Field fieldItem in fieldList)
                        {
                            fieldItem.Delete();
                        }

                        //构造需要上传的路径
                        String   XmlFilePath = String.Format("{0}PowerForms\\Import\\{1}_{2}", PortalSettings.HomeDirectoryMapPath, xUserTime.UtcTime().ToString("yyyyMMddHHmmssffff"), fuImportFormXml.FileName);
                        FileInfo XmlFile     = new FileInfo(XmlFilePath);
                        //判断文件夹是否存在
                        if (!XmlFile.Directory.Exists)
                        {
                            XmlFile.Directory.Create();
                        }
                        //保存文件
                        fuImportFormXml.SaveAs(XmlFilePath);

                        XmlFormat xf = new XmlFormat(XmlFilePath);

                        List <FieldEntity> XmlFieldList = xf.ToList <FieldEntity>();


                        Int32 InsertResult = 0;
                        foreach (FieldEntity XmlField in XmlFieldList)
                        {
                            DNNGo_PowerForms_Field FieldItem = ieHelper.XmlToEntity(XmlField);


                            FieldItem.CreateUser = UserId;
                            FieldItem.CreateTime = xUserTime.UtcTime();

                            FieldItem.ModuleId = ModuleId;
                            FieldItem.PortalId = PortalId;

                            FieldItem.LastIP   = WebHelper.UserHost;
                            FieldItem.LastTime = xUserTime.UtcTime();
                            FieldItem.LastUser = UserId;

                            if (FieldItem.Insert() > 0)
                            {
                                InsertResult++;
                            }
                        }

                        //提示
                        mTips.LoadMessage("ImportFieldSuccess", EnumTips.Success, this, new String[] { InsertResult.ToString() });

                        //跳转
                        Response.Redirect(xUrl("FieldList"));
                    }
                    else
                    {
                        //上传文件的后缀名错误
                        mTips.IsPostBack = true;
                        mTips.LoadMessage("UploadFieldExtensionError", EnumTips.Warning, this, new String[] { "xml" });
                    }
                }
                else
                {
                    //为上传任何数据
                    mTips.IsPostBack = true;
                    mTips.LoadMessage("ImportFieldNullError", EnumTips.Success, this, new String[] { "" });
                }
            }
            catch (Exception ex)
            {
                DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, ex);
            }
        }