예제 #1
0
        /// <summary>
        /// Kiem tra su ton tai cua danh sach cac id dong thoi lay ve du lieu
        /// </summary>
        /// <param name="id"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        internal bool VerifyIds(List <long> listId, List <ApplicationRole> listObject)
        {
            bool valid = true;

            try
            {
                if (listId != null && listId.Count > 0)
                {
                    ApplicationRoleFilterQuery filter = new ApplicationRoleFilterQuery();
                    filter.Ids = listId;
                    List <ApplicationRole> listData = new ApplicationRoleManagerGet().Get(filter);
                    if (listData == null || listId.Count != listData.Count)
                    {
                        BugUtil.SetBugCode(param, LibraryBug.Bug.Enum.Common__KXDDDuLieuCanXuLy);
                        Logging("ListId invalid." + LogUtil.TraceData("listData", listData) + LogUtil.TraceData("listId", listId), LogType.Error);
                        valid = false;
                    }
                    else
                    {
                        listObject.AddRange(listData);
                    }
                }
            }
            catch (Exception ex)
            {
                LogSystem.Error(ex);
                valid = false;
                param.HasException = true;
            }
            return(valid);
        }
예제 #2
0
        internal bool Run(AasAuthorizeSDO data, ref User resultData)
        {
            bool result = false;

            try
            {
                bool                valid       = true;
                User                raw         = null;
                Application         application = null;
                TokenAuthorizeCheck checker     = new TokenAuthorizeCheck(param);
                AasUserCheck        userChecker = new AasUserCheck(param);
                valid = valid && checker.VerifyRequireField(data);
                valid = valid && userChecker.VerifyLoginname(data.Loginname, ref raw);
                if (valid)
                {
                    application = new ApplicationManagerGet().GetByCode(data.ApplicationCode);
                    if (application == null)
                    {
                        MessageUtil.SetMessage(param, LibraryMessage.Message.Enum.Common_UngDungChuaDuocDangKyTrenHeThong);
                        throw new Exception("ApplicationCode invalid: " + data.ApplicationCode);
                    }

                    List <ApplicationRole> appRoles = new ApplicationRoleManagerGet().GetByApplicationId(application.Id);
                    if (!IsNotNullOrEmpty(appRoles))
                    {
                        MessageUtil.SetMessage(param, LibraryMessage.Message.Enum.Common_TaiKhoanKhongCoQuyenTruyCapUngDung);
                        throw new Exception("Ung dung cua duc gan vao vao tro nao");
                    }

                    List <UserRole> userRoles = new UserRoleManagerGet().GetByUserId(raw.Id);
                    if (!IsNotNullOrEmpty(userRoles))
                    {
                        MessageUtil.SetMessage(param, LibraryMessage.Message.Enum.Common_TaiKhoanKhongCoQuyenTruyCapUngDung);
                        throw new Exception("Nguoi dung chua duc gan vai trong o cho naof");
                    }

                    List <long> userRoleIds = userRoles.Select(s => s.RoleId).ToList();
                    if (!appRoles.Exists(e => userRoleIds.Contains(e.RoleId)))
                    {
                        MessageUtil.SetMessage(param, LibraryMessage.Message.Enum.Common_TaiKhoanKhongCoQuyenTruyCapUngDung);
                        throw new Exception("Nguoi dung khong duoc phan quyen truy cap vao ung dung");
                    }
                    raw.Password = "";
                    resultData   = raw;
                    result       = true;
                }
            }
            catch (Exception ex)
            {
                DungLH.Util.CommonLogging.LogSystem.Error(ex);
                result = false;
            }
            return(result);
        }
 public ApiResult Get(ApiParam <ApplicationRoleFilterQuery> param)
 {
     try
     {
         ApiResultObject <List <ApplicationRole> > result = new ApiResultObject <List <ApplicationRole> >(null);
         if (param != null)
         {
             ApplicationRoleManagerGet mng = new ApplicationRoleManagerGet(param.CommonParam);
             result = mng.GetResult(param.ApiData);
         }
         return(new ApiResult(result, this.ActionContext));
     }
     catch (Exception ex)
     {
         LogSystem.Error(ex);
         return(null);
     }
 }
예제 #4
0
        /// <summary>
        /// Kiem tra su ton tai cua id dong thoi lay ve du lieu
        /// </summary>
        /// <param name="id"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        internal bool VerifyId(long id, ref ApplicationRole data)
        {
            bool valid = true;

            try
            {
                data = new ApplicationRoleManagerGet().GetById(id);
                if (data == null)
                {
                    BugUtil.SetBugCode(param, LibraryBug.Bug.Enum.Common__KXDDDuLieuCanXuLy);
                    Logging("Id invalid." + LogUtil.TraceData("id", id), LogType.Error);
                    valid = false;
                }
            }
            catch (Exception ex)
            {
                LogSystem.Error(ex);
                valid = false;
                param.HasException = true;
            }
            return(valid);
        }
예제 #5
0
        /// <summary>
        /// Kiem tra du lieu co o trang thai unlock (su dung danh sach id)
        /// </summary>
        /// <param name="id"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        internal bool IsUnLock(List <long> listId)
        {
            bool valid = true;

            try
            {
                if (listId != null && listId.Count > 0)
                {
                    ApplicationRoleFilterQuery filter = new ApplicationRoleFilterQuery();
                    filter.Ids = listId;
                    List <ApplicationRole> listData = new ApplicationRoleManagerGet().Get(filter);
                    if (listData != null && listData.Count > 0)
                    {
                        foreach (var data in listData)
                        {
                            if (Constant.IS_TRUE != data.IsActive)
                            {
                                valid = false;
                                break;
                            }
                        }
                        if (!valid)
                        {
                            MessageUtil.SetMessage(param, LibraryMessage.Message.Enum.Common__DuLieuDangBiKhoa);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogSystem.Error(ex);
                valid = false;
                param.HasException = true;
            }
            return(valid);
        }