Example #1
0
 public ActionResult List(string blockSystem, int blockType, int pageIndex, int pageSize)
 {
     if (pageIndex <= 0)
     {
         pageIndex = 1;
     }
     if (pageSize <= 0 || pageSize > 500)
     {
         pageSize = 20;
     }
     using (var client = new BlockListConfigClient())
     {
         var result = client.SelectPagedBlockList(blockSystem, blockType, pageIndex, pageSize);
         if (result.Success)
         {
             return(Content(JsonConvert.SerializeObject(new PagedDataModel <BlockListItem>
             {
                 PageIndex = pageIndex,
                 PageSize = pageSize,
                 TotalSize = result.Result.Item1,
                 Data = result.Result.Item2.ToArray(),
                 Status = 1
             }, DefaultJsonSerializerSettings), "application/json", Encoding.UTF8));
         }
         else
         {
             return(Json(new
             {
                 Status = -1,
                 ErrorMsg = result.ErrorMessage
             }, JsonRequestBehavior.AllowGet));
         }
     }
 }
Example #2
0
        /// <summary>
        /// 新增黑名单
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public async Task <bool> AddBlockListItem(BlockListItem item)
        {
            try
            {
                using (var configClient = new BlockListConfigClient())
                {
                    var configResult = await configClient.AddBlockListItemAsync(item);

                    configResult.ThrowIfException(true);
                    return(configResult.Result);
                }
            }
            catch (Exception ex)
            {
                _logger.Error($"新增黑名单失败 {item.BlockValue}", ex);
                return(false);
            }
        }
Example #3
0
        /// <summary>
        /// 根据系统和黑名单值查询黑名单列表
        /// </summary>
        /// <param name="blockSystem">系统名称</param>
        /// <param name="blockValue">黑名单值</param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public async Task <PagedModel <BlockListItem> > SearchPagedBlockList
            (string blockSystem, string blockValue, int pageIndex, int pageSize)
        {
            try
            {
                using (var configClient = new BlockListConfigClient())
                {
                    var configResult = await configClient
                                       .SearchPagedBlockListAsync(blockSystem, blockValue, pageIndex, pageSize);

                    configResult.ThrowIfException(true);
                    return(configResult?.Result);
                }
            }
            catch (Exception ex)
            {
                _logger.Error($"查询黑名单列表失败 {blockValue}", ex);
                return(null);
            }
        }
Example #4
0
        public JsonResult DeleteById(BlockListItem item)
        {
            using (var client = new BlockListConfigClient())
            {
                var blackModel = new BlockListItem
                {
                    PKID     = item.PKID,
                    UpdateBy = User.Identity.Name
                };

                var result = client.DeleteBlockListItemByPkid(blackModel);
                if (result.Success)
                {
                    if (result.Result)
                    {
                        ConfigLogManager.AddCommonConfigLogInfo(new CommonConfigLogModel
                        {
                            ObjectId    = $"{item.BlockType}-{item.BlockValue}",
                            BeforeValue = JsonConvert.SerializeObject(item),
                            ObjectType  = $"{item.BlockSystem}BlockListLog",
                            Creator     = User.Identity.Name,
                            Remark      = $"删除黑名单{(BlockListType)item.BlockType}-{item.BlockValue}"
                        });
                    }
                    return(Json(new
                    {
                        Status = 1,
                        Success = result.Result
                    }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new
                    {
                        Status = -1,
                        ErrorMsg = result.ErrorMessage
                    }, JsonRequestBehavior.AllowGet));
                }
            }
        }
Example #5
0
        public JsonResult Add(BlockListItem item)
        {
            using (var client = new BlockListConfigClient())
            {
                item.UpdateBy = User.Identity.Name;

                var result = client.AddBlockListItem(item);
                if (result.Success)
                {
                    if (result.Result)
                    {
                        ConfigLogManager.AddCommonConfigLogInfo(new CommonConfigLogModel
                        {
                            ObjectId   = $"{item.BlockType}-{item.BlockValue}",
                            AfterValue = JsonConvert.SerializeObject(item),
                            ObjectType = $"{item.BlockSystem}BlockListLog",
                            Creator    = User.Identity.Name,
                            Remark     = $"新增黑名单{(BlockListType)item.BlockType}-{item.BlockValue}"
                        });
                    }
                    return(Json(new
                    {
                        Status = 1,
                        Success = result.Result
                    }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new
                    {
                        Status = -1,
                        ErrorMsg = result.ErrorMessage
                    }, JsonRequestBehavior.AllowGet));
                }
            }
        }