コード例 #1
0
        public List <RolePrivilegeModel> GetRoles(int page, int pageSize, out int recordCount, FilterLinked filterLinked = null, Sort sort = null)
        {
            Dictionary <string, object> parameters = new Dictionary <string, object>();
            string condition = string.Empty, order = string.Empty;

            if (filterLinked != null)
            {
                condition = filterLinked.ToString(parameters);
            }
            if (sort != null)
            {
                order = sort.ToString();
            }
            //string dynamicConditions = this.ParseDynamicConditions(e, parameters, fieldMap);
            var list2 = this._privilegeBase.GetRoles(page, pageSize, condition, order, out recordCount, parameters.Values.ToArray()).ToList();

            list2.ForEach(delegate(RolePrivilegeModel role)
            {
                if (role.Name == this._privilegeBase.SystemRoleName)
                {
                    role.Privileges = "全部权限";
                }
            });
            return(list2);
        }
コード例 #2
0
        //private string BuildSql(string sql, List<IDbDataParameter> dbParameters, params DynamicSqlParam[] sqlParams)
        //{
        //    List<string> conditions = new List<string>();
        //    List<string> sorts = new List<string>();
        //    this.BuildSql(conditions, dbParameters, sqlParams);
        //    this.BuildSql(sorts, sqlParams);
        //    return this.BuildSql(sql, conditions, sorts);
        //}

        //private string BuildSql(string sql, List<string> conditions, List<string> orderbys)
        //{
        //    sql = sql.ToLower();
        //    if (conditions.Count > 0)
        //    {
        //        if (sql.IndexOf("{@dynamicCondition}", StringComparison.InvariantCultureIgnoreCase) > 0)
        //        {
        //            sql = Regex.Replace(sql, "{@dynamicCondition}", " and " + string.Join(" and ", conditions), RegexOptions.IgnoreCase);
        //        }
        //        else
        //        {
        //            if (!sql.EndsWith("where "))
        //            {
        //                if (sql.EndsWith("where"))
        //                {
        //                    sql = sql + " ";
        //                }
        //                else
        //                {
        //                    sql = sql + " where ";
        //                }
        //            }
        //            sql = sql + string.Join(" and ", conditions);
        //        }
        //    }
        //    else if (sql.IndexOf("{@dynamicCondition}", StringComparison.InvariantCultureIgnoreCase) > 0)
        //    {
        //        sql = Regex.Replace(sql, "{@dynamicCondition}", string.Empty, RegexOptions.IgnoreCase);
        //    }
        //    if (orderbys.Count > 0)
        //    {
        //        sql = sql + " order by " + string.Join(",", orderbys);
        //    }
        //    return sql;
        //}

        ///// <summary>
        ///// 将给定的DynamicSqlParam参数中的排序参数转换成条件字符串列表
        ///// </summary>
        ///// <param name="sorts">用于返回转换结果集</param>
        ///// <param name="sqlParams">要转换的动态sql参数</param>
        //private void BuildSql(List<string> sorts, params DynamicSqlParam[] sqlParams)
        //{
        //    foreach (DynamicSqlSorter sorter in from x in sqlParams
        //                                        where x.Type == DynamicSqlParamType.Sort
        //                                        select x)
        //    {
        //        sorts.Add(sorter.ToSql());
        //    }
        //}

        /// <summary>
        /// 将提供的不带条件子句的sql语句拼接为完整的sql语句
        /// </summary>
        /// <param name="sql">原始sql</param>
        /// <param name="filterLinked">条件链表</param>
        /// <param name="sort">排序对象</param>
        /// <returns></returns>
        string BuildSql(string sql, FilterLinked filterLinked, Sort sort, List <IDbDataParameter> dbParameters)
        {
            if (dbParameters == null)
            {
                throw new ArgumentNullException("dbParameters");
            }
            StringBuilder sqlBuilder = new StringBuilder(sql);
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            if (filterLinked != null)
            {
                string condition = filterLinked.ToString(parameters);
                foreach (var parameterName in parameters.Keys)
                {
                    dbParameters.Add(CreateParameter(parameterName, parameters[parameterName]));
                }
                sqlBuilder.Append(" where ").Append(condition);
            }
            if (sort != null)
            {
                string order = sort.ToString();
                sqlBuilder.Append(" order by ").Append(order);
            }
            return(sqlBuilder.ToString());
        }
コード例 #3
0
ファイル: Privilege.cs プロジェクト: wzxinchen/BaseComponent
        public IList <UserRoleDetailInfo> GetUsers(int page, int pageSize, out int recordCount, FilterLinked filterLinked = null, Sort sort = null)
        {
            Dictionary <string, object> parameters = new Dictionary <string, object>();
            string condition = null, order = null;

            if (filterLinked != null)
            {
                condition = filterLinked.ToString(parameters);
            }

            if (sort != null)
            {
                order = sort.ToString();
            }

            return(_privilegeBase.GetUsers(page, pageSize, out recordCount, condition, order, parameters.Values.ToArray()));
        }
コード例 #4
0
ファイル: Privilege.cs プロジェクト: dusdong/BaseComponent
 public List<RolePrivilegeModel> GetRoles(int page, int pageSize, out int recordCount, FilterLinked filterLinked = null, Sort sort = null)
 {
     Dictionary<string, object> parameters = new Dictionary<string, object>();
     string condition = string.Empty, order = string.Empty;
     if (filterLinked != null)
     {
         condition = filterLinked.ToString(parameters);
     }
     if (sort != null)
     {
         order = sort.ToString();
     }
     //string dynamicConditions = this.ParseDynamicConditions(e, parameters, fieldMap);
     var list2 = this._privilegeBase.GetRoles(page, pageSize, condition, order, out recordCount, parameters.Values.ToArray()).ToList();
     list2.ForEach(delegate(RolePrivilegeModel role)
     {
         if (role.Name == this._privilegeBase.SystemRoleName)
         {
             role.Privileges = "全部权限";
         }
     });
     return list2;
 }
コード例 #5
0
ファイル: Privilege.cs プロジェクト: dusdong/BaseComponent
        public IList<UserRoleDetailInfo> GetUsers(int page, int pageSize, out int recordCount, FilterLinked filterLinked = null, Sort sort = null)
        {
            Dictionary<string, object> parameters = new Dictionary<string, object>();
            string condition = null, order = null;

            if (filterLinked != null)
            {
                condition = filterLinked.ToString(parameters);
            }

            if (sort != null)
            {
                order = sort.ToString();
            }

            return _privilegeBase.GetUsers(page, pageSize, out recordCount, condition, order, parameters.Values.ToArray());
        }