public bool WhiteListUpdate(WhiteListModel model)
 {
     return(BSClient.Send <WhiteListUpdateResponse>(new WhiteListUpdate
     {
         UpdDto = Mapper.Map <WhiteListModel, WhiteListDto>(model)
     }).DoFlag);
 }
 public bool WhiteListAdd(WhiteListModel model)
 {
     return(BSClient.Send <WhiteListAddResponse>(new WhiteListAdd
     {
         AddDto = Mapper.Map <WhiteListModel, WhiteListDto>(model)
     }).DoFlag);
 }
Exemple #3
0
        public JsonResult Base(WhiteListType type, string name, string value)
        {
            if (string.IsNullOrWhiteSpace(name) && string.IsNullOrWhiteSpace(value) && type == WhiteListType.Not)
            {
                return(Json(new TrueOrFalse(false)));
            }

            // База
            JsonDB jsonDB = Service.Get <JsonDB>();

            // Добавляем значение
            var md = new WhiteListModel(name, value, type);

            md.Id = int.Parse(Generate.Passwd(6, true));
            jsonDB.WhiteList.Add(md);

            // Обновляем
            jsonDB.Save();
            WhiteUserList.UpdateCache();

            //
            Trigger.OnChange((0, 0));

            // Успех
            return(Json(new TrueOrFalse(true)));
        }
Exemple #4
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Source,Url")] WhiteListModel whiteListModel)
        {
            if (id != whiteListModel.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    whiteListModel.Modified = DateTime.UtcNow;

                    _context.Update(whiteListModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!WhiteListModelExists(whiteListModel.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(whiteListModel));
        }
Exemple #5
0
        public JsonResult AddWhiteList(WhiteListModel model)
        {
            var result = new BaseResponse()
            {
                DoFlag = false, DoResult = "添加失败,请稍后重试... ..."
            };

            #region 参数验证

            if (string.IsNullOrEmpty(model.Mobile))
            {
                result.DoResult = "手机号不为空";
                return(Json(result));
            }
            else
            {
                if (!Regex.IsMatch(model.Mobile, @"^[1]+[3,5]+\d{9}"))
                {
                    result.DoResult = "手机号码验证不正确";
                    return(Json(result));
                }
            }
            if (string.IsNullOrEmpty(model.UserName))
            {
                result.DoResult = "用户姓名不为空";
                return(Json(result));
            }


            model.RowCreateTime = DateTime.Now;
            model.IsEnable      = 1;
            #endregion

            try
            {
                var refer = ShortMessageClient.Instance.QueryWhitePageList(new WhiteListRefer()
                {
                    Search = new WhiteListModel()
                    {
                        Mobile = model.Mobile
                    }
                });
                if (refer.List.Any())
                {
                    result.DoResult = "此手机号已添加白名单";
                    return(Json(result));
                }
                result.DoFlag = ShortMessageClient.Instance.WhiteListAdd(model);
            }
            catch (Exception ex)
            {
                result.DoResult = "添加异常,请稍后重试... ...";
            }

            return(Json(result));
        }
Exemple #6
0
        public ActionResult WhiteListUpdate(int sysNo)
        {
            var gad    = new WhiteListModel();
            var result = ShortMessageClient.Instance.QueryWhiteListEntity(sysNo);

            if (result.SysNo != null)
            {
                gad = result;
            }
            return(View(gad));
        }
Exemple #7
0
        public async Task <IActionResult> Create([Bind("Id,Source,Url")] WhiteListModel whiteListModel)
        {
            if (ModelState.IsValid)
            {
                whiteListModel.Modified = DateTime.UtcNow;
                _context.Add(whiteListModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(whiteListModel));
        }
        public WhiteListModel QueryWhiteListEntity(int SysNo)
        {
            var model    = new WhiteListModel();
            var response = BSClient.Send <QueryWhiteListEntityResponse>(new QueryWhiteListEntity
            {
                SysNo = SysNo
            });

            if (response.DoFlag && response.Dto != null)
            {
                model = Mapper.Map <WhiteListDto, WhiteListModel>(response.Dto);
            }
            return(model);
        }
Exemple #9
0
        public JsonResult UpdWhiteList(WhiteListModel model)
        {
            var result = new BaseResponse()
            {
                DoFlag   = false,
                DoResult = "更新失败 ,请稍后重试……"
            };

            #region 参数验证

            if (string.IsNullOrEmpty(model.Mobile))
            {
                result.DoResult = "手机号不为空";
                return(Json(result));
            }
            else
            {
                if (!Regex.IsMatch(model.Mobile, @"^[1]+[3,5]+\d{9}"))
                {
                    result.DoResult = "手机号码验证不正确";
                    return(Json(result));
                }
            }
            if (string.IsNullOrEmpty(model.UserName))
            {
                result.DoResult = "用户姓名不为空";
                return(Json(result));
            }

            model.RowCreateTime = DateTime.Now;
            model.IsEnable      = model.IsEnable ?? 1;
            #endregion


            try
            {
                var flag = ShortMessageClient.Instance.WhiteListUpdate(model);
                if (flag)
                {
                    result.DoFlag   = true;
                    result.DoResult = "更新成功";
                }
            }
            catch (Exception ex)
            {
                result.DoResult = "更新异常";
            }
            return(Json(result));
        }