/// <summary>
        /// 返回实体列表信息
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public List <T> ToList <T>()
            where T : new()
        {
            List <T> list = new List <T>();

            if (_xmlDoc != null)
            {
                //找出对应路径下的节点,遍历节点
                XmlNodeList Nodelist = ToNodeList(typeof(T));
                if (Nodelist != null && Nodelist.Count > 0)
                {
                    Type           t         = typeof(T);
                    PropertyInfo[] Propertys = t.GetProperties();

                    //遍历节点
                    foreach (XmlNode node in Nodelist)
                    {
                        T       tItem  = new T();
                        Boolean isTrue = false;
                        //遍历字段
                        foreach (PropertyInfo Property in Propertys)
                        {
                            String ColumnName = Property.Name;
                            if (node[ColumnName] != null && !String.IsNullOrEmpty(node[ColumnName].InnerText.Trim()))
                            {
                                object o = ConvertTo.FormatValue(node[ColumnName].InnerText.Trim(), Type.GetType(Property.PropertyType.FullName));
                                t.GetProperty(ColumnName).SetValue(tItem, o, null);

                                isTrue = true;
                            }
                        }
                        //增加到列表
                        if (isTrue)
                        {
                            list.Add(tItem);
                        }
                    }
                }
            }

            return(list);
        }
Ejemplo n.º 2
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));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 保存需要提示的内容
        /// </summary>
        public void Put()
        {
            if (!String.IsNullOrEmpty(_Content))
            {
                //将当前的内容序列化到个人缓存

                String s = ConvertTo.Serialize <MessageTips>((MessageTips)this);
                //如果有Session的话需要先清除
                if (HttpContext.Current.Session[SessionName()] != null)
                {
                    HttpContext.Current.Session.Remove(SessionName());
                }
                //增加当前序列化的内容到Session
                HttpContext.Current.Session.Add(SessionName(), s);
            }
            //跳转
            if (!String.IsNullOrEmpty(_GoUrl))
            {
                HttpContext.Current.Response.Redirect(_GoUrl, true);
            }
        }
Ejemplo n.º 4
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);
            }
        }
 /// <summary>
 /// 将泛型集合类转换成DataTable
 /// </summary>
 /// <typeparam name="T">集合项类型</typeparam>
 /// <param name="list">集合</param>
 /// <returns>数据集(表)</returns>
 public static DataTable ToDataTable <T>(IList <T> list)
 {
     return(ConvertTo.ToDataTable <T>(list, null));
 }