/// <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); }
/// <summary> /// Gets the date time param. /// </summary> /// <param name="request">The request.</param> /// <param name="paramName">Name of the param.</param> /// <param name="errorReturn">The error return.</param> /// <returns>The param value.</returns> public static DateTime GetDateTimeParam(System.Web.HttpRequest request, string paramName, DateTime errorReturn) { string retStr = request.Form[paramName]; if (retStr == null) { retStr = request.QueryString[paramName]; } if (retStr == null || retStr.Trim() == string.Empty) { return(errorReturn); } try { return((DateTime)ConvertTo.FormatValue(retStr, typeof(DateTime))); } catch { return(errorReturn); } }
/// <summary> /// 读取数据项参数 /// </summary> /// <param name="DataItem">数据项</param> /// <param name="Name">参数名</param> /// <param name="DefaultValue">默认值</param> /// <returns></returns> public object ViewItemSetting(DNNGo_LayerGallery_Content 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); }
/// <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); } }
/// <summary> /// 读取XML参数 /// </summary> /// <param name="Name">参数名</param> /// <param name="DefaultValue">默认值</param> /// <returns></returns> public object ViewXmlSetting(String Name, object DefaultValue) { String SettingKey = EffectSettingsFormat(Settings_EffectName, Name); return(Settings[SettingKey] != null?ConvertTo.FormatValue(Settings[SettingKey].ToString(), DefaultValue.GetType()) : DefaultValue); }
/// <summary> /// 获取默认的设置 /// </summary> /// <returns></returns> public List <KeyValueEntity> GetDefaultSettings() { Dictionary <String, object> dicts = (Dictionary <String, object>)jsSerializer.DeserializeObject(System.IO.File.ReadAllText(Server.MapPath(String.Format("{0}Resource/xml/GlobalSetting.json", ModulePath)))); return(ConvertTo.ToList(dicts)); }
/// <summary> /// 更新单个Slider设置 /// </summary> /// <param name="Slider_Items"></param> /// <returns></returns> public Int32 UpdateSliderItem(Dictionary <String, object> Slider_Items, int Slider_Index) { List <KeyValueEntity> tempSlider = ConvertTo.ToList(Slider_Items); DNNGo_LayerGallery_Content Slider = new DNNGo_LayerGallery_Content(); //取出编号 Slider.ID = ConvertTo.GetValue <Int32>(tempSlider, "id", 0); if (Slider.ID > 0) { Slider = DNNGo_LayerGallery_Content.FindByKeyForEdit(Slider.ID); } //移除层的定义,将Slider项的定义序列化后存储 Slider_Items.Remove("layers"); Slider.Options = jsSerializer.Serialize(Slider_Items); //取出排序编号 Slider.Sort = ConvertTo.GetValue <Int32>(tempSlider, "sort", Slider_Index + 1); //取出标题 Slider.Title = ConvertTo.GetValue <String>(tempSlider, "title", ""); //开始时间 DateTime oTime = xUserTime.LocalTime(); string[] expectedFormats = { "G", "g", "f", "F" }; string StartTime = ConvertTo.GetValue <String>(tempSlider, "StartTime", oTime.ToString("MM/dd/yyyy HH:mm", new CultureInfo("en-US", false))); if (DateTime.TryParseExact(StartTime, "MM/dd/yyyy HH:mm", new CultureInfo("en-US", false), DateTimeStyles.AllowWhiteSpaces, out oTime)) { if (oTime.Second == 0) { oTime = oTime.AddSeconds(xUserTime.LocalTime().Second); //补秒 } Slider.StartTime = oTime; } //结束时间 DateTime EndTime = xUserTime.LocalTime().AddYears(10); string sEndTime = ConvertTo.GetValue <String>(tempSlider, "EndTime", EndTime.ToString("MM/dd/yyyy HH:mm", new CultureInfo("en-US", false))); if (DateTime.TryParseExact(sEndTime, "MM/dd/yyyy HH:mm", new CultureInfo("en-US", false), DateTimeStyles.AllowWhiteSpaces, out EndTime)) { if (EndTime.Second == 0) { EndTime = EndTime.AddSeconds(xUserTime.LocalTime().Second); //补秒 } Slider.EndTime = EndTime; } Slider.LastTime = xUserTime.UtcTime(); Slider.LastIP = WebHelper.UserHost; Slider.LastUser = UserId; if (Slider.ID > 0) { //更新 Slider.Update(); } else { //新增 Slider.ModuleId = ModuleId; Slider.PortalId = PortalId; Slider.Status = (Int32)EnumStatus.Published; Slider.ID = Slider.Insert(); } return(Slider.ID); }
/// <summary> /// 读取XML参数 /// </summary> /// <param name="Name">参数名</param> /// <param name="DefaultValue">默认值</param> /// <returns></returns> public object ViewXmlSetting(String Name, object DefaultValue) { String SettingKey = String.Format("Global_{0}", Name);// bpm.EffectSettingsFormat(bpm.Settings_EffectName, Name); return(bpm.Settings[SettingKey] != null?ConvertTo.FormatValue(bpm.Settings[SettingKey].ToString(), DefaultValue.GetType()) : DefaultValue); }