public async Task <JsonResult> SelectExportExcel([FromBody] FMArrayIntIds entity)
        {
            var jm = new AdminUiCallBack();

            //创建Excel文件的对象
            var book = new HSSFWorkbook();
            //添加一个sheet
            var sheet1 = book.CreateSheet("Sheet1");
            //获取list数据
            var listmodel =
                await _sysUserRoleServices.QueryListByClauseAsync(p => entity.id.Contains(p.id), p => p.id,
                                                                  OrderByType.Asc);

            //给sheet1添加第一行的头部标题
            var row1 = sheet1.CreateRow(0);

            row1.CreateCell(0).SetCellValue("主键");
            row1.CreateCell(1).SetCellValue("用户id");
            row1.CreateCell(2).SetCellValue("角色id");
            row1.CreateCell(3).SetCellValue("创建时间");
            row1.CreateCell(4).SetCellValue("修改时间");

            //将数据逐步写入sheet1各个行
            for (var i = 0; i < listmodel.Count; i++)
            {
                var rowtemp = sheet1.CreateRow(i + 1);
                rowtemp.CreateCell(0).SetCellValue(listmodel[i].id.ToString());
                rowtemp.CreateCell(1).SetCellValue(listmodel[i].userId.ToString());
                rowtemp.CreateCell(2).SetCellValue(listmodel[i].roleId.ToString());
                rowtemp.CreateCell(3).SetCellValue(listmodel[i].createTime.ToString());
                rowtemp.CreateCell(4).SetCellValue(listmodel[i].updateTime.ToString());
            }

            // 导出excel
            var webRootPath = _webHostEnvironment.WebRootPath;
            var tpath       = "/files/" + DateTime.Now.ToString("yyyy-MM-dd") + "/";
            var fileName    = DateTime.Now.ToString("yyyyMMddHHmmssfff") + "-SysUserRole导出(选择结果).xls";
            var filePath    = webRootPath + tpath;
            var di          = new DirectoryInfo(filePath);

            if (!di.Exists)
            {
                di.Create();
            }
            var fileHssf = new FileStream(filePath + fileName, FileMode.Create);

            book.Write(fileHssf);
            fileHssf.Close();

            jm.code = 0;
            jm.msg  = GlobalConstVars.ExcelExportSuccess;
            jm.data = tpath + fileName;


            return(new JsonResult(jm));
        }
        public async Task <JsonResult> DoBatchDelete([FromBody] FMArrayIntIds entity)
        {
            var jm = new AdminUiCallBack();

            var bl = await _sysUserRoleServices.DeleteByIdsAsync(entity.id);

            jm.code = bl ? 0 : 1;
            jm.msg  = bl ? GlobalConstVars.DeleteSuccess : GlobalConstVars.DeleteFailure;

            return(new JsonResult(jm));
        }
Beispiel #3
0
        public async Task <JsonResult> SelectExportExcel([FromBody] FMArrayIntIds entity)
        {
            var jm = new AdminUiCallBack();

            //创建Excel文件的对象
            var book = new HSSFWorkbook();
            //添加一个sheet
            var mySheet = book.CreateSheet("Sheet1");
            //获取list数据
            var listModel =
                await _sysTaskLogServices.QueryListByClauseAsync(p => entity.id.Contains(p.id), p => p.id,
                                                                 OrderByType.Asc);

            //给sheet1添加第一行的头部标题
            var headerRow   = mySheet.CreateRow(0);
            var headerStyle = ExcelHelper.GetHeaderStyle(book);

            var cell0 = headerRow.CreateCell(0);

            cell0.SetCellValue("序列");
            cell0.CellStyle = headerStyle;
            mySheet.SetColumnWidth(0, 10 * 256);

            var cell1 = headerRow.CreateCell(1);

            cell1.SetCellValue("任务名称");
            cell1.CellStyle = headerStyle;
            mySheet.SetColumnWidth(1, 10 * 256);

            var cell2 = headerRow.CreateCell(2);

            cell2.SetCellValue("完成时间");
            cell2.CellStyle = headerStyle;
            mySheet.SetColumnWidth(2, 10 * 256);

            var cell3 = headerRow.CreateCell(3);

            cell3.SetCellValue("是否完成");
            cell3.CellStyle = headerStyle;
            mySheet.SetColumnWidth(3, 10 * 256);

            var cell4 = headerRow.CreateCell(4);

            cell4.SetCellValue("其他数据");
            cell4.CellStyle = headerStyle;
            mySheet.SetColumnWidth(4, 10 * 256);

            headerRow.Height = 30 * 20;
            var commonCellStyle = ExcelHelper.GetCommonStyle(book);

            //将数据逐步写入sheet1各个行
            for (var i = 0; i < listModel.Count; i++)
            {
                var rowTemp = mySheet.CreateRow(i + 1);

                var rowTemp0 = rowTemp.CreateCell(0);
                rowTemp0.SetCellValue(listModel[i].id.ToString());
                rowTemp0.CellStyle = commonCellStyle;

                var rowTemp1 = rowTemp.CreateCell(1);
                rowTemp1.SetCellValue(listModel[i].name);
                rowTemp1.CellStyle = commonCellStyle;

                var rowTemp2 = rowTemp.CreateCell(2);
                rowTemp2.SetCellValue(listModel[i].createTime.ToString());
                rowTemp2.CellStyle = commonCellStyle;

                var rowTemp3 = rowTemp.CreateCell(3);
                rowTemp3.SetCellValue(listModel[i].isSuccess.ToString());
                rowTemp3.CellStyle = commonCellStyle;

                var rowTemp4 = rowTemp.CreateCell(4);
                rowTemp4.SetCellValue(listModel[i].parameters);
                rowTemp4.CellStyle = commonCellStyle;
            }

            // 导出excel
            var webRootPath = _webHostEnvironment.WebRootPath;
            var tpath       = "/files/" + DateTime.Now.ToString("yyyy-MM-dd") + "/";
            var fileName    = DateTime.Now.ToString("yyyyMMddHHmmssfff") + "-SysTaskLog导出(选择结果).xls";
            var filePath    = webRootPath + tpath;
            var di          = new DirectoryInfo(filePath);

            if (!di.Exists)
            {
                di.Create();
            }
            var fileHssf = new FileStream(filePath + fileName, FileMode.Create);

            book.Write(fileHssf);
            fileHssf.Close();

            jm.code = 0;
            jm.msg  = GlobalConstVars.ExcelExportSuccess;
            jm.data = tpath + fileName;

            return(new JsonResult(jm));
        }
Beispiel #4
0
        public async Task <JsonResult> SelectExportExcel([FromBody] FMArrayIntIds entity)
        {
            var jm = new AdminUiCallBack();

            //创建Excel文件的对象
            var book = new HSSFWorkbook();
            //添加一个sheet
            var sheet1 = book.CreateSheet("Sheet1");
            //获取list数据
            var listmodel = await _SysOperRecordServices.QueryListByClauseAsync(p => entity.id.Contains(p.id),
                                                                                p => p.id, OrderByType.Asc);

            //给sheet1添加第一行的头部标题
            var row1 = sheet1.CreateRow(0);

            row1.CreateCell(0).SetCellValue("主键");
            row1.CreateCell(1).SetCellValue("用户id");
            row1.CreateCell(2).SetCellValue("操作模块");
            row1.CreateCell(3).SetCellValue("操作方法");
            row1.CreateCell(4).SetCellValue("请求地址");
            row1.CreateCell(5).SetCellValue("请求方式");
            row1.CreateCell(6).SetCellValue("调用方法");
            row1.CreateCell(7).SetCellValue("请求参数");
            row1.CreateCell(8).SetCellValue("返回结果");
            row1.CreateCell(9).SetCellValue("ip地址");
            row1.CreateCell(10).SetCellValue("请求耗时,单位毫秒");
            row1.CreateCell(11).SetCellValue("状态,0成功,1异常");
            row1.CreateCell(12).SetCellValue("备注");
            row1.CreateCell(13).SetCellValue("登录时间");
            row1.CreateCell(14).SetCellValue("修改时间");

            //将数据逐步写入sheet1各个行
            for (var i = 0; i < listmodel.Count; i++)
            {
                var rowtemp = sheet1.CreateRow(i + 1);
                rowtemp.CreateCell(0).SetCellValue(listmodel[i].id.ToString());
                rowtemp.CreateCell(1).SetCellValue(listmodel[i].userId.ToString());
                rowtemp.CreateCell(2).SetCellValue(listmodel[i].model);
                rowtemp.CreateCell(3).SetCellValue(listmodel[i].description);
                rowtemp.CreateCell(4).SetCellValue(listmodel[i].url);
                rowtemp.CreateCell(5).SetCellValue(listmodel[i].requestMethod);
                rowtemp.CreateCell(6).SetCellValue(listmodel[i].operMethod);
                rowtemp.CreateCell(7).SetCellValue(listmodel[i].param);
                rowtemp.CreateCell(8).SetCellValue(listmodel[i].result);
                rowtemp.CreateCell(9).SetCellValue(listmodel[i].ip);
                rowtemp.CreateCell(10).SetCellValue(listmodel[i].spendTime.ToString());
                rowtemp.CreateCell(11).SetCellValue(listmodel[i].state.ToString());
                rowtemp.CreateCell(12).SetCellValue(listmodel[i].comments);
                rowtemp.CreateCell(13).SetCellValue(listmodel[i].createTime.ToString());
                rowtemp.CreateCell(14).SetCellValue(listmodel[i].updateTime.ToString());
            }

            // 导出excel
            var webRootPath = _webHostEnvironment.WebRootPath;
            var tpath       = "/files/" + DateTime.Now.ToString("yyyy-MM-dd") + "/";
            var fileName    = DateTime.Now.ToString("yyyyMMddHHmmssfff") + "-SysOperRecord导出(选择结果).xls";
            var filePath    = webRootPath + tpath;
            var di          = new DirectoryInfo(filePath);

            if (!di.Exists)
            {
                di.Create();
            }
            var fileHssf = new FileStream(filePath + fileName, FileMode.Create);

            book.Write(fileHssf);
            fileHssf.Close();

            jm.code = 0;
            jm.msg  = GlobalConstVars.ExcelExportSuccess;
            jm.data = tpath + fileName;


            return(new JsonResult(jm));
        }
Beispiel #5
0
        public async Task <JsonResult> SelectExportExcel([FromBody] FMArrayIntIds entity)
        {
            var jm = new AdminUiCallBack();

            //创建Excel文件的对象
            var book = new HSSFWorkbook();
            //添加一个sheet
            var sheet1 = book.CreateSheet("Sheet1");
            //获取list数据
            var listmodel = await _sysNLogRecordsServices.QueryListByClauseAsync(p => entity.id.Contains(p.id),
                                                                                 p => p.id, OrderByType.Asc);

            //给sheet1添加第一行的头部标题
            var row1 = sheet1.CreateRow(0);

            row1.CreateCell(0).SetCellValue("序列");
            row1.CreateCell(1).SetCellValue("时间");
            row1.CreateCell(2).SetCellValue("级别");
            row1.CreateCell(3).SetCellValue("事件日志上下文");
            row1.CreateCell(4).SetCellValue("记录器名字");
            row1.CreateCell(5).SetCellValue("消息");
            row1.CreateCell(6).SetCellValue("名称");
            row1.CreateCell(7).SetCellValue("ip");
            row1.CreateCell(8).SetCellValue("请求方式");
            row1.CreateCell(9).SetCellValue("请求地址");
            row1.CreateCell(10).SetCellValue("是否授权");
            row1.CreateCell(11).SetCellValue("授权类型");
            row1.CreateCell(12).SetCellValue("身份认证");
            row1.CreateCell(13).SetCellValue("异常信息");

            //将数据逐步写入sheet1各个行
            for (var i = 0; i < listmodel.Count; i++)
            {
                var rowtemp = sheet1.CreateRow(i + 1);
                rowtemp.CreateCell(0).SetCellValue(listmodel[i].id.ToString());
                rowtemp.CreateCell(1).SetCellValue(listmodel[i].LogDate.ToString());
                rowtemp.CreateCell(2).SetCellValue(listmodel[i].LogLevel);
                rowtemp.CreateCell(3).SetCellValue(listmodel[i].LogType);
                rowtemp.CreateCell(4).SetCellValue(listmodel[i].Logger);
                rowtemp.CreateCell(5).SetCellValue(listmodel[i].Message);
                rowtemp.CreateCell(6).SetCellValue(listmodel[i].MachineName);
                rowtemp.CreateCell(7).SetCellValue(listmodel[i].MachineIp);
                rowtemp.CreateCell(8).SetCellValue(listmodel[i].NetRequestMethod);
                rowtemp.CreateCell(9).SetCellValue(listmodel[i].NetRequestUrl);
                rowtemp.CreateCell(10).SetCellValue(listmodel[i].NetUserIsauthenticated);
                rowtemp.CreateCell(11).SetCellValue(listmodel[i].NetUserAuthtype);
                rowtemp.CreateCell(12).SetCellValue(listmodel[i].NetUserIdentity);
                rowtemp.CreateCell(13).SetCellValue(listmodel[i].Exception);
            }

            // 导出excel
            var webRootPath = _webHostEnvironment.WebRootPath;
            var tpath       = "/files/" + DateTime.Now.ToString("yyyy-MM-dd") + "/";
            var fileName    = DateTime.Now.ToString("yyyyMMddHHmmssfff") + "-SysNLogRecords导出(选择结果).xls";
            var filePath    = webRootPath + tpath;
            var di          = new DirectoryInfo(filePath);

            if (!di.Exists)
            {
                di.Create();
            }
            var fileHssf = new FileStream(filePath + fileName, FileMode.Create);

            book.Write(fileHssf);
            fileHssf.Close();

            jm.code = 0;
            jm.msg  = GlobalConstVars.ExcelExportSuccess;
            jm.data = tpath + fileName;


            return(new JsonResult(jm));
        }