Esempio n. 1
0
        public JsonResult OnGetJsonLocais(String bairro, int logradouro)
        {
            var strbairro     = _dbBairro.ObterPorIdString(bairro).Nome;
            var strLogradouro = _dbLogradouro.ObterPorId(logradouro).Nome;

            return(new JsonResult(_dbDenuncia.Buscar(x => x.bairro.Equals(strbairro) && x.logradouro.Equals(strLogradouro))));
        }
Esempio n. 2
0
 public JsonResult OnGetNumero(String param)
 {
     return(new JsonResult(_dbDenuncia.Buscar(x => x.numero.Equals(param)).FirstOrDefault()));
 }
Esempio n. 3
0
        public async Task <IActionResult> OnPostExport(string DataInicio, string DataFim)
        {
            if (!String.IsNullOrEmpty(DataInicio) && !String.IsNullOrEmpty(DataFim))
            {
                DateTime dtInicio = _dbDenuncia.ConverteStringData(DataInicio);
                DateTime dtFim    = _dbDenuncia.ConverteStringData(DataFim);

                ListaDenuncia = _dbDenuncia.Buscar(x => x.data >= dtInicio && x.data <= dtFim);

                string   sWebRootFolder = _hostingEnvironment.WebRootPath;
                string   sFileName      = @"consultaPorData.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);

                    row.CreateCell(0).SetCellValue("idDenuncia");
                    row.CreateCell(1).SetCellValue("numero");
                    row.CreateCell(2).SetCellValue("categoria");
                    row.CreateCell(3).SetCellValue("data");
                    row.CreateCell(4).SetCellValue("agente");
                    row.CreateCell(5).SetCellValue("processo");
                    row.CreateCell(6).SetCellValue("logradouro");
                    row.CreateCell(7).SetCellValue("complemento");
                    row.CreateCell(8).SetCellValue("bairro");
                    row.CreateCell(9).SetCellValue("cep");
                    row.CreateCell(10).SetCellValue("lat");
                    row.CreateCell(11).SetCellValue("lng");
                    row.CreateCell(12).SetCellValue("respostaPadrao");

                    int cont = 1;

                    foreach (var list in ListaDenuncia)
                    {
                        row = excelSheet.CreateRow(cont);
                        row.CreateCell(0).SetCellValue(list.idDenuncia);
                        row.CreateCell(1).SetCellValue(list.numero);
                        row.CreateCell(2).SetCellValue(list.categoria);
                        row.CreateCell(3).SetCellValue(list.data);
                        row.CreateCell(4).SetCellValue(list.agente);
                        row.CreateCell(5).SetCellValue(list.processo);
                        row.CreateCell(6).SetCellValue(list.logradouro);
                        row.CreateCell(7).SetCellValue(list.complemento);
                        row.CreateCell(8).SetCellValue(list.bairro);
                        row.CreateCell(9).SetCellValue(list.cep);
                        row.CreateCell(10).SetCellValue(list.lat);
                        row.CreateCell(11).SetCellValue(list.lng);
                        row.CreateCell(12).SetCellValue(list.respostaPadrao);

                        cont++;
                    }

                    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));
            }

            return(Page());
        }
Esempio n. 4
0
 public JsonResult OnGetJson(String numero)
 {
     return(new JsonResult(_dbDenuncia.Buscar(x => x.numero.Equals(numero))));
 }