public bool BlackListUpdate(BlackListModel model) { return(BSClient.Send <BlackListUpdateResponse>(new BlackListUpdate { UpdDto = Mapper.Map <BlackListModel, BlackListDto>(model) }).DoFlag); }
public bool BlackListAdd(BlackListModel model) { return(BSClient.Send <BlackListAddResponse>(new BlackListAdd { AddDto = Mapper.Map <BlackListModel, BlackListDto>(model) }).DoFlag); }
private static bool IsBlocked(string blockedAddress, BlackListModel blackList) { var isBlocked = blackList.IsCaseSensitive && blockedAddress == blackList.BlockedAddress || !blackList.IsCaseSensitive && blockedAddress.ToLower() == blackList.BlockedAddressLowCase; return(isBlocked); }
private BlackListModel SaveBlackListModel(string blockedAddress, bool isCaseSensitiv) { var model = new BlackListModel(BlockchainType, blockedAddress, isCaseSensitiv); _logic.SaveAsync(model).Wait(); return(model); }
public JsonResult AddBlackList(BlackListModel model) { var result = new BaseResponse() { DoFlag = false, DoResult = "添加失败,请稍后重试... ..." }; #region 参数验证 if (!string.IsNullOrEmpty(model.Mobile)) { if (!Regex.IsMatch(model.Mobile, @"^[1]+[3,5]+\d{9}")) { result.DoResult = "手机号码验证不正确"; return(Json(result)); } } if (string.IsNullOrEmpty(model.LimitReason)) { result.DoResult = "限制原因不为空"; return(Json(result)); } if (!model.LimitEndTime.HasValue) { result.DoResult = "限制日期不为空"; return(Json(result)); } model.Operator = UserInfo.UserName; model.RowCreateDate = DateTime.Now; model.IsDel = false; #endregion try { if (!string.IsNullOrEmpty(model.Mobile)) { var refer = ShortMessageClient.Instance.QueryBackPageList(new BlackListRefer() { Search = new BlackListModel() { Mobile = model.Mobile } }); if (refer.List.Any()) { result.DoResult = "此手机号已添加黑名单"; return(Json(result)); } } result.DoFlag = ShortMessageClient.Instance.BlackListAdd(model); } catch (Exception ex) { result.DoResult = "添加异常,请稍后重试... ..."; } return(Json(result)); }
private BlackListResponse Map(BlackListModel blackListModel) { return(new BlackListResponse() { IsCaseSensitive = blackListModel.IsCaseSensitive, BlockedAddress = blackListModel.BlockedAddress, BlockchainType = blackListModel.BlockchainType }); }
public async Task <IActionResult> UpdateBlockedAddressAsync([FromBody] AddBlackListModel request) { string blockedAddress = Trim(request.BlockedAddress); BlackListModel model = new BlackListModel(request.BlockchainType, blockedAddress, request.IsCaseSensitive); await _blackListService.SaveAsync(model); return(Ok()); }
public ActionResult BlackListUpdate(int sysNo) { var gad = new BlackListModel(); var result = ShortMessageClient.Instance.QueryBackListEntity(sysNo); if (result.SysNo != null) { gad = result; } return(View(gad)); }
public static BlackListEntity FromDomain(BlackListModel model) { return(new BlackListEntity { PartitionKey = GetPartitionKey(model.BlockchainType), RowKey = GetRowKey(model.BlockedAddress), BlockchainIntegrationLayerId = model.BlockchainType, BlockedAddress = model.BlockedAddress, BlockedAddressLowCase = model.BlockedAddress?.ToLower(), IsCaseSensitive = model.IsCaseSensitive, }); }
public BlackListModel QueryBackListEntity(int SysNo) { var model = new BlackListModel(); var response = BSClient.Send <QueryBackListEntityResponse>(new QueryBackListEntity { SysNo = SysNo }); if (response.DoFlag && response.Dto != null) { model = Mapper.Map <BlackListDto, BlackListModel>(response.Dto); } return(model); }
public ActionResult Create(BlackListModel model) { if (ModelState.IsValid) { var dataFile = Server.MapPath("~/App_Data/blacklist.txt"); var result = ""; Array SiteCount = null; if (System.IO.File.Exists(dataFile)) { SiteCount = System.IO.File.ReadAllLines(dataFile); if (SiteCount == null) { // Empty file. result = "The file is empty."; } } else { // File does not exist. result = "The file does not exist."; } var SiteId = 0; if (result == "") { foreach (string dataLine in SiteCount) { var dataItem = dataLine.Split(','); if (dataItem[1] == model.site) { result = "Loi dinh menh"; ViewBag.result = result; return(View()); } SiteId = SiteCount.Length; } } var SiteData = SiteId++ + "," + model.site + Environment.NewLine; System.IO.File.AppendAllText(@dataFile, SiteData); return(RedirectToAction("Index", "Proxy")); } return(View()); }
public ActionResult BlackList(string page) { ViewData["AdditionHeader"] = "我的设置"; int pageIndex = 1; if (!string.IsNullOrEmpty(page)) { pageIndex = Convert.ToInt32(page); } BlackListModel model = new BlackListModel(); model.CurUser = CurrentUser; model.CurUserConfig = CurrentUserConfig; int recordCount = 0; model.BlackLists = BlackLists.GetMyBlackList(pageIndex, 10, model.CurUser.ID, ref recordCount); model.RecordCount = recordCount; model.PageIndex = pageIndex; model.PageSize = 10; return(View(model)); }
public async Task SaveAsync(BlackListModel model) { await DeleteAsync(model.BlockchainType, model.BlockedAddress); BlackList.Add(model); }
public JsonResult UpdBlackList(BlackListModel model) { var result = new BaseResponse() { DoFlag = false, DoResult = "更新失败 ,请稍后重试……" }; #region 参数验证 if (!string.IsNullOrEmpty(model.Mobile)) { if (!Regex.IsMatch(model.Mobile, @"^[1]+[3,5]+\d{9}")) { result.DoResult = "手机号码验证不正确"; return(Json(result)); } } if (string.IsNullOrEmpty(model.LimitReason)) { result.DoResult = "限制原因不为空"; return(Json(result)); } if (!model.LimitEndTime.HasValue) { result.DoResult = "限制日期不为空"; return(Json(result)); } if (string.IsNullOrEmpty(model.UserGuid)) { model.UserGuid = ""; } if (string.IsNullOrEmpty(model.Mobile)) { model.Mobile = ""; } if (string.IsNullOrEmpty(model.ClientIp)) { model.ClientIp = ""; } if (string.IsNullOrEmpty(model.Remark)) { model.Remark = ""; } model.RowModifyDate = DateTime.Now; model.IsDel = false; model.IsEnable = model.IsEnable ?? true; model.Operator = UserInfo.UserName; #endregion try { var flag = ShortMessageClient.Instance.BlackListUpdate(model); if (flag) { result.DoFlag = true; result.DoResult = "更新成功"; } } catch (Exception ex) { result.DoResult = "更新异常"; } return(Json(result)); }
public async Task SaveAsync(BlackListModel aggregate) { var entity = BlackListEntity.FromDomain(aggregate); await _storage.InsertOrReplaceAsync(entity); }
public async Task SaveAsync(BlackListModel model) { await ThrowOnNotSupportedBlockchainType(model?.BlockchainType ?? "", model?.BlockedAddress); await _blackListRepository.SaveAsync(model); }