/// <summary>
        /// 导入数据
        /// </summary>
        /// <param name="XmlContent"></param>
        /// <returns></returns>
        public Int32 Import(Stream XmlContent)
        {
            //插入成功的数量
            Int32 InsertResult = 0;


            if (XmlContent != null && XmlContent.Length > 0)
            {
                //将XML转换为实体
                XmlFormat xf = new XmlFormat();
                xf.XmlDoc.Load(XmlContent);
                List <XmlSliserEntity>       XmlContentList = xf.ToList <XmlSliserEntity>();
                List <GallerySettingsEntity> XmlSettingList = xf.ToList <GallerySettingsEntity>();
                List <GalleryGroupEntity>    XmlGroupList   = xf.ToList <GalleryGroupEntity>();


                //插入分组的记录
                foreach (GalleryGroupEntity XmlGroupItem in XmlGroupList)
                {
                    QueryParam qp = new QueryParam();
                    qp.Where.Add(new SearchParam(DNNGo_DNNGalleryProGame_Group._.ModuleId, ModuleID, SearchType.Equal));
                    qp.Where.Add(new SearchParam(DNNGo_DNNGalleryProGame_Group._.Name, XmlGroupItem.Name, SearchType.Equal));
                    if (DNNGo_DNNGalleryProGame_Group.FindCount(qp) == 0)
                    {
                        DNNGo_DNNGalleryProGame_Group ContentItem = new DNNGo_DNNGalleryProGame_Group();
                        ContentItem.Name        = XmlGroupItem.Name;
                        ContentItem.Description = XmlGroupItem.Description;
                        ContentItem.QuoteCount  = Convert.ToInt32(XmlGroupItem.QuoteCount);
                        ContentItem.Sort        = Convert.ToInt32(XmlGroupItem.Sort);

                        ContentItem.ModuleId = ModuleID;
                        ContentItem.PortalId = DNNGalleryProGame_PortalSettings.PortalId;
                        ContentItem.Insert();
                    }
                }


                //插入内容的记录
                foreach (XmlSliserEntity XmlContentItem in XmlContentList)
                {
                    DNNGo_DNNGalleryProGame_Slider ContentItem = XmlToEntity(XmlContentItem);
                    ContentItem.ID = ContentItem.Insert();
                    if (ContentItem.ID > 0)
                    {
                        InsertResult++;
                        ImportLayers(ContentItem, Common.XmlDecode(XmlContentItem.Layers));


                        //插入分组
                        DNNGo_DNNGalleryProGame_Slider_Group.InsertItem(ContentItem, XmlContentItem.Groups);
                    }
                }



                //移除掉部分设置
                XmlSettingList.RemoveAll(r => r.SettingName == "DNNGalleryProGame_CopyOfOtherModule");
                XmlSettingList.RemoveAll(r => r.SettingName == "DNNGalleryProGame_CopyOfPortal");
                XmlSettingList.RemoveAll(r => r.SettingName == "DNNGalleryProGame_TabID");
                XmlSettingList.RemoveAll(r => r.SettingName == "DNNGalleryProGame_ModuleID");

                //插入设置的记录
                foreach (GallerySettingsEntity XmlSettingItem in XmlSettingList)
                {
                    UpdateModuleSetting(ModuleID, XmlSettingItem.SettingName, XmlSettingItem.SettingValue);
                }
            }

            return(InsertResult);
        }
Exemple #2
0
        /// <Description>
        /// 保存文章
        /// </Description>
        /// <param name="ArticleStatus">文章状态(为-1的时候取选项的值)</param>
        private Int32 SaveDataItem(Int32 ArticleStatus, ref DNNGo_DNNGalleryProGame_Slider Article)
        {
            int ResultArticle = 0;

            Article = SliderItem;



            //数字更新
            Article.Heats  = WebHelper.GetIntParam(Request, txtHeatNumber.UniqueID, 0);
            Article.Clicks = WebHelper.GetIntParam(Request, txtDownloadNumber.UniqueID, 0);

            //权限
            Article.Per_AllUsers = cbPermissionsAllUsers.Checked ? 0 : 1;


            String textStr, idStr = String.Empty;

            WebHelper.GetSelected(cblPermissionsRoles, out textStr, out idStr);
            Article.Per_Roles = idStr;

            //文章的发布状态
            Article.Status = Convert.ToInt32(ddlArticleStatus.Items[ddlArticleStatus.SelectedIndex].Value);

            //设置属性
            SetItemSettings(ref Article);
            Article.Extension = SetExtensionSettings();


            //关联集合
            Article.Relations = hfRelations.Value;

            //更新项
            Article.LastIP   = WebHelper.UserHost;
            Article.LastTime = xUserTime.UtcTime();
            Article.LastUser = UserId;

            //发布状态和时间
            DateTime oTime = xUserTime.LocalTime();

            string[] expectedFormats = { "G", "g", "f", "F" };
            string   StartDate       = WebHelper.GetStringParam(Request, txtStartDate.UniqueID, oTime.ToString("MM/dd/yyyy"));
            string   StartTime       = WebHelper.GetStringParam(Request, txtStartTime.UniqueID, oTime.ToString("hh:mm tt"));

            if (DateTime.TryParseExact(String.Format("{0} {1}", StartDate, StartTime), "MM/dd/yyyy hh:mm tt", new CultureInfo("en-US", false), DateTimeStyles.AllowWhiteSpaces, out oTime))
            {
                if (oTime.Second == 0)
                {
                    oTime = oTime.AddSeconds(DateTime.Now.Second);                   //补秒
                }
                Article.StartTime = oTime;
            }
            //发布状态和时间
            DateTime EndTime     = xUserTime.LocalTime().AddYears(10);
            string   DisableDate = WebHelper.GetStringParam(Request, txtDisableDate.UniqueID, EndTime.ToString("MM/dd/yyyy"));
            string   DisableTime = WebHelper.GetStringParam(Request, txtDisableTime.UniqueID, EndTime.ToString("hh:mm tt"));

            if (DateTime.TryParseExact(String.Format("{0} {1}", DisableDate, DisableTime), "MM/dd/yyyy hh:mm tt", new CultureInfo("en-US", false), DateTimeStyles.AllowWhiteSpaces, out EndTime))
            {
                if (EndTime.Second == 0)
                {
                    EndTime = EndTime.AddSeconds(DateTime.Now.Second);                     //补秒
                }
                Article.EndTime = EndTime;
            }

            //创建用户改为可以选择
            //Article.CreateUser = WebHelper.GetIntParam(Request, txtCreateUser.UniqueID, UserId);


            if (ArticleStatus == -1)//如果没有指定状态就取控件的
            {
                Article.Status = WebHelper.GetIntParam(Request, ddlArticleStatus.UniqueID, (Int32)EnumStatus.Activated);
            }
            else
            {
                Article.Status = ArticleStatus;
            }


            if (Article.ID > 0)
            {
                //更新
                ResultArticle = Article.Update();
            }
            else
            {
                //新增
                Article.CreateTime = xUserTime.UtcTime();
                Article.CreateUser = UserId;

                Article.ModuleId = ModuleId;
                Article.PortalId = PortalId;

                QueryParam Sqp = new QueryParam();
                Sqp.ReturnFields = Sqp.Orderfld = DNNGo_DNNGalleryProGame_Slider._.Sort;
                Sqp.OrderType    = 1;
                Sqp.Where.Add(new SearchParam(DNNGo_DNNGalleryProGame_Slider._.ModuleId, ModuleId, SearchType.Equal));
                Article.Sort = Convert.ToInt32(DNNGo_DNNGalleryProGame_Slider.FindScalar(Sqp)) + 2;

                Article.ID = ResultArticle = Article.Insert();
            }



            if (ResultArticle > 0)
            {
                if (divGroups.Visible)
                {
                    //更新分类项
                    String Categorys = WebHelper.GetStringParam(Request, String.Format("post$groups${0}", ModuleId), "");
                    ManagedThreadPool.QueueUserWorkItem(new WaitCallback(ThreadUpdateGroups), new KeyValueEntity(Article.ID.ToString(), Categorys));
                }



                ////操作成功
                //mTips.LoadMessage("SaveArticleSuccess", EnumTips.Success, this, new String[] { Article.Title });

                ////操作成功需要跳转到首页
                //Response.Redirect(xUrl("Posts"));
            }
            else
            {
                //mTips.IsPostBack = false;

                ////操作失败
                //mTips.LoadMessage("SaveArticleError", EnumTips.Success, this, new String[] { Article.Title });

                ////操作失败就留在本页面
            }
            return(ResultArticle);
        }