예제 #1
0
        /// <summary>
        /// 取得給使用者的權限
        /// </summary>
        public EO_PermissionDataTable queryPermissionForUsers(string[] userIds, string[] extendFieldNames)
        {
            var       qrydb = new NsDbQuery();
            DataTable dt1   = null;
            {
                //人員所擁有的權限
                qrydb.setSelect(s =>
                {
                    var t1 = s.from <EO_PermissionSetting>();
                    var t2 = s.join <EO_Permission>()
                             .on(t => t.EOP_PermissionId == t1.EOPS_PermissionId);
                    s.select(t2.EOP_PermissionId);
                    s.Where = t1.EOPS_PermissionUserId.batchin(userIds.toConstReq1())
                              & t2.EOP_IsObjectNeed == "N"
                              & t2.EOP_IsEveryOneAllow == "N";
                });
                dt1 = qrydb.queryData();
            }

            {
                //EveryOne都可以有的權限
                qrydb.setSelect(s =>
                {
                    var t1 = s.from <EO_Permission>();
                    s.select(t1.EOP_PermissionId);
                    s.Where = t1.EOP_IsObjectNeed == "N"
                              & t1.EOP_IsEveryOneAllow == "Y";
                });
                qrydb.fillData(dt1);
            }

            {
                var pks = FtdDataHelper.getDistinctArray <string>(dt1, dt1.Columns[0]);
                var qry = new NsDmQuery();
                var t1  = qry.from <EO_Permission>();
                qry.selectAll(extendFieldNames);
                qry.Where = t1.EOP_PermissionId.batchin(pks.toConstReq1());
                var dt = (EO_PermissionDataTable)qry.queryData();
                return(dt);
            }
        }