Exemplo n.º 1
0
 /// <summary>
 /// 写日志文件
 /// </summary>
 /// <param name="modelType">日志的类型</param>
 /// <param name="operatorId">操作员的ID</param>
 /// <param name="modifiedId">被操作对象的ID</param>
 /// <param name="opType">操作的类型</param>
 /// <returns></returns>
 public async Task WriteOPLog(char modelType, Guid operatorId, Guid modifiedId, char opType = '1')
 {
     if (modelType == '1')
     {
         using (IAccountOperateLogService accountOperateLogService = new AccountOperateLogService())
         {
             await accountOperateLogService.CreateAsync(new Model.AccountOperateLog()
             {
                 OperatorId  = operatorId,
                 ModifiedId  = modifiedId,
                 OPerateType = opType.ToString()
             });
         }
     }
     else
     {
         using (IWebsiteOperateLogService websiteOperateLogService = new WebsiteOperateLogService())
         {
             await websiteOperateLogService.CreateAsync(new Model.WebSiteOperateLog()
             {
                 OperatorId  = operatorId,
                 WebsiteId   = modifiedId,
                 OPerateType = opType.ToString()
             });
         }
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// 增加多个职员
        /// </summary>
        /// <param name="staffInfos">职员信息</param>
        /// <param name="operatorId">操作员id</param>
        /// <param name="key">秘钥</param>
        /// <param name="originalRoleName">角色名</param>
        /// <returns></returns>
        public async Task AddGroupStaff(List <StaffBsicInfoDto> staffInfos, Guid operatorId, string key, string originalRoleName)
        {
            List <Guid> modifyIds = new List <Guid>();

            using (IStaffInfoService staffInfoService = new StaffInfoService())
            {
                foreach (var staffInfo in staffInfos)
                {
                    var staff = new Model.StaffInfo()
                    {
                        Name      = staffInfo.Name,
                        Tel       = staffInfo.Tel,
                        Password  = StringEncryptAndDecrypt.AESEncrypt(staffInfo.Tel, key),
                        Email     = staffInfo.Email,
                        Address   = staffInfo.Address,
                        IdCard    = staffInfo.IdCard,
                        ImagePath = staffInfo.ImagePath,
                        SectionId = staffInfo.SectionId,
                        Position  = staffInfo.Position
                    };
                    await staffInfoService.CreateAsync(staff, false);

                    modifyIds.Add(staff.Id);
                }
                await staffInfoService.Save();
            }

            using (IAccountOperateLogService accountOperateLogService = new AccountOperateLogService())
            {
                using (IStaffPowerInfoService staffPowerInfoService = new StaffPowerInfoService())
                {
                    using (IRoleInfoService roleInfoService = new RoleInfoService())
                    {
                        foreach (var modifyId in modifyIds)
                        {
                            await accountOperateLogService.CreateAsync(new Model.AccountOperateLog()
                            {
                                OperatorId  = operatorId,
                                ModifiedId  = modifyId,
                                OPerateType = ('1').ToString()
                            }, false);

                            //初始权限
                            await staffPowerInfoService.CreateAsync(new Model.StaffPowerInfo()
                            {
                                StaffId = modifyId,
                                RoleId  = (await roleInfoService.GetAll().Where(p => p.Name == originalRoleName).FirstAsync()).Id //得到对应权限的Id
                            }, false);
                        }

                        //一起更新
                        await accountOperateLogService.Save();

                        await staffPowerInfoService.Save();
                    }
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 查询日志
        /// </summary>
        /// <param name="type">1:account  2:file  3:notice  4:wesite</param>
        /// <returns></returns>
        public async Task <List <LogInfoDto> > GetLOg(string type)
        {
            List <LogInfoDto> logList = new List <LogInfoDto>();

            if (type == "1")
            {
                using (var accountOperateLogService = new AccountOperateLogService())
                {
                    logList = accountOperateLogService.GetAll().Include(p => p.OpStaffInfo).Include(p => p.MoStaffInfo).Select(p => new LogInfoDto()
                    {
                        CreatTime  = p.CreatTime,
                        ModifyType = p.OPerateType,
                        Operator   = p.OpStaffInfo.Name,
                        ModifyObj  = p.MoStaffInfo.Name,
                        SectionId  = p.OpStaffInfo.SectionId
                    }).ToList();
                }
            }
            else
            {
                using (var websiteOperateLogService = new WebsiteOperateLogService())
                {
                    logList = websiteOperateLogService.GetAll().Include(p => p.StaffInfo).Include(p => p.WebsiteInfo).Select(p => new LogInfoDto()
                    {
                        CreatTime  = p.CreatTime,
                        ModifyType = p.OPerateType,
                        Operator   = p.StaffInfo.Name,
                        ModifyObj  = p.WebsiteInfo.SiteName,
                        SectionId  = p.StaffInfo.SectionId
                    }).ToList();
                }
            }

            using (var sectionService = new SectionService())
            {
                foreach (var log in logList)
                {
                    log.Section = (await sectionService.GetOneById(log.SectionId)).Name;
                }
            }

            return(logList);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 增加一个职员
        /// </summary>
        /// <param name="staffInfo">职员信息</param>
        /// <param name="operatorId">操作员id</param>
        /// <param name="key">秘钥</param>
        /// <param name="originalRoleName">角色名</param>
        /// <returns></returns>
        public async Task AddOneStaff(StaffBsicInfoDto staffInfo, Guid operatorId, string key, string originalRoleName)
        {
            using (IStaffInfoService staffInfoService = new StaffInfoService())
            {
                var staff = new Model.StaffInfo()
                {
                    Name      = staffInfo.Name,
                    Tel       = staffInfo.Tel,
                    Password  = StringEncryptAndDecrypt.AESEncrypt(staffInfo.Tel, key),
                    Email     = staffInfo.Email,
                    Address   = staffInfo.Address,
                    IdCard    = staffInfo.IdCard,
                    ImagePath = staffInfo.ImagePath,
                    SectionId = staffInfo.SectionId,
                    Position  = staffInfo.Position
                };
                await staffInfoService.CreateAsync(staff);

                using (IAccountOperateLogService accountOperateLogService = new AccountOperateLogService())
                {
                    await accountOperateLogService.CreateAsync(new Model.AccountOperateLog()
                    {
                        OperatorId  = operatorId,
                        ModifiedId  = staff.Id,
                        OPerateType = "1"
                    });
                }

                //初始权限
                using (IStaffPowerInfoService staffPowerInfoService = new StaffPowerInfoService())
                {
                    using (IRoleInfoService roleInfoService = new RoleInfoService())
                    {
                        await staffPowerInfoService.CreateAsync(new Model.StaffPowerInfo()
                        {
                            StaffId = staff.Id,
                            RoleId  = (await roleInfoService.GetAll().Where(p => p.Name == "一级权限").FirstAsync()).Id
                        });
                    }
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 移除职员状态
        /// </summary>
        /// <param name="staffId"></param>
        /// <param name="operatorId"></param>
        /// <returns></returns>
        public async Task ChangeStaffStatusById(Guid staffId, Guid operatorId)
        {
            using (var staffInfoService = new StaffInfoService())
            {
                var staff = await staffInfoService.GetOneById(staffId);

                staff.Status = !staff.Status;
                await staffInfoService.EditAsync(staff);

                using (var accountOperateLogService = new AccountOperateLogService())
                {
                    await accountOperateLogService.CreateAsync(new Model.AccountOperateLog()
                    {
                        OperatorId  = operatorId,
                        ModifiedId  = staffId,
                        OPerateType = "2"
                    });
                }
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// 解封职员账号(管理员操作)
        /// </summary>
        /// <param name="tel">账号(电话)</param>
        /// <param name="_operatorId">操作员的ID</param>
        /// <returns></returns>
        public async Task UnlockAccount(string tel, Guid _operatorId)
        {
            using (IStaffInfoService staffInfoService = new StaffInfoService())
            {
                var staff = staffInfoService.GetAll().FirstOrDefault(p => p.Tel == tel);
                if (staff != null && !staff.Status)
                {
                    staff.Status = true;
                    await staffInfoService.CreateAsync(staff);

                    using (IAccountOperateLogService accountOperateLogService = new AccountOperateLogService())
                    {
                        await accountOperateLogService.CreateAsync(new AccountOperateLog()
                        {
                            OperatorId  = _operatorId,
                            ModifiedId  = staff.Id,
                            OPerateType = "2" //代表update操作
                        });
                    }
                }
            }
        }