예제 #1
0
        /// <summary>
        /// 转换选项集合
        /// </summary>
        /// <param name="Options"></param>
        /// <returns></returns>
        public String ConvertOptions(String Options, List <SettingEntity> ItemSettings)
        {
            String String_Options = String.Empty;

            if (!String.IsNullOrEmpty(Options))
            {
                //读取当前相关的
                List <KeyValueEntity> ItemOptions = ConvertTo.Deserialize <List <KeyValueEntity> >(Options);

                Dictionary <String, Object> Dicts = new Dictionary <String, Object>();


                foreach (var ItemSetting in ItemSettings)
                {
                    if (ItemOptions.Exists(r => r.Key == ItemSetting.Name))
                    {
                        KeyValueEntity ItemOption = ItemOptions.Find(r => r.Key == ItemSetting.Name);

                        if (ItemSetting.ControlType == EnumControlType.Urls.ToString())
                        {
                            ItemOption.Value = ViewLinkUrl(ItemOption.Value.ToString());
                        }
                        Dicts.Add(ItemOption.Key, ItemOption.Value);
                    }
                }
                JavaScriptSerializer jsSerializer = new JavaScriptSerializer();
                String_Options = jsSerializer.Serialize(Dicts);
            }
            return(String_Options);
        }
예제 #2
0
        protected void RepeaterOptions_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                SettingEntity ThemeSetting = e.Item.DataItem as SettingEntity;

                KeyValueEntity KeyValue = ItemSettings.Find(r1 => r1.Key == ThemeSetting.Name);
                if (KeyValue != null && !String.IsNullOrEmpty(KeyValue.Key))
                {
                    ThemeSetting.DefaultValue = KeyValue.Value.ToString();
                }

                //构造输入控件
                PlaceHolder ThemePH = e.Item.FindControl("ThemePH") as PlaceHolder;

                #region "创建控件"
                ControlHelper ctl = new ControlHelper(this);

                ThemePH.Controls.Add((Control)ctl.ViewControl(ThemeSetting));
                #endregion

                Literal liTitle = e.Item.FindControl("liTitle") as Literal;
                liTitle.Text = String.Format("<label class=\"col-sm-3 control-label\" for=\"{1}\">{0}:</label>", !String.IsNullOrEmpty(ThemeSetting.Alias) ? ThemeSetting.Alias : ThemeSetting.Name, ctl.ViewControlID(ThemeSetting));

                if (!String.IsNullOrEmpty(ThemeSetting.Description))
                {
                    Literal liHelp = e.Item.FindControl("liHelp") as Literal;
                    liHelp.Text = String.Format("<span class=\"help-block\"><i class=\"fa fa-info-circle\"></i> {0}</span>", ThemeSetting.Description);
                }
            }
        }
        /// <Description>
        /// 利用线程执行更新文章分类关系的方法
        /// </Description>
        /// <param name="Article"></param>
        public void ThreadUpdateGroups(object KeyValue)
        {
            KeyValueEntity KeyValueItem = KeyValue as KeyValueEntity;

            if (KeyValueItem != null && !String.IsNullOrEmpty(KeyValueItem.Key))
            {
                DNNGo_DNNGalleryPro_Slider_Group.Update(int.Parse(KeyValueItem.Key), KeyValueItem.Value.ToString());
            }
        }
예제 #4
0
        /// <summary>
        /// 绑定数据
        /// </summary>
        private void BindDataToPage()
        {
            EffectDBEntity XmlDB = Setting_EffectDB;

            if (!(XmlDB != null && String.IsNullOrEmpty(XmlDB.Name)))
            {
                lblEffectName.Text        = XmlDB.Name;
                lblEffectDescription.Text = XmlDB.Description;

                //绑定效果的主题
                String        EffectDirPath = String.Format("{0}Effects/{1}/Themes/", Server.MapPath(ModulePath), XmlDB.Name);
                DirectoryInfo EffectDir     = new DirectoryInfo(EffectDirPath);
                if (!EffectDir.Exists)
                {
                    EffectDir.Create();
                }
                DirectoryInfo[]       ThemeDirs = EffectDir.GetDirectories();
                List <KeyValueEntity> dirs      = new List <KeyValueEntity>();
                if (ThemeDirs != null && ThemeDirs.Length > 0)
                {
                    foreach (DirectoryInfo dir in ThemeDirs)
                    {
                        KeyValueEntity dirEntity = new KeyValueEntity();
                        dirEntity.Key = dir.Name;

                        FileInfo imgFile = new FileInfo(MapPath(String.Format("{0}Effects/{1}/Themes/{2}/image.jpg", ModulePath, XmlDB.Name, dir.Name)));
                        if (imgFile.Exists)
                        {
                            dirEntity.Value = String.Format("{0}Effects/{1}/Themes/{2}/image.jpg", ModulePath, XmlDB.Name, dir.Name);
                        }
                        else
                        {
                            dirEntity.Value = String.Format("http://www.dnngo.net/DesktopModules/DNNGo_DNNGalleryPro/Effects/{0}/Themes/{1}/image.jpg", XmlDB.Name, dir.Name);
                        }


                        dirs.Add(dirEntity);
                    }
                    WebHelper.BindList <KeyValueEntity>(ddlThemeName, dirs, "Key", "Value");
                }
                WebHelper.SelectedListByText(ddlThemeName, Settings_EffectThemeName);


                // hfThemeThumbnails.Value = String.Format("{0}Effects/{1}/Themes/[EffectThemeName]/image.jpg", ModulePath, XmlDB.Name);
                if (!String.IsNullOrEmpty(Settings_EffectThemeName))
                {
                    imgThemeThumbnails.Attributes.Add("onError", String.Format("this.src='{0}Resource/images/no_image.png'", ModulePath));
                    imgThemeThumbnails.ToolTip = Settings_EffectThemeName;
                    KeyValueEntity dirEntity = dirs.Find(r1 => r1.Key.IndexOf(Settings_EffectThemeName, StringComparison.CurrentCultureIgnoreCase) >= 0);
                    imgThemeThumbnails.ImageUrl = dirEntity != null?dirEntity.Value.ToString() : "";

                    imgThemeThumbnails.Visible = true;
                }
            }
        }
        /// <summary>
        /// 分组绑定事件
        /// </summary>
        protected void RepeaterCategories_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Repeater       RepeaterGroup  = e.Item.FindControl("RepeaterGroup") as Repeater;
                KeyValueEntity CategoriesItem = e.Item.DataItem as KeyValueEntity;
                int            OptionCount    = 0;
                BindGroupToPage(RepeaterGroup, CategoriesItem.Key, out OptionCount);

                if (OptionCount == 0)
                {
                    e.Item.Visible = false;
                }
            }
        }
예제 #6
0
        /// <summary>
        /// 把JSON的参数处理后转换成XML
        /// </summary>
        /// <param name="JsonOptions"></param>
        /// <returns></returns>
        public String ConvertOptions_XML(String JsonOptions, List <SettingEntity> ItemSettings)
        {
            String String_Options = String.Empty;

            if (!String.IsNullOrEmpty(JsonOptions))
            {
                List <KeyValueEntity> ItemOptions = new List <KeyValueEntity>();

                JavaScriptSerializer jsSerializer = new JavaScriptSerializer();

                Dictionary <String, Object> Dicts = jsSerializer.DeserializeObject(JsonOptions) as Dictionary <String, Object>;

                if (Dicts != null && Dicts.Count > 0)
                {
                    foreach (var d in Dicts.Keys)
                    {
                        KeyValueEntity item = new KeyValueEntity();
                        item.Key   = d;
                        item.Value = Dicts[d];
                        String ValueUrls = item.Value.ToString();

                        //需要检测该值是否为图片
                        if (!String.IsNullOrEmpty(ValueUrls) && ItemSettings.Exists(r => r.Name == d))
                        {
                            SettingEntity sEntity = ItemSettings.Find(r => r.Name == d);
                            if (sEntity.ControlType == EnumControlType.Urls.ToString())
                            {
                                string extension = System.IO.Path.GetExtension(ValueUrls);//扩展名 “.aspx”
                                if (NeedExtension(extension))
                                {
                                    item.Value = ImportPicture(ValueUrls);
                                }
                            }
                        }


                        ItemOptions.Add(item);
                    }


                    String_Options = ConvertTo.Serialize <List <KeyValueEntity> >(ItemOptions);
                }
            }
            return(String_Options);
        }
        /// <Description>
        /// 拼接数据项的设置参数
        /// </Description>
        /// <returns></returns>
        public void SetItemSettings(ref DNNGo_DNNGalleryPro_Slider Article)
        {
            //获取效果参数
            List <SettingEntity>  ItemSettingDB = Setting_SliderSettingDB;
            List <KeyValueEntity> list          = new List <KeyValueEntity>();

            if (ItemSettingDB != null && ItemSettingDB.Count > 0)
            {
                ControlHelper ControlItem = new ControlHelper(ModuleId);

                foreach (SettingEntity ri in ItemSettingDB)
                {
                    KeyValueEntity item = new KeyValueEntity();
                    item.Key   = ri.Name;
                    item.Value = ControlHelper.GetWebFormValue(ri, this);
                    list.Add(item);
                }
            }
            Article.Options = ConvertTo.Serialize <List <KeyValueEntity> >(list);

            if (list.Exists(r => r.Key == "Attribute1"))
            {
                KeyValueEntity Attribute1       = list.Find(r => r.Key == "Attribute1");
                Int32          Attribute1_Value = 0;
                if (int.TryParse(Attribute1.Value.ToString(), out Attribute1_Value))
                {
                    Article.Attribute1 = Attribute1_Value;
                }
            }

            if (list.Exists(r => r.Key == "Attribute2"))
            {
                KeyValueEntity Attribute2 = list.Find(r => r.Key == "Attribute2");
                Article.Attribute2 = Attribute2.Value.ToString();
            }

            if (list.Exists(r => r.Key == "Title"))
            {
                KeyValueEntity TitleEntity = list.Find(r => r.Key == "Title");
                Article.Title = TitleEntity.Value.ToString();
            }
        }
예제 #8
0
        /// <summary>
        /// 拼接数据项的设置参数
        /// </summary>
        /// <returns></returns>
        public String SetItemSettings()
        {
            //获取效果参数
            List <SettingEntity>  ItemSettingDB = Setting_CategorySettingDB;
            List <KeyValueEntity> list          = new List <KeyValueEntity>();

            if (ItemSettingDB != null && ItemSettingDB.Count > 0)
            {
                ControlHelper ControlItem = new ControlHelper(ModuleId);

                foreach (SettingEntity ri in ItemSettingDB)
                {
                    KeyValueEntity item = new KeyValueEntity();
                    item.Key   = ri.Name;
                    item.Value = ControlHelper.GetWebFormValue(ri, this);
                    list.Add(item);
                }
            }
            return(ConvertTo.Serialize <List <KeyValueEntity> >(list));
        }
        /// <summary>
        /// 读取数据项参数
        /// </summary>
        /// <param name="DataItem">数据项</param>
        /// <param name="Name">参数名</param>
        /// <param name="DefaultValue">默认值</param>
        /// <returns></returns>
        public static object ViewCategorySettingByStatic(DNNGo_DNNGalleryPro_Group DataItem, String Name, object DefaultValue)
        {
            object o = DefaultValue;

            if (DataItem != null && DataItem.ID > 0 && !String.IsNullOrEmpty(DataItem.Options))
            {
                try
                {
                    List <KeyValueEntity> ItemSettings = ConvertTo.Deserialize <List <KeyValueEntity> >(DataItem.Options);
                    KeyValueEntity        KeyValue     = ItemSettings.Find(r1 => r1.Key.ToLower() == Name.ToLower());
                    if (KeyValue != null && !String.IsNullOrEmpty(KeyValue.Key))
                    {
                        o = KeyValue.Value;
                    }
                }
                catch
                {
                }
            }
            return(o);
        }
        /// <Description>
        /// 拼接数据项的设置参数
        /// </Description>
        /// <returns></returns>
        public String SetItemSettings()
        {
            //获取效果参数
            List <SettingEntity>  LayerSettingDB = Setting_LayerSettingDB;
            List <KeyValueEntity> list           = new List <KeyValueEntity>();

            if (LayerSettingDB != null && LayerSettingDB.Count > 0)
            {
                ControlHelper ControlItem = new ControlHelper(this);

                foreach (SettingEntity ri in LayerSettingDB)
                {
                    KeyValueEntity item = new KeyValueEntity();
                    item.Key   = ri.Name;
                    item.Value = ControlHelper.GetWebFormValue(ri, this);
                    list.Add(item);
                }
            }
            //添加层的类型
            list.Add(new KeyValueEntity("LayerType", LayerType));

            return(ConvertTo.Serialize <List <KeyValueEntity> >(list));
        }
        /// <summary>
        /// 拼接扩展数据项的设置参数
        /// </summary>
        /// <returns></returns>
        public String SetExtensionSettings()
        {
            List <KeyValueEntity> list = new List <KeyValueEntity>();
            String Names  = Request.Form[String.Format("Model$Name${0}", ModuleId)];
            String Values = Request.Form[String.Format("Model$Value${0}", ModuleId)];

            if (!String.IsNullOrEmpty(Names) && !String.IsNullOrEmpty(Values))
            {
                List <String> NameList  = Common.GetList(Names, ",");
                List <String> ValueList = Common.GetList(Values, ",");

                for (Int32 i = 0; i < NameList.Count && i < ValueList.Count; i++)
                {
                    KeyValueEntity kv = new KeyValueEntity();
                    if (!String.IsNullOrEmpty(NameList[i]))
                    {
                        kv.Key   = NameList[i];
                        kv.Value = ValueList[i];
                        list.Add(kv);
                    }
                }
            }
            return(ConvertTo.Serialize <List <KeyValueEntity> >(list));
        }
예제 #12
0
        /// <summary>
        /// 列表行绑定
        /// </summary>
        protected void gvArticleList_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                //还原出数据
                DNNGo_DNNGalleryPro_Slider Article = e.Row.DataItem as DNNGo_DNNGalleryPro_Slider;

                if (Article != null && Article.ID > 0)
                {
                    HyperLink  hlEdit          = e.Row.FindControl("hlEdit") as HyperLink;
                    HyperLink  hlMobileEdit    = e.Row.FindControl("hlMobileEdit") as HyperLink;
                    LinkButton btnRemove       = e.Row.FindControl("btnRemove") as LinkButton;
                    LinkButton btnMobileRemove = e.Row.FindControl("btnMobileRemove") as LinkButton;

                    //移动分类按钮
                    LinkButton lbSortUp         = e.Row.FindControl("lbSortUp") as LinkButton;
                    LinkButton lbSortDown       = e.Row.FindControl("lbSortDown") as LinkButton;
                    LinkButton lbMobileSortUp   = e.Row.FindControl("lbMobileSortUp") as LinkButton;
                    LinkButton lbMobileSortDown = e.Row.FindControl("lbMobileSortDown") as LinkButton;
                    lbSortUp.CommandArgument                     =
                        lbSortDown.CommandArgument               =
                            lbMobileSortUp.CommandArgument       =
                                lbMobileSortDown.CommandArgument = Article.ID.ToString();

                    //设置按钮的CommandArgument
                    btnRemove.CommandArgument = btnMobileRemove.CommandArgument = Article.ID.ToString();
                    //设置删除按钮的提示
                    if (Article.Status == (Int32)EnumStatus.RecycleBin)
                    {
                        btnRemove.Attributes.Add("onClick", "javascript:return confirm('" + Localization.GetString("DeleteItem") + "');");
                        btnMobileRemove.Attributes.Add("onClick", "javascript:return confirm('" + Localization.GetString("DeleteItem") + "');");
                    }
                    else
                    {
                        btnRemove.Attributes.Add("onClick", "javascript:return confirm('" + ViewResourceText("DeleteRecycleItem", "Are you sure to move it to recycle bin?") + "');");
                        btnMobileRemove.Attributes.Add("onClick", "javascript:return confirm('" + ViewResourceText("DeleteRecycleItem", "Are you sure to move it to recycle bin?") + "');");
                    }

                    hlEdit.NavigateUrl = hlMobileEdit.NavigateUrl = xUrl("ID", Article.ID.ToString(), "AddNew");


                    //文章状态
                    e.Row.Cells[7].Text = EnumHelper.GetEnumTextVal(Article.Status, typeof(EnumStatus));

                    //格式化2种时间为短日期格式
                    e.Row.Cells[5].Text = Article.StartTime.ToShortDateString();
                    e.Row.Cells[6].Text = Article.EndTime.ToShortDateString();

                    //显示分组
                    if (Setting_EffectDB.Groups)
                    {
                        e.Row.Cells[4].Text = DNNGo_DNNGalleryPro_Group.FindGroupsBySliderID(Article.ID);
                    }

                    if (!String.IsNullOrEmpty(Article.Options))
                    {
                        if (gvArticleList.Columns[1].Visible || gvArticleList.Columns[2].Visible)
                        {
                            List <KeyValueEntity> kvList = new List <KeyValueEntity>();
                            try
                            {
                                kvList = ConvertTo.Deserialize <List <KeyValueEntity> >(Article.Options);
                            }
                            catch
                            { }


                            if (kvList != null && kvList.Count > 0)
                            {
                                if (kvList.Exists(r => r.Key == "Title"))
                                {
                                    KeyValueEntity rowEntity = kvList.Find(r => r.Key == "Title");
                                    if (rowEntity != null && !String.IsNullOrEmpty(rowEntity.Key))
                                    {
                                        e.Row.Cells[2].Text = Convert.ToString(rowEntity.Value);
                                    }
                                }

                                TemplateFormat tf         = new TemplateFormat(this);
                                Image          imgPicture = e.Row.FindControl("imgPicture") as Image;
                                if (kvList.Exists(r => r.Key == "Thumbnails"))
                                {
                                    KeyValueEntity rowEntity = kvList.Find(r => r.Key == "Thumbnails");
                                    if (rowEntity != null && !String.IsNullOrEmpty(rowEntity.Key))
                                    {
                                        imgPicture.ImageUrl = tf.ViewLinkUrl(Convert.ToString(rowEntity.Value));
                                    }
                                }
                                else if (kvList.Exists(r => r.Key == "Picture"))
                                {
                                    KeyValueEntity rowEntity = kvList.Find(r => r.Key == "Picture");
                                    if (rowEntity != null && !String.IsNullOrEmpty(rowEntity.Key))
                                    {
                                        imgPicture.ImageUrl = tf.ViewLinkUrl(Convert.ToString(rowEntity.Value));
                                    }
                                }
                                else
                                {
                                    imgPicture.Visible = false;
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #13
0
        /// <summary>
        /// 导入图片到媒体库
        /// </summary>
        /// <param name="PictureUrl">图片地址</param>
        /// <returns></returns>
        public String ImportPicture(String PictureUrl)
        {
            String Picture = "";

            if (!String.IsNullOrEmpty(PictureUrl))
            {
                //查看该图片是否已经存在过
                KeyValueEntity PictureTemp = ImportPictureList.Find(r1 => r1.Key == PictureUrl);
                if (PictureTemp != null && !String.IsNullOrEmpty(PictureTemp.Key))
                {
                    Picture = PictureTemp.Value.ToString();
                }
                else
                {
                    DNNGo_DNNGalleryPro_Files PhotoItem = new DNNGo_DNNGalleryPro_Files();

                    //将图片的URL转换为相应的文件名,文件后缀等内容
                    PhotoItem.FileName = System.IO.Path.GetFileName(PictureUrl);//文件名 “Default.aspx”

                    if (!String.IsNullOrEmpty(PhotoItem.FileName) && PhotoItem.FileName.IndexOf(".") > 0)
                    {
                        PhotoItem.FileExtension = System.IO.Path.GetExtension(PhotoItem.FileName).Replace(".", "");
                        PhotoItem.Name          = PhotoItem.FileName.Replace(System.IO.Path.GetExtension(PictureUrl), "");

                        //判断哪些文件需要被下载
                        if (NeedExtension(PhotoItem.FileExtension))
                        {
                            String   FullFile = String.Format("{0}DNNGalleryPro\\uploads\\{1}\\{2}\\{3}\\{4}", DNNGalleryPro_PortalSettings.HomeDirectoryMapPath, DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, PhotoItem.FileName);
                            FileInfo file     = new FileInfo(FullFile);

                            int ExistsCount = 1;
                            //如果有重复的文件,需要改变文件名
                            while (file.Exists)
                            {
                                PhotoItem.FileName = String.Format("{0}_{1}.{2}", PhotoItem.Name, ExistsCount, PhotoItem.FileExtension);
                                FullFile           = String.Format("{0}DNNGalleryPro\\uploads\\{1}\\{2}\\{3}\\{4}", DNNGalleryPro_PortalSettings.HomeDirectoryMapPath, DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, PhotoItem.FileName);
                                file = new FileInfo(FullFile);
                                ExistsCount++;
                            }

                            try
                            {
                                if (!file.Directory.Exists)
                                {
                                    file.Directory.Create();
                                }

                                //下载图片
                                WebClientX web = new WebClientX();
                                web.DownloadFile(new Uri(PictureUrl), FullFile);

                                file = new FileInfo(FullFile);
                                if (file.Exists)
                                {
                                    PhotoItem.ModuleId = ModuleID;
                                    PhotoItem.PortalId = DNNGalleryPro_PortalSettings.PortalId;
                                    PhotoItem.FileSize = Convert.ToInt32(file.Length / 1024);
                                    PhotoItem.FileMate = FileSystemUtils.GetContentType(Path.GetExtension(PhotoItem.FileName).Replace(".", ""));
                                    PhotoItem.Status   = (Int32)EnumFileStatus.Approved;
                                    PhotoItem.FilePath = String.Format("DNNGalleryPro/uploads/{0}/{1}/{2}/{3}", DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, PhotoItem.FileName);


                                    try
                                    {
                                        if (("png,gif,jpg,jpeg,bmp").IndexOf(PhotoItem.FileExtension) >= 0)
                                        {
                                            //图片的流
                                            System.Drawing.Image image = System.Drawing.Image.FromFile(file.FullName);
                                            PhotoItem.ImageWidth  = image.Width;
                                            PhotoItem.ImageHeight = image.Height;

                                            PhotoItem.Exif = Common.Serialize <EXIFMetaData.Metadata>(new EXIFMetaData().GetEXIFMetaData(image));
                                        }
                                    }
                                    catch
                                    {
                                    }

                                    PhotoItem.LastTime = DateTime.Now;
                                    PhotoItem.LastIP   = WebHelper.UserHost;
                                    //PhotoItem.LastUser = DNNGalleryPro_PortalSettings.UserInfo.UserID;
                                    PhotoItem.ID = PhotoItem.Insert();

                                    //返回图片的路径
                                    Picture = String.Format("MediaID={0}", PhotoItem.ID);
                                    ImportPictureList.Add(new KeyValueEntity(PictureUrl, Picture));
                                }
                            }
                            catch (Exception ex)
                            {
                            }
                        }
                        else
                        {
                            Picture = PictureUrl;
                        }
                    }
                    else
                    {
                        Picture = PictureUrl;
                    }
                }
            }


            return(Picture);
        }