示例#1
0
        public async Task <JsonResult> InspectionByIdForEventTable(int id)
        {
            await CheckPermission();

            var service = new EventsTableService(_logger, _mapper);
            var result  = await service.InspectionByIdForEventTable(id);

            return(Json(result));
        }
示例#2
0
        public async Task <IActionResult> Create(int id)
        {
            var service = new EventsTableService(_logger, _mapper);
            var toExcel = await service.GetTaskAndInspections(new ReportRequest
            {
                Paging = new Paging {
                    Skip = "0", Limit = Int32.MaxValue.ToString()
                }
            });

            string   sWebRootFolder = @"c:\Temp";
            string   sFileName      = @"demo.xlsx";
            string   URL            = string.Format("{0}://{1}/{2}", Request.Scheme, Request.Host, sFileName);
            FileInfo file           = new FileInfo(Path.Combine(sWebRootFolder, sFileName));
            var      memory         = new MemoryStream();

            using (var fs = new FileStream(Path.Combine(sWebRootFolder, sFileName), FileMode.Create, FileAccess.Write))
            {
                IWorkbook workbook;
                workbook = new XSSFWorkbook();
                ISheet excelSheet = workbook.CreateSheet("Demo");
                IRow   row        = excelSheet.CreateRow(0);

                for (int i = 0; i < toExcel.Columns.Count; i++)
                {
                    row.CreateCell(i).SetCellValue(toExcel.Columns[i].Title);
                }

                for (var index = 0; index < toExcel.Rows.Count; index++)
                {
                    var deRow = toExcel.Rows[index];
                    row = excelSheet.CreateRow(index + 1);
                    row.CreateCell(0).SetCellValue(deRow.Col0);
                    row.CreateCell(1).SetCellValue(deRow.Col1);
                    row.CreateCell(2).SetCellValue(deRow.Col2);
                    row.CreateCell(3).SetCellValue(deRow.Col3);
                    row.CreateCell(4).SetCellValue(deRow.Col4);
                    row.CreateCell(5).SetCellValue(deRow.Col5);
                    row.CreateCell(6).SetCellValue(deRow.Col6);
                    row.CreateCell(7).SetCellValue(deRow.Col7);
                    row.CreateCell(8).SetCellValue(deRow.Col8);
                    row.CreateCell(9).SetCellValue(deRow.Col9);
                    row.CreateCell(10).SetCellValue(deRow.Col10);
                }

                workbook.Write(fs);
            }

            using (var stream = new FileStream(Path.Combine(sWebRootFolder, sFileName), FileMode.Open))
            {
                await stream.CopyToAsync(memory);
            }

            memory.Position = 0;
            return(File(memory, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", sFileName));
        }
示例#3
0
        public async Task <JsonResult> EventTable([FromBody] ReportRequest input)
        {
            if (!int.TryParse(input.ReportId, out var reportId))
            {
                throw new ValidationException("Id отчета не int");
            }

            await CheckPermission();

            switch (reportId)
            {
            case (int)ReportsTableEnum.Inspections:
            {
                var service = new EventsTableService(_logger, _mapper);
                return(Json(await service.GetTaskAndInspections(input)));
            }

            case (int)ReportsTableEnum.TaskReport:
            {
                var service = new ReportTableService(_logger, _mapper);
                return(Json(await service.GetReportTasks(input)));
            }

            case (int)ReportsTableEnum.Tasks:
            {
                var service = new EventsTableService(_logger, _mapper);
                return(Json(await service.GetTaskAndInspections(input)));
            }

            case (int)ReportsTableEnum.TaskAndInspections:
            {
                var service = new EventsTableService(_logger, _mapper);
                input.ReportId = "1";
                return(Json(await service.GetTaskAndInspections(input)));
            }

            default:
                throw new ValidationException($"Неизвестный Id отчета: {reportId}");
            }
        }