5 changed files with 160 additions and 35 deletions
-
15src/Shentun.Peis.Application.Contracts/Reports/PrintReportDto.cs
-
15src/Shentun.Peis.Application.Contracts/Reports/UploadPdfDto.cs
-
45src/Shentun.Peis.Application/ReportFormatTemplates/ReportFormatTemplateAppService.cs
-
76src/Shentun.Peis.Application/Reports/ReportAppService.cs
-
42src/Shentun.Peis.Domain/FileHelper.cs
@ -0,0 +1,15 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
using Shentun.Peis.ReportFormatTemplates; |
|||
using Shentun.Peis.ReportPrinters; |
|||
|
|||
namespace Shentun.Peis.Reports |
|||
{ |
|||
public class PrintReportDto |
|||
{ |
|||
public ReportFormatTemplateDto reportFormatTemplate { get; set; } |
|||
|
|||
public ReportPrinterDto reportPrinter { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
|
|||
namespace Shentun.Peis.Reports |
|||
{ |
|||
public class UploadPdfDto |
|||
{ |
|||
public string File { get; set; } |
|||
|
|||
public string ReportId { get; set; } |
|||
|
|||
public string PatientId { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,42 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.IO; |
|||
using System.Linq; |
|||
using System.Resources; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using static OpenIddict.Abstractions.OpenIddictConstants; |
|||
|
|||
namespace Shentun.Peis |
|||
{ |
|||
public class FileHelper |
|||
{ |
|||
public static bool IsBase64String(string input) |
|||
{ |
|||
input = input.Trim(); |
|||
return (input.Length % 4 == 0) && |
|||
System.Text.RegularExpressions.Regex.IsMatch(input, @"^[a-zA-Z0-9\+/]*={0,2}$", System.Text.RegularExpressions.RegexOptions.None); |
|||
} |
|||
public static async Task<string> Base64StringConvertPDF(string file,string fileName) |
|||
{ |
|||
Task<String> task = Task.Factory.StartNew<String>(() => |
|||
{ |
|||
string base64BinaryStr = file; |
|||
if (!IsBase64String(base64BinaryStr)) return "非法字符串,不是BASE64"; |
|||
byte[] bytes = Convert.FromBase64String(base64BinaryStr); |
|||
|
|||
using (var stream = new FileStream(fileName, FileMode.CreateNew)) |
|||
{ |
|||
using (var writer = new BinaryWriter(stream)) |
|||
{ |
|||
writer.Write(bytes, 0, bytes.Length); |
|||
} |
|||
} |
|||
return "Success"; |
|||
|
|||
}); |
|||
String result= await task; |
|||
return result; |
|||
} |
|||
} |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue