/// <summary> /// 更新爬虫任务 /// </summary> /// <returns></returns> private async Task UpdateProxy(ProxyAddOrEditInput input) { var spiderTask = await _proxyRepository.GetEntityByIdAsync(input.Proxy.Id.Value); if (spiderTask != null) { var newSpiderTask = input.Proxy.MapTo <Proxy>(); await _proxyRepository.UpdateAsync(spiderTask); } }
/// <summary> /// 添加或者更新 /// </summary> /// <returns></returns> public async Task AddOrUpdateProxy(ProxyAddOrEditInput input) { //是否存在有效值 if (input.Proxy.Id.HasValue) { await UpdateProxy(input); } else { await CreateProxy(input); } }
public IActionResult AddOrUpdateProxy(ProxyAddOrEditInput input) { int result = 0; try { _proxyService.AddOrUpdateProxy(input); } catch (Exception) { result = -1; } return(Json(result)); }
/// <summary> /// 创建爬虫任务 /// </summary> /// <returns></returns> private async Task CreateProxy(ProxyAddOrEditInput input) { Proxy proxy = input.Proxy.MapTo <Proxy>(); await _proxyRepository.InsertAsync(proxy); }