C#.NET 大型通用資訊化系統整合快速開發平台 4.1 版本 - 大資料分頁功能改進、資料許可權改進

來源:互聯網
上載者:User

標籤:style   blog   class   code   java   tar   

代碼產生器大資料分頁

 

下面參考代碼是簡易的資料許可權的實現,大多情況下下面的資料許可權的功能可以滿足很多企業的需要了

        #region public DataTable GetDataTableByPage(BaseUserInfo userInfo, out int recordCount, int pageIndex = 0, int pageSize = 20, string sortExpression = null, string sortDire = null) 分頁查詢        /// <summary>        /// 分頁查詢        /// </summary>        /// <param name="userInfo">使用者</param>        /// <param name="recordCount">記錄數</param>        /// <param name="pageIndex">當前頁</param>        /// <param name="pageSize">每頁顯示記錄條數</param>        /// <param name="sortExpression">排序欄位</param>        /// <param name="sortDire">排序方向</param>        /// <returns>資料表</returns>        public DataTable GetDataTableByPage(BaseUserInfo userInfo, out int recordCount, int pageIndex = 0, int pageSize = 20, string sortExpression = null, string sortDire = null)        {            // 寫入調試資訊            #if (DEBUG)                int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());            #endif            // 加強安全驗證防止未登入使用者調用            #if (!DEBUG)                LogOnService.UserIsLogOn(userInfo);            #endif            var dt = new DataTable(LanNiaoKeJiEntity.TableName);                        using (IDbHelper ucDbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))            {                try                {                    ucDbHelper.Open(UserCenterDbConnection);                    BaseLogManager.Instance.Add(userInfo, this.serviceName, "取得列表", MethodBase.GetCurrentMethod());                    using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.BusinessDbType))                    {                        try                        {                            dbHelper.Open(BusinessDbConnection);                            // 取得列表                            LanNiaoKeJiManager manager = new LanNiaoKeJiManager(dbHelper, userInfo);                            string order = sortExpression + " " + sortDire;                            string whereConditional = string.Empty;                            List<IDbDataParameter> dbParameters = new List<IDbDataParameter>();                            BaseUserManager userManager = new BaseUserManager();                            if (userManager.IsInRoleByCode(userInfo, "User"))                            {                                // 普通使用者,只能看自己的                                whereConditional = BaseBusinessLogic.FieldUserId + "=" + dbHelper.GetParameter(BaseBusinessLogic.FieldUserId);                                dbParameters.Add(dbHelper.MakeParameter(BaseBusinessLogic.FieldUserId, userInfo.Id));                            }                            else if (userManager.IsInRoleByCode(userInfo, "DepartmentManager"))                            {                                // 部門主管,只能看自己部門的                                whereConditional = BaseBusinessLogic.FieldDepartmentId + "=" + dbHelper.GetParameter(BaseBusinessLogic.FieldDepartmentId);                                dbParameters.Add(dbHelper.MakeParameter(BaseBusinessLogic.FieldDepartmentId, userInfo.DepartmentId));                            }                            else if (userManager.IsInRoleByCode(userInfo, "CompanyManager"))                            {                                // 公司主管,只能看自己公司的                                whereConditional = BaseBusinessLogic.FieldCompanyId + "=" + dbHelper.GetParameter(BaseBusinessLogic.FieldCompanyId);                                dbParameters.Add(dbHelper.MakeParameter(BaseBusinessLogic.FieldCompanyId, userInfo.CompanyId));                            }                            else if (userManager.IsInRoleByCode(userInfo, "Manager"))                            {                                // 管理者,可以看所有的,不限制條件                            }                            dt.TableName = LanNiaoKeJiEntity.TableName;                        }                        catch (Exception ex)                        {                            BaseExceptionManager.LogException(ucDbHelper, userInfo, ex);                            throw;                        }                        finally                        {                            dbHelper.Close();                        }                    }                }                catch (Exception ex)                {                    BaseExceptionManager.LogException(ucDbHelper, userInfo, ex);                    throw;                }                finally                {                    ucDbHelper.Close();                }            }            // 寫入調試資訊            #if (DEBUG)                BaseBusinessLogic.EndDebug(userInfo, MethodBase.GetCurrentMethod(), milliStart);            #endif            return dt;        }        #endregion

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.