Exemple #1
0
 private object InternalGetConfigObj(EmrAppConfig eac)
 {
     //string assInfo = eac.DesignClass;
     //IAppConfigDesign iacd = null;
     //if (string.IsNullOrEmpty(assInfo))
     //{
     //    //用通用的设置类,返回string类型的config值
     //    return eac.Config;
     //}
     //else
     //{
     //    Type t = Type.GetType(assInfo);
     //    if (t != null)
     //    {
     //        iacd = (IAppConfigDesign)Activator.CreateInstance(t);
     //    }
     //    if (iacd == null) throw new ArgumentException("design assembly load fail! ");
     //    Dictionary<string, EmrAppConfig> dics = new Dictionary<string, EmrAppConfig>();
     //    dics.Add(eac.Key, eac);
     //    iacd.Load(null, dics);
     //    return iacd.ConfigObj;
     //}
     //todo
     return(null);
 }
Exemple #2
0
 private void GetSubConfigs(EmrAppConfig config)
 {
     if (config.Ptype == ConfigParamType.Set && config.Keyset != null && config.Keyset.Count > 0)
     {
         string[] keys = new string[config.Keyset.Count];
         config.Keyset.CopyTo(keys, 0);
         config.SubConfigs = SelectAppConfigs(keys);
     }
 }
Exemple #3
0
        /// <summary>
        /// 获取指定键值对应的参数设置
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public static Stream GetConfig(string key)
        {
            EmrAppConfig config = ConfigDalc.SelectAppConfig(key);

            if (config != null)
            {
                return(new MemoryStream(System.Text.Encoding.UTF8.GetBytes(config.Config)));
            }

            return(null);
        }
Exemple #4
0
        /// <summary>
        /// 数据行构造配置类实例
        /// </summary>
        /// <param Name="row"></param>
        /// <returns></returns>
        public EmrAppConfig DataRow2EmrAppConfig(DataRow row)
        {
            EmrAppConfig eac = new EmrAppConfig();

            eac.Key         = row[ColKey].ToString();
            eac.Name        = row[ColName].ToString();
            eac.Config      = row[ColValue].ToString();
            eac.DesignClass = row[ColDesign].ToString();
            eac.Descript    = row[ColDescript].ToString();
            eac.Ptype       = (ConfigParamType)(int.Parse(row[ColType].ToString()));
            eac.Valid       = int.Parse(row[ColValid].ToString()) == 1 ? true : false;
            eac.Plevel      = ConfigParamLevel.System;
            eac.IsHide      = row[ColHide].ToString();
            GetSubConfigs(eac);
            return(eac);
        }
Exemple #5
0
        /// <summary>
        /// 获取String类型的配置
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public static string GetStringConfig(string key)
        {
            if (!m_Configs.ContainsKey(key))
            {
                EmrAppConfig config = ConfigDalc.SelectAppConfig(key);
                if (config != null)
                {
                    m_Configs.Add(key, config.Config);
                }
                else
                {
                    return(String.Empty);
                }
            }

            return(m_Configs[key] as string);
        }
Exemple #6
0
        SqlParameter[] GetUpdateParams(EmrAppConfig config)
        {
            SqlParameter paramKey   = new SqlParameter(ColKey, SqlDbType.VarChar, 32);                 ////参数key
            SqlParameter paramName  = new SqlParameter(ColName, SqlDbType.VarChar, 64);                ////参数名称
            SqlParameter paramValue = new SqlParameter(ColValue, SqlDbType.NVarChar, int.MaxValue);    //参数值
            SqlParameter paramDespc = new SqlParameter(ColDescript, SqlDbType.NVarChar, int.MaxValue); //参数描述
            SqlParameter paramValid = new SqlParameter(ColValid, SqlDbType.NVarChar, int.MaxValue);    //有效
            SqlParameter paramHide  = new SqlParameter(ColHide, SqlDbType.NVarChar, int.MaxValue);     //隐藏

            paramValue.Value = config.Config;
            paramDespc.Value = config.Descript;
            paramValid.Value = config.Valid1;
            paramHide.Value  = config.IsHide;
            paramKey.Value   = config.Key;
            paramName.Value  = config.Name;
            return(new SqlParameter[] { paramKey, paramName, paramValue, paramDespc, paramValid, paramHide });
        }
Exemple #7
0
        /// <summary>
        /// 更新配置值
        /// </summary>
        /// <param Name="config"></param>
        public void UpdateEmrAppConfig(EmrAppConfig config)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }
            SqlParameter[] sqlParams = GetUpdateParams(config);
            switch (config.Plevel)
            {
            case ConfigParamLevel.System:
                _sqlHelper.ExecuteNoneQuery(sqlUpdateAppConfig, sqlParams);
                break;

            default:
                break;
            }
        }
Exemple #8
0
        /// <summary>
        /// 取得用户的默认配置
        /// 优先级(高->低): 用户配置 -> 岗位配置(默认第一个) -> 系统配置
        /// </summary>
        /// <returns></returns>
        public EmrAppConfig GetDefaultConfig()
        {
            EmrAppConfig defconfig   = null;
            bool         isFirstRole = true;

            foreach (EmrAppConfig config in _configs)
            {
                if (config.Plevel == ConfigParamLevel.User)
                {
                    defconfig = config;
                    break;
                }
                if (config.Plevel == ConfigParamLevel.System)
                {
                    defconfig = config;
                }
                if (config.Plevel == ConfigParamLevel.Role && isFirstRole)
                {
                    defconfig   = config;
                    isFirstRole = false;
                }
            }
            return(defconfig);
        }
Exemple #9
0
        /// <summary>
        /// 读取配置对象
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public object GetConfigObj(string key)
        {
            EmrAppConfig eac = _acd.SelectAppConfig(key);

            return(InternalGetConfigObj(eac));
        }