public DynamicSetting() { string fileName = this.GetType().Name; _fileDir = HttpContext.Current != null ? HttpContext.Current.Server.MapPath("~/" + ConfigPath + "/") : AppDomain.CurrentDomain.BaseDirectory + "/" + ConfigPath + "/"; _filePath = _fileDir + fileName + ".config"; if (File.Exists(_filePath)) { string cacheKey = "common_dynamic_setting"; _innerSettings = HttpRuntime.Cache.Get(cacheKey) as List <ItemPair>; if (_innerSettings == null) { lock (_syncRoot) { _innerSettings = XmlSerializerUtils.Deserialize <List <ItemPair> >(_filePath); if (_innerSettings != null) { HttpRuntime.Cache.Insert(cacheKey, _innerSettings, new CacheDependency(_filePath)); } } } } if (_innerSettings == null) { _innerSettings = new List <ItemPair>(); } }
protected void rptDetail_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item) { ProductFieldInfo productFieldInfo = e.Item.DataItem as ProductFieldInfo; FieldControl fieldControl = e.Item.FindControl("field") as FieldControl; if (fieldControl != null) { fieldControl.ControlType = (FieldType)productFieldInfo.FieldType; fieldControl.ControlPath = "~/Platform/h5/FieldControls/"; fieldControl.LoadControlId = ((FieldType)productFieldInfo.FieldType).ToString(); fieldControl.FieldName = productFieldInfo.FieldName; fieldControl.FieldAlias = productFieldInfo.Alias; fieldControl.FieldId = productFieldInfo.AutoID; fieldControl.Settings = XmlSerializerUtils.Deserialize <SinGooCMS.Control.FieldSetting>(productFieldInfo.Setting); fieldControl.DataLength = productFieldInfo.DataLength; fieldControl.EnableNull = productFieldInfo.EnableNull; if (!string.IsNullOrEmpty(productFieldInfo.Value)) { fieldControl.Value = productFieldInfo.Value; } else { fieldControl.Value = (productFieldInfo.DefaultValue ?? string.Empty); } } } }
public static T GetConfig <T>() where T : class, ISetting { string filePath = GetFilePath(typeof(T)); T setting = null; if (File.Exists(filePath)) { string cacheKey = "common_classify_setting_" + typeof(T).Name; setting = HttpRuntime.Cache.Get(cacheKey) as T; if (setting == null) { lock (GetLock(typeof(T))) { setting = XmlSerializerUtils.Deserialize <T>(filePath); if (setting != null) { HttpRuntime.Cache.Insert(cacheKey, setting, new CacheDependency(filePath)); } } } } return(setting); }
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item) { ContFieldInfo contFieldInfo = e.Item.DataItem as ContFieldInfo; FieldControl fieldControl = e.Item.FindControl("field") as FieldControl; if (fieldControl != null) { fieldControl.ControlType = (FieldType)contFieldInfo.FieldType; fieldControl.ControlPath = "~/Platform/h5/FieldControls/"; fieldControl.LoadControlId = ((FieldType)contFieldInfo.FieldType).ToString(); fieldControl.FieldName = contFieldInfo.FieldName; fieldControl.FieldAlias = contFieldInfo.Alias; fieldControl.Tips = contFieldInfo.Tip; fieldControl.FieldId = contFieldInfo.AutoID; fieldControl.Settings = XmlSerializerUtils.Deserialize <SinGooCMS.Control.FieldSetting>(contFieldInfo.Setting); fieldControl.DataLength = contFieldInfo.DataLength; fieldControl.EnableNull = contFieldInfo.EnableNull; if (!string.IsNullOrEmpty(contFieldInfo.Value)) { fieldControl.Value = contFieldInfo.Value; } else { fieldControl.Value = (contFieldInfo.DefaultValue ?? string.Empty); } if (!base.IsEdit && fieldControl.FieldName == "Sort") { fieldControl.Value = (SinGooCMS.BLL.Content.MaxSort + 1).ToString(); } } } }
public static List <OAuthConfig> LoadAll() { List <OAuthConfig> result; try { string xmlString = File.ReadAllText(HttpContext.Current.Server.MapPath("/Config/thirdlogin.config")); result = XmlSerializerUtils.Deserialize <List <OAuthConfig> >(xmlString); } catch { result = new List <OAuthConfig>(); } return(result); }
public async Task <CbCurrencyJsonResponseModel> GetDailyCurrencies() { var response = await _RestProvider.GetAsync("XML_daily.asp"); if (response.IsSuccess) { var xmlModel = XmlSerializerUtils.Deserialize <CbCurrencyXmlResponseModel>(response.Content); var jsonModel = xmlModel.ToJsonModel(); return(jsonModel); } else { return(null); } }
public static NodeSetting LoadNodeSetting(string settings) { NodeSetting result; if (string.IsNullOrEmpty(settings)) { result = new NodeSetting(); } else { NodeSetting nodeSetting = XmlSerializerUtils.Deserialize <NodeSetting>(settings); if (nodeSetting == null) { nodeSetting = new NodeSetting(); } result = nodeSetting; } return(result); }
private void InitForModify() { UserFieldInfo dataById = SinGooCMS.BLL.UserField.GetDataById(base.OpID); if (dataById != null) { this.TextBox2.Text = dataById.FieldName; this.TextBox2.Enabled = false; this.TextBox3.Text = dataById.Alias; this.TextBox4.Text = dataById.Tip; ListItem listItem = this.DropDownList5.Items.FindByValue(((FieldType)dataById.FieldType).ToString()); if (listItem != null) { listItem.Selected = true; } if (dataById.IsSystem) { this.DropDownList5.Enabled = false; } switch (dataById.FieldType) { case 0: this.ShowGroup = "group1"; break; case 1: this.ShowGroup = "group2"; break; case 2: this.ShowGroup = "group7"; break; case 4: case 5: case 6: this.ShowGroup = "group3"; break; case 7: this.ShowGroup = "group6"; break; case 8: case 10: this.ShowGroup = "group4"; break; case 9: case 11: this.ShowGroup = "group5"; break; } this.TextBox6.Text = dataById.DefaultValue; this.CheckBox9.Checked = dataById.EnableNull; this.ExtTextBox5.Text = dataById.DataLength.ToString(); if (dataById.IsSystem) { this.ExtTextBox5.Enabled = false; } SinGooCMS.Control.FieldSetting fieldSetting = XmlSerializerUtils.Deserialize <SinGooCMS.Control.FieldSetting>(dataById.Setting); if (fieldSetting != null) { this.ExtTextBox1.Text = fieldSetting.ControlWidth.ToString(); this.ExtTextBox2.Text = fieldSetting.ControlHeight.ToString(); ListItem listItem2 = this.ExtRadioButtonList3.Items.FindByValue(fieldSetting.TextMode); if (listItem2 != null) { listItem2.Selected = true; } this.ExtTextBox4.Text = fieldSetting.DataFormat; ListItem listItem3 = this.ExtDropDownList6.Items.FindByValue(fieldSetting.DataFrom); if (listItem3 != null) { listItem3.Selected = true; } string dataFrom = fieldSetting.DataFrom; if (dataFrom != null) { if (!(dataFrom == "Text")) { if (!(dataFrom == "DataDictionary")) { if (!(dataFrom == "SQLQuery")) { if (dataFrom == "AjaxData") { this.ExtTextBox11.Text = fieldSetting.DataSource; this.DataSource = "AjaxData"; } } else { this.ExtTextBox9.Text = fieldSetting.DataSource; this.DataSource = "SQLQuery"; } } else { this.ExtTextBox8.Text = fieldSetting.DataSource; this.DataSource = "DataDictionary"; } } else { this.ExtTextBox7.Text = fieldSetting.DataSource; this.DataSource = "Text"; } } } } }
private void InitForModify() { SettingInfo entityById = SettingProvider.GetEntityById(base.OpID); if (entityById != null) { this.TextBox1.Text = entityById.KeyName; this.TextBox3.Text = entityById.KeyDesc; ListItem listItem = this.DropDownList5.Items.FindByValue(entityById.ControlType); if (listItem != null) { listItem.Selected = true; } switch ((FieldType)System.Enum.Parse(typeof(FieldType), entityById.ControlType)) { case FieldType.SingleTextType: this.ShowGroup = "group1"; break; case FieldType.MultipleTextType: this.ShowGroup = "group2"; break; case FieldType.MultipleHtmlType: this.ShowGroup = "group7"; break; case FieldType.RadioButtonType: case FieldType.CheckBoxType: case FieldType.DropDownListType: this.ShowGroup = "group3"; break; case FieldType.DateTimeType: this.ShowGroup = "group6"; break; case FieldType.PictureType: case FieldType.FileType: this.ShowGroup = "group4"; break; case FieldType.MultiPictureType: case FieldType.MultiFileType: this.ShowGroup = "group5"; break; } this.TextBox6.Text = entityById.DefaultValue; this.CheckBox7.Checked = entityById.IsUsing; this.ExtTextBox5.Text = entityById.DataLength.ToString(); SinGooCMS.Control.FieldSetting fieldSetting = XmlSerializerUtils.Deserialize <SinGooCMS.Control.FieldSetting>(entityById.Setting); if (fieldSetting != null) { this.ExtTextBox1.Text = fieldSetting.ControlWidth.ToString(); this.ExtTextBox2.Text = fieldSetting.ControlHeight.ToString(); ListItem listItem2 = this.ExtRadioButtonList3.Items.FindByValue(fieldSetting.TextMode); if (listItem2 != null) { listItem2.Selected = true; } this.ExtTextBox4.Text = fieldSetting.DataFormat; ListItem listItem3 = this.ExtDropDownList6.Items.FindByValue(fieldSetting.DataFrom); if (listItem3 != null) { listItem3.Selected = true; } string dataFrom = fieldSetting.DataFrom; if (dataFrom != null) { if (!(dataFrom == "Text")) { if (!(dataFrom == "DataDictionary")) { if (!(dataFrom == "SQLQuery")) { if (dataFrom == "AjaxData") { this.ExtTextBox11.Text = fieldSetting.DataSource; this.DataSource = "AjaxData"; } } else { this.ExtTextBox9.Text = fieldSetting.DataSource; this.DataSource = "SQLQuery"; } } else { this.ExtTextBox8.Text = fieldSetting.DataSource; this.DataSource = "DataDictionary"; } } else { this.ExtTextBox7.Text = fieldSetting.DataSource; this.DataSource = "Text"; } } } } }