Example #1
0
        /// <summary>
        /// 拼接数据项的设置参数
        /// </summary>
        /// <returns></returns>
        public String SetItemSettings(ref List <KeyValueEntity> list, List <SettingEntity> x_OptionList)
        {
            //获取效果参数
            List <SettingEntity> ItemSettingDB = x_OptionList;


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

                foreach (SettingEntity ri in ItemSettingDB)
                {
                    KeyValueEntity OldKV = ItemValues.Find(r1 => r1.Key == ri.Name);

                    if (OldKV != null && !String.IsNullOrEmpty(OldKV.Value))
                    {
                        ri.DefaultValue = OldKV.Value;
                    }

                    KeyValueEntity item = new KeyValueEntity();
                    item.Key   = ri.Name;
                    item.Value = ControlHelper.GetWebFormValue(ri, this);
                    list.Add(item);
                }
            }
            return(ConvertTo.Serialize <List <KeyValueEntity> >(list));
        }
Example #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).Clone();

                KeyValueEntity KeyValue = GlobalValues.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 = ViewTitleAndHelp(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);
                }
            }
        }
Example #3
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));

                Literal liHelp = e.Item.FindControl("liHelp") as Literal;
                liHelp.Text = ThemeSetting.Description.Trim();
            }
        }
Example #4
0
 /// <summary>
 /// 绑定菜单
 /// </summary>
 /// <param name="tabs"></param>
 /// <returns></returns>
 public void ViewMenuBind(List <TabInfo> tabs, Int32 ParentId, Int32 Level, ref List <KeyValueEntity> KeyValueList)
 {
     foreach (TabInfo tab in tabs)
     {
         if (tab.ParentId == ParentId)
         {
             KeyValueEntity KeyValue = new KeyValueEntity();
             KeyValue.Value = tab.DisableLink ?"" :  FormatTabUrl(tab);
             KeyValue.Key   = Common.FillVacancy(FormatTabName(tab), Level, "- ");
             KeyValueList.Add(KeyValue);
             ViewMenuBind(tabs, tab.TabID, Level + 1, ref KeyValueList);
         }
     }
 }
        /// <summary>
        /// 读取XML参数
        /// </summary>
        /// <param name="Name">参数名</param>
        /// <param name="DefaultValue">默认值</param>
        /// <returns></returns>
        public object ViewGlobalSetting(String Name, object DefaultValue)
        {
            String o = String.Empty;

            if (!String.IsNullOrEmpty(Name) && GlobalValues != null && GlobalValues.Count > 0)
            {
                KeyValueEntity item = GlobalValues.Find(r1 => r1.Key == Name);
                if (item != null && item.Key == Name)
                {
                    o = item.Value.ToString();
                }
            }
            return(!String.IsNullOrEmpty(o) ? ConvertTo.FormatValue(o, DefaultValue.GetType()) : DefaultValue);
        }
Example #6
0
        /// <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;
                }
            }
        }
Example #7
0
        /// <summary>
        /// 重置数据项参数
        /// </summary>
        /// <returns></returns>
        public String ResetItemSettings(ref List <KeyValueEntity> list, List <SettingEntity> ItemSettingDB)
        {
            if (ItemSettingDB != null && ItemSettingDB.Count > 0)
            {
                ControlHelper ControlItem = new ControlHelper(PortalId);

                foreach (SettingEntity ri in ItemSettingDB)
                {
                    KeyValueEntity item = new KeyValueEntity();
                    item.Key   = ri.Name;
                    item.Value = ri.DefaultValue;
                    list.Add(item);
                }
            }
            return(ConvertTo.Serialize <List <KeyValueEntity> >(list));
        }
Example #8
0
        /// <Description>
        /// 拼接数据项的设置参数
        /// </Description>
        /// <returns></returns>
        public String SetItemSettings()
        {
            //获取效果参数
            List <SettingEntity>  ItemSettingDB = XmlSettings;
            List <KeyValueEntity> list          = new List <KeyValueEntity>();

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

                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));
        }
Example #9
0
        /// <summary>
        /// 读取数据项参数
        /// </summary>
        /// <param name="DataItem">数据项</param>
        /// <param name="Name">参数名</param>
        /// <param name="DefaultValue">默认值</param>
        /// <returns></returns>
        public object GetSettingByStatic(DNNGo_ThemePlugin_MenuPane DataItem, String Name, object DefaultValue)
        {
            object o = DefaultValue;

            if (DataItem != null && DataItem.ID > 0 && !String.IsNullOrEmpty(DataItem.Options))
            {
                try
                {
                    List <KeyValueEntity> ItemSettings = DataItem.Options.ToList <KeyValueEntity>();
                    KeyValueEntity        KeyValue     = ItemSettings.Find(r1 => r1.Key.ToLower() == Name.ToLower());
                    if (KeyValue != null && !String.IsNullOrEmpty(KeyValue.Key))
                    {
                        o = KeyValue.Value;
                    }
                }
                catch
                {
                }
            }
            return(o);
        }
        public void Execute(BasePage Context)
        {
            List <SettingEntity>  OptionList = Context.OptionList;
            List <KeyValueEntity> ItemValues = Context.ItemValues;

            if (OptionList != null && OptionList.Count > 0)
            {
                foreach (var OptionItemValue in OptionList)
                {
                    if (ItemValues.Exists(r => r.Key == OptionItemValue.Name))
                    {
                        KeyValueEntity ItemValue = ItemValues.Find(r => r.Key == OptionItemValue.Name);
                        if (ItemValue != null && !String.IsNullOrEmpty(ItemValue.Key))
                        {
                            OptionItemValue.DefaultValue = ItemValue.Value;
                        }
                    }
                }
            }
            ResponseString = OptionList.ToJson();
        }
Example #11
0
        /// <summary>
        /// 批量更新模版
        /// </summary>
        /// <param name="templateName">模版名称</param>
        public void BulkUpdateTemplate(string templateName, List <KeyValueEntity> objItemValues)
        {
            if (templateName == "Global")
            {
                //以当前模版文件的参数为主,将当前接受的参数对比,有的就更新。
                List <KeyValueEntity> new_ItemValues = new List <KeyValueEntity>();
                List <SettingEntity>  x_OptionList   = _OptionList(templateName);
                List <KeyValueEntity> x_ItemValues   = _ItemValues(templateName);

                foreach (SettingEntity item in x_OptionList)
                {
                    KeyValueEntity new_Value = x_ItemValues.Find(r => r.Key == item.Name);
                    if (!(new_Value != null && !String.IsNullOrEmpty(new_Value.Key)))
                    {
                        new_Value       = new KeyValueEntity();
                        new_Value.Key   = item.Name;
                        new_Value.Value = item.DefaultValue;
                    }

                    if (objItemValues.Exists(r => r.Key == item.Name))
                    {
                        KeyValueEntity old_value = objItemValues.Find(r => r.Key == item.Name);
                        if (old_value != null && !String.IsNullOrEmpty(old_value.Key))
                        {
                            new_Value.Value = old_value.Value;
                        }
                    }

                    new_ItemValues.Add(new_Value);
                }

                GlobalValues = new_ItemValues;

                //保存参数到XML
                WriteTextToFile(_ItemValueXmlPath(templateName), ConvertTo.Serialize <List <KeyValueEntity> >(new_ItemValues));
            }
            else
            {
                Hashtable      Puts = new Hashtable();
                TemplateFormat xf   = new TemplateFormat(this);
                xf.GlobalValues     = GlobalValues;
                xf.GlobalOptionList = GlobalOptionList;

                xf.ItemValues = ItemValues;
                xf.OptionList = OptionList;

                Puts.Add("ItemValues", ItemValues);
                Puts.Add("OptionList", OptionList);
                Puts.Add("SkinName", SkinName);
                Puts.Add("SkinFileName", templateName);


                Puts.Add("GlobalValues", GlobalValues);
                Puts.Add("GlobalOptionList", GlobalOptionList);

                //更新模版
                String ascxFileName = String.Format("{0}.ascx", templateName);
                String ascxContent  = HttpUtility.HtmlDecode(ViewTemplate(ascxFileName, Puts, xf));
                WriteTemplate(ascxFileName, ascxContent);

                //更新CSS
                String cssFileName = String.Format("{0}.css", templateName);
                string cssContent  = HttpUtility.HtmlDecode(ViewTemplate(cssFileName, Puts, xf));
                WriteTemplate(cssFileName, cssContent);
            }
        }