Exemplo n.º 1
0
 private void Add(object sender, EventArgs e)
 {
     try
     {
         // using (BizDataContext context = new BizDataContext())
         {
             if (CheckKeyExist(tbT_Configuration_Key.Text.Trim()))
             {
                 throw new ApplicationException("配置键已经存在!");
             }
             T_Configuration data = new T_Configuration();
             data.Configuration_Description = tbT_Configuration_Description.Text.Trim();
             data.Configuration_Title       = tbT_Configuration_Title.Text.Trim();
             data.Configuration_Value       = tbT_Configuration_Value.Text.Trim();
             data.Configuration_Key         = tbT_Configuration_Key.Text.Trim();
             data.Last_Modified             = DateTime.Now;
             data.Date_Added             = DateTime.Now;
             data.Configuration_Group_Id = 0;
             data.Sort_Order             = CaculateSortOrder();
             data.Configuration_Id       = DataHelper.GetNextIdentity_Int();
             DataHelper.Insert(data);
             this.AjaxAlert("保存成功!", "EnableButton();");
             Response.Redirect("~/SystemManagement/ConfigurationQuery.aspx", false);
         }
     }
     catch (ApplicationException ex)
     {
         this.AjaxAlert(ex.Message, "EnableButton();");
     }
 }
Exemplo n.º 2
0
        private static T_Configuration GetConfiguration(string Key)
        {
            if ((configurationList == null) || (DateTime.Now.Ticks > dt))
            {
                using (BizDataContext context = new BizDataContext(true))
                {
                    Interlocked.Exchange <List <T_Configuration> >(ref configurationList, context.FetchAll <T_Configuration>());
                    Interlocked.Exchange(ref dt, DateTime.Now.AddSeconds(30.0).Ticks);
                }
            }
            T_Configuration configuration = configurationList.FirstOrDefault <T_Configuration>(p => p.Configuration_Key == Key);

            if (configuration == null)
            {
                throw new ApplicationException(string.Format("未找到{0}配置项", Key));
            }
            return(configuration);
        }