예제 #1
0
        /// <summary>
        /// 根据SQL语句获得对象列表
        /// </summary>
        /// <param name="strSql"></param>
        /// <param name="dbParameter"></param>
        /// <param name="pagination"></param>
        /// <returns></returns>
        public ResultClass <List <TEntity> > FindList(string strSql, Dictionary <string, object> dbParameters, Pagination pagination)
        {
            ResultClass <List <TEntity> > _ret = new ResultClass <List <TEntity> >();

            try
            {
                ResultClass <List <TEntity> > tmp = FindList(strSql, dbParameters);
                pagination.records = tmp.Result ? tmp.ResultData.Count : 0;
                if (pagination.records > 0)
                {
                    string StrSql = DatabasePage.GetStrSql(strSql, dbParameters, pagination);
                    _ret.ResultData = dbcontext.Database.SqlQuery <TEntity>(strSql, new List <DbParameter>()).ToList <TEntity>();
                    if (_ret.ResultData != null)
                    {
                        _ret.Result = true;
                    }
                    else
                    {
                        _ret.ErrorMessage = "没有数据!";
                    }
                }
                else
                {
                    _ret.ErrorMessage = "没有数据!";
                }
            }
            catch (Exception ex)
            {
                _ret.ErrorMessage = ex.Message;
            }
            return(_ret);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="objectType"></param>
        /// <param name="objectID"></param>
        /// <returns></returns>
        public ResultClass <List <ModuleButtonEntity> > GetModuleButtonByObjectID(Pagination pagination, string objectType, string objectID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append(@"select t.*
                            from Sys_ModuleButton t,Sys_RoleAuthorize r
                            where t.F_Id=r.F_ItemId and r.F_ItemType=2
                                  and r.F_ObjectType=@F_ObjectType and r.F_ObjectId=@F_ObjectId");
            Dictionary <string, object> parameter = new Dictionary <string, object>();

            parameter.Add("F_ObjectType", objectType);
            parameter.Add("F_ObjectId", objectID);
            string sql = DatabasePage.GetStrSql(strSql.ToString(), parameter, pagination);

            return(this.FindList(sql, new Dictionary <string, object>()));
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="enCode"></param>
        /// <returns></returns>
        public List <ItemsDetailEntity> GetItemList(Pagination pagination, string enCode)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append(@"SELECT  d.*
                            FROM    Sys_ItemsDetail d
                                    INNER  JOIN Sys_Items i ON i.F_Id = d.F_ItemId
                            WHERE   1 = 1
                                    AND i.F_EnCode = @enCode
                                    AND d.F_EnabledMark = 1
                                    AND d.F_DeleteMark = 0 ");
            Dictionary <string, object> parameter = new Dictionary <string, object>();

            parameter.Add("enCode", enCode);
            string sql = DatabasePage.GetStrSql(strSql.ToString(), parameter, pagination);
            ResultClass <List <ItemsDetailEntity> > _ret = this.FindList(sql, new Dictionary <string, object>());

            if (_ret.Result)
            {
                return(_ret.ResultData);
            }
            return(new List <ItemsDetailEntity>());
        }