コード例 #1
0
        void UpdateUserSitemap(string roleID)
        {
            AdmUserroleDT userRoleDT = new AdmUserroleDT();

            string    getUserIdCond = "RoleID = " + roleID;
            DataTable userIds       = userRoleDT.GetByCond(getUserIdCond);

            if (userIds != null)
            {
                foreach (DataRow rowUserId in userIds.Rows)
                {
                    string    userId        = rowUserId["UserID"].ToString();
                    string    getRoleIdCond = "UserID = " + userId;
                    DataTable dtRoleIds     = userRoleDT.GetByCond(getRoleIdCond);
                    if (dtRoleIds != null)
                    {
                        string[]  roleIds        = DataTableHelper.ExtractToStringArray(dtRoleIds, "RoleID");
                        string    sitemap        = AdmUserOvrController.buildSiteMap(roleIds);
                        AdmUserDT userDT         = new AdmUserDT();
                        string    userUpdateCond = "ID=" + userId;
                        userDT.Update(new string[] { "SiteMap" }, new string[] { "N'" + sitemap + "'" }, userUpdateCond);
                    }
                }
            }
        }
コード例 #2
0
 public HttpResponseMessage GetRoleList(string userId)
 {
     try
     {
         DataTable dt = userRoleDT.GetByCond("UserId=" + userId);
         return(Request.CreateResponse <string[]>(HttpStatusCode.OK, DataTableHelper.ExtractToStringArray(dt, "RoleId")));
     }
     catch (Exception e)
     {
         ExceptionHandler.Log(e);
         return(null);
     }
 }
コード例 #3
0
 public AdmUserroleRule IsExits(string cond, string message)
 {
     try
     {
         DataTable dt = dta.GetByCond(cond);
         if (dt != null && dt.Rows.Count > 0)
         {
             IsPassed    = false;
             ErrMessage += message;
         }
         return(this);
     }
     catch (Exception e)
     {
         IsPassed = false;
         throw e;
     }
 }
コード例 #4
0
ファイル: AuthModel.cs プロジェクト: nhatlbh/MinhTin
        public static AuthInfo GetAuthInfo(string sessionKey)
        {
            string    sessionCond = "SessionID='" + sessionKey + "'";
            DataTable dtSession   = sessionDT.GetByCond(sessionCond);

            if (dtSession != null && dtSession.Rows.Count > 0)
            {
                string    getUserCond = "ID=" + dtSession.Rows[0]["UserID"].ToString();
                DataTable dtUser      = userDT.GetByCond(getUserCond);
                if (dtUser != null && dtSession.Rows.Count > 0)
                {
                    string    userId       = dtUser.Rows[0]["ID"].ToString();
                    string    getStaffCond = "UserID=" + userId;
                    DataTable dtStaff      = staffDT.GetByCond(getStaffCond);
                    if (dtStaff != null && dtStaff.Rows.Count > 0)
                    {
                        string    staffGroupCond     = "SaleStaffID=" + dtStaff.Rows[0]["ID"].ToString();
                        string    getUserRoleCond    = "UserID=" + userId;
                        DataTable dtUserRole         = userRoleDt.GetByCond(getUserRoleCond);
                        string    getUserRightCond   = "RoleID in (" + string.Join(",", dtUserRole.ColToListString("RoleID").ToArray()) + ")";
                        DataTable dtUserRight        = roleRightDT.GetByCond(getUserRightCond);
                        DataTable dtStaffMgtGroup    = staffMgntGroupDT.GetByCond(staffGroupCond);
                        DataTable dtStaffProductType = staffProducTypeDT.GetByCond(staffGroupCond);
                        AuthInfo  authInfo           = new AuthInfo();
                        authInfo.StaffId             = dtStaff.Rows[0]["ID"].ToString();
                        authInfo.UserId              = dtStaff.Rows[0]["UserID"].ToString();
                        authInfo.BranchId            = dtStaff.Rows[0]["BranchID"].ToString();
                        authInfo.StaffMgntGroupIds   = dtStaffMgtGroup.ColToListString("ManagementGroupID");
                        authInfo.StaffProductTypeIds = dtStaffProductType.ColToListString("ProductTypeID");
                        authInfo.UserRightIds        = dtUserRight.Distinct("RightID").ColToListString("RightID");
                        return(authInfo);
                    }
                }
            }
            return(null);
        }