コード例 #1
0
        internal bool Create(Address data)
        {
            bool result = false;

            try
            {
                bool            valid          = true;
                Project         project        = null;
                PcsAddressCheck checker        = new PcsAddressCheck(param);
                PcsProjectCheck projectChecker = new PcsProjectCheck(param);
                valid = valid && checker.VerifyRequireField(data);
                valid = valid && projectChecker.VerifyId(data.ProjectId, ref project);
                valid = valid && projectChecker.IsUnLock(project);
                valid = valid && projectChecker.IsUnFinish(project);
                if (valid)
                {
                    if (!DAOWorker.PcsAddressDAO.Create(data))
                    {
                        BugUtil.SetBugCode(param, LibraryBug.Bug.Enum.PcsAddress_ThemMoiThatBai);
                        throw new Exception("Them moi thong tin PcsAddress that bai." + LogUtil.TraceData("data", data));
                    }
                    this.recentPcsAddresss.Add(data);
                    result = true;
                }
            }
            catch (Exception ex)
            {
                LogSystem.Error(ex);
                param.HasException = true;
                result             = false;
            }
            return(result);
        }
コード例 #2
0
        internal bool VerifyRequireField(ModuleRole data)
        {
            bool valid = true;

            try
            {
                if (data == null)
                {
                    throw new ArgumentNullException("data");
                }
            }
            catch (ArgumentNullException ex)
            {
                BugUtil.SetBugCode(param, LibraryBug.Bug.Enum.Common__ThieuThongTinBatBuoc);
                LogSystem.Error(ex);
                valid = false;
            }
            catch (Exception ex)
            {
                LogSystem.Error(ex);
                valid = false;
                param.HasException = true;
            }
            return(valid);
        }
コード例 #3
0
        internal bool Update(UserRole data)
        {
            bool result = false;

            try
            {
                bool             valid   = true;
                AasUserRoleCheck checker = new AasUserRoleCheck(param);
                valid = valid && checker.VerifyRequireField(data);
                UserRole raw = null;
                valid = valid && checker.VerifyId(data.Id, ref raw);
                valid = valid && checker.IsUnLock(raw);
                if (valid)
                {
                    if (!DAOWorker.AasUserRoleDAO.Update(data))
                    {
                        BugUtil.SetBugCode(param, LibraryBug.Bug.Enum.AasUserRole_CapNhatThatBai);
                        throw new Exception("Cap nhat thong tin AasUserRole that bai." + LogUtil.TraceData("data", data));
                    }

                    this.beforeUpdateAasUserRoles.Add(raw);
                    result = true;
                }
            }
            catch (Exception ex)
            {
                LogSystem.Error(ex);
                param.HasException = true;
                result             = false;
            }
            return(result);
        }
コード例 #4
0
        internal bool Create(UserRole data)
        {
            bool result = false;

            try
            {
                bool             valid   = true;
                AasUserRoleCheck checker = new AasUserRoleCheck(param);
                valid = valid && checker.VerifyRequireField(data);
                if (valid)
                {
                    if (!DAOWorker.AasUserRoleDAO.Create(data))
                    {
                        BugUtil.SetBugCode(param, LibraryBug.Bug.Enum.AasUserRole_ThemMoiThatBai);
                        throw new Exception("Them moi thong tin AasUserRole that bai." + LogUtil.TraceData("data", data));
                    }
                    this.recentAasUserRoles.Add(data);
                    result = true;
                }
            }
            catch (Exception ex)
            {
                LogSystem.Error(ex);
                param.HasException = true;
                result             = false;
            }
            return(result);
        }
コード例 #5
0
        internal bool VerifyRequireField(CredentialData data)
        {
            bool valid = true;

            try
            {
                if (data == null)
                {
                    throw new ArgumentNullException("data");
                }
                if (String.IsNullOrWhiteSpace(data.TokenCode))
                {
                    throw new ArgumentNullException("data.TokenCode");
                }
                if (String.IsNullOrWhiteSpace(data.DataKey))
                {
                    throw new ArgumentNullException("data.DataKey");
                }
            }
            catch (ArgumentNullException ex)
            {
                BugUtil.SetBugCode(param, LibraryBug.Bug.Enum.Common__ThieuThongTinBatBuoc);
                LogSystem.Error(ex);
                valid = false;
            }
            catch (Exception ex)
            {
                LogSystem.Error(ex);
                valid = false;
                param.HasException = true;
            }
            return(valid);
        }
コード例 #6
0
ファイル: PcsEmployeeCheck.cs プロジェクト: dunglh/MyProject
        internal bool VerifyRequireField(Employee data)
        {
            bool valid = true;

            try
            {
                if (data == null)
                {
                    throw new ArgumentNullException("data");
                }
                if (String.IsNullOrWhiteSpace(data.Loginname))
                {
                    throw new ArgumentNullException("data.Loginname");
                }
                if (data.RoleId <= 0 || data.RoleId > 3)
                {
                    throw new ArgumentNullException("data.RoleId");
                }
            }
            catch (ArgumentNullException ex)
            {
                BugUtil.SetBugCode(param, LibraryBug.Bug.Enum.Common__ThieuThongTinBatBuoc);
                LogSystem.Error(ex);
                valid = false;
            }
            catch (Exception ex)
            {
                LogSystem.Error(ex);
                valid = false;
                param.HasException = true;
            }
            return(valid);
        }
コード例 #7
0
ファイル: AasUserUpdate.cs プロジェクト: dunglh/MyProject
        internal bool Update(User data, User before)
        {
            bool result = false;

            try
            {
                bool         valid   = true;
                AasUserCheck checker = new AasUserCheck(param);
                valid = valid && checker.VerifyRequireField(data);
                valid = valid && checker.IsUnLock(before);
                valid = valid && checker.ExistsLoginname(data.Loginname, data.Id);
                if (valid)
                {
                    if (!DAOWorker.AasUserDAO.Update(data))
                    {
                        BugUtil.SetBugCode(param, LibraryBug.Bug.Enum.AasUser_CapNhatThatBai);
                        throw new Exception("Cap nhat thong tin AasUser that bai." + LogUtil.TraceData("data", data));
                    }
                    this.beforeUpdateAasUsers.Add(before);
                    result = true;
                }
            }
            catch (Exception ex)
            {
                LogSystem.Error(ex);
                param.HasException = true;
                result             = false;
            }
            return(result);
        }
コード例 #8
0
        internal bool Update(Project data, Project before)
        {
            bool result = false;

            try
            {
                bool            valid   = true;
                PcsProjectCheck checker = new PcsProjectCheck(param);
                valid = valid && checker.VerifyRequireField(data);
                valid = valid && checker.IsUnLock(before);
                valid = valid && checker.IsUnFinish(before);
                valid = valid && checker.ExistsCode(data.ProjectCode, data.Id);
                if (valid)
                {
                    if (!DAOWorker.PcsProjectDAO.Update(data))
                    {
                        BugUtil.SetBugCode(param, LibraryBug.Bug.Enum.PcsProject_CapNhatThatBai);
                        throw new Exception("Cap nhat thong tin PcsProject that bai." + LogUtil.TraceData("data", data));
                    }

                    this.beforeUpdatePcsProjects.Add(before);
                    result = true;
                }
            }
            catch (Exception ex)
            {
                LogSystem.Error(ex);
                param.HasException = true;
                result             = false;
            }
            return(result);
        }
コード例 #9
0
        internal bool VerifyRequireField(AasAuthorizeSDO data)
        {
            bool valid = true;

            try
            {
                if (data == null)
                {
                    throw new ArgumentNullException("data");
                }
                if (String.IsNullOrWhiteSpace(data.ApplicationCode))
                {
                    throw new ArgumentNullException("data.ApplicationCode");
                }
                if (String.IsNullOrWhiteSpace(data.Loginname))
                {
                    throw new ArgumentNullException("data.Loginname");
                }
                data.Loginname = data.Loginname.ToLower().Trim();
            }
            catch (ArgumentNullException ex)
            {
                BugUtil.SetBugCode(param, LibraryBug.Bug.Enum.Common__ThieuThongTinBatBuoc);
                LogSystem.Error(ex);
                valid = false;
            }
            catch (Exception ex)
            {
                LogSystem.Error(ex);
                valid = false;
                param.HasException = true;
            }
            return(valid);
        }
コード例 #10
0
ファイル: PcsPostUpdate.cs プロジェクト: dunglh/MyProject
        internal bool UpdateList(List <Post> listData, List <Post> listBefore)
        {
            bool result = false;

            try
            {
                bool valid = true;
                valid = IsNotNullOrEmpty(listData);
                PcsPostCheck checker = new PcsPostCheck(param);
                valid = valid && checker.IsUnLock(listBefore);
                foreach (var data in listData)
                {
                    valid = valid && checker.VerifyRequireField(data);
                }
                if (valid)
                {
                    if (!DAOWorker.PcsPostDAO.UpdateList(listData))
                    {
                        BugUtil.SetBugCode(param, LibraryBug.Bug.Enum.PcsPost_CapNhatThatBai);
                        throw new Exception("Cap nhat thong tin PcsPost that bai." + LogUtil.TraceData("listData", listData));
                    }
                    this.beforeUpdatePcsPosts.AddRange(listBefore);
                    result = true;
                }
            }
            catch (Exception ex)
            {
                LogSystem.Error(ex);
                param.HasException = true;
                result             = false;
            }
            return(result);
        }
コード例 #11
0
ファイル: PcsPostUpdate.cs プロジェクト: dunglh/MyProject
        internal bool Update(Post data)
        {
            bool result = false;

            try
            {
                bool         valid   = true;
                PcsPostCheck checker = new PcsPostCheck(param);
                valid = valid && checker.VerifyRequireField(data);
                Post raw = null;
                valid = valid && checker.VerifyId(data.Id, ref raw);
                valid = valid && checker.IsUnLock(raw);
                valid = valid && checker.CheckSttForDeleteOrUpdate(raw);
                if (valid)
                {
                    if (!DAOWorker.PcsPostDAO.Update(data))
                    {
                        BugUtil.SetBugCode(param, LibraryBug.Bug.Enum.PcsPost_CapNhatThatBai);
                        throw new Exception("Cap nhat thong tin PcsPost that bai." + LogUtil.TraceData("data", data));
                    }

                    this.beforeUpdatePcsPosts.Add(raw);
                    result = true;
                }
            }
            catch (Exception ex)
            {
                LogSystem.Error(ex);
                param.HasException = true;
                result             = false;
            }
            return(result);
        }
コード例 #12
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 <ModuleRole> listObject)
        {
            bool valid = true;

            try
            {
                if (listId != null && listId.Count > 0)
                {
                    ModuleRoleFilterQuery filter = new ModuleRoleFilterQuery();
                    filter.Ids = listId;
                    List <ModuleRole> listData = new ModuleRoleManagerGet().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);
        }
コード例 #13
0
        internal bool ValidData(PcsPostSDO data, ref List <Post> listPost)
        {
            bool valid = true;

            try
            {
                List <Post> posts = new List <Post>();
                if (IsNotNullOrEmpty(data.Posts))
                {
                    valid = valid && new PcsPostCheck(param).VerifyIds(data.Posts.Select(s => s.Id).ToList(), posts);
                    if (valid)
                    {
                        if (!IsNotNullOrEmpty(posts))
                        {
                            BugUtil.SetBugCode(param, LibraryBug.Bug.Enum.Common__DuLieuDauVaoKhongChinhXac);
                            throw new Exception("PostIds invalid");
                        }

                        if (posts.Exists(e => e.ProjectId != data.ProjectId))
                        {
                            MessageUtil.SetMessage(param, LibraryMessage.Message.Enum.PcsPost__TonTaiBaiDangKhongThuocDuAn);
                            throw new Exception("Ton tai bai dang khong thuoc du an");
                        }
                    }
                    else
                    {
                        return(valid);
                    }
                }
                else
                {
                    PcsPostFilterQuery filterQuery = new PcsPostFilterQuery();
                    filterQuery.ProjectId = data.ProjectId;
                    filterQuery.PostSttId = PostSttConstant.POST_STT_ID__NOT_APPROVAL;
                    posts = new PcsPostManagerGet().Get(filterQuery);
                    if (!IsNotNullOrEmpty(posts))
                    {
                        MessageUtil.SetMessage(param, LibraryMessage.Message.Enum.PcsPost__DuAnKhongCoBaiDangNaoHopLe);
                        throw new Exception("Project Khong co bai dang nao hop le");
                    }
                }
                listPost = posts;
            }
            catch (Exception ex)
            {
                LogSystem.Error(ex);
                valid = false;
                param.HasException = true;
            }
            return(valid);
        }
コード例 #14
0
ファイル: TokenManagerBase.cs プロジェクト: dunglh/MyProject
        internal bool DeleteCredentialData(string backendCode, string tokenCode, string dataKey, CommonParam commonParam)
        {
            bool result = false;

            try
            {
                if (String.IsNullOrWhiteSpace(backendCode))
                {
                    throw new ArgumentNullException("backendCode");
                }
                if (String.IsNullOrWhiteSpace(tokenCode))
                {
                    throw new ArgumentNullException("tokenCode");
                }
                if (String.IsNullOrWhiteSpace(dataKey))
                {
                    throw new ArgumentNullException("dataKey");
                }

                CredentialDataFilterQuery filter = new CredentialDataFilterQuery();
                filter.BackendCodeExact = backendCode;
                filter.TokenCodeExact   = tokenCode;
                filter.DataKeyExact     = dataKey;
                List <CredentialData> listData = new CredentialDataManagerGet().Get(filter);
                if (listData == null || listData.Count <= 0)
                {
                    BugUtil.SetBugCode(commonParam, LibraryBug.Bug.Enum.Common_DuLieuDauVaoKhongChinhXac);
                    throw new Exception("Khong tim thay CredentialData tuong ung");
                }

                if (!new AasCredentialDataTruncate(commonParam).TruncateList(listData))
                {
                    throw new Exception("Xoa credentialData that bai");
                }
                result = true;
            }
            catch (ArgumentNullException ex)
            {
                BugUtil.SetBugCode(commonParam, LibraryBug.Bug.Enum.Common__ThieuThongTinBatBuoc);
                DungLH.Util.CommonLogging.LogSystem.Error(ex);
                result = false;
            }
            catch (Exception ex)
            {
                DungLH.Util.CommonLogging.LogSystem.Error(ex);
                result = false;
            }
            return(result);
        }
コード例 #15
0
ファイル: TokenManagerBase.cs プロジェクト: dunglh/MyProject
        internal DungLH.Util.Token.Core.CredentialData GetCredentialData(string backendCode, string tokenCode, string dataKey, CommonParam commonParam)
        {
            DungLH.Util.Token.Core.CredentialData result = null;
            try
            {
                if (String.IsNullOrWhiteSpace(backendCode))
                {
                    throw new ArgumentNullException("backendCode");
                }
                if (String.IsNullOrWhiteSpace(tokenCode))
                {
                    throw new ArgumentNullException("tokenCode");
                }
                if (String.IsNullOrWhiteSpace(dataKey))
                {
                    throw new ArgumentNullException("dataKey");
                }

                CredentialDataFilterQuery filter = new CredentialDataFilterQuery();
                filter.BackendCodeExact = backendCode;
                filter.TokenCodeExact   = tokenCode;
                filter.DataKeyExact     = dataKey;
                List <CredentialData> listData = new CredentialDataManagerGet().Get(filter);
                if (listData == null || listData.Count <= 0)
                {
                    BugUtil.SetBugCode(commonParam, LibraryBug.Bug.Enum.Common_DuLieuDauVaoKhongChinhXac);
                    throw new Exception("Khong tim thay CredentialData tuong ung");
                }
                CredentialData data = listData.FirstOrDefault();
                result             = new DungLH.Util.Token.Core.CredentialData();
                result.BackendCode = data.BackendCode;
                result.Data        = data.Data;
                result.DataKey     = data.DataKey;
                result.TokenCode   = data.TokenCode;
            }
            catch (ArgumentNullException ex)
            {
                BugUtil.SetBugCode(commonParam, LibraryBug.Bug.Enum.Common__ThieuThongTinBatBuoc);
                DungLH.Util.CommonLogging.LogSystem.Error(ex);
                result = null;
            }
            catch (Exception ex)
            {
                DungLH.Util.CommonLogging.LogSystem.Error(ex);
                result = null;
            }
            return(result);
        }
コード例 #16
0
ファイル: PcsPostCreate.cs プロジェクト: dunglh/MyProject
        internal bool Create(Post data)
        {
            bool result = false;

            try
            {
                bool            valid          = true;
                Project         project        = null;
                PcsPostCheck    checker        = new PcsPostCheck(param);
                PcsProjectCheck projectChecker = new PcsProjectCheck(param);
                valid = valid && IsNotNull(data);
                valid = valid && checker.VerifyRequireField(data);
                valid = valid && projectChecker.VerifyId(data.ProjectId, ref project);
                valid = valid && projectChecker.IsUnFinish(project);
                if (valid)
                {
                    data.PostSttId = PostSttConstant.POST_STT_ID__NOT_APPROVAL;
                    if (String.IsNullOrWhiteSpace(data.PostType))
                    {
                        data.PostType = "post";
                    }
                    if (String.IsNullOrWhiteSpace(data.Status))
                    {
                        data.Status = "publish";
                    }
                    data.ApprovalLoginname = null;
                    data.ApprovalTime      = null;
                    data.ApprovalUsername  = null;
                    data.PostTime          = null;
                    data.ApprovalNote      = null;

                    if (!DAOWorker.PcsPostDAO.Create(data))
                    {
                        BugUtil.SetBugCode(param, LibraryBug.Bug.Enum.PcsPost_ThemMoiThatBai);
                        throw new Exception("Them moi thong tin PcsPost that bai." + LogUtil.TraceData("data", data));
                    }
                    this.recentPcsPosts.Add(data);
                    result = true;
                }
            }
            catch (Exception ex)
            {
                LogSystem.Error(ex);
                param.HasException = true;
                result             = false;
            }
            return(result);
        }
コード例 #17
0
        internal bool VerifyRequireField(Post data)
        {
            bool valid = true;

            try
            {
                if (data == null)
                {
                    throw new ArgumentNullException("data");
                }
                if (String.IsNullOrWhiteSpace(data.Content))
                {
                    throw new ArgumentNullException("data.Content");
                }
                if (String.IsNullOrWhiteSpace(data.Title))
                {
                    throw new ArgumentNullException("data.Title");
                }
                if (data.AddressId <= 0)
                {
                    throw new ArgumentNullException("data.AddressId");
                }
                if (data.PostSttId <= 0 || data.PostSttId > 5)
                {
                    throw new ArgumentNullException("data.PostSttId");
                }
                if (data.ProjectId <= 0)
                {
                    throw new ArgumentNullException("data.ProjectId");
                }
            }
            catch (ArgumentNullException ex)
            {
                BugUtil.SetBugCode(param, LibraryBug.Bug.Enum.Common__ThieuThongTinBatBuoc);
                LogSystem.Error(ex);
                valid = false;
            }
            catch (Exception ex)
            {
                LogSystem.Error(ex);
                valid = false;
                param.HasException = true;
            }
            return(valid);
        }
コード例 #18
0
        internal bool Create(User data)
        {
            bool result = false;

            try
            {
                bool            valid           = true;
                PasswordManager passwordManager = new PasswordManager();
                AasUserCheck    checker         = new AasUserCheck(param);
                valid = valid && checker.VerifyRequireField(data);
                valid = valid && checker.ExistsLoginname(data.Loginname, null);
                if (valid)
                {
                    string password = "";
                    if (!String.IsNullOrWhiteSpace(data.Password))
                    {
                        password = data.Password;
                    }
                    else
                    {
                        password = data.Loginname;
                    }
                    data.Salt     = passwordManager.GenerateSalt();
                    data.Password = passwordManager.HashPassword(password, data.Salt, data.Loginname);

                    if (!DAOWorker.AasUserDAO.Create(data))
                    {
                        BugUtil.SetBugCode(param, LibraryBug.Bug.Enum.AasUser_ThemMoiThatBai);
                        throw new Exception("Them moi thong tin AasUser that bai." + LogUtil.TraceData("data", data));
                    }
                    data.Password = "";
                    data.Salt     = "";
                    this.recentAasUsers.Add(data);
                    result = true;
                }
            }
            catch (Exception ex)
            {
                LogSystem.Error(ex);
                param.HasException = true;
                result             = false;
            }
            return(result);
        }
コード例 #19
0
ファイル: AasModuleCheck.cs プロジェクト: dunglh/MyProject
        /// <summary>
        /// Kiem tra su ton tai cua id
        /// </summary>
        /// <param name="id"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        internal bool VerifyId(long id)
        {
            bool valid = true;

            try
            {
                if (new ModuleManagerGet().GetById(id) == 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);
        }
コード例 #20
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 User data)
        {
            bool valid = true;

            try
            {
                data = new UserManagerGet().GetById(id);
                if (data == null)
                {
                    BugUtil.SetBugCode(param, LibraryBug.Bug.Enum.Common_DuLieuDauVaoKhongChinhXac);
                    Logging("Id invalid." + LogUtil.TraceData("id", id), LogType.Error);
                    valid = false;
                }
            }
            catch (Exception ex)
            {
                LogSystem.Error(ex);
                valid = false;
                param.HasException = true;
            }
            return(valid);
        }
コード例 #21
0
ファイル: AasRoleLock.cs プロジェクト: dunglh/MyProject
        internal bool Unlock(Role data)
        {
            bool result = false;

            try
            {
                bool valid = true;
                Role raw   = null;
                valid = valid && new AasRoleCheck().VerifyId(data.Id, ref raw);
                if (valid && raw != null)
                {
                    if (raw.IsActive == Constant.IS_TRUE)
                    {
                        MessageUtil.SetMessage(param, LibraryMessage.Message.Enum.Common__DuLieuDangMoKhoa);
                        throw new Exception("Du lieu dang duoc mo khoa");
                    }

                    raw.IsActive = Constant.IS_TRUE;
                    result       = DAOWorker.AasRoleDAO.Update(raw);
                    if (result)
                    {
                        data.IsActive = raw.IsActive;
                    }
                }
                else
                {
                    BugUtil.SetBugCode(param, LibraryBug.Bug.Enum.Common__KXDDDuLieuCanXuLy);
                }
            }
            catch (Exception ex)
            {
                LogSystem.Error(ex);
                param.HasException = true;
                result             = false;
            }
            return(result);
        }
コード例 #22
0
ファイル: AasUserUpdate.cs プロジェクト: dunglh/MyProject
        internal bool UpdateList(List <User> listData)
        {
            bool result = false;

            try
            {
                bool valid = true;
                valid = IsNotNullOrEmpty(listData);
                AasUserCheck checker = new AasUserCheck(param);
                List <User>  listRaw = new List <User>();
                List <long>  listId  = listData.Select(o => o.Id).ToList();
                valid = valid && checker.VerifyIds(listId, listRaw);
                valid = valid && checker.IsUnLock(listRaw);
                foreach (var data in listData)
                {
                    valid = valid && checker.VerifyRequireField(data);
                    valid = valid && checker.ExistsLoginname(data.Loginname, data.Id);
                }
                if (valid)
                {
                    if (!DAOWorker.AasUserDAO.UpdateList(listData))
                    {
                        BugUtil.SetBugCode(param, LibraryBug.Bug.Enum.AasUser_CapNhatThatBai);
                        throw new Exception("Cap nhat thong tin AasUser that bai." + LogUtil.TraceData("listData", listData));
                    }
                    this.beforeUpdateAasUsers.AddRange(listRaw);
                    result = true;
                }
            }
            catch (Exception ex)
            {
                LogSystem.Error(ex);
                param.HasException = true;
                result             = false;
            }
            return(result);
        }
コード例 #23
0
ファイル: TokenManagerBase.cs プロジェクト: dunglh/MyProject
        internal bool CreateCredentialData(DungLH.Util.Token.Core.CredentialData credentialData, CommonParam commonParam)
        {
            bool result = false;

            try
            {
                bool valid = true;
                valid = valid && credentialData != null;
                if (!valid)
                {
                    throw new ArgumentNullException("credentialData is null");
                }
                CredentialData data = new CredentialData();
                data.BackendCode = credentialData.BackendCode;
                data.Data        = credentialData.Data;
                data.DataKey     = credentialData.DataKey;
                data.TokenCode   = credentialData.TokenCode;
                if (!new AasCredentialDataCreate(commonParam).Create(data))
                {
                    throw new Exception("Insert CredentialData that bai \n" + DungLH.Util.CommonLogging.LogUtil.TraceData("credentialData", credentialData));
                }
                result = true;
            }
            catch (ArgumentNullException ex)
            {
                BugUtil.SetBugCode(commonParam, LibraryBug.Bug.Enum.Common__ThieuThongTinBatBuoc);
                DungLH.Util.CommonLogging.LogSystem.Error(ex);
                result = false;
            }
            catch (Exception ex)
            {
                DungLH.Util.CommonLogging.LogSystem.Error(ex);
                result = false;
            }
            return(result);
        }
コード例 #24
0
ファイル: TokenManagerBase.cs プロジェクト: dunglh/MyProject
        internal bool UpdateUserPassword(string loginname, string oldPassword, string newPassword, CommonParam commonParam)
        {
            bool result = false;

            try
            {
                if (String.IsNullOrWhiteSpace(loginname))
                {
                    throw new ArgumentNullException("loginname");
                }
                if (String.IsNullOrWhiteSpace(oldPassword))
                {
                    throw new ArgumentNullException("oldPassword");
                }
                if (String.IsNullOrWhiteSpace(newPassword))
                {
                    throw new ArgumentNullException("newPassword");
                }
                if (oldPassword.Length < Constant.MIN_LENGTH_PASSWORD)
                {
                    MessageUtil.SetMessage(commonParam, LibraryMessage.Message.Enum.Common__MatKhauKhongDuocNhoHon6KyTu);
                    throw new Exception("Mat khau khong duoc nho hon 6 ky tu");
                }
                PasswordManager       passwordManager = new PasswordManager();
                AasUser.AasUserUpdate aasUserUpdate   = new AasUser.AasUserUpdate(commonParam);
                User user = new UserManagerGet().GetByLoginname(loginname);
                if (user == null)
                {
                    MessageUtil.SetMessage(commonParam, LibraryMessage.Message.Enum.Common_TaiKhoanKhongChinhXac);
                    throw new Exception("Loginname invalid: " + loginname);
                }
                if (!passwordManager.CheckPassword(user.Password, oldPassword, user.Salt, loginname))
                {
                    MessageUtil.SetMessage(commonParam, LibraryMessage.Message.Enum.Common_TaiKhoanHoacMatKhauKhongChinhXac);
                    throw new Exception("Tai khoan hoac mat khau khong chinh xac");
                }

                string newHashPassword = passwordManager.HashPassword(newPassword, user.Salt, loginname);
                Mapper.CreateMap <User, User>();
                User before = Mapper.Map <User>(user);
                user.Password = newHashPassword;
                if (!aasUserUpdate.Update(user, before))
                {
                    throw new Exception("Update mat khau cho tai khoan that bai");
                }
                result        = true;
                user.Password = "";
            }
            catch (ArgumentNullException ex)
            {
                BugUtil.SetBugCode(commonParam, LibraryBug.Bug.Enum.Common__ThieuThongTinBatBuoc);
                DungLH.Util.CommonLogging.LogSystem.Error(ex);
                result = false;
            }
            catch (Exception ex)
            {
                DungLH.Util.CommonLogging.LogSystem.Error(ex);
                result = false;
            }
            return(result);
        }