コード例 #1
0
        public Int32 UpdateLayerItem(Dictionary <String, object> Layer_Items, Int32 SliderID, int Layer_Index)
        {
            List <KeyValueEntity> tempLayer = ConvertTo.ToList(Layer_Items);


            DNNGo_LayerGallery_Item Layer = new DNNGo_LayerGallery_Item();


            //取出编号
            Layer.ID = ConvertTo.GetValue <Int32>(tempLayer, "id", 0);
            //读取数据库中的数据
            if (Layer.ID > 0)
            {
                Layer = DNNGo_LayerGallery_Item.FindByKeyForEdit(Layer.ID);
            }

            //将Layer项的定义序列化后存储
            Layer.Options = jsSerializer.Serialize(Layer_Items);

            //取出排序编号
            Layer.Sort = ConvertTo.GetValue <Int32>(tempLayer, "sort", Layer_Index + 1);

            //取出标题
            Layer.Title = ConvertTo.GetValue <String>(tempLayer, "title", "");

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


            if (Layer.ID > 0)
            {
                //更新
                Layer.Update();
            }
            else
            {
                //新增
                Layer.ModuleId = ModuleId;
                Layer.PortalId = PortalId;

                Layer.ContentID = ConvertTo.GetValue <Int32>(tempLayer, "SliderID", SliderID);
                Layer.Status    = (Int32)EnumStatus.Published;

                Layer.ID = Layer.Insert();
            }

            return(Layer.ID);
        }
コード例 #2
0
        /// <summary>
        /// 导入项
        /// </summary>
        /// <param name="Content"></param>
        /// <param name="ContentEntity"></param>
        /// <returns></returns>
        public Int32 ImportItem(DNNGo_LayerGallery_Content Content, String ItemList)
        {
            Int32 Result = 0;

            if (Content != null && Content.ID > 0 && !String.IsNullOrEmpty(ItemList))
            {
                //还原出项的列表
                XmlFormat xf = new XmlFormat();
                xf.XmlDoc.LoadXml(Common.XmlDecode(ItemList));

                List <GalleryItemEntity> list = xf.ToList <GalleryItemEntity>();

                foreach (GalleryItemEntity itemEntity in list)
                {
                    DNNGo_LayerGallery_Item item = new DNNGo_LayerGallery_Item();

                    item.Options = Common.XmlDecode(itemEntity.Options);
                    item.Status  = itemEntity.Status;
                    item.Title   = itemEntity.Title;
                    item.Sort    = itemEntity.Sort;



                    item.ModuleId  = Content.ModuleId;
                    item.PortalId  = Content.PortalId;
                    item.LastTime  = Content.LastTime;
                    item.LastUser  = Content.LastUser;
                    item.LastIP    = Content.LastIP;
                    item.ContentID = Content.ID;

                    //添加项
                    if (item.Insert() > 0)
                    {
                        Result++;
                    }
                }
            }
            return(Result);
        }