Exemple #1
0
        /// <summary>
        /// Gets a list of config objects that are all in the specified type.
        /// </summary>
        /// <param name="configObjectType">A integer value represents the type of the config object.</param>
        /// <returns>A list of config objects.</returns>
        public static List <RiMEConfigModel> GetConfig(int configObjectType)
        {
            List <RiMEConfigModel> result = new List <RiMEConfigModel>();
            string    sql = "SELECT iConfigObjectType, vcKey, nvcValue, dtUpdatedTime FROM RiMEConfig.dbo.Config WHERE iConfigObjectType = @configObjectType";
            DataTable dt  = SqlServerHelper.Query(sql, new SqlParameter("configObjectType", configObjectType));

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                RiMEConfigModel model = new RiMEConfigModel()
                {
                    ConfigObjectType = dt.Rows[i][0].ToInt(), Key = dt.Rows[i][1].ToString(), Value = dt.Rows[i][2].ToString(), UpdatedTime = dt.Rows[i][3].ToDateTime()
                };
                result.Add(model);
            }

            return(result);
        }
Exemple #2
0
        /// <summary>
        /// Gets a config by its key and configObjectType.
        /// </summary>
        /// <param name="configObjectType">The integer value that represents the type of the config object.</param>
        /// <param name="key">The key.</param>
        /// <returns>The config object</returns>
        public static RiMEConfigModel GetConfig(int configObjectType, string key)
        {
            string    sql = "SELECT iConfigObjectType, vcKey, nvcValue, dtUpdatedTime FROM RiMEConfig.dbo.Config WHERE iConfigObjectType = @configObjectType AND vcKey = @key";
            DataTable dt  = SqlServerHelper.Query(sql, new SqlParameter("configObjectType", configObjectType), new SqlParameter("key", key));

            if (dt.Rows.Count > 0)
            {
                RiMEConfigModel model = new RiMEConfigModel()
                {
                    ConfigObjectType = dt.Rows[0][0].ToInt(), Key = dt.Rows[0][1].ToString(), Value = dt.Rows[0][2].ToString(), UpdatedTime = dt.Rows[0][3].ToDateTime()
                };
                return(model);
            }
            else
            {
                return(null);
            }
        }
Exemple #3
0
        public static bool IsKeyConflicted(int configObjectType, string key)
        {
            string sql = "SELECT * FROM RiMEConfig.dbo.Config WHERE iConfigObjectType = @configObjectType AND vcKey = @key";

            return(SqlServerHelper.Query(sql, new SqlParameter("configObjectType", configObjectType), new SqlParameter("key", key)).Rows.Count > 0);
        }