public ApiResult <IList <StockInfo> > Get() { var result = _service.GetList(); if (!result.IsSuccess) { _logger.LogError(result.InnerException, result.ErrorMessage); } return(new ApiResult <IList <StockInfo> >(result)); }
/// <summary> /// grab stock /// <param name="now">special date</param> /// </summary> public void Grab(DateTime now) { var results = _infoService.GetList(); if (results.IsSuccess) { var list = new List <Stock>(); foreach (var item in results.InnerResult) { list.AddRange(Grab(now, item.Id)); Thread.Sleep(TimeSpan.FromSeconds(WaitGrabSecond)); if (list.Count > MaxStockInsertCount) { var insertResult = _service.Insert(list); if (!insertResult.IsSuccess) { _logger.LogError(insertResult.InnerException, insertResult.ErrorMessage); } _logger.LogInformation($"InsertResult:{insertResult}"); list.Clear(); } } if (list.Count > 0) { var insertResult = _service.Insert(list); if (!insertResult.IsSuccess) { _logger.LogError(insertResult.InnerException, insertResult.ErrorMessage); } _logger.LogInformation($"InsertResult:{insertResult}"); list.Clear(); } } }