// using BMA.EHR.Recurit.Exam.Service.Core; // using BMA.EHR.Recurit.Exam.Service.Data; // using BMA.EHR.Recurit.Exam.Service.Models; // using BMA.EHR.Recurit.Exam.Service.Request; // using BMA.EHR.Recurit.Exam.Service.Response; // using BMA.EHR.Recurit.Exam.Service.Services; // using Microsoft.AspNetCore.Authorization; // using Microsoft.AspNetCore.Mvc; // using Microsoft.EntityFrameworkCore; // using Swashbuckle.AspNetCore.Annotations; // using Telerik.Reporting; // using Telerik.Reporting.Processing; // namespace BMA.EHR.Recurit.Exam.Service.Controllers // { // [Route("api/v{version:apiVersion}/report")] // [ApiVersion("1.0")] // [ApiController] // [Produces("application/json")] // [Authorize] // [SwaggerTag("จัดการข้อมูลหน้าเว็บสมัครสอบ เพื่อนำไปใช้งานในระบบ")] // public class ReportController : BaseController // { // #region " Fields " // private readonly ApplicationDbContext _context; // private readonly CMSCandidateService _cmsCandidateService; // private readonly IWebHostEnvironment _hostingEnvironment; // #endregion // #region " Constructor and Destructor " // public ReportController(ApplicationDbContext context, CMSCandidateService cmsCandidateService, IWebHostEnvironment hostingEnvironment) // { // _context = context; // _cmsCandidateService = cmsCandidateService; // _hostingEnvironment = hostingEnvironment; // } // #endregion // public static IConfigurationRoot Configuration // { // get // { // return new ConfigurationBuilder() // .SetBasePath(Directory.GetCurrentDirectory()) // .AddJsonFile("appsettings.json") // .Build(); // } // } // #region " Methods " // /// // /// ใบเสร็จผู้สมัครสอบ // /// // /// รหัสใบสมัคร // /// // /// เมื่อทำการอ่านใบเสร็จผู้สมัครสอบสำเร็จ // /// ไม่ได้ Login เข้าระบบ // /// เมื่อเกิดข้อผิดพลาดในการทำงาน // [HttpGet] // [ProducesResponseType(StatusCodes.Status200OK)] // [ProducesResponseType(StatusCodes.Status401Unauthorized)] // [ProducesResponseType(StatusCodes.Status500InternalServerError)] // public async Task> GetsAsync(string candidateId) // { // try // { // return Success("ยังใช้ไม่ได้จ้าา"); // var candidate = await _context.Candidates.AsQueryable() // .Where(x => x.Id == Guid.Parse(candidateId)) // .Select(x => new // { // Fee = x.PeriodExam == null ? 0 : x.PeriodExam.Fee, // // DateBill = DateTime.now, // }) // .FirstOrDefaultAsync(); // if (candidate == null) // throw new Exception(GlobalMessages.CandidateNotFound); // var rptFile = ""; // rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Report", "rptBillPayment.trdp"); // ReportPackager reportPackager = new ReportPackager(); // Telerik.Reporting.Report? report = null; // using (var sourceStream = System.IO.File.OpenRead(rptFile)) // { // report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); // } // report.DataSource = candidate; // System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); // InstanceReportSource instanceReportSource = new InstanceReportSource() // { // ReportDocument = report // }; // ReportProcessor reportProcessor = new ReportProcessor(Configuration); // RenderingResult result = reportProcessor.RenderReport("PDF", instanceReportSource, deviceInfo); // var outputfile = $"DoctorOrderSheet_.pdf"; // return File(result.DocumentBytes, "application/pdf", outputfile); // } // catch (Exception ex) // { // return Error(ex); // } // } // #endregion // } // }