/// <summary>
 /// 删除活动室
 /// </summary>
 /// <param name="placeId"> 活动室id </param>
 /// <param name="placeName"> 活动室名称 </param>
 /// <returns></returns>
 public JsonResult DeletePlace(Guid placeId, string placeName)
 {
     if (string.IsNullOrEmpty(placeName))
     {
         return(Json("活动室名称不能为空"));
     }
     if (!_reservationPlaceHelper.Exist(p => p.PlaceId == placeId))
     {
         return(Json("活动室不存在"));
     }
     try
     {
         _reservationPlaceHelper.Update(
             new ReservationPlace()
         {
             PlaceId = placeId, IsDel = true, UpdateBy = Username
         }, new[] { "IsDel", "UpdateBy",
                    "UpdateTime" });
         OperLogHelper.AddOperLog($"删除活动室{placeId.ToString()}:{placeName}", OperLogModule.ReservationPlace,
                                  Username);
         return(Json(""));
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
         return(Json("删除活动室失败,发生异常:" + ex.Message));
     }
     ;
 }
 /// <summary>
 /// 添加到黑名单
 /// </summary>
 /// <param name="model">黑名单model</param>
 /// <returns></returns>
 public ActionResult AddEntity(Guid typeId, string blockValue)
 {
     if (ModelState.IsValid)
     {
         var entity = new BlockEntity()
         {
             BlockId     = Guid.NewGuid(),
             BlockTypeId = typeId,
             BlockValue  = blockValue,
             BlockTime   = DateTime.Now
         };
         try
         {
             var count = BusinessHelper.BlockEntityHelper.Add(entity);
             if (count == 1)
             {
                 //记录日志
                 OperLogHelper.AddOperLog(string.Format("添加 {0} 到黑名单", blockValue), OperLogModule.BlockEntity,
                                          Username);
                 return(Json(true));
             }
         }
         catch (Exception ex)
         {
             Logger.Error(ex);
         }
         return(Json(false));
     }
     else
     {
         return(Json(false));
     }
 }
 /// <summary>
 /// 删除活动室
 /// </summary>
 /// <param name="placeId"> 活动室id </param>
 /// <param name="placeName"> 活动室名称 </param>
 /// <param name="status">活动室状态,大于0启用,否则禁用</param>
 /// <returns></returns>
 public JsonResult UpdatePlaceStatus(Guid placeId, string placeName, int status)
 {
     if (string.IsNullOrEmpty(placeName))
     {
         return(Json("活动室名称不能为空"));
     }
     if (!_reservationPlaceHelper.Exist(p => p.PlaceId == placeId))
     {
         return(Json("活动室不存在"));
     }
     try
     {
         var bStatus = (status > 0);
         _reservationPlaceHelper.Update(
             new ReservationPlace()
         {
             PlaceId = placeId, UpdateBy = Username, IsActive = bStatus
         }, new[] { "IsActive",
                    "UpdateBy", "UpdateTime" });
         OperLogHelper.AddOperLog(
             string.Format("修改活动室{0}:{1}状态,{2}", placeId.ToString(), placeName, (status > 0) ? "启用" : "禁用"),
             OperLogModule.ReservationPlace, Username);
         return(Json(""));
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
         return(Json("修改活动室状态失败,发生异常:" + ex.Message));
     }
     ;
 }
 /// <summary>
 /// 更新活动室名称
 /// </summary>
 /// <param name="placeId">活动室id</param>
 /// <param name="newName">修改后的活动室名称</param>
 /// <param name="beforeName">修改之前的活动室名称</param>
 /// <returns></returns>
 public ActionResult UpdatePlaceName(Guid placeId, string newName, string beforeName)
 {
     if (string.IsNullOrEmpty(newName))
     {
         return(Json("活动室名称不能为空"));
     }
     if (!_reservationPlaceHelper.Exist(p => p.PlaceId == placeId))
     {
         return(Json("活动室不存在"));
     }
     if (_reservationPlaceHelper.Exist(p =>
                                       p.PlaceName.ToUpperInvariant().Equals(newName.ToUpperInvariant()) && p.IsDel == false))
     {
         return(Json("活动室名称已存在"));
     }
     try
     {
         _reservationPlaceHelper.Update(
             new ReservationPlace()
         {
             PlaceId    = placeId,
             PlaceName  = newName,
             UpdateBy   = Username,
             UpdateTime = DateTime.Now
         }, new[] { "PlaceName", "UpdateBy", "UpdateTime" });
         OperLogHelper.AddOperLog($"更新活动室 {placeId.ToString()} 名称,从 {beforeName} 修改为{newName}",
                                  OperLogModule.ReservationPlace, Username);
         return(Json(""));
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
         return(Json("更新活动室名称失败,发生异常:" + ex.Message));
     }
 }
        /// <summary>
        /// 更新黑名单实体状态
        /// </summary>
        /// <param name="entityId">黑名单数据id</param>
        /// <param name="status">状态</param>
        /// <returns></returns>
        public ActionResult UpdateEntityStatus(Guid entityId, string entityName, int status)
        {
            var entity = new BlockEntity()
            {
                BlockId = entityId
            };

            if (status > 0)
            {
                entity.IsActive = true;
            }
            else
            {
                entity.IsActive = false;
            }
            try
            {
                var count = BusinessHelper.BlockEntityHelper.Update(entity, "IsActive");
                if (count > 0)
                {
                    OperLogHelper.AddOperLog(
                        string.Format("更改黑名单 {0} 状态为 {1}", entityName, entity.IsActive ? "启用" : "禁用"),
                        OperLogModule.BlockEntity, Username);
                    return(Json(true));
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
            }
            return(Json(false));
        }
예제 #6
0
 /// <summary>
 /// 添加到黑名单
 /// </summary>
 /// <returns></returns>
 public ActionResult AddEntity(Guid typeId, string blockValue)
 {
     if (ModelState.IsValid)
     {
         var entity = new BlockEntity()
         {
             BlockId     = Guid.NewGuid(),
             BlockTypeId = typeId,
             BlockValue  = blockValue,
             BlockTime   = DateTime.UtcNow
         };
         try
         {
             var count = _blockEntityHelper.Insert(entity);
             if (count == 1)
             {
                 ReloadBlackListCache();
                 //记录日志
                 OperLogHelper.AddOperLog($"添加 {blockValue} 到黑名单", OperLogModule.BlockEntity,
                                          UserName);
                 return(Json(true));
             }
         }
         catch (Exception ex)
         {
             Logger.Error(ex);
         }
         return(Json(false));
     }
     else
     {
         return(Json(false));
     }
 }
        public ActionResult MakeReservation([FromBody] ReservationViewModel model)
        {
            var result = new JsonResultModel <bool> {
                Result = false, Status = JsonResultStatus.RequestError
            };

            try
            {
                if (ModelState.IsValid)
                {
                    if (!HttpContext.RequestServices.GetService <ReservationHelper>()
                        .MakeReservation(model, out var msg, true))
                    {
                        result.ErrorMsg = msg;
                        return(Json(result));
                    }

                    OperLogHelper.AddOperLog(
                        $"管理员 {UserName} 后台预约 {model.ReservationForDate:yyyy-MM-dd} {model.ReservationPlaceName}:{model.ReservationActivityContent}",
                        OperLogModule.Reservation, UserName);
                    result.Result = true;
                    result.Status = JsonResultStatus.Success;
                    return(Json(result));
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                result.Status   = JsonResultStatus.ProcessFail;
                result.ErrorMsg = ex.Message;
            }
            return(Json(result));
        }
 public JsonResult UpdateReservationStatus(Guid reservationId, int status)
 {
     try
     {
         var reservation = _reservationHelper.Fetch(r => r.ReservationId == reservationId);
         if (reservation == null)
         {
             return(Json(false));
         }
         reservation.ReservationStatus = status > 0 ? ReservationStatus.Reviewed : ReservationStatus.Rejected;
         var count = _reservationHelper.Update(reservation, r => r.ReservationStatus);
         if (count == 1)
         {
             //记录操作日志
             OperLogHelper.AddOperLog(
                 $"更新 {reservationId}:{reservation.ReservationActivityContent} 预约状态",
                 OperLogModule.Reservation, UserName);
             return(Json(true));
         }
     }
     catch (Exception ex)
     {
         Logger.Error("更新预约状态失败", ex);
     }
     return(Json(false));
 }
 public ActionResult DeleteAccount(User u)
 {
     try
     {
         if (u.UserName.IsNullOrWhiteSpace())
         {
             u = _bLLUser.Fetch(ur => ur.UserId == u.UserId);
         }
         if (u == null)
         {
             return(Json(false));
         }
         if ("admin".EqualsIgnoreCase(u.UserName) || "Alice".EqualsIgnoreCase(u.UserName))
         {
             return(Json(false));
         }
         var count = _bLLUser.Delete(u);
         if (count == 1)
         {
             OperLogHelper.AddOperLog($"删除用户 {u.UserId:N} {u.UserName}", OperLogModule.Account, UserName);
             return(Json(true));
         }
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
     }
     return(Json(false));
 }
예제 #10
0
        /// <summary>
        /// 更新禁用时间段状态
        /// </summary>
        /// <param name="periodId">时间段id</param>
        /// <param name="status">状态</param>
        /// <returns></returns>
        public JsonResult UpdatePeriodStatus(Guid periodId, int status)
        {
            var result = new JsonResultModel <bool>();
            var period = _bllDisabledPeriod.Fetch(p => p.PeriodId == periodId);

            if (period == null)
            {
                result.ErrorMsg = "时间段不存在,请求参数异常";
                result.Status   = JsonResultStatus.RequestError;
                return(Json(result));
            }
            if ((status > 0 && period.IsActive) || (status <= 0 && !period.IsActive))
            {
                result.ErrorMsg = "不需要更新状态";
                result.Result   = true;
                result.Status   = JsonResultStatus.Success;
            }
            else
            {
                period.IsActive = status > 0;
                var count = _bllDisabledPeriod.Update(p => p.PeriodId == periodId, p => p.IsActive, period.IsActive);
                if (count > 0)
                {
                    OperLogHelper.AddOperLog($"{(period.IsActive ? "启用" : "禁用")} 禁止预约时间段 {periodId:N}",
                                             OperLogModule.DisabledPeriod, Username);

                    result.Status = JsonResultStatus.Success;
                    result.Result = true;
                }
            }
            return(Json(result));
        }
 /// <summary>
 /// 添加活动室
 /// </summary>
 /// <returns></returns>
 public ActionResult AddPlace(string placeName)
 {
     if (!string.IsNullOrEmpty(placeName))
     {
         if (_reservationPlaceHelper.Exist(p =>
                                           p.PlaceName.ToUpperInvariant().Equals(placeName.ToUpperInvariant()) && p.IsDel == false))
         {
             return(Json("活动室已存在"));
         }
         var place = new ReservationPlace()
         {
             PlaceId   = Guid.NewGuid(),
             PlaceName = placeName,
             UpdateBy  = Username
         };
         try
         {
             _reservationPlaceHelper.Insert(place);
             //记录日志
             OperLogHelper.AddOperLog($"新增活动室:{placeName}", OperLogModule.ReservationPlace, place.UpdateBy);
             return(Json(""));
         }
         catch (Exception ex)
         {
             Logger.Error(ex);
             return(Json("添加失败,出现异常:" + ex.Message));
         }
     }
     else
     {
         return(Json("活动室名称不能为空"));
     }
 }
예제 #12
0
        public ActionResult MakeReservation([FromBody] ReservationViewModel model)
        {
            var result = new JsonResultModel <bool> {
                Result = false, Status = JsonResultStatus.RequestError
            };

            try
            {
                if (ModelState.IsValid)
                {
                    string msg;
                    if (!HttpContext.RequestServices.GetService <ReservationHelper>().IsReservationAvailable(model, out msg, true))
                    {
                        result.ErrorMsg = msg;
                        return(Json(result));
                    }

                    var reservation = new Reservation()
                    {
                        ReservationForDate = model.ReservationForDate,
                        ReservationForTime = model.ReservationForTime,
                        ReservationPlaceId = model.ReservationPlaceId,

                        ReservationUnit            = model.ReservationUnit,
                        ReservationActivityContent = model.ReservationActivityContent,
                        ReservationPersonName      = model.ReservationPersonName,
                        ReservationPersonPhone     = model.ReservationPersonPhone,

                        ReservationFromIp = HttpContext.Connection.RemoteIpAddress.ToString(), //记录预约人IP地址

                        //管理员预约自动审核通过
                        ReservationStatus = 1,
                        ReservationTime   = DateTime.Now,

                        UpdateBy      = model.ReservationPersonName,
                        UpdateTime    = DateTime.Now,
                        ReservationId = Guid.NewGuid()
                    };
                    foreach (var item in model.ReservationForTimeIds.Split(',').Select(_ => Convert.ToInt32(_)))
                    {
                        reservation.ReservationPeriod += (1 << item);
                    }
                    _reservationHelper.Insert(reservation);
                    OperLogHelper.AddOperLog(
                        $"管理员 {Username} 后台预约 {reservation.ReservationId}:{reservation.ReservationActivityContent}",
                        OperLogModule.Reservation, Username);
                    result.Result = true;
                    result.Status = JsonResultStatus.Success;
                    return(Json(result));
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                result.Status   = JsonResultStatus.ProcessFail;
                result.ErrorMsg = ex.Message;
            }
            return(Json(result));
        }
 public SystemSettingsController(ILogger <SystemSettingsController> logger,
                                 OperLogHelper operLogHelper,
                                 IApplicationSettingService applicationSettingService,
                                 IBLLSystemSettings bLLSystemSettings) : base(logger, operLogHelper)
 {
     _applicationSettingService = applicationSettingService;
     _systemSettingHelper       = bLLSystemSettings;
 }
예제 #14
0
        public ActionResult Create([FromForm] NoticeViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            try
            {
                //notice
                var n = new Notice()
                {
                    NoticeId          = Guid.NewGuid(),
                    CheckStatus       = true, //默认审核通过
                    NoticeContent     = model.Content,
                    NoticeTitle       = model.Title,
                    NoticeCustomPath  = model.CustomPath,
                    NoticePublisher   = UserName,
                    NoticePublishTime = DateTime.UtcNow,
                    UpdateBy          = UserName,
                    UpdateTime        = DateTime.UtcNow
                };
                //
                if (!string.IsNullOrEmpty(n.NoticeCustomPath))
                {
                    if (n.NoticeCustomPath.EndsWith(".html"))
                    {
                        n.NoticeCustomPath = n.NoticeCustomPath.Substring(0, n.NoticeCustomPath.Length - 5); // trim end ".html"
                    }
                }
                else
                {
                    n.NoticeCustomPath = DateTime.UtcNow.ToString("yyyyMMddHHmmss");
                }
                var existStatus = _bLLNotice.Exist(nx => nx.NoticeCustomPath.ToLower().Equals(n.NoticeCustomPath.ToLower()));
                if (existStatus)
                {
                    n.NoticeCustomPath = DateTime.UtcNow.ToString("yyyyMMddHHmmss");
                }
                n.NoticePath = $"{n.NoticeCustomPath}.html";

                var c = _bLLNotice.Insert(n);
                if (c == 1)
                {
                    OperLogHelper.AddOperLog($"{UserName}添加新公告,{n.NoticeTitle},ID:{n.NoticeId:N}",
                                             OperLogModule.Notice, UserName);
                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(View(model));
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                throw;
            }
        }
 public ActionResult Create(NoticeViewModel model)
 {
     if (!ModelState.IsValid)
     {
         return(View());
     }
     try
     {
         //notice
         var n = new Notice()
         {
             NoticeId          = Guid.NewGuid(),
             CheckStatus       = true, //默认审核通过
             NoticeContent     = model.Content,
             NoticeTitle       = model.Title,
             NoticeCustomPath  = model.CustomPath,
             NoticePublisher   = Username,
             NoticePublishTime = DateTime.Now,
             UpdateBy          = Username,
             UpdateTime        = DateTime.Now
         };
         //
         if (!string.IsNullOrEmpty(n.NoticeCustomPath))
         {
             if (n.NoticeCustomPath.EndsWith(".html"))
             {
                 n.NoticePath = n.NoticeCustomPath;
             }
             else
             {
                 n.NoticePath = n.NoticeCustomPath + ".html";
             }
         }
         else
         {
             n.NoticePath = DateTime.Now.ToString("yyyyMMddHHmmss") + ".html";
         }
         var c = BusinessHelper.NoticeHelper.Add(n);
         if (c == 1)
         {
             OperLogHelper.AddOperLog($"{Username}添加新公告,{n.NoticeTitle},ID:{n.NoticeId:N}",
                                      OperLogModule.Notice, Username);
             return(RedirectToAction("Index"));
         }
         else
         {
             return(View());
         }
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
         throw;
     }
 }
        public JsonResult Delete(Guid noticeId)
        {
            var result = _bLLNotice.Delete(n => n.NoticeId == noticeId);

            if (result > 0)
            {
                OperLogHelper.AddOperLog($"删除公告{noticeId:N}", OperLogModule.Notice, Username);
                return(Json(""));
            }
            return(Json("删除失败"));
        }
예제 #17
0
        /// <summary>
        /// 删除禁用时间段
        /// </summary>
        /// <param name="periodId">时间段id</param>
        /// <returns></returns>
        public JsonResult DeletePeriod(Guid periodId)
        {
            var count = _bllDisabledPeriod.Delete(p => p.PeriodId == periodId);

            if (count > 0)
            {
                OperLogHelper.AddOperLog($"删除禁用时间段 {periodId:N}", OperLogModule.DisabledPeriod, Username);
                return(Json(""));
            }
            return(Json("删除失败"));
        }
        public JsonResult Delete(Guid noticeId)
        {
            var result = BusinessHelper.NoticeHelper.Delete(new Notice {
                NoticeId = noticeId
            });

            if (result > 0)
            {
                OperLogHelper.AddOperLog($"删除公告{noticeId:N}", OperLogModule.Notice, Username);
                return(Json(""));
            }
            return(Json("删除失败"));
        }
예제 #19
0
        /// <summary>
        /// 删除禁用时间段
        /// </summary>
        /// <param name="periodId">时间段id</param>
        /// <returns></returns>
        public JsonResult DeletePeriod(Guid periodId)
        {
            var count = BusinessHelper.DisabledPeriodHelper.Delete(new DisabledPeriod {
                PeriodId = periodId
            });

            if (count > 0)
            {
                OperLogHelper.AddOperLog($"删除禁用时间段 {periodId:N}", OperLogModule.DisabledPeriod, Username);
                return(Json(""));
            }
            return(Json("删除失败"));
        }
예제 #20
0
        public JsonResult Delete(Guid noticeId)
        {
            var result = _bLLNotice.Update(new Notice()
            {
                NoticeId = noticeId, IsDeleted = true, UpdateBy = UserName, UpdateTime = DateTime.UtcNow
            }, n => n.IsDeleted);

            if (result > 0)
            {
                OperLogHelper.AddOperLog($"删除公告{noticeId:N}", OperLogModule.Notice, UserName);
                return(Json(""));
            }
            return(Json("删除失败"));
        }
        public JsonResult AddReservationPeriod(ReservationPeriod model)
        {
            if (model.PlaceId == Guid.Empty)
            {
                return(Json("预约活动室不能为空"));
            }

            if (model.PeriodTitle.IsNullOrWhiteSpace())
            {
                return(Json("预约时间段不能为空"));
            }

            if (!_reservationPlaceHelper.Exist(p => p.PlaceId == model.PlaceId))
            {
                return(Json("活动室不存在"));
            }

            using (var redLock = RedisManager.GetRedLockClient($"reservation_{model.PlaceId:N}_periods"))
            {
                if (redLock.TryLock())
                {
                    if (_reservationPeriodHelper.Any(builder => builder
                                                     .IgnoreQueryFilters()
                                                     .WithPredict(p => p.PeriodIndex == model.PeriodIndex && p.PlaceId == model.PlaceId && p.PeriodId != model.PeriodId)
                                                     )
                        )
                    {
                        return(Json("排序重复,请修改"));
                    }

                    model.PeriodId   = Guid.NewGuid();
                    model.CreateBy   = UserName;
                    model.CreateTime = DateTime.UtcNow;
                    model.UpdateBy   = UserName;
                    model.UpdateTime = DateTime.UtcNow;

                    var result = _reservationPeriodHelper.Insert(model);
                    if (result > 0)
                    {
                        OperLogHelper.AddOperLog($"创建预约时间段{model.PeriodId:N},{model.PeriodTitle}", OperLogModule.ReservationPlace, UserName);
                    }
                    return(Json(result > 0 ? "" : "创建预约时间段失败"));
                }
                else
                {
                    return(Json("系统繁忙,请稍后重试"));
                }
            }
        }
예제 #22
0
 public ActionResult DeleteAccount(User u)
 {
     try
     {
         var count = _bLLUser.Delete(ur => ur.UserId == u.UserId);
         if (count == 1)
         {
             OperLogHelper.AddOperLog($"删除用户 {u.UserId.ToString("N")} {u.UserName}", OperLogModule.Account, Username);
             return(Json(true));
         }
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
     }
     return(Json(false));
 }
 public ActionResult DeleteAccount(User u)
 {
     try
     {
         var count = BusinessHelper.UserHelper.Delete(u);
         if (count == 1)
         {
             OperLogHelper.AddOperLog(String.Format("删除用户 {0}", u.UserName), OperLogModule.Account, Username);
             return(Json(true));
         }
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
     }
     return(Json(false));
 }
        /// <summary>
        /// 更新活动室状态
        /// </summary>
        /// <param name="placeId"> 活动室id </param>
        /// <param name="placeName"> 活动室名称 </param>
        /// <param name="status">活动室状态,大于0启用,否则禁用</param>
        /// <returns></returns>
        public JsonResult UpdatePlaceStatus(Guid placeId, string placeName, int status)
        {
            if (string.IsNullOrEmpty(placeName))
            {
                return(Json("活动室名称不能为空"));
            }
            if (!_reservationPlaceHelper.Exist(p => p.PlaceId == placeId))
            {
                return(Json("活动室不存在"));
            }
            try
            {
                var bStatus = (status > 0);
                if (bStatus)
                {
                    // 验证是否有可用的预约时间段
                    if (!_reservationPeriodHelper.Exist(p => p.PlaceId == placeId))
                    {
                        return(Json("没有可用的预约时间段,不可修改为已启用,请先添加预约时间段"));
                    }
                }

                _reservationPlaceHelper.Update(
                    new ReservationPlace()
                {
                    PlaceId  = placeId,
                    UpdateBy = UserName,
                    IsActive = bStatus
                },
                    x => x.IsActive,
                    x => x.UpdateBy,
                    x => x.UpdateTime
                    );
                OperLogHelper.AddOperLog(
                    $"修改活动室{placeId.ToString()}:{placeName}状态,{((status > 0) ? "启用" : "禁用")}",
                    OperLogModule.ReservationPlace, UserName);
                return(Json(""));
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                return(Json("修改活动室状态失败,发生异常:" + ex.Message));
            }
            ;
        }
 /// <summary>
 /// 从黑名单中删除一条数据
 /// </summary>
 /// <param name="entityId">黑名单数据id</param>
 /// <param name="entityName">黑名单数据名称</param>
 /// <returns></returns>
 public ActionResult DeleteEntity(Guid entityId, string entityName)
 {
     try
     {
         var c = _blockEntityHelper.Delete(b => b.BlockId == entityId);
         if (c == 1)
         {
             //记录日志
             OperLogHelper.AddOperLog($"删除黑名单 {entityName}", OperLogModule.BlockEntity, Username);
             return(Json(true));
         }
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
     }
     return(Json(false));
 }
 public ActionResult ResetPass(User u)
 {
     try
     {
         //加密
         u.UserPassword = HashHelper.GetHashedString(HashType.SHA256, u.UserPassword);
         var count = _bLLUser.Update(u, ur => ur.UserPassword);
         if (count == 1)
         {
             OperLogHelper.AddOperLog($"重置用户 {u.UserName} 密码", OperLogModule.Account, UserName);
             return(Json(true));
         }
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
     }
     return(Json(false));
 }
 public ActionResult ResetPass(User u)
 {
     try
     {
         //加密
         u.UserPassword = SecurityHelper.SHA256_Encrypt(u.UserPassword);
         var count = BusinessHelper.UserHelper.Update(u, "UserPassword");
         if (count == 1)
         {
             OperLogHelper.AddOperLog(String.Format("重置用户 {0} 密码", u.UserName), OperLogModule.Account, Username);
             return(Json(true));
         }
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
     }
     return(Json(false));
 }
 /// <summary>
 /// 更新设置
 /// </summary>
 /// <param name="setting">设置</param>
 /// <returns></returns>
 public ActionResult UpdateSettings(SystemSettings setting)
 {
     try
     {
         var count = _systemSettingHelper.Update(s => s.SettingId == setting.SettingId, s => s.SettingValue, setting.SettingValue);
         if (count == 1)
         {
             _applicationSettingService.SetSettingValue(setting.SettingName, setting.SettingValue);
             OperLogHelper.AddOperLog(
                 $"更新系统设置{setting.SettingId}---{setting.SettingName}:{setting.SettingValue}", OperLogModule.Settings, UserName);
             return(Json(true));
         }
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
     }
     return(Json(false));
 }
        public JsonResult DeleteReservationPeriod(Guid periodId)
        {
            if (periodId == Guid.Empty)
            {
                return(Json("预约时间段不能为空"));
            }
            if (!_reservationPeriodHelper.Exist(p => p.PeriodId == periodId))
            {
                return(Json("预约时间段不存在"));
            }

            var result = _reservationPeriodHelper.Delete(p => p.PeriodId == periodId);

            if (result > 0)
            {
                OperLogHelper.AddOperLog($"删除预约时间段{periodId:N}", OperLogModule.ReservationPlace, Username);
            }
            return(Json(result > 0 ? "" : "删除失败"));
        }
 /// <summary>
 /// 更新黑名单实体状态
 /// </summary>
 /// <param name="entityId">黑名单数据id</param>
 /// <param name="status">状态</param>
 /// <returns></returns>
 public ActionResult UpdateEntityStatus(Guid entityId, string entityName, int status)
 {
     try
     {
         var count = _blockEntityHelper.Update(e => e.BlockId == entityId, e => e.IsActive, status > 0);
         if (count > 0)
         {
             OperLogHelper.AddOperLog(
                 string.Format("更改黑名单 {0} 状态为 {1}", entityName, status > 0 ? "启用" : "禁用"),
                 OperLogModule.BlockEntity, Username);
             return(Json(true));
         }
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
     }
     return(Json(false));
 }