public async Task <Dictionary <string, int> > GetVintageAnalysisAsync() { int time = DateTime.Now.Year; PagedAndSortedResultRequestDto resultRequestDto = new PagedAndSortedResultRequestDto() { MaxResultCount = 20000, SkipCount = 0, Sorting = null }; Dictionary <string, int> keyValues = new Dictionary <string, int>(); var data = _cameraAppService.GetListAsync(resultRequestDto).Result.Items.ToList(); for (int i = 0; i < 10; i++) { string year = (time - i).ToString(); CameraCondition cameraCondition = new CameraCondition() { install_time = year }; var data2 = data.Where(u => u.install_time.Contains(year)); keyValues.Add(year, data2.Count()); } return(keyValues);//Newtonsoft.Json.JsonConvert.SerializeObject(keyValues); }
public IActionResult GetOutExcel(CameraCondition condition) { PagedSortedRequestDto resultRequestDto = new PagedSortedRequestDto() { MaxResultCount = 200000, SkipCount = 0 }; var data = _cameraAppService.GetListByCondition(condition, resultRequestDto); var list = data.Result.Items.ToList(); DataTable dataTable = ListToDataTable.toDataTable <CameraDto>(list); var pathname = $"{System.AppDomain.CurrentDomain.BaseDirectory}Basics\\OutExcel.xlsx"; var requst = ExcelHelper.DataTableToExcel(dataTable, pathname, "Sheet1", true); var stream = System.IO.File.OpenRead(pathname); string fileExt = Path.GetExtension(pathname); var provider = new FileExtensionContentTypeProvider(); var meni = provider.Mappings[fileExt]; var returnFile = File(stream, meni, Path.GetFileName(pathname)); return(returnFile); }