示例#1
0
        /// <summary>
        /// 取得默认值
        /// </summary>
        /// <param name="key"></param>
        /// <param name="ctx"></param>
        /// <param name="dc"></param>
        /// <returns></returns>
        public static object GetDefaultValue(string key, PanelContext ctx, We7DataColumn dc)
        {
            DefaultGenerator generator = GetGenerator(key);

            generator.Ctx = ctx;
            generator.DC  = dc;
            return(generator != null?generator.Generate() : null);
        }
示例#2
0
        /// <summary>
        /// 取得默认值生成器
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public static DefaultGenerator GetGenerator(string key)
        {
            DefaultGenerator generator = AppCtx.Cache.RetrieveObject <DefaultGenerator>(GetCacheKey(key));

            if (generator == null)
            {
                if (ModelConfig.Defaults.Get(key) == null)
                {
                    generator = new DefaultDefaultGenerator();
                }
                else
                {
                    generator = Utils.CreateInstance <DefaultGenerator>(ModelConfig.Defaults[key]);
                    AppCtx.Cache.AddObjectWithFileChange(GetCacheKey(key), generator, ModelConfig.ConfigFilePath);
                }
            }
            return(generator);
        }
示例#3
0
 /// <summary>
 /// 处理所有数据列
 /// </summary>
 /// <param name="ctx"></param>
 void ProcessAllDataColumns(PanelContext ctx)
 {
     foreach (We7DataColumn dc in ctx.DataSet.Tables[0].Columns)
     {
         if (!String.IsNullOrEmpty(dc.DefaultValue) &&
             dc.Direction != ParameterDirection.ReturnValue &&
             (ctx.Row[dc.Name] == null || String.IsNullOrEmpty(ctx.Row[dc.Name].ToString())))
         {
             if (String.Compare(dc.Name, "AccountID") == 0)
             {
                 continue;
             }
             if (IsEdit && String.Compare(dc.Name, "Updated", true) == 0)
             {
                 continue;
             }
             ctx.Row[dc.Name] = DefaultGenerator.GetDefaultValue(dc.DefaultValue, ctx, dc);
         }
     }
 }