diff --git a/BMA.EHR.Application/Repositories/Commands/CommandReportRepository.cs b/BMA.EHR.Application/Repositories/Commands/CommandReportRepository.cs index 6046d317..89a83e31 100644 --- a/BMA.EHR.Application/Repositories/Commands/CommandReportRepository.cs +++ b/BMA.EHR.Application/Repositories/Commands/CommandReportRepository.cs @@ -92,7 +92,7 @@ namespace BMA.EHR.Application.Repositories.Commands Education = p.PlacementEducations == null || p.PlacementEducations.Count == 0 ? "" : p.PlacementEducations.FirstOrDefault().Degree, Seq = r.Sequence.ToString().ToThaiNumber(), - CitizenId = r.CitizenId, + CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", Oc = p.root == null ? "" : p.root, PositionName = p.positionName == null ? "" : p.positionName, @@ -151,7 +151,7 @@ namespace BMA.EHR.Application.Repositories.Commands Education = p.PlacementEducations == null || p.PlacementEducations.Count == 0 ? "" : p.PlacementEducations.FirstOrDefault().Degree, Seq = r.Sequence.ToString().ToThaiNumber(), - CitizenId = r.CitizenId, + CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", Oc = p.root == null ? "" : p.root, PositionName = p.positionName == null ? "" : p.positionName, @@ -215,7 +215,7 @@ namespace BMA.EHR.Application.Repositories.Commands Education = p.PlacementEducations == null || p.PlacementEducations.Count == 0 ? "" : p.PlacementEducations.FirstOrDefault().Degree, Seq = r.Sequence.ToString().ToThaiNumber(), - CitizenId = r.CitizenId, + CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", OldOc = pf.Oc == null ? "" : pf.Oc.Replace("/", " "), Probation = pf.IsProbation ? "(อยู่ระหว่างปฏิบัติหน้าที่ราชการ)" : "", @@ -285,7 +285,7 @@ namespace BMA.EHR.Application.Repositories.Commands Education = p.PlacementEducations == null || p.PlacementEducations.Count == 0 ? "" : p.PlacementEducations.FirstOrDefault().Degree, Seq = r.Sequence.ToString().ToThaiNumber(), - CitizenId = r.CitizenId, + CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", OldOc = pf.Oc == null ? "" : pf.Oc.Replace("/", " "), OldPositionName = pf.Position == null ? "" : pf.Position.Name, @@ -351,13 +351,13 @@ namespace BMA.EHR.Application.Repositories.Commands { Education = p.EducationOld == null ? "-" : p.EducationOld, Seq = r.Sequence.ToString().ToThaiNumber(), - CitizenId = r.CitizenId, + CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", OldOc = p.rootOld == null ? "" : p.rootOld, OldPositionName = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld, OldPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld, OldPositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld, - OldPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld, + OldPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), OldSalaryDate = p.PositionDate == null ? "" : p.PositionDate.Value.ToThaiShortDate2().ToThaiNumber(), NewOc = p.root == null ? "" : p.root, @@ -421,13 +421,13 @@ namespace BMA.EHR.Application.Repositories.Commands // pf.Educations.OrderByDescending(x => x.StartDate).FirstOrDefault().Degree, Education = p.EducationOld == null ? "-" : p.EducationOld, Seq = r.Sequence.ToString().ToThaiNumber(), - CitizenId = r.CitizenId, + CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", OldOc = p.rootOld == null ? "" : p.rootOld, OldPositionName = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld, OldPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld, OldPositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld, - OldPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld, + OldPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), OldSalaryDate = p.PositionDate == null ? "" : p.PositionDate.Value.ToThaiShortDate2().ToThaiNumber(), NewOc = p.root == null ? "" : p.root, @@ -475,20 +475,20 @@ namespace BMA.EHR.Application.Repositories.Commands { Education = p.EducationOld == null ? "-" : p.EducationOld, Seq = r.Sequence.ToString().ToThaiNumber(), - CitizenId = r.CitizenId, + CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", OldOc = p.rootOld == null ? "" : p.rootOld, OldPositionName = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld, OldPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld, OldPositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld, - OldPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld, + OldPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), OldSalaryDate = p.PositionDate == null ? "" : p.PositionDate.Value.ToThaiShortDate2().ToThaiNumber(), NewOc = p.rootOld == null ? "" : p.rootOld, NewPositionName = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld, NewPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld, NewPositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld, - NewPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld, + NewPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(), AppointDate = p.PositionDate == null ? "" : p.PositionDate.Value.ToThaiShortDate2().ToThaiNumber(), LeaveDate = p.LeaveDate == null ? "" : p.LeaveDate.Value.ToThaiShortDate2().ToThaiNumber(), @@ -525,20 +525,20 @@ namespace BMA.EHR.Application.Repositories.Commands { Education = p.EducationOld == null ? "-" : p.EducationOld, Seq = r.Sequence.ToString().ToThaiNumber(), - CitizenId = r.CitizenId, + CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", OldOc = p.rootOld == null ? "" : p.rootOld, OldPositionName = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld, OldPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld, OldPositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld, - OldPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld, + OldPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), OldSalaryDate = p.PositionDate == null ? "" : p.PositionDate.Value.ToThaiShortDate2().ToThaiNumber(), NewOc = p.rootOld == null ? "" : p.rootOld, NewPositionName = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld, NewPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld, NewPositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld, - NewPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld, + NewPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(), AppointDate = p.PositionDate == null ? "" : p.PositionDate.Value.ToThaiShortDate2().ToThaiNumber(), LeaveDate = p.LeaveDate == null ? "" : p.LeaveDate.Value.ToThaiShortDate2().ToThaiNumber(), @@ -570,7 +570,7 @@ namespace BMA.EHR.Application.Repositories.Commands IssuerOrganizationName = r.Command.IssuerOrganizationName, AuthorizedUserFullName = r.Command.AuthorizedUserFullName, AuthorizedPosition = r.Command.AuthorizedPosition, - CitizenId = r.CitizenId, + CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", PlacementCommandIssuer = r.Command.PlacementCommandIssuer ?? "", PlacementCommandNo = r.Command.PlacementCommandNo == null ? "" : r.Command.PlacementCommandNo.ToThaiNumber(), @@ -606,7 +606,7 @@ namespace BMA.EHR.Application.Repositories.Commands IssuerOrganizationName = r.Command.IssuerOrganizationName, AuthorizedUserFullName = r.Command.AuthorizedUserFullName, AuthorizedPosition = r.Command.AuthorizedPosition, - CitizenId = r.CitizenId, + CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", PlacementCommandIssuer = r.Command.PlacementCommandIssuer ?? "", PlacementCommandNo = r.Command.PlacementCommandNo == null ? "" : r.Command.PlacementCommandNo.ToThaiNumber(), @@ -647,13 +647,13 @@ namespace BMA.EHR.Application.Repositories.Commands select new CommandType13Response { Seq = r.Sequence.ToString().ToThaiNumber(), - CitizenId = r.CitizenId, + CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", Organization = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld, PositionName = p.PositionOld == null ? "" : p.PositionOld, PositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld, PositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld, - PositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld, + PositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(), Salary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(), //Salary = pf.Salaries == null || pf.Salaries.Count == 0 ? "" : pf.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount.Value.ToNumericNoDecimalText().ToThaiNumber(), ActiveDate = p.Date == null ? "" : p.Date.Value.ToThaiShortDate2().ToThaiNumber(), @@ -695,7 +695,7 @@ namespace BMA.EHR.Application.Repositories.Commands { Education = p.EducationOld == null ? "-" : p.EducationOld, Seq = r.Sequence.ToString().ToThaiNumber(), - CitizenId = r.CitizenId, + CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", OldOc = p.OrganizationPositionOld ?? "", OldPositionName = p.OrganizationPositionOld ?? "", @@ -744,7 +744,7 @@ namespace BMA.EHR.Application.Repositories.Commands select new CommandType15Response { Seq = r.Sequence.ToString().ToThaiNumber(), - CitizenId = r.CitizenId, + CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", PositionName = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld, // PositionName = p.Profile.Position == null ? "" : p.Profile.Position.Name, @@ -836,7 +836,7 @@ namespace BMA.EHR.Application.Repositories.Commands select new CommandType17Response { Seq = r.Sequence.ToString().ToThaiNumber(), - CitizenId = r.CitizenId, + CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", PositionName = p.PositionOld ?? "", Organization = p.OrganizationPositionOld ?? "", @@ -888,7 +888,7 @@ namespace BMA.EHR.Application.Repositories.Commands IssuerOrganizationName = r.Command.IssuerOrganizationName, AuthorizedUserFullName = r.Command.AuthorizedUserFullName, AuthorizedPosition = r.Command.AuthorizedPosition, - CitizenId = r.CitizenId, + CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", // PositionName = p.Profile.Position == null ? "" : p.Profile.Position.Name, Organization = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld, @@ -943,7 +943,7 @@ namespace BMA.EHR.Application.Repositories.Commands IssuerOrganizationName = r.Command.IssuerOrganizationName, AuthorizedUserFullName = r.Command.AuthorizedUserFullName, AuthorizedPosition = r.Command.AuthorizedPosition, - CitizenId = r.CitizenId, + CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", PositionName = p.Profile.Position == null ? "" : p.Profile.Position.Name, Organization = p.OrganizationPositionOld ?? "", @@ -997,7 +997,7 @@ namespace BMA.EHR.Application.Repositories.Commands IssuerOrganizationName = r.Command.IssuerOrganizationName, AuthorizedUserFullName = r.Command.AuthorizedUserFullName, AuthorizedPosition = r.Command.AuthorizedPosition, - CitizenId = r.CitizenId, + CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", PositionName = p.Profile.Position == null ? "" : p.Profile.Position.Name, Organization = p.OrganizationPositionOld ?? "", @@ -1060,7 +1060,7 @@ namespace BMA.EHR.Application.Repositories.Commands select new CommandType21Response { Seq = r.Sequence.ToString().ToThaiNumber(), - CitizenId = r.CitizenId.ToThaiNumber(), + CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", Organization = r.Organization == null ? "" : r.Organization.ToThaiNumber(), PositionName = r.PositionName == null ? "" : r.PositionName.ToThaiNumber(), @@ -1192,7 +1192,7 @@ namespace BMA.EHR.Application.Repositories.Commands select new CommandType21Response { Seq = r.Sequence.ToString().ToThaiNumber(), - CitizenId = r.CitizenId.ToThaiNumber(), + CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(), FullName = $"{r.Prefix}{r.FirstName} {r.LastName}", Organization = p.OrganizationPositionOld ?? "", PositionName = p.PositionOld ?? "", @@ -1311,7 +1311,7 @@ namespace BMA.EHR.Application.Repositories.Commands { fullName = $"{org.result.prefix}{org.result.firstName} {org.result.lastName}", positionname = org.result.position, - positionno = org.result.posNo, + positionno = org.result.posNo == null ? null : org.result.posNo.ToThaiNumber(), organizationname = org.result.organization, salary = org.result.salary == null ? null : org.result.salary.Value.ToNumericNoDecimalText().ToString(), }; diff --git a/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs b/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs index daf17ebb..bc0482e2 100644 --- a/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs +++ b/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs @@ -2764,7 +2764,7 @@ namespace BMA.EHR.Application.Repositories.Commands isProbation = true, isLeave = false, dateRetire = (DateTime?)null, - dateAppoint = placementProfile.RecruitDate == null ? (DateTime?)null : placementProfile.RecruitDate, + dateAppoint = command.CommandAffectDate == null ? null : command.CommandAffectDate, dateStart = command.CommandAffectDate == null ? null : command.CommandAffectDate, govAgeAbsent = 0, govAgePlus = 0, @@ -5562,6 +5562,10 @@ namespace BMA.EHR.Application.Repositories.Commands { PersonId = x.RefPlacementProfileId, Id = x.RefDisciplineId, + CommandAffectDate = command.CommandAffectDate, + CommandNo = command.CommandNo, + CommandYear = command.CommandYear.ToInteger().ToThaiYear(), + Detail = "คำสั่งลงโทษ ตัดเงินเดือน" }); var _baseAPI = _configuration["API"]; @@ -5710,6 +5714,10 @@ namespace BMA.EHR.Application.Repositories.Commands { PersonId = x.RefPlacementProfileId, Id = x.RefDisciplineId, + CommandAffectDate = command.CommandAffectDate, + CommandNo = command.CommandNo, + CommandYear = command.CommandYear.ToInteger().ToThaiYear(), + Detail = "คำสั่งลงโทษ ตัดเงินเดือน" }); var _baseAPI = _configuration["API"]; @@ -6346,6 +6354,10 @@ namespace BMA.EHR.Application.Repositories.Commands { PersonId = x.RefPlacementProfileId, Id = x.RefDisciplineId, + CommandAffectDate = command.CommandAffectDate, + CommandNo = command.CommandNo, + CommandYear = command.CommandYear.ToInteger().ToThaiYear(), + Detail = "คำสั่งลงโทษ ตัดเงินเดือน" }); var baseAPI = _configuration["API"]; @@ -6475,6 +6487,10 @@ namespace BMA.EHR.Application.Repositories.Commands { PersonId = x.RefPlacementProfileId, Id = x.RefDisciplineId, + CommandAffectDate = command.CommandAffectDate, + CommandNo = command.CommandNo, + CommandYear = command.CommandYear.ToInteger().ToThaiYear(), + Detail = "คำสั่งลงโทษ ตัดเงินเดือน" }); var baseAPI = _configuration["API"]; @@ -6605,6 +6621,10 @@ namespace BMA.EHR.Application.Repositories.Commands { PersonId = x.RefPlacementProfileId, Id = x.RefDisciplineId, + CommandAffectDate = command.CommandAffectDate, + CommandNo = command.CommandNo, + CommandYear = command.CommandYear.ToInteger().ToThaiYear(), + Detail = "คำสั่งลงโทษ ตัดเงินเดือน" }); var baseAPI = _configuration["API"]; @@ -6735,6 +6755,10 @@ namespace BMA.EHR.Application.Repositories.Commands { PersonId = x.RefPlacementProfileId, Id = x.RefDisciplineId, + CommandAffectDate = command.CommandAffectDate, + CommandNo = command.CommandNo, + CommandYear = command.CommandYear.ToInteger().ToThaiYear(), + Detail = "คำสั่งลงโทษ ตัดเงินเดือน" }); var baseAPI = _configuration["API"]; @@ -6865,6 +6889,10 @@ namespace BMA.EHR.Application.Repositories.Commands { PersonId = x.RefPlacementProfileId, Id = x.RefDisciplineId, + CommandAffectDate = command.CommandAffectDate, + CommandNo = command.CommandNo, + CommandYear = command.CommandYear.ToInteger().ToThaiYear(), + Detail = "คำสั่งลงโทษ ลดขั้นเงินเดือน" }); var baseAPI = _configuration["API"]; @@ -6995,6 +7023,10 @@ namespace BMA.EHR.Application.Repositories.Commands { PersonId = x.RefPlacementProfileId, Id = x.RefDisciplineId, + CommandAffectDate = command.CommandAffectDate, + CommandNo = command.CommandNo, + CommandYear = command.CommandYear.ToInteger().ToThaiYear(), + Detail = "คำสั่งเพิ่มโทษ" }); var baseAPI = _configuration["API"]; @@ -7125,6 +7157,10 @@ namespace BMA.EHR.Application.Repositories.Commands { PersonId = x.RefPlacementProfileId, Id = x.RefDisciplineId, + CommandAffectDate = command.CommandAffectDate, + CommandNo = command.CommandNo, + CommandYear = command.CommandYear.ToInteger().ToThaiYear(), + Detail = "คำสั่งงดโทษ" }); var baseAPI = _configuration["API"]; @@ -7255,6 +7291,10 @@ namespace BMA.EHR.Application.Repositories.Commands { PersonId = x.RefPlacementProfileId, Id = x.RefDisciplineId, + CommandAffectDate = command.CommandAffectDate, + CommandNo = command.CommandNo, + CommandYear = command.CommandYear.ToInteger().ToThaiYear(), + Detail = "คำสั่งยุติเรื่อง" }); var baseAPI = _configuration["API"]; diff --git a/BMA.EHR.Application/Repositories/Leaves/LeaveRequests/LeaveRequestRepository.cs b/BMA.EHR.Application/Repositories/Leaves/LeaveRequests/LeaveRequestRepository.cs index 4a9731f3..578c700e 100644 --- a/BMA.EHR.Application/Repositories/Leaves/LeaveRequests/LeaveRequestRepository.cs +++ b/BMA.EHR.Application/Repositories/Leaves/LeaveRequests/LeaveRequestRepository.cs @@ -1,4 +1,6 @@ using System.Drawing; +using System.Net.Http.Headers; +using System.Net.Http.Json; using BMA.EHR.Application.Common.Interfaces; using BMA.EHR.Application.Messaging; using BMA.EHR.Domain.Models.HR; @@ -404,7 +406,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests throw new Exception("คำขอนี้ยังไม่ได้รับการอนุมัติจากผู้บังคับบัญชา ไม่สามารถทำรายการได้"); } - var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId,AccessToken); + var profile = await _userProfileRepository.GetProfileByKeycloakIdAsync(rawData.KeycloakUserId, AccessToken); if (profile == null) { throw new Exception(GlobalMessages.DataNotFound); @@ -421,19 +423,38 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests // insert to profile leave - var profileLeave = new ProfileLeave + // var profileLeave = new ProfileLeave + // { + // DateStartLeave = rawData.LeaveStartDate, + // DateEndLeave = rawData.LeaveEndDate, + + // TotalLeave = rawData.LeaveTotal, + // Status = "approve", + // Reason = rawData.LeaveDetail, + + // ProfileId = profile.Id, // change from profile object to id + // TypeLeave = leaveType + // }; + // _appDbContext.Set().Add(profileLeave); + var _baseAPI = _configuration["API"]; + var apiUrlSalary = $"{_baseAPI}/org/profile/leave"; + using (var client = new HttpClient()) { - DateStartLeave = rawData.LeaveStartDate, - DateEndLeave = rawData.LeaveEndDate, - - TotalLeave = rawData.LeaveTotal, - Status = "approve", - Reason = rawData.LeaveDetail, - - ProfileId = profile.Id, // change from profile object to id - TypeLeave = leaveType - }; - _appDbContext.Set().Add(profileLeave); + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken.Replace("Bearer ", "")); + var _res = await client.PostAsJsonAsync(apiUrlSalary, new + { + profileId = profile.Id, + leaveTypeId = leaveType?.Id ?? null, + dateLeaveStart = rawData.LeaveStartDate, + dateLeaveEnd = rawData.LeaveEndDate, + leaveDays = 0,//หน้า fe ไม่ได้ใช้ + leaveCount = 0,//หน้า fe ไม่ได้ใช้ + totalLeave = rawData.LeaveTotal, + status = "approve", + reason = rawData.LeaveDetail, + }); + // var _result = await _res.Content.ReadAsStringAsync(); + } await _appDbContext.SaveChangesAsync(); // insert to process timestamp diff --git a/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs b/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs index 2bc4032c..ade28dd0 100644 --- a/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs +++ b/BMA.EHR.Discipline.Service/Controllers/DisciplineResultController.cs @@ -11,6 +11,8 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using Swashbuckle.AspNetCore.Annotations; +using System.Configuration; +using System.Net.Http.Headers; using System.Security.Claims; namespace BMA.EHR.DisciplineResult.Service.Controllers @@ -26,15 +28,18 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers private readonly DisciplineDbContext _context; private readonly MinIODisciplineService _documentService; private readonly IHttpContextAccessor _httpContextAccessor; + private readonly IConfiguration _configuration; public DisciplineResultController(DisciplineDbContext context, MinIODisciplineService documentService, - IHttpContextAccessor httpContextAccessor) + IHttpContextAccessor httpContextAccessor, + IConfiguration configuration) { // _repository = repository; _context = context; _documentService = documentService; _httpContextAccessor = httpContextAccessor; + _configuration = configuration; } #region " Properties " @@ -42,6 +47,7 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value; private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value; + private string? token => _httpContextAccessor?.HttpContext?.Request.Headers["Authorization"]; #endregion @@ -465,6 +471,7 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers foreach (var d in req.result) { var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates + .Include(x=>x.DisciplineDisciplinary) .Where(x => x.Status == "REPORT") .Where(x => x.Id == d.id) .FirstOrDefaultAsync(); @@ -472,6 +479,24 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers { data.Status = "NEW"; data.CommandTypeId = null; + var baseAPI = _configuration["API"]; + var apiUrlDiscipline = $"{baseAPI}org/profile/discipline"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlDiscipline); + var _res = await client.PostAsJsonAsync(apiUrlDiscipline, new + { + profileId = d.personId, + date = d.commandAffectDate, + detail = data.DisciplineDisciplinary.Title, + level = data.DisciplineDisciplinary.DisciplinaryFaultLevel, + refCommandDate = "", + refCommandNo = $"{d.commandNo}/{d.commandYear}", + unStigma = d.detail, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } } await _context.SaveChangesAsync(); } @@ -492,6 +517,7 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers foreach (var d in req.result) { var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates + .Include(x => x.DisciplineDisciplinary) .Where(x => x.StatusDiscard == "REPORT") .Where(x => x.Id == d.id) .FirstOrDefaultAsync(); @@ -499,6 +525,24 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers { data.StatusDiscard = "NEW"; data.CommandTypeDiscardId = null; + var baseAPI = _configuration["API"]; + var apiUrlDiscipline = $"{baseAPI}org/profile/discipline"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlDiscipline); + var _res = await client.PostAsJsonAsync(apiUrlDiscipline, new + { + profileId = d.personId, + date = d.commandAffectDate, + detail = data.DisciplineDisciplinary.Title, + level = data.DisciplineDisciplinary.DisciplinaryFaultLevel, + refCommandDate = "", + refCommandNo = $"{d.commandNo}/{d.commandYear}", + unStigma = d.detail, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } } await _context.SaveChangesAsync(); } @@ -519,17 +563,58 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers foreach (var d in req.result) { var data1 = await _context.DisciplineInvestigate_ProfileComplaints + .Include(x => x.DisciplineInvestigate) .Where(x => x.IsReport == "REPORT") .Where(x => x.Id == d.id) .FirstOrDefaultAsync(); if (data1 != null) + { data1.IsReport = "NEW"; + var baseAPI = _configuration["API"]; + var apiUrlDiscipline = $"{baseAPI}org/profile/discipline"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlDiscipline); + var _res = await client.PostAsJsonAsync(apiUrlDiscipline, new + { + profileId = d.personId, + date = d.commandAffectDate, + detail = data1.DisciplineInvestigate.Title, + level = "", + refCommandDate = "", + refCommandNo = $"{d.commandNo}/{d.commandYear}", + unStigma = d.detail, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + } var data2 = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates + .Include(x => x.DisciplineDisciplinary) .Where(x => x.IsReport == "REPORT") .Where(x => x.Id == d.id) .FirstOrDefaultAsync(); - if (data2 != null) - data2.IsReport = "NEW"; + if (data2 != null) { + data2.IsReport = "NEW"; + var baseAPI = _configuration["API"]; + var apiUrlDiscipline = $"{baseAPI}org/profile/discipline"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlDiscipline); + var _res = await client.PostAsJsonAsync(apiUrlDiscipline, new + { + profileId = d.personId, + date = d.commandAffectDate, + detail = data2.DisciplineDisciplinary.Title, + level = data2.DisciplineDisciplinary.DisciplinaryFaultLevel, + refCommandDate = "", + refCommandNo = $"{d.commandNo}/{d.commandYear}", + unStigma = d.detail, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + } await _context.SaveChangesAsync(); } return Success(); @@ -549,11 +634,31 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers foreach (var d in req.result) { var data = await _context.DisciplineReport_Profiles + .Include(x => x.DisciplineDisciplinary) .Where(x => x.Status == "REPORT") .Where(x => x.Id == d.id) .FirstOrDefaultAsync(); - if (data != null) + if (data != null) { data.Status = "DONE"; + var baseAPI = _configuration["API"]; + var apiUrlDiscipline = $"{baseAPI}org/profile/discipline"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlDiscipline); + var _res = await client.PostAsJsonAsync(apiUrlDiscipline, new + { + profileId = d.personId, + date = d.commandAffectDate, + detail = data.DisciplineDisciplinary.Title, + level = data.DisciplineDisciplinary.DisciplinaryFaultLevel, + refCommandDate = "", + refCommandNo = $"{d.commandNo}/{d.commandYear}", + unStigma = d.detail, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + } await _context.SaveChangesAsync(); } return Success(); diff --git a/BMA.EHR.Discipline.Service/Requests/PassDisciplineResponse.cs b/BMA.EHR.Discipline.Service/Requests/PassDisciplineResponse.cs index 8e237ccc..c95f888c 100644 --- a/BMA.EHR.Discipline.Service/Requests/PassDisciplineResponse.cs +++ b/BMA.EHR.Discipline.Service/Requests/PassDisciplineResponse.cs @@ -13,5 +13,10 @@ namespace BMA.EHR.Discipline.Service.Requests public Guid id { get; set; } = Guid.Empty; public Guid personId { get; set; } = Guid.Empty; public Guid? commandId { get; set; } = Guid.Empty; + + public DateTime? commandAffectDate { get; set; } + public string? commandNo { get; set; } + public string? commandYear { get; set; } + public string? detail { get; set; } } } diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs index d21433f7..e17edde6 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentController.cs @@ -662,24 +662,24 @@ namespace BMA.EHR.Placement.Service.Controllers return Success(); } - // /// - // /// หน่วยงานที่ถูกเลือกไปแล้ว - // /// - // /// - // /// - // /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง - // /// ไม่ได้ Login เข้าระบบ - // /// เมื่อเกิดข้อผิดพลาดในการทำงาน - // [HttpGet("use")] - // public async Task> GetAppointmentsUse() - // { - // var appointments = await _context.PlacementAppointments - // // .Where(x => x.PositionNumber != null) - // // .Where(x => x.Profile.ProfileType == "officer") - // // .Select(x => x.PositionNumber.Id) - // .ToListAsync(); - - // return Success(appointments); - // } + /// + /// หน่วยงานที่ถูกเลือกไปแล้ว + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpGet("use")] + public async Task> GetAppointmentsUse() + { + var appointments = await _context.PlacementAppointments + .Where(x => x.posmasterId != null) + .Where(x => x.Status != "DONE") + .Where(x => x.type == "OFFICER") + .Select(x => x.posmasterId) + .ToListAsync(); + return Success(appointments); + } } } diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentEmployeeController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentEmployeeController.cs index aa1c5ed3..7f7e9afe 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentEmployeeController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementAppointmentEmployeeController.cs @@ -648,24 +648,24 @@ namespace BMA.EHR.Placement.Service.Controllers return Success(); } - // /// - // /// หน่วยงานที่ถูกเลือกไปแล้ว - // /// - // /// - // /// - // /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง - // /// ไม่ได้ Login เข้าระบบ - // /// เมื่อเกิดข้อผิดพลาดในการทำงาน - // [HttpGet("use")] - // public async Task> GetAppointmentsUse() - // { - // var appointments = await _context.PlacementAppointments - // .Where(x => x.PositionNumber != null) - // .Where(x => x.Profile.ProfileType == "employee" && x.Profile.EmployeeClass == "perm") - // .Select(x => x.PositionNumber.Id) - // .ToListAsync(); - - // return Success(appointments); - // } + /// + /// หน่วยงานที่ถูกเลือกไปแล้ว + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpGet("use")] + public async Task> GetAppointmentsUse() + { + var appointments = await _context.PlacementAppointments + .Where(x => x.posmasterId != null) + .Where(x => x.Status != "DONE") + .Where(x => x.type == "EMPLOYEE") + .Select(x => x.posmasterId) + .ToListAsync(); + return Success(appointments); + } } } diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs index b141ebbb..14bd46aa 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs @@ -1045,17 +1045,6 @@ namespace BMA.EHR.Placement.Service.Controllers return Success(); } - [HttpGet("position/use")] - public async Task> GetPositionUse() - { - var position = await _context.PlacementProfiles - .Where(x => x.PositionNumber != null) - .Select(x => x.PositionNumber) - .ToListAsync(); - - return Success(position); - } - [HttpPut("position/{personalId:length(36)}")] public async Task> UpdatePositionDraft([FromBody] List items, Guid personalId) { @@ -1283,5 +1272,24 @@ namespace BMA.EHR.Placement.Service.Controllers return Success(); } + /// + /// หน่วยงานที่ถูกเลือกไปแล้ว + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpGet("use")] + public async Task> GetPositionUse() + { + var position = await _context.PlacementProfiles + .Where(x => x.posmasterId != null) + .Where(x => x.PlacementStatus != "CONTAIN") + .Select(x => x.posmasterId) + .ToListAsync(); + return Success(position); + } + } } diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs index 8f9c2df5..42eb09e7 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementReceiveController.cs @@ -794,23 +794,23 @@ namespace BMA.EHR.Placement.Service.Controllers return Success(); } - // /// - // /// หน่วยงานที่ถูกเลือกไปแล้ว - // /// - // /// - // /// - // /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง - // /// ไม่ได้ Login เข้าระบบ - // /// เมื่อเกิดข้อผิดพลาดในการทำงาน - // [HttpGet("use")] - // public async Task> GetReceiveUse() - // { - // var receives = await _context.PlacementReceives - // .Where(x => x.PositionNumber != null) - // .Select(x => x.PositionNumber.Id) - // .ToListAsync(); - - // return Success(receives); - // } + /// + /// หน่วยงานที่ถูกเลือกไปแล้ว + /// + /// + /// + /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง + /// ไม่ได้ Login เข้าระบบ + /// เมื่อเกิดข้อผิดพลาดในการทำงาน + [HttpGet("use")] + public async Task> GetPositionUse() + { + var position = await _context.PlacementReceives + .Where(x => x.posmasterId != null) + .Where(x => x.Status != "DONE") + .Select(x => x.posmasterId) + .ToListAsync(); + return Success(position); + } } } diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementRelocationController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementRelocationController.cs index 183e242f..81ca987b 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementRelocationController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementRelocationController.cs @@ -525,24 +525,5 @@ namespace BMA.EHR.Placement.Service.Controllers return Success(); } - - /// - /// หน่วยงานที่ถูกเลือกไปแล้ว - /// - /// - /// - /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง - /// ไม่ได้ Login เข้าระบบ - /// เมื่อเกิดข้อผิดพลาดในการทำงาน - [HttpGet("use")] - public async Task> GetRelocationUse() - { - var relocation = await _context.PlacementRelocations - .Where(x => x.PositionNumber != null) - .Select(x => x.PositionNumber.Id) - .ToListAsync(); - - return Success(relocation); - } } } diff --git a/BMA.EHR.Report.Service/Controllers/CommandReportController.cs b/BMA.EHR.Report.Service/Controllers/CommandReportController.cs index 99245de5..3daa078d 100644 --- a/BMA.EHR.Report.Service/Controllers/CommandReportController.cs +++ b/BMA.EHR.Report.Service/Controllers/CommandReportController.cs @@ -54,7 +54,7 @@ namespace BMA.EHR.Report.Service.Controllers #region " C-PM-01 " - private async Task GenerateCommandReportType01_Cover(Guid commandId, string exportType) + private async Task GenerateCommandReportType01_Cover(Guid commandId, string exportType) { try { @@ -83,34 +83,34 @@ namespace BMA.EHR.Report.Service.Controllers AuthorizedPosition = raw_data.AuthorizedPosition, Subject = $"เรื่อง {raw_data.CommandSubject}", }; + return command; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"01-คำสั่งบรรจุและแต่งตั้งผู้สอบแข่งขันได้-1.trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"01-คำสั่งบรรจุและแต่งตั้งผู้สอบแข่งขันได้-1.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); + //} - 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 = command; - report.DataSource = command; + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + //if (exportType == "docx") + // deviceInfo["OutputFormat"] = "DOCX"; - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - if (exportType == "docx") - deviceInfo["OutputFormat"] = "DOCX"; - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); - var content = result.DocumentBytes; + //var content = result.DocumentBytes; - return content; + //return content; } catch { @@ -118,7 +118,7 @@ namespace BMA.EHR.Report.Service.Controllers } } - private async Task GenerateCommandReportType01_Attachment(Guid commandId, string exportType) + private async Task GenerateCommandReportType01_Attachment(Guid commandId, string exportType) { try { @@ -129,39 +129,39 @@ namespace BMA.EHR.Report.Service.Controllers } var data = await _commandReportRepository.GetCommandType01AttachmentAsync(commandId); + return data; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"01-คำสั่งบรรจุและแต่งตั้งผู้สอบแข่งขันได้-2.trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"01-คำสั่งบรรจุและแต่งตั้งผู้สอบแข่งขันได้-2.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); + //} - ReportPackager reportPackager = new ReportPackager(); - Telerik.Reporting.Report? report = null; - using (var sourceStream = System.IO.File.OpenRead(rptFile)) - { - report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); - } + //var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["tblData"]; - var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["tblData"]; + //tblData.DataSource = data; - tblData.DataSource = data; + //report.ReportParameters["IssuerOrganizationName"].Value = command.IssuerOrganizationName; + //report.ReportParameters["CommandNo"].Value = command.CommandNo.ToThaiNumber(); + //report.ReportParameters["CommandYear"].Value = command.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(); + //report.ReportParameters["CommandExecuteDate"].Value = command.CommandExcecuteDate == null ? "" : command.CommandExcecuteDate.Value.ToThaiFullDate2().ToThaiNumber(); - report.ReportParameters["IssuerOrganizationName"].Value = command.IssuerOrganizationName; - report.ReportParameters["CommandNo"].Value = command.CommandNo.ToThaiNumber(); - report.ReportParameters["CommandYear"].Value = command.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(); - report.ReportParameters["CommandExecuteDate"].Value = command.CommandExcecuteDate == null ? "" : command.CommandExcecuteDate.Value.ToThaiFullDate2().ToThaiNumber(); + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); - var content = result.DocumentBytes; + //var content = result.DocumentBytes; - return content; + //return content; } catch { @@ -173,7 +173,7 @@ namespace BMA.EHR.Report.Service.Controllers #region " C-PM-02 " - private async Task GenerateCommandReportType02_Cover(Guid commandId, string exportType) + private async Task GenerateCommandReportType02_Cover(Guid commandId, string exportType) { try { @@ -202,34 +202,34 @@ namespace BMA.EHR.Report.Service.Controllers AuthorizedPosition = raw_data.AuthorizedPosition, Subject = $"เรื่อง {raw_data.CommandSubject}", }; + return command; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"02-คำสั่งบรรจุและแต่งตั้งผู้ได้รับคัดเลือก-3.trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"02-คำสั่งบรรจุและแต่งตั้งผู้ได้รับคัดเลือก-3.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); + //} - 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 = command; - report.DataSource = command; + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + //if (exportType == "docx") + // deviceInfo["OutputFormat"] = "DOCX"; - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - if (exportType == "docx") - deviceInfo["OutputFormat"] = "DOCX"; - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); - var content = result.DocumentBytes; + //var content = result.DocumentBytes; - return content; + //return content; } catch { @@ -237,7 +237,7 @@ namespace BMA.EHR.Report.Service.Controllers } } - private async Task GenerateCommandReportType02_Attachment(Guid commandId, string exportType) + private async Task GenerateCommandReportType02_Attachment(Guid commandId, string exportType) { try { @@ -248,39 +248,39 @@ namespace BMA.EHR.Report.Service.Controllers } var data = await _commandReportRepository.GetCommandType02AttachmentAsync(commandId); + return data; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"02-คำสั่งบรรจุและแต่งตั้งผู้ได้รับคัดเลือก-4.trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"02-คำสั่งบรรจุและแต่งตั้งผู้ได้รับคัดเลือก-4.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); + //} - ReportPackager reportPackager = new ReportPackager(); - Telerik.Reporting.Report? report = null; - using (var sourceStream = System.IO.File.OpenRead(rptFile)) - { - report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); - } + //var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["tblData"]; - var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["tblData"]; + //tblData.DataSource = data; - tblData.DataSource = data; + //report.ReportParameters["IssuerOrganizationName"].Value = command.IssuerOrganizationName; + //report.ReportParameters["CommandNo"].Value = command.CommandNo.ToThaiNumber(); + //report.ReportParameters["CommandYear"].Value = command.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(); + //report.ReportParameters["CommandExecuteDate"].Value = command.CommandExcecuteDate == null ? "" : command.CommandExcecuteDate.Value.ToThaiFullDate2().ToThaiNumber(); - report.ReportParameters["IssuerOrganizationName"].Value = command.IssuerOrganizationName; - report.ReportParameters["CommandNo"].Value = command.CommandNo.ToThaiNumber(); - report.ReportParameters["CommandYear"].Value = command.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(); - report.ReportParameters["CommandExecuteDate"].Value = command.CommandExcecuteDate == null ? "" : command.CommandExcecuteDate.Value.ToThaiFullDate2().ToThaiNumber(); + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); - var content = result.DocumentBytes; + //var content = result.DocumentBytes; - return content; + //return content; } catch { @@ -292,7 +292,7 @@ namespace BMA.EHR.Report.Service.Controllers #region " C-PM-03 " - private async Task GenerateCommandReportType03_Cover(Guid commandId, string exportType) + private async Task GenerateCommandReportType03_Cover(Guid commandId, string exportType) { try { @@ -321,34 +321,34 @@ namespace BMA.EHR.Report.Service.Controllers AuthorizedPosition = raw_data.AuthorizedPosition, Subject = $"เรื่อง {raw_data.CommandSubject}", }; + return command; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"03-คำสั่งแต่งตั้งผู้สอบแข่งขัน-Head.trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"03-คำสั่งแต่งตั้งผู้สอบแข่งขัน-Head.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); + //} - 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 = command; - report.DataSource = command; + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + //if (exportType == "docx") + // deviceInfo["OutputFormat"] = "DOCX"; - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - if (exportType == "docx") - deviceInfo["OutputFormat"] = "DOCX"; - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); - var content = result.DocumentBytes; + //var content = result.DocumentBytes; - return content; + //return content; } catch { @@ -356,7 +356,7 @@ namespace BMA.EHR.Report.Service.Controllers } } - private async Task GenerateCommandReportType03_Attachment(Guid commandId, string exportType) + private async Task GenerateCommandReportType03_Attachment(Guid commandId, string exportType) { try { @@ -367,39 +367,39 @@ namespace BMA.EHR.Report.Service.Controllers } var data = await _commandReportRepository.GetCommandType03AttachmentAsync(commandId); + return data; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"03-คำสั่งแต่งตั้งผู้สอบแข่งขัน.trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"03-คำสั่งแต่งตั้งผู้สอบแข่งขัน.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); + //} - ReportPackager reportPackager = new ReportPackager(); - Telerik.Reporting.Report? report = null; - using (var sourceStream = System.IO.File.OpenRead(rptFile)) - { - report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); - } + //var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["tblData"]; - var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["tblData"]; + //tblData.DataSource = data; - tblData.DataSource = data; + //report.ReportParameters["IssuerOrganizationName"].Value = command.IssuerOrganizationName; + //report.ReportParameters["CommandNo"].Value = command.CommandNo.ToThaiNumber(); + //report.ReportParameters["CommandYear"].Value = command.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(); + //report.ReportParameters["CommandExecuteDate"].Value = command.CommandExcecuteDate == null ? "" : command.CommandExcecuteDate.Value.ToThaiFullDate2().ToThaiNumber(); - report.ReportParameters["IssuerOrganizationName"].Value = command.IssuerOrganizationName; - report.ReportParameters["CommandNo"].Value = command.CommandNo.ToThaiNumber(); - report.ReportParameters["CommandYear"].Value = command.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(); - report.ReportParameters["CommandExecuteDate"].Value = command.CommandExcecuteDate == null ? "" : command.CommandExcecuteDate.Value.ToThaiFullDate2().ToThaiNumber(); + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); - var content = result.DocumentBytes; + //var content = result.DocumentBytes; - return content; + //return content; } catch { @@ -411,7 +411,7 @@ namespace BMA.EHR.Report.Service.Controllers #region " C-PM-04 " - private async Task GenerateCommandReportType04_Cover(Guid commandId, string exportType) + private async Task GenerateCommandReportType04_Cover(Guid commandId, string exportType) { try { @@ -440,34 +440,34 @@ namespace BMA.EHR.Report.Service.Controllers AuthorizedPosition = raw_data.AuthorizedPosition, Subject = $"เรื่อง {raw_data.CommandSubject}", }; + return command; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"04-คำสั่งย้ายผู้สอบแข่งขัน-Head.trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"04-คำสั่งย้ายผู้สอบแข่งขัน-Head.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); + //} - 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 = command; - report.DataSource = command; + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + //if (exportType == "docx") + // deviceInfo["OutputFormat"] = "DOCX"; - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - if (exportType == "docx") - deviceInfo["OutputFormat"] = "DOCX"; - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); - var content = result.DocumentBytes; + //var content = result.DocumentBytes; - return content; + //return content; } catch { @@ -475,7 +475,7 @@ namespace BMA.EHR.Report.Service.Controllers } } - private async Task GenerateCommandReportType04_Attachment(Guid commandId, string exportType) + private async Task GenerateCommandReportType04_Attachment(Guid commandId, string exportType) { try { @@ -486,38 +486,38 @@ namespace BMA.EHR.Report.Service.Controllers } var data = await _commandReportRepository.GetCommandType03AttachmentAsync(commandId); + return data; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"04-คำสั่งย้ายผู้สอบแข่งขัน.trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"04-คำสั่งย้ายผู้สอบแข่งขัน.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); + //} - ReportPackager reportPackager = new ReportPackager(); - Telerik.Reporting.Report? report = null; - using (var sourceStream = System.IO.File.OpenRead(rptFile)) - { - report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); - } + //var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["tblData"]; - var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["tblData"]; + //tblData.DataSource = data; - tblData.DataSource = data; + //report.ReportParameters["IssuerOrganizationName"].Value = command.IssuerOrganizationName; + //report.ReportParameters["CommandNo"].Value = command.CommandNo.ToThaiNumber(); + //report.ReportParameters["CommandYear"].Value = command.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(); + //report.ReportParameters["CommandExecuteDate"].Value = command.CommandExcecuteDate == null ? "" : command.CommandExcecuteDate.Value.ToThaiFullDate2().ToThaiNumber(); - report.ReportParameters["IssuerOrganizationName"].Value = command.IssuerOrganizationName; - report.ReportParameters["CommandNo"].Value = command.CommandNo.ToThaiNumber(); - report.ReportParameters["CommandYear"].Value = command.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(); - report.ReportParameters["CommandExecuteDate"].Value = command.CommandExcecuteDate == null ? "" : command.CommandExcecuteDate.Value.ToThaiFullDate2().ToThaiNumber(); + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); + //var content = result.DocumentBytes; - var content = result.DocumentBytes; - - return content; + //return content; } catch { @@ -529,7 +529,7 @@ namespace BMA.EHR.Report.Service.Controllers #region " C-PM-05 " - private async Task GenerateCommandReportType05_Cover(Guid commandId, string exportType) + private async Task GenerateCommandReportType05_Cover(Guid commandId, string exportType) { try { @@ -560,34 +560,34 @@ namespace BMA.EHR.Report.Service.Controllers AuthorizedPosition = raw_data.AuthorizedPosition, Subject = $"เรื่อง {raw_data.CommandSubject}", }; + return command; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"05-06-คำสั่งแต่งตั้ง-คำสั่งเลื่อน.trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"05-06-คำสั่งแต่งตั้ง-คำสั่งเลื่อน.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); + //} - 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 = command; - report.DataSource = command; + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + //if (exportType == "docx") + // deviceInfo["OutputFormat"] = "DOCX"; - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - if (exportType == "docx") - deviceInfo["OutputFormat"] = "DOCX"; - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); - var content = result.DocumentBytes; + //var content = result.DocumentBytes; - return content; + //return content; } catch { @@ -595,50 +595,69 @@ namespace BMA.EHR.Report.Service.Controllers } } - private async Task GenerateCommandReportType05_Attachment(Guid commandId, string exportType) + private async Task GenerateCommandReportType05_Attachment(Guid commandId, string exportType) { try { - var command = await _repository.GetByIdAsync(commandId); - if (command == null) + //var command = await _repository.GetByIdAsync(commandId); + //if (command == null) + //{ + // throw new Exception(GlobalMessages.CommandNotFound); + //} + var raw_data = await _repository.GetByIdAsync(commandId); + if (raw_data == null) { throw new Exception(GlobalMessages.CommandNotFound); } - var data = await _commandReportRepository.GetCommandType05_06AttachmentAsync(commandId); - - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"05-06-แนบท้ายคำสั่งแต่งตั้ง-คำสั่งเลื่อน.trdp"); - - ReportPackager reportPackager = new ReportPackager(); - Telerik.Reporting.Report? report = null; - using (var sourceStream = System.IO.File.OpenRead(rptFile)) + var command = new { - report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); - } - - var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["tblData"]; - - tblData.DataSource = data; - - report.ReportParameters["IssuerOrganizationName"].Value = command.IssuerOrganizationName; - report.ReportParameters["CommandNo"].Value = command.CommandNo.ToThaiNumber(); - report.ReportParameters["CommandYear"].Value = command.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(); - report.ReportParameters["CommandExecuteDate"].Value = command.CommandExcecuteDate == null ? "" : command.CommandExcecuteDate.Value.ToThaiFullDate2().ToThaiNumber(); - - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report + CommandNo = raw_data.CommandNo.ToThaiNumber(), + CommandYear = raw_data.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(), + IssuerOrganizationName = raw_data.IssuerOrganizationName, + CommandExcecuteDate = raw_data.CommandExcecuteDate != null ? raw_data.CommandExcecuteDate.Value.ToThaiFullDate3().ToThaiNumber() : "-", }; + var data = await _commandReportRepository.GetCommandType05_06AttachmentAsync(commandId); + return new + { + CommandNo = command.CommandNo, + CommandYear = command.CommandYear, + IssuerOrganizationName = command.IssuerOrganizationName, + CommandExcecuteDate = command.CommandExcecuteDate, + data = data, + }; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"05-06-แนบท้ายคำสั่งแต่งตั้ง-คำสั่งเลื่อน.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); + //} + + //var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["tblData"]; + + //tblData.DataSource = data; + + //report.ReportParameters["IssuerOrganizationName"].Value = command.IssuerOrganizationName; + //report.ReportParameters["CommandNo"].Value = command.CommandNo.ToThaiNumber(); + //report.ReportParameters["CommandYear"].Value = command.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(); + //report.ReportParameters["CommandExecuteDate"].Value = command.CommandExcecuteDate == null ? "" : command.CommandExcecuteDate.Value.ToThaiFullDate2().ToThaiNumber(); + + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); - var content = result.DocumentBytes; + //var content = result.DocumentBytes; - return content; + //return content; } catch { @@ -650,7 +669,7 @@ namespace BMA.EHR.Report.Service.Controllers #region " C-PM-06 " - private async Task GenerateCommandReportType06_Cover(Guid commandId, string exportType) + private async Task GenerateCommandReportType06_Cover(Guid commandId, string exportType) { try { @@ -681,34 +700,34 @@ namespace BMA.EHR.Report.Service.Controllers ConclusionMeetingDate = raw_data.ConclusionMeetingDate == null ? "" : raw_data.ConclusionMeetingDate.Value.ToThaiFullDate3().ToThaiNumber(), Subject = $"เรื่อง {raw_data.CommandSubject}", }; + return command; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"05-06-คำสั่งแต่งตั้ง-คำสั่งเลื่อน.trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"05-06-คำสั่งแต่งตั้ง-คำสั่งเลื่อน.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); + //} - 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 = command; - report.DataSource = command; + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + //if (exportType == "docx") + // deviceInfo["OutputFormat"] = "DOCX"; - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - if (exportType == "docx") - deviceInfo["OutputFormat"] = "DOCX"; - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); - var content = result.DocumentBytes; + //var content = result.DocumentBytes; - return content; + //return content; } catch { @@ -716,50 +735,70 @@ namespace BMA.EHR.Report.Service.Controllers } } - private async Task GenerateCommandReportType06_Attachment(Guid commandId, string exportType) + private async Task GenerateCommandReportType06_Attachment(Guid commandId, string exportType) { try { - var command = await _repository.GetByIdAsync(commandId); - if (command == null) + //var command = await _repository.GetByIdAsync(commandId); + //if (command == null) + //{ + // throw new Exception(GlobalMessages.CommandNotFound); + //} + var raw_data = await _repository.GetByIdAsync(commandId); + if (raw_data == null) { throw new Exception(GlobalMessages.CommandNotFound); } + var command = new + { + CommandNo = raw_data.CommandNo.ToThaiNumber(), + CommandYear = raw_data.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(), + IssuerOrganizationName = raw_data.IssuerOrganizationName, + CommandExcecuteDate = raw_data.CommandExcecuteDate != null ? raw_data.CommandExcecuteDate.Value.ToThaiFullDate3().ToThaiNumber() : "-", + }; var data = await _commandReportRepository.GetCommandType05_06AttachmentAsync(commandId); - - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"05-06-แนบท้ายคำสั่งแต่งตั้ง-คำสั่งเลื่อน.trdp"); - - ReportPackager reportPackager = new ReportPackager(); - Telerik.Reporting.Report? report = null; - using (var sourceStream = System.IO.File.OpenRead(rptFile)) + return new { - report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); - } - - var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["tblData"]; - - tblData.DataSource = data; - - report.ReportParameters["IssuerOrganizationName"].Value = command.IssuerOrganizationName; - report.ReportParameters["CommandNo"].Value = command.CommandNo.ToThaiNumber(); - report.ReportParameters["CommandYear"].Value = command.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(); - report.ReportParameters["CommandExecuteDate"].Value = command.CommandExcecuteDate == null ? "" : command.CommandExcecuteDate.Value.ToThaiFullDate2().ToThaiNumber(); - - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report + CommandNo = command.CommandNo, + CommandYear = command.CommandYear, + IssuerOrganizationName = command.IssuerOrganizationName, + CommandExcecuteDate = command.CommandExcecuteDate, + data = data, }; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"05-06-แนบท้ายคำสั่งแต่งตั้ง-คำสั่งเลื่อน.trdp"); - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); + //ReportPackager reportPackager = new ReportPackager(); + //Telerik.Reporting.Report? report = null; + //using (var sourceStream = System.IO.File.OpenRead(rptFile)) + //{ + // report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); + //} - var content = result.DocumentBytes; + //var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["tblData"]; - return content; + //tblData.DataSource = data; + + //report.ReportParameters["IssuerOrganizationName"].Value = command.IssuerOrganizationName; + //report.ReportParameters["CommandNo"].Value = command.CommandNo.ToThaiNumber(); + //report.ReportParameters["CommandYear"].Value = command.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(); + //report.ReportParameters["CommandExecuteDate"].Value = command.CommandExcecuteDate == null ? "" : command.CommandExcecuteDate.Value.ToThaiFullDate2().ToThaiNumber(); + + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; + + + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); + + //var content = result.DocumentBytes; + + //return content; } catch { @@ -771,7 +810,7 @@ namespace BMA.EHR.Report.Service.Controllers #region " C-PM-07 " - private async Task GenerateCommandReportType07_Cover(Guid commandId, string exportType) + private async Task GenerateCommandReportType07_Cover(Guid commandId, string exportType) { try { @@ -800,34 +839,34 @@ namespace BMA.EHR.Report.Service.Controllers AuthorizedPosition = raw_data.AuthorizedPosition, Subject = $"เรื่อง {raw_data.CommandSubject}", }; + return command; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"07-คำสั่งย้าย.trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"07-คำสั่งย้าย.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); + //} - 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 = command; - report.DataSource = command; + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + //if (exportType == "docx") + // deviceInfo["OutputFormat"] = "DOCX"; - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - if (exportType == "docx") - deviceInfo["OutputFormat"] = "DOCX"; - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); - var content = result.DocumentBytes; + //var content = result.DocumentBytes; - return content; + //return content; } catch { @@ -835,50 +874,69 @@ namespace BMA.EHR.Report.Service.Controllers } } - private async Task GenerateCommandReportType07_Attachment(Guid commandId, string exportType) + private async Task GenerateCommandReportType07_Attachment(Guid commandId, string exportType) { try { - var command = await _repository.GetByIdAsync(commandId); - if (command == null) + //var command = await _repository.GetByIdAsync(commandId); + //if (command == null) + //{ + // throw new Exception(GlobalMessages.CommandNotFound); + //} + var raw_data = await _repository.GetByIdAsync(commandId); + if (raw_data == null) { throw new Exception(GlobalMessages.CommandNotFound); } - + var command = new + { + CommandNo = raw_data.CommandNo.ToThaiNumber(), + CommandYear = raw_data.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(), + IssuerOrganizationName = raw_data.IssuerOrganizationName, + CommandExcecuteDate = raw_data.CommandExcecuteDate != null ? raw_data.CommandExcecuteDate.Value.ToThaiFullDate3().ToThaiNumber() : "-", + }; var data = await _commandReportRepository.GetCommandType07AttachmentAsync(commandId); - - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"07-แนบท้ายคำสั่งย้าย.trdp"); - - ReportPackager reportPackager = new ReportPackager(); - Telerik.Reporting.Report? report = null; - using (var sourceStream = System.IO.File.OpenRead(rptFile)) + return new { - report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); - } - - var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["tblData"]; - - tblData.DataSource = data; - - report.ReportParameters["IssuerOrganizationName"].Value = command.IssuerOrganizationName; - report.ReportParameters["CommandNo"].Value = command.CommandNo.ToThaiNumber(); - report.ReportParameters["CommandYear"].Value = command.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(); - report.ReportParameters["CommandExecuteDate"].Value = command.CommandExcecuteDate == null ? "" : command.CommandExcecuteDate.Value.ToThaiFullDate2().ToThaiNumber(); - - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report + CommandNo = command.CommandNo, + CommandYear = command.CommandYear, + IssuerOrganizationName = command.IssuerOrganizationName, + CommandExcecuteDate = command.CommandExcecuteDate, + data = data, }; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"07-แนบท้ายคำสั่งย้าย.trdp"); - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); + //ReportPackager reportPackager = new ReportPackager(); + //Telerik.Reporting.Report? report = null; + //using (var sourceStream = System.IO.File.OpenRead(rptFile)) + //{ + // report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); + //} - var content = result.DocumentBytes; + //var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["tblData"]; - return content; + //tblData.DataSource = data; + + //report.ReportParameters["IssuerOrganizationName"].Value = command.IssuerOrganizationName; + //report.ReportParameters["CommandNo"].Value = command.CommandNo.ToThaiNumber(); + //report.ReportParameters["CommandYear"].Value = command.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(); + //report.ReportParameters["CommandExecuteDate"].Value = command.CommandExcecuteDate == null ? "" : command.CommandExcecuteDate.Value.ToThaiFullDate2().ToThaiNumber(); + + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; + + + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); + + //var content = result.DocumentBytes; + + //return content; } catch { @@ -890,7 +948,7 @@ namespace BMA.EHR.Report.Service.Controllers #region " C-PM-08 " - private async Task GenerateCommandReportType08_Cover(Guid commandId, string exportType) + private async Task GenerateCommandReportType08_Cover(Guid commandId, string exportType) { try { @@ -908,7 +966,6 @@ namespace BMA.EHR.Report.Service.Controllers CommandNo = raw_data.CommandNo.ToThaiNumber(), CommandYear = raw_data.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(), IssuerOrganizationName = raw_data.IssuerOrganizationName, - ConclusionRegisterNo = raw_data.ConclusionRegisterNo == null ? "" : raw_data.ConclusionRegisterNo.ToThaiNumber(), ConclusionRegisterDate = raw_data.ConclusionRegisterDate == null ? "" : raw_data.ConclusionRegisterDate.Value.ToThaiFullDate3().ToThaiNumber(), ConclusionResultNo = raw_data.ConclusionResultNo == null ? "" : raw_data.ConclusionResultNo.ToThaiNumber(), ConclusionResultDate = raw_data.ConclusionResultDate == null ? "" : raw_data.ConclusionResultDate.Value.ToThaiFullDate3().ToThaiNumber(), @@ -921,34 +978,34 @@ namespace BMA.EHR.Report.Service.Controllers ConclusionReturnDate = raw_data.ConclusionReturnDate == null ? "" : raw_data.ConclusionReturnDate.Value.ToThaiFullDate3().ToThaiNumber(), Subject = $"เรื่อง {raw_data.CommandSubject}", }; + return command; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"08-คำสั่งบรรจุและแต่งตั้งข้าราชการฯกลับเข้ารับราชการ-5.trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"08-คำสั่งบรรจุและแต่งตั้งข้าราชการฯกลับเข้ารับราชการ-5.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); + //} - 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 = command; - report.DataSource = command; + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + //if (exportType == "docx") + // deviceInfo["OutputFormat"] = "DOCX"; - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - if (exportType == "docx") - deviceInfo["OutputFormat"] = "DOCX"; - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); - var content = result.DocumentBytes; + //var content = result.DocumentBytes; - return content; + //return content; } catch { @@ -956,50 +1013,67 @@ namespace BMA.EHR.Report.Service.Controllers } } - private async Task GenerateCommandReportType08_Attachment(Guid commandId, string exportType) + private async Task GenerateCommandReportType08_Attachment(Guid commandId, string exportType) { try { - var command = await _repository.GetByIdAsync(commandId); - if (command == null) + //var command = await _repository.GetByIdAsync(commandId); + //if (command == null) + //{ + // throw new Exception(GlobalMessages.CommandNotFound); + //} + var raw_data = await _repository.GetByIdAsync(commandId); + if (raw_data == null) { throw new Exception(GlobalMessages.CommandNotFound); } - - var data = await _commandReportRepository.GetCommandType08AttachmentAsync(commandId); - - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"08-คำสั่งบรรจุและแต่งตั้งข้าราชการฯกลับเข้ารับราชการ-6.trdp"); - - ReportPackager reportPackager = new ReportPackager(); - Telerik.Reporting.Report? report = null; - using (var sourceStream = System.IO.File.OpenRead(rptFile)) + var command = new { - report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); - } - - var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["table1"]; - - tblData.DataSource = data; - - report.ReportParameters["IssuerOrganizationName"].Value = command.IssuerOrganizationName; - report.ReportParameters["CommandNo"].Value = command.CommandNo.ToThaiNumber(); - report.ReportParameters["CommandYear"].Value = command.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(); - report.ReportParameters["CommandExecuteDate"].Value = command.CommandExcecuteDate == null ? "" : command.CommandExcecuteDate.Value.ToThaiFullDate2().ToThaiNumber(); - - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report + CommandNo = raw_data.CommandNo.ToThaiNumber(), + CommandYear = raw_data.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(), + IssuerOrganizationName = raw_data.IssuerOrganizationName, + CommandExcecuteDate = raw_data.CommandExcecuteDate != null ? raw_data.CommandExcecuteDate.Value.ToThaiFullDate3().ToThaiNumber() : "-", }; + var data = await _commandReportRepository.GetCommandType08AttachmentAsync(commandId); + return new { + CommandNo = command.CommandNo, + CommandYear = command.CommandYear, + IssuerOrganizationName = command.IssuerOrganizationName, + CommandExcecuteDate = command.CommandExcecuteDate, + data = data, + }; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"08-คำสั่งบรรจุและแต่งตั้งข้าราชการฯกลับเข้ารับราชการ-6.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); + //} + + //var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["table1"]; + + //tblData.DataSource = data; + + //report.ReportParameters["IssuerOrganizationName"].Value = command.IssuerOrganizationName; + //report.ReportParameters["CommandNo"].Value = command.CommandNo.ToThaiNumber(); + //report.ReportParameters["CommandYear"].Value = command.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(); + //report.ReportParameters["CommandExecuteDate"].Value = command.CommandExcecuteDate == null ? "" : command.CommandExcecuteDate.Value.ToThaiFullDate2().ToThaiNumber(); + + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); - var content = result.DocumentBytes; + //var content = result.DocumentBytes; - return content; + //return content; } catch { @@ -1011,7 +1085,7 @@ namespace BMA.EHR.Report.Service.Controllers #region " C-PM-09 " - private async Task GenerateCommandReportType09_Cover(Guid commandId, string exportType) + private async Task GenerateCommandReportType09_Cover(Guid commandId, string exportType) { try { @@ -1045,34 +1119,34 @@ namespace BMA.EHR.Report.Service.Controllers MilitaryCommanDate = raw_data.MilitaryCommanDate == null ? "" : raw_data.MilitaryCommanDate.Value.ToThaiFullDate3().ToThaiNumber(), Subject = $"เรื่อง {raw_data.CommandSubject}", }; + return command; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"09-คำสั่งบรรจุและแต่งตั้งผู้ออกไปรับราชการทหารกลับเข้ารับราชการ-7.trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"09-คำสั่งบรรจุและแต่งตั้งผู้ออกไปรับราชการทหารกลับเข้ารับราชการ-7.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); + //} - 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 = command; - report.DataSource = command; + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + //if (exportType == "docx") + // deviceInfo["OutputFormat"] = "DOCX"; - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - if (exportType == "docx") - deviceInfo["OutputFormat"] = "DOCX"; - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); - var content = result.DocumentBytes; + //var content = result.DocumentBytes; - return content; + //return content; } catch { @@ -1080,50 +1154,68 @@ namespace BMA.EHR.Report.Service.Controllers } } - private async Task GenerateCommandReportType09_Attachment(Guid commandId, string exportType) + private async Task GenerateCommandReportType09_Attachment(Guid commandId, string exportType) { try { - var command = await _repository.GetByIdAsync(commandId); - if (command == null) + //var command = await _repository.GetByIdAsync(commandId); + //if (command == null) + //{ + // throw new Exception(GlobalMessages.CommandNotFound); + //} + var raw_data = await _repository.GetByIdAsync(commandId); + if (raw_data == null) { throw new Exception(GlobalMessages.CommandNotFound); } - - var data = await _commandReportRepository.GetCommandType09AttachmentAsync(commandId); - - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"09-คำสั่งบรรจุและแต่งตั้งผู้ออกไปรับราชการทหารกลับเข้ารับราชการ-8.trdp"); - - ReportPackager reportPackager = new ReportPackager(); - Telerik.Reporting.Report? report = null; - using (var sourceStream = System.IO.File.OpenRead(rptFile)) + var command = new { - report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); - } - - var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["table1"]; - - tblData.DataSource = data; - - report.ReportParameters["IssuerOrganizationName"].Value = command.IssuerOrganizationName; - report.ReportParameters["CommandNo"].Value = command.CommandNo.ToThaiNumber(); - report.ReportParameters["CommandYear"].Value = command.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(); - report.ReportParameters["CommandExecuteDate"].Value = command.CommandExcecuteDate == null ? "" : command.CommandExcecuteDate.Value.ToThaiFullDate2().ToThaiNumber(); - - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report + CommandNo = raw_data.CommandNo.ToThaiNumber(), + CommandYear = raw_data.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(), + IssuerOrganizationName = raw_data.IssuerOrganizationName, + CommandExcecuteDate = raw_data.CommandExcecuteDate != null ? raw_data.CommandExcecuteDate.Value.ToThaiFullDate3().ToThaiNumber() : "-", }; + var data = await _commandReportRepository.GetCommandType09AttachmentAsync(commandId); + return new + { + CommandNo = command.CommandNo, + CommandYear = command.CommandYear, + IssuerOrganizationName = command.IssuerOrganizationName, + CommandExcecuteDate = command.CommandExcecuteDate, + data = data, + }; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"09-คำสั่งบรรจุและแต่งตั้งผู้ออกไปรับราชการทหารกลับเข้ารับราชการ-8.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); + //} + + //var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["table1"]; + + //tblData.DataSource = data; + + //report.ReportParameters["IssuerOrganizationName"].Value = command.IssuerOrganizationName; + //report.ReportParameters["CommandNo"].Value = command.CommandNo.ToThaiNumber(); + //report.ReportParameters["CommandYear"].Value = command.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(); + //report.ReportParameters["CommandExecuteDate"].Value = command.CommandExcecuteDate == null ? "" : command.CommandExcecuteDate.Value.ToThaiFullDate2().ToThaiNumber(); + + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); - var content = result.DocumentBytes; + //var content = result.DocumentBytes; - return content; + //return content; } catch { @@ -1135,7 +1227,7 @@ namespace BMA.EHR.Report.Service.Controllers #region " C-PM-10 " - private async Task GenerateCommandReportType10_Cover(Guid commandId, string exportType) + private async Task GenerateCommandReportType10_Cover(Guid commandId, string exportType) { try { @@ -1176,34 +1268,34 @@ namespace BMA.EHR.Report.Service.Controllers Duration = raw_data.ProbationStartDate == null || raw_data.ProbationEndDate == null ? "" : raw_data.ProbationStartDate.Value.CalculateBetweenDateV2(raw_data.ProbationEndDate.Value).ToThaiNumber(), Subject = $"เรื่อง {raw_data.CommandSubject}", }; + return command; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"10-แต่งตั้งคณะกรรมการประเมินผลการทดลองปฏิบัติหน้าที่ราชการ.trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"10-แต่งตั้งคณะกรรมการประเมินผลการทดลองปฏิบัติหน้าที่ราชการ.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); + //} - 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 = command; - report.DataSource = command; + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + //if (exportType == "docx") + // deviceInfo["OutputFormat"] = "DOCX"; - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - if (exportType == "docx") - deviceInfo["OutputFormat"] = "DOCX"; - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); - var content = result.DocumentBytes; + //var content = result.DocumentBytes; - return content; + //return content; } catch { @@ -1215,7 +1307,7 @@ namespace BMA.EHR.Report.Service.Controllers #region " C-PM-11 " - private async Task GenerateCommandReportType11_Cover(Guid commandId, string exportType) + private async Task GenerateCommandReportType11_Cover(Guid commandId, string exportType) { try { @@ -1226,31 +1318,31 @@ namespace BMA.EHR.Report.Service.Controllers } var data = await _commandReportRepository.GetCommandType11Async(commandId); + return data; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"11-คำสั่งให้ข้าราชการที่ผ่านการประเมิน รับราชการต่อไป.trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"11-คำสั่งให้ข้าราชการที่ผ่านการประเมิน รับราชการต่อไป.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); + //} - 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 = data; - report.DataSource = data; + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); + //var content = result.DocumentBytes; - var content = result.DocumentBytes; - - return content; + //return content; } catch { @@ -1262,7 +1354,7 @@ namespace BMA.EHR.Report.Service.Controllers #region " C-PM-12 " - private async Task GenerateCommandReportType12_Cover(Guid commandId, string exportType) + private async Task GenerateCommandReportType12_Cover(Guid commandId, string exportType) { try { @@ -1273,31 +1365,31 @@ namespace BMA.EHR.Report.Service.Controllers } var data = await _commandReportRepository.GetCommandType11Async(commandId); + return data; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"12-คำสั่งให้ข้าราชการที่ไม่ผ่านการประเมิน ออกจากราชการ.trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"12-คำสั่งให้ข้าราชการที่ไม่ผ่านการประเมิน ออกจากราชการ.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); + //} - 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 = data; - report.DataSource = data; + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); + //var content = result.DocumentBytes; - var content = result.DocumentBytes; - - return content; + //return content; } catch { @@ -1309,7 +1401,7 @@ namespace BMA.EHR.Report.Service.Controllers #region " C-PM-13 " - private async Task GenerateCommandReportType13_Cover(Guid commandId, string exportType) + private async Task GenerateCommandReportType13_Cover(Guid commandId, string exportType) { try { @@ -1339,34 +1431,34 @@ namespace BMA.EHR.Report.Service.Controllers ReceiveOrganizationName = raw_data.ReceiveOrganizationName, Subject = $"เรื่อง {raw_data.CommandSubject}", }; + return command; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"27-คำสั่งให้โอนข้าราชการกรุงเทพมหานครสามัญ-1.trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"27-คำสั่งให้โอนข้าราชการกรุงเทพมหานครสามัญ-1.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); + //} - 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 = command; - report.DataSource = command; + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + //if (exportType == "docx") + // deviceInfo["OutputFormat"] = "DOCX"; - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - if (exportType == "docx") - deviceInfo["OutputFormat"] = "DOCX"; - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); - var content = result.DocumentBytes; + //var content = result.DocumentBytes; - return content; + //return content; } catch { @@ -1374,50 +1466,68 @@ namespace BMA.EHR.Report.Service.Controllers } } - private async Task GenerateCommandReportType13_Attachment(Guid commandId, string exportType) + private async Task GenerateCommandReportType13_Attachment(Guid commandId, string exportType) { try { - var command = await _repository.GetByIdAsync(commandId); - if (command == null) + //var command = await _repository.GetByIdAsync(commandId); + //if (command == null) + //{ + // throw new Exception(GlobalMessages.CommandNotFound); + //} + var raw_data = await _repository.GetByIdAsync(commandId); + if (raw_data == null) { throw new Exception(GlobalMessages.CommandNotFound); } - - var data = await _commandReportRepository.GetCommandType13AttachmentAsync(commandId); - - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"27-คำสั่งให้โอนข้าราชการกรุงเทพมหานครสามัญ-2.trdp"); - - ReportPackager reportPackager = new ReportPackager(); - Telerik.Reporting.Report? report = null; - using (var sourceStream = System.IO.File.OpenRead(rptFile)) + var command = new { - report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); - } - - var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["table1"]; - - tblData.DataSource = data; - - report.ReportParameters["IssuerOrganizationName"].Value = command.IssuerOrganizationName; - report.ReportParameters["CommandNo"].Value = command.CommandNo.ToThaiNumber(); - report.ReportParameters["CommandYear"].Value = command.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(); - report.ReportParameters["CommandExecuteDate"].Value = command.CommandExcecuteDate == null ? "" : command.CommandExcecuteDate.Value.ToThaiFullDate2().ToThaiNumber(); - - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report + CommandNo = raw_data.CommandNo.ToThaiNumber(), + CommandYear = raw_data.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(), + IssuerOrganizationName = raw_data.IssuerOrganizationName, + CommandExcecuteDate = raw_data.CommandExcecuteDate != null ? raw_data.CommandExcecuteDate.Value.ToThaiFullDate3().ToThaiNumber() : "-", }; + var data = await _commandReportRepository.GetCommandType13AttachmentAsync(commandId); + return new + { + CommandNo = command.CommandNo, + CommandYear = command.CommandYear, + IssuerOrganizationName = command.IssuerOrganizationName, + CommandExcecuteDate = command.CommandExcecuteDate, + data = data, + }; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"27-คำสั่งให้โอนข้าราชการกรุงเทพมหานครสามัญ-2.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); + //} + + //var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["table1"]; + + //tblData.DataSource = data; + + //report.ReportParameters["IssuerOrganizationName"].Value = command.IssuerOrganizationName; + //report.ReportParameters["CommandNo"].Value = command.CommandNo.ToThaiNumber(); + //report.ReportParameters["CommandYear"].Value = command.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(); + //report.ReportParameters["CommandExecuteDate"].Value = command.CommandExcecuteDate == null ? "" : command.CommandExcecuteDate.Value.ToThaiFullDate2().ToThaiNumber(); + + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); - var content = result.DocumentBytes; + //var content = result.DocumentBytes; - return content; + //return content; } catch { @@ -1429,7 +1539,7 @@ namespace BMA.EHR.Report.Service.Controllers #region " C-PM-14 " - private async Task GenerateCommandReportType14_Cover(Guid commandId, string exportType) + private async Task GenerateCommandReportType14_Cover(Guid commandId, string exportType) { try { @@ -1461,34 +1571,34 @@ namespace BMA.EHR.Report.Service.Controllers ConclusionReceiveDate = raw_data.ConclusionReceiveDate == null ? "" : raw_data.ConclusionReceiveDate.Value.ToThaiFullDate3().ToThaiNumber(), Subject = $"เรื่อง {raw_data.CommandSubject}", }; + return command; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"28-คำสั่งรับโอนข้าราชการกรุงเทพมหานครสามัญ-5.trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"28-คำสั่งรับโอนข้าราชการกรุงเทพมหานครสามัญ-5.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); + //} - 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 = command; - report.DataSource = command; + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + //if (exportType == "docx") + // deviceInfo["OutputFormat"] = "DOCX"; - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - if (exportType == "docx") - deviceInfo["OutputFormat"] = "DOCX"; - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); - var content = result.DocumentBytes; + //var content = result.DocumentBytes; - return content; + //return content; } catch { @@ -1496,50 +1606,69 @@ namespace BMA.EHR.Report.Service.Controllers } } - private async Task GenerateCommandReportType14_Attachment(Guid commandId, string exportType) + private async Task GenerateCommandReportType14_Attachment(Guid commandId, string exportType) { try { - var command = await _repository.GetByIdAsync(commandId); - if (command == null) + //var command = await _repository.GetByIdAsync(commandId); + //if (command == null) + //{ + // throw new Exception(GlobalMessages.CommandNotFound); + //} + var raw_data = await _repository.GetByIdAsync(commandId); + if (raw_data == null) { throw new Exception(GlobalMessages.CommandNotFound); } - + var command = new + { + CommandNo = raw_data.CommandNo.ToThaiNumber(), + CommandYear = raw_data.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(), + IssuerOrganizationName = raw_data.IssuerOrganizationName, + CommandExcecuteDate = raw_data.CommandExcecuteDate != null ? raw_data.CommandExcecuteDate.Value.ToThaiFullDate3().ToThaiNumber() : "-", + }; var data = await _commandReportRepository.GetCommandType14AttachmentAsync(commandId); - - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"28-คำสั่งรับโอนข้าราชการกรุงเทพมหานครสามัญ5-10.trdp"); - - ReportPackager reportPackager = new ReportPackager(); - Telerik.Reporting.Report? report = null; - using (var sourceStream = System.IO.File.OpenRead(rptFile)) + return new { - report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); - } - - var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["table1"]; - - tblData.DataSource = data; - - report.ReportParameters["IssuerOrganizationName"].Value = command.IssuerOrganizationName; - report.ReportParameters["CommandNo"].Value = command.CommandNo.ToThaiNumber(); - report.ReportParameters["CommandYear"].Value = command.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(); - report.ReportParameters["CommandExecuteDate"].Value = command.CommandExcecuteDate == null ? "" : command.CommandExcecuteDate.Value.ToThaiFullDate2().ToThaiNumber(); - - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report + CommandNo = command.CommandNo, + CommandYear = command.CommandYear, + IssuerOrganizationName = command.IssuerOrganizationName, + CommandExcecuteDate = command.CommandExcecuteDate, + data = data, }; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"28-คำสั่งรับโอนข้าราชการกรุงเทพมหานครสามัญ5-10.trdp"); - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); + //ReportPackager reportPackager = new ReportPackager(); + //Telerik.Reporting.Report? report = null; + //using (var sourceStream = System.IO.File.OpenRead(rptFile)) + //{ + // report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); + //} - var content = result.DocumentBytes; + //var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["table1"]; - return content; + //tblData.DataSource = data; + + //report.ReportParameters["IssuerOrganizationName"].Value = command.IssuerOrganizationName; + //report.ReportParameters["CommandNo"].Value = command.CommandNo.ToThaiNumber(); + //report.ReportParameters["CommandYear"].Value = command.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(); + //report.ReportParameters["CommandExecuteDate"].Value = command.CommandExcecuteDate == null ? "" : command.CommandExcecuteDate.Value.ToThaiFullDate2().ToThaiNumber(); + + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; + + + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); + + //var content = result.DocumentBytes; + + //return content; } catch { @@ -1551,7 +1680,7 @@ namespace BMA.EHR.Report.Service.Controllers #region " C-PM-15 " - private async Task GenerateCommandReportType15_Cover(Guid commandId, string exportType) + private async Task GenerateCommandReportType15_Cover(Guid commandId, string exportType) { try { @@ -1580,34 +1709,34 @@ namespace BMA.EHR.Report.Service.Controllers AuthorizedPosition = raw_data.AuthorizedPosition, Subject = $"เรื่อง {raw_data.CommandSubject}", }; + return command; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"29-คำสั่งให้ช่วยราชการ-1.trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"29-คำสั่งให้ช่วยราชการ-1.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); + //} - 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 = command; - report.DataSource = command; + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + //if (exportType == "docx") + // deviceInfo["OutputFormat"] = "DOCX"; - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - if (exportType == "docx") - deviceInfo["OutputFormat"] = "DOCX"; - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); - var content = result.DocumentBytes; + //var content = result.DocumentBytes; - return content; + //return content; } catch { @@ -1615,50 +1744,70 @@ namespace BMA.EHR.Report.Service.Controllers } } - private async Task GenerateCommandReportType15_Attachment(Guid commandId, string exportType) + private async Task GenerateCommandReportType15_Attachment(Guid commandId, string exportType) { try { - var command = await _repository.GetByIdAsync(commandId); - if (command == null) + //var command = await _repository.GetByIdAsync(commandId); + //if (command == null) + //{ + // throw new Exception(GlobalMessages.CommandNotFound); + //} + var raw_data = await _repository.GetByIdAsync(commandId); + if (raw_data == null) { throw new Exception(GlobalMessages.CommandNotFound); } - - var data = await _commandReportRepository.GetCommandType15AttachmentAsync(commandId); - - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"29-คำสั่งให้ช่วยราชการ-2.trdp"); - - ReportPackager reportPackager = new ReportPackager(); - Telerik.Reporting.Report? report = null; - using (var sourceStream = System.IO.File.OpenRead(rptFile)) + var command = new { - report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); - } - - var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["table1"]; - - tblData.DataSource = data; - - report.ReportParameters["IssuerOrganizationName"].Value = command.IssuerOrganizationName; - report.ReportParameters["CommandNo"].Value = command.CommandNo.ToThaiNumber(); - report.ReportParameters["CommandYear"].Value = command.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(); - report.ReportParameters["CommandExecuteDate"].Value = command.CommandExcecuteDate == null ? "" : command.CommandExcecuteDate.Value.ToThaiFullDate2().ToThaiNumber(); - - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report + CommandNo = raw_data.CommandNo.ToThaiNumber(), + CommandYear = raw_data.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(), + IssuerOrganizationName = raw_data.IssuerOrganizationName, + CommandExcecuteDate = raw_data.CommandExcecuteDate != null ? raw_data.CommandExcecuteDate.Value.ToThaiFullDate3().ToThaiNumber() : "-", }; + var data = await _commandReportRepository.GetCommandType15AttachmentAsync(commandId); + return new + { + CommandNo = command.CommandNo, + CommandYear = command.CommandYear, + IssuerOrganizationName = command.IssuerOrganizationName, + CommandExcecuteDate = command.CommandExcecuteDate, + data = data, + }; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"29-คำสั่งให้ช่วยราชการ-2.trdp"); - var content = result.DocumentBytes; + //ReportPackager reportPackager = new ReportPackager(); + //Telerik.Reporting.Report? report = null; + //using (var sourceStream = System.IO.File.OpenRead(rptFile)) + //{ + // report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); + //} - return content; + //var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["table1"]; + + //tblData.DataSource = data; + + //report.ReportParameters["IssuerOrganizationName"].Value = command.IssuerOrganizationName; + //report.ReportParameters["CommandNo"].Value = command.CommandNo.ToThaiNumber(); + //report.ReportParameters["CommandYear"].Value = command.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(); + //report.ReportParameters["CommandExecuteDate"].Value = command.CommandExcecuteDate == null ? "" : command.CommandExcecuteDate.Value.ToThaiFullDate2().ToThaiNumber(); + + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; + + + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); + + //var content = result.DocumentBytes; + + //return content; } catch { @@ -1670,7 +1819,7 @@ namespace BMA.EHR.Report.Service.Controllers #region " C-PM-16 " - private async Task GenerateCommandReportType16_Cover(Guid commandId, string exportType) + private async Task GenerateCommandReportType16_Cover(Guid commandId, string exportType) { try { @@ -1702,34 +1851,34 @@ namespace BMA.EHR.Report.Service.Controllers //}; var data = await _commandReportRepository.GetCommandType16Async(commandId); + return data; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"30-คำสั่งส่งตัวกลับไปปฏิบัติงานทางต้นสังกัดเดิม.trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"30-คำสั่งส่งตัวกลับไปปฏิบัติงานทางต้นสังกัดเดิม.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); + //} - 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 = data; - report.DataSource = data; + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + //if (exportType == "docx") + // deviceInfo["OutputFormat"] = "DOCX"; - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - if (exportType == "docx") - deviceInfo["OutputFormat"] = "DOCX"; - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); - var content = result.DocumentBytes; + //var content = result.DocumentBytes; - return content; + //return content; } catch { @@ -1741,7 +1890,7 @@ namespace BMA.EHR.Report.Service.Controllers #region " C-PM-17 " - private async Task GenerateCommandReportType17_Cover(Guid commandId, string exportType) + private async Task GenerateCommandReportType17_Cover(Guid commandId, string exportType) { try { @@ -1770,34 +1919,34 @@ namespace BMA.EHR.Report.Service.Controllers AuthorizedPosition = raw_data.AuthorizedPosition, Subject = $"เรื่อง {raw_data.CommandSubject}", }; + return command; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"34-คำสั่งอนุญาตให้ข้าราชการลาออกจากราชการ-4.trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"34-คำสั่งอนุญาตให้ข้าราชการลาออกจากราชการ-4.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); + //} - 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 = command; - report.DataSource = command; + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + //if (exportType == "docx") + // deviceInfo["OutputFormat"] = "DOCX"; - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - if (exportType == "docx") - deviceInfo["OutputFormat"] = "DOCX"; - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); - var content = result.DocumentBytes; + //var content = result.DocumentBytes; - return content; + //return content; } catch { @@ -1805,7 +1954,7 @@ namespace BMA.EHR.Report.Service.Controllers } } - private async Task GenerateCommandReportType17_Attachment(Guid commandId, string exportType) + private async Task GenerateCommandReportType17_Attachment(Guid commandId, string exportType) { try { @@ -1816,39 +1965,39 @@ namespace BMA.EHR.Report.Service.Controllers } var data = await _commandReportRepository.GetCommandType17AttachmentAsync(commandId); + return data; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"34-คำสั่งอนุญาตให้ข้าราชการลาออกจากราชการ-5.trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"34-คำสั่งอนุญาตให้ข้าราชการลาออกจากราชการ-5.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); + //} - ReportPackager reportPackager = new ReportPackager(); - Telerik.Reporting.Report? report = null; - using (var sourceStream = System.IO.File.OpenRead(rptFile)) - { - report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); - } + //var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["table1"]; - var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["table1"]; + //tblData.DataSource = data; - tblData.DataSource = data; + //report.ReportParameters["IssuerOrganizationName"].Value = command.IssuerOrganizationName; + //report.ReportParameters["CommandNo"].Value = command.CommandNo.ToThaiNumber(); + //report.ReportParameters["CommandYear"].Value = command.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(); + //report.ReportParameters["CommandExecuteDate"].Value = command.CommandExcecuteDate == null ? "" : command.CommandExcecuteDate.Value.ToThaiFullDate2().ToThaiNumber(); - report.ReportParameters["IssuerOrganizationName"].Value = command.IssuerOrganizationName; - report.ReportParameters["CommandNo"].Value = command.CommandNo.ToThaiNumber(); - report.ReportParameters["CommandYear"].Value = command.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(); - report.ReportParameters["CommandExecuteDate"].Value = command.CommandExcecuteDate == null ? "" : command.CommandExcecuteDate.Value.ToThaiFullDate2().ToThaiNumber(); + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); - var content = result.DocumentBytes; + //var content = result.DocumentBytes; - return content; + //return content; } catch { @@ -1860,7 +2009,7 @@ namespace BMA.EHR.Report.Service.Controllers #region " C-PM-18 " - private async Task GenerateCommandReportType18_Cover(Guid commandId, string exportType) + private async Task GenerateCommandReportType18_Cover(Guid commandId, string exportType) { try { @@ -1871,31 +2020,31 @@ namespace BMA.EHR.Report.Service.Controllers } var data = await _commandReportRepository.GetCommandType18Async(commandId); + return data; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"37-คำสั่งให้ออกจากราชการ.trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"37-คำสั่งให้ออกจากราชการ.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); + //} - 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 = data; - report.DataSource = data; + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); + //var content = result.DocumentBytes; - var content = result.DocumentBytes; - - return content; + //return content; } catch { @@ -2093,7 +2242,7 @@ namespace BMA.EHR.Report.Service.Controllers #region " C-PM-21 " - private async Task GenerateCommandReportType21_Cover(Guid commandId, string exportType) + private async Task GenerateCommandReportType21_Cover(Guid commandId, string exportType) { try { @@ -2123,40 +2272,40 @@ namespace BMA.EHR.Report.Service.Controllers Subject = $"เรื่อง {raw_data.CommandSubject}", }; + return command; + //var receiver = await _commandReportRepository.GetCommandType21AttachmentAsync(commandId); - var receiver = await _commandReportRepository.GetCommandType21AttachmentAsync(commandId); + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"20-คำสั่งแต่งตั้งลูกจ้างชั่วคราวเป็นลูกจ้างประจำ-2.trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"20-คำสั่งแต่งตั้งลูกจ้างชั่วคราวเป็นลูกจ้างประจำ-2.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); + //} - 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 = command; - report.DataSource = command; + //var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["table1"]; - var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["table1"]; + //tblData.DataSource = receiver; - tblData.DataSource = receiver; + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + //if (exportType == "docx") + // deviceInfo["OutputFormat"] = "DOCX"; - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - if (exportType == "docx") - deviceInfo["OutputFormat"] = "DOCX"; - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); - var content = result.DocumentBytes; + //var content = result.DocumentBytes; - return content; + //return content; } catch { @@ -2168,7 +2317,7 @@ namespace BMA.EHR.Report.Service.Controllers #region " C-PM-22 " - private async Task GenerateCommandReportType22_Cover(Guid commandId, string exportType) + private async Task GenerateCommandReportType22_Cover(Guid commandId, string exportType) { try { @@ -2199,34 +2348,34 @@ namespace BMA.EHR.Report.Service.Controllers // ConclusionReturnDate = raw_data.ConclusionReturnDate == null ? "" : raw_data.ConclusionReturnDate.Value.ToThaiFullDate3().ToThaiNumber(), Subject = $"เรื่อง {raw_data.CommandSubject}", }; + return command; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"คำสั่งแต่งตั้งลูกจ้างประจำ(ปรับระดับชั้นงาน).trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"คำสั่งแต่งตั้งลูกจ้างประจำ(ปรับระดับชั้นงาน).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); + //} - 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 = command; - report.DataSource = command; + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + //if (exportType == "docx") + // deviceInfo["OutputFormat"] = "DOCX"; - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - if (exportType == "docx") - deviceInfo["OutputFormat"] = "DOCX"; - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); - var content = result.DocumentBytes; + //var content = result.DocumentBytes; - return content; + //return content; } catch { @@ -2234,7 +2383,7 @@ namespace BMA.EHR.Report.Service.Controllers } } - private async Task GenerateCommandReportType22_Attachment(Guid commandId, string exportType) + private async Task GenerateCommandReportType22_Attachment(Guid commandId, string exportType) { try { @@ -2245,39 +2394,39 @@ namespace BMA.EHR.Report.Service.Controllers } var data = await _commandReportRepository.GetCommandType22AttachmentAsync(commandId); + return data; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"คำสั่งแต่งตั้งลูกจ้างประจำ(ปรับระดับชั้นงาน)-แนบท้าย.trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"คำสั่งแต่งตั้งลูกจ้างประจำ(ปรับระดับชั้นงาน)-แนบท้าย.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); + //} - ReportPackager reportPackager = new ReportPackager(); - Telerik.Reporting.Report? report = null; - using (var sourceStream = System.IO.File.OpenRead(rptFile)) - { - report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); - } + //var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["tblData"]; - var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["tblData"]; + //tblData.DataSource = data; - tblData.DataSource = data; + //report.ReportParameters["IssuerOrganizationName"].Value = command.IssuerOrganizationName; + //report.ReportParameters["CommandNo"].Value = command.CommandNo.ToThaiNumber(); + //report.ReportParameters["CommandYear"].Value = command.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(); + //report.ReportParameters["CommandExecuteDate"].Value = command.CommandExcecuteDate == null ? "" : command.CommandExcecuteDate.Value.ToThaiFullDate2().ToThaiNumber(); - report.ReportParameters["IssuerOrganizationName"].Value = command.IssuerOrganizationName; - report.ReportParameters["CommandNo"].Value = command.CommandNo.ToThaiNumber(); - report.ReportParameters["CommandYear"].Value = command.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(); - report.ReportParameters["CommandExecuteDate"].Value = command.CommandExcecuteDate == null ? "" : command.CommandExcecuteDate.Value.ToThaiFullDate2().ToThaiNumber(); + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); - var content = result.DocumentBytes; + //var content = result.DocumentBytes; - return content; + //return content; } catch { @@ -2288,7 +2437,7 @@ namespace BMA.EHR.Report.Service.Controllers #region " C-PM-23 " - private async Task GenerateCommandReportType23_Cover(Guid commandId, string exportType) + private async Task GenerateCommandReportType23_Cover(Guid commandId, string exportType) { try { @@ -2318,40 +2467,40 @@ namespace BMA.EHR.Report.Service.Controllers Subject = $"เรื่อง {raw_data.CommandSubject}", }; + return command; + //var receiver = await _commandReportRepository.GetCommandType23AttachmentAsync(commandId); - var receiver = await _commandReportRepository.GetCommandType23AttachmentAsync(commandId); + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"35-คำสั่งอนุญาตให้ลูกจ้างลาออก.trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"35-คำสั่งอนุญาตให้ลูกจ้างลาออก.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); + //} - 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 = command; - report.DataSource = command; + //var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["table1"]; - var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["table1"]; + //tblData.DataSource = receiver; - tblData.DataSource = receiver; + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + //if (exportType == "docx") + // deviceInfo["OutputFormat"] = "DOCX"; - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - if (exportType == "docx") - deviceInfo["OutputFormat"] = "DOCX"; - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); - var content = result.DocumentBytes; + //var content = result.DocumentBytes; - return content; + //return content; } catch { @@ -2363,7 +2512,7 @@ namespace BMA.EHR.Report.Service.Controllers #region " C-PM-24 " - private async Task GenerateCommandReportType24_Cover(Guid commandId, string exportType) + private async Task GenerateCommandReportType24_Cover(Guid commandId, string exportType) { try { @@ -2396,34 +2545,34 @@ namespace BMA.EHR.Report.Service.Controllers // ConclusionReturnDate = raw_data.ConclusionReturnDate == null ? "" : raw_data.ConclusionReturnDate.Value.ToThaiFullDate3().ToThaiNumber(), Subject = $"เรื่อง {raw_data.CommandSubject}", }; + return command; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"คำสั่งแต่งตั้งลูกจ้างประจำ(ย้าย).trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"คำสั่งแต่งตั้งลูกจ้างประจำ(ย้าย).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); + //} - 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 = command; - report.DataSource = command; + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + //if (exportType == "docx") + // deviceInfo["OutputFormat"] = "DOCX"; - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - if (exportType == "docx") - deviceInfo["OutputFormat"] = "DOCX"; - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); - var content = result.DocumentBytes; + //var content = result.DocumentBytes; - return content; + //return content; } catch { @@ -2431,7 +2580,7 @@ namespace BMA.EHR.Report.Service.Controllers } } - private async Task GenerateCommandReportType24_Attachment(Guid commandId, string exportType) + private async Task GenerateCommandReportType24_Attachment(Guid commandId, string exportType) { try { @@ -2442,39 +2591,39 @@ namespace BMA.EHR.Report.Service.Controllers } var data = await _commandReportRepository.GetCommandType24AttachmentAsync(commandId); + return data; + //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"คำสั่งแต่งตั้งลูกจ้างประจำ(ย้าย)-แนบท้าย.trdp"); - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"คำสั่งแต่งตั้งลูกจ้างประจำ(ย้าย)-แนบท้าย.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); + //} - ReportPackager reportPackager = new ReportPackager(); - Telerik.Reporting.Report? report = null; - using (var sourceStream = System.IO.File.OpenRead(rptFile)) - { - report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); - } + //var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["tblData"]; - var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["tblData"]; + //tblData.DataSource = data; - tblData.DataSource = data; + //report.ReportParameters["IssuerOrganizationName"].Value = command.IssuerOrganizationName; + //report.ReportParameters["CommandNo"].Value = command.CommandNo.ToThaiNumber(); + //report.ReportParameters["CommandYear"].Value = command.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(); + //report.ReportParameters["CommandExecuteDate"].Value = command.CommandExcecuteDate == null ? "" : command.CommandExcecuteDate.Value.ToThaiFullDate2().ToThaiNumber(); - report.ReportParameters["IssuerOrganizationName"].Value = command.IssuerOrganizationName; - report.ReportParameters["CommandNo"].Value = command.CommandNo.ToThaiNumber(); - report.ReportParameters["CommandYear"].Value = command.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(); - report.ReportParameters["CommandExecuteDate"].Value = command.CommandExcecuteDate == null ? "" : command.CommandExcecuteDate.Value.ToThaiFullDate2().ToThaiNumber(); + //System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report - }; + //InstanceReportSource instanceReportSource = new InstanceReportSource() + //{ + // ReportDocument = report + //}; - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); + //ReportProcessor reportProcessor = new ReportProcessor(_configuration); + //RenderingResult result = reportProcessor.RenderReport(exportType, instanceReportSource, deviceInfo); - var content = result.DocumentBytes; + //var content = result.DocumentBytes; - return content; + //return content; } catch { @@ -2521,11 +2670,11 @@ namespace BMA.EHR.Report.Service.Controllers RefRaw = raw_data.RefRaw == null ? "" : raw_data.RefRaw.ToThaiNumber(), Result = raw_data.Result == null ? "" : raw_data.Result.ToThaiNumber(), - Fullname = raw_data_profile == null ? "" : raw_data_profile.fullName, - Positionname = raw_data_profile == null ? "" : raw_data_profile.positionname, - Positionno = raw_data_profile == null ? "" : raw_data_profile.positionno.ToThaiNumber(), - Organizationname = raw_data_profile == null ? "" : raw_data_profile.organizationname.ToThaiNumber(), - Salary = raw_data_profile == null ? "" : raw_data_profile.salary.ToThaiNumber(), + Fullname = raw_data_profile == null ? "" : raw_data_profile.fullName != null ? raw_data_profile.fullName : "-", + Positionname = raw_data_profile == null ? "" : raw_data_profile.positionname != null ? raw_data_profile.positionname : "-", + Positionno = raw_data_profile == null ? "" : raw_data_profile.positionno != null ? raw_data_profile.positionno.ToThaiNumber() : "-", + Organizationname = raw_data_profile == null ? "" : raw_data_profile.organizationname != null ? raw_data_profile.organizationname.ToThaiNumber() : "-", + Salary = raw_data_profile == null ? "" : raw_data_profile.salary != null ? raw_data_profile.salary.ToThaiNumber() : "-", OrderDate = raw_data.CommandAffectDate == null ? "" : raw_data.CommandAffectDate.Value.ToThaiFullDate3().ToThaiNumber(), SignatoryBy = raw_data.AuthorizedUserFullName, @@ -2543,6 +2692,7 @@ namespace BMA.EHR.Report.Service.Controllers } #endregion + #region " C-PM-33 " private async Task GenerateCommandReportType33_Cover(Guid commandId, string exportType) @@ -2640,7 +2790,14 @@ namespace BMA.EHR.Report.Service.Controllers throw new Exception(GlobalMessages.CommandNotFound); var contentData = await GenerateCommandReportType01_Cover(id, exportType); - return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-01", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -2679,7 +2836,14 @@ namespace BMA.EHR.Report.Service.Controllers } var contentData = await GenerateCommandReportType01_Attachment(id, exportType); - return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-01", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -2722,8 +2886,14 @@ namespace BMA.EHR.Report.Service.Controllers throw new Exception(GlobalMessages.CommandNotFound); var contentData = await GenerateCommandReportType02_Cover(id, exportType); - return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); - + //return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-02", + reportName = "docx-report", + data = contentData + }; + return Success(data); //var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"02-คำสั่งบรรจุและแต่งตั้งผู้ได้รับคัดเลือก-3.trdp"); //var contentData = _reportGenerator.GenerateReport(rptFile, exportType); @@ -2767,7 +2937,14 @@ namespace BMA.EHR.Report.Service.Controllers } var contentData = await GenerateCommandReportType02_Attachment(id, exportType); - return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-02", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -2810,7 +2987,14 @@ namespace BMA.EHR.Report.Service.Controllers throw new Exception(GlobalMessages.CommandNotFound); var contentData = await GenerateCommandReportType03_Cover(id, exportType); - return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-03", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -2849,7 +3033,14 @@ namespace BMA.EHR.Report.Service.Controllers } var contentData = await GenerateCommandReportType03_Attachment(id, exportType); - return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-03", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -2892,7 +3083,14 @@ namespace BMA.EHR.Report.Service.Controllers throw new Exception(GlobalMessages.CommandNotFound); var contentData = await GenerateCommandReportType04_Cover(id, exportType); - return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-04", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -2931,7 +3129,14 @@ namespace BMA.EHR.Report.Service.Controllers } var contentData = await GenerateCommandReportType04_Attachment(id, exportType); - return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-04", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -2974,7 +3179,14 @@ namespace BMA.EHR.Report.Service.Controllers throw new Exception(GlobalMessages.CommandNotFound); var contentData = await GenerateCommandReportType05_Cover(id, exportType); - return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-05", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -3013,7 +3225,14 @@ namespace BMA.EHR.Report.Service.Controllers } var contentData = await GenerateCommandReportType05_Attachment(id, exportType); - return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-05-attachment", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -3056,7 +3275,14 @@ namespace BMA.EHR.Report.Service.Controllers throw new Exception(GlobalMessages.CommandNotFound); var contentData = await GenerateCommandReportType06_Cover(id, exportType); - return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-06", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -3095,7 +3321,14 @@ namespace BMA.EHR.Report.Service.Controllers } var contentData = await GenerateCommandReportType06_Attachment(id, exportType); - return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-06-attachment", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -3138,7 +3371,14 @@ namespace BMA.EHR.Report.Service.Controllers throw new Exception(GlobalMessages.CommandNotFound); var contentData = await GenerateCommandReportType07_Cover(id, exportType); - return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-07", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -3177,7 +3417,14 @@ namespace BMA.EHR.Report.Service.Controllers } var contentData = await GenerateCommandReportType07_Attachment(id, exportType); - return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-07-attachment", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -3220,7 +3467,14 @@ namespace BMA.EHR.Report.Service.Controllers throw new Exception(GlobalMessages.CommandNotFound); var contentData = await GenerateCommandReportType08_Cover(id, exportType); - return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-08", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -3259,7 +3513,14 @@ namespace BMA.EHR.Report.Service.Controllers throw new Exception(GlobalMessages.CommandNotFound); var contentData = await GenerateCommandReportType08_Attachment(id, exportType); - return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-08-attachment", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -3302,7 +3563,14 @@ namespace BMA.EHR.Report.Service.Controllers throw new Exception(GlobalMessages.CommandNotFound); var contentData = await GenerateCommandReportType09_Cover(id, exportType); - return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-09", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -3341,7 +3609,14 @@ namespace BMA.EHR.Report.Service.Controllers throw new Exception(GlobalMessages.CommandNotFound); var contentData = await GenerateCommandReportType09_Attachment(id, exportType); - return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-09-attachment", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -3384,7 +3659,14 @@ namespace BMA.EHR.Report.Service.Controllers throw new Exception(GlobalMessages.CommandNotFound); var contentData = await GenerateCommandReportType10_Cover(id, exportType); - return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-10", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -3427,7 +3709,17 @@ namespace BMA.EHR.Report.Service.Controllers throw new Exception(GlobalMessages.CommandNotFound); var contentData = await GenerateCommandReportType11_Cover(id, exportType); - return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-11", + reportName = "docx-report", + data = new + { + data = contentData + } + }; + return Success(data); } catch { @@ -3470,7 +3762,17 @@ namespace BMA.EHR.Report.Service.Controllers throw new Exception(GlobalMessages.CommandNotFound); var contentData = await GenerateCommandReportType12_Cover(id, exportType); - return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-12", + reportName = "docx-report", + data = new + { + data = contentData + } + }; + return Success(data); } catch { @@ -3513,7 +3815,14 @@ namespace BMA.EHR.Report.Service.Controllers throw new Exception(GlobalMessages.CommandNotFound); var contentData = await GenerateCommandReportType13_Cover(id, exportType); - return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-13", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -3552,7 +3861,14 @@ namespace BMA.EHR.Report.Service.Controllers } var contentData = await GenerateCommandReportType13_Attachment(id, exportType); - return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-13-attachment", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -3595,7 +3911,14 @@ namespace BMA.EHR.Report.Service.Controllers throw new Exception(GlobalMessages.CommandNotFound); var contentData = await GenerateCommandReportType14_Cover(id, exportType); - return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-14", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -3634,7 +3957,14 @@ namespace BMA.EHR.Report.Service.Controllers } var contentData = await GenerateCommandReportType14_Attachment(id, exportType); - return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-14-attachment", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -3677,7 +4007,14 @@ namespace BMA.EHR.Report.Service.Controllers throw new Exception(GlobalMessages.CommandNotFound); var contentData = await GenerateCommandReportType15_Cover(id, exportType); - return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-15", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -3716,7 +4053,14 @@ namespace BMA.EHR.Report.Service.Controllers } var contentData = await GenerateCommandReportType15_Attachment(id, exportType); - return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-15-attachment", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -3759,7 +4103,18 @@ namespace BMA.EHR.Report.Service.Controllers throw new Exception(GlobalMessages.CommandNotFound); var contentData = await GenerateCommandReportType16_Cover(id, exportType); - return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + + var data = new + { + template = "C-PM-16", + reportName = "docx-report", + data = new + { + data = contentData + } + }; + return Success(data); } catch { @@ -3802,7 +4157,14 @@ namespace BMA.EHR.Report.Service.Controllers throw new Exception(GlobalMessages.CommandNotFound); var contentData = await GenerateCommandReportType17_Cover(id, exportType); - return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-17", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -3841,7 +4203,14 @@ namespace BMA.EHR.Report.Service.Controllers throw new Exception(GlobalMessages.CommandNotFound); var contentData = await GenerateCommandReportType17_Attachment(id, exportType); - return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-17", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -3884,7 +4253,17 @@ namespace BMA.EHR.Report.Service.Controllers throw new Exception(GlobalMessages.CommandNotFound); var contentData = await GenerateCommandReportType18_Cover(id, exportType); - return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-18", + reportName = "docx-report", + data = new + { + data = contentData + } + }; + return Success(data); } catch { @@ -4055,7 +4434,14 @@ namespace BMA.EHR.Report.Service.Controllers throw new Exception(GlobalMessages.CommandNotFound); var contentData = await GenerateCommandReportType21_Cover(id, exportType); - return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-21", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -4098,7 +4484,14 @@ namespace BMA.EHR.Report.Service.Controllers throw new Exception(GlobalMessages.CommandNotFound); var contentData = await GenerateCommandReportType22_Cover(id, exportType); - return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-22", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -4137,7 +4530,14 @@ namespace BMA.EHR.Report.Service.Controllers } var contentData = await GenerateCommandReportType22_Attachment(id, exportType); - return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-22", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -4180,7 +4580,14 @@ namespace BMA.EHR.Report.Service.Controllers throw new Exception(GlobalMessages.CommandNotFound); var contentData = await GenerateCommandReportType23_Cover(id, exportType); - return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-23", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -4223,7 +4630,14 @@ namespace BMA.EHR.Report.Service.Controllers throw new Exception(GlobalMessages.CommandNotFound); var contentData = await GenerateCommandReportType24_Cover(id, exportType); - return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-24", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -4262,7 +4676,14 @@ namespace BMA.EHR.Report.Service.Controllers } var contentData = await GenerateCommandReportType24_Attachment(id, exportType); - return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + //return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "C-PM-24", + reportName = "docx-report", + data = contentData + }; + return Success(data); } catch { @@ -4334,6 +4755,7 @@ namespace BMA.EHR.Report.Service.Controllers } } #endregion + #region " C-PM-26 คำสั่งให้ออกจากราชการไว้ก่อนxxxx " /// @@ -4396,6 +4818,7 @@ namespace BMA.EHR.Report.Service.Controllers } } #endregion + #region " C-PM-27 คำสั่งลงโทษ ภาคทัณฑ์ " /// @@ -4458,6 +4881,7 @@ namespace BMA.EHR.Report.Service.Controllers } } #endregion + #region " C-PM-28 คำสั่งลงโทษ ตัดเงินเดือน " /// @@ -4520,6 +4944,7 @@ namespace BMA.EHR.Report.Service.Controllers } } #endregion + #region " C-PM-29 คำสั่งลงโทษ ลดขั้นเงินเดือน " /// @@ -4582,6 +5007,7 @@ namespace BMA.EHR.Report.Service.Controllers } } #endregion + #region " C-PM-30 คำสั่งเพิ่มโทษ " /// @@ -4644,6 +5070,7 @@ namespace BMA.EHR.Report.Service.Controllers } } #endregion + #region " C-PM-31 คำสั่งงดโทษ " /// @@ -4706,6 +5133,7 @@ namespace BMA.EHR.Report.Service.Controllers } } #endregion + #region " C-PM-32 คำสั่งยุติเรื่อง " /// @@ -4768,6 +5196,7 @@ namespace BMA.EHR.Report.Service.Controllers } } #endregion + #region " C-PM-33 คำสั่งยุติเรื่อง " /// @@ -4814,6 +5243,7 @@ namespace BMA.EHR.Report.Service.Controllers } } #endregion + #region " C-PM-34 คำสั่งยุติเรื่อง " /// @@ -4860,6 +5290,7 @@ namespace BMA.EHR.Report.Service.Controllers } } #endregion + #region " C-PM-35 คำสั่งยุติเรื่อง " /// @@ -4906,6 +5337,7 @@ namespace BMA.EHR.Report.Service.Controllers } } #endregion + #region " C-PM-36 คำสั่งยุติเรื่อง " /// @@ -4952,6 +5384,7 @@ namespace BMA.EHR.Report.Service.Controllers } } #endregion + #region " C-PM-37 คำสั่งยุติเรื่อง " /// @@ -4998,6 +5431,7 @@ namespace BMA.EHR.Report.Service.Controllers } } #endregion + #endregion } }