Commit df44949d by zim78

no message

0 parents
# The 5 approved on boarding samples that need wwwroot/lib/ can add a local .gitignore that allows wwwroot/lib/.
# with 2.1 templates and excluding .min & .map -> 27 files and < 1 KB
# 3.0 templates should be even less
# wwwroot/lib/
# When wwwroot/lib/ is commented out, excluse .min and .map files
*.min.css
*.min.js
*.map
_build/
_site/
Properties/
# See #577
# Use git add -f to force override .sln when required. Not needed in most cases.
# git add -f myProj.sln
*.sln
Project_Readme.html
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
.vscode/
!.vscode/extensions.json
!.vscode/settings.json
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
build/
bld/
[Bb]in/
[Oo]bj/
# Visual Studo 2015 cache/options directory
.vs/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile
# Visual Studio profiler
*.psess
*.vsp
*.vspx
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding addin-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
_NCrunch_*
.*crunch*.local.xml
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# TODO: Comment the next line if you want to checkin your web deploy settings
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
# Windows Azure Build Output
csx/
*.build.csdef
# Windows Store app package directory
AppPackages/
# Others
*.[Cc]ache
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.pfx
*.publishsettings
node_modules/
bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
*.mdf
*.ldf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
# Microsoft Fakes
FakesAssemblies/
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
project.lock.json
__pycache__/
#Mac OSX
.DS_Store
# Windows thumbnail cache files
Thumbs.db
MTAntiFake/.config/dotnet-tools.json
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PDFExportOpri_CLI
{
public class AutoModifyReprtClass
{
}
}
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<RootNamespace>PDFExportOpri_CLI</RootNamespace>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<OutputPath>..\PdfExportOpri\bin\Debug</OutputPath>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="DevExpress.Reporting.Core" Version="20.1.3" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="SqlSugarCore" Version="5.0.5.2" />
<PackageReference Include="System.Diagnostics.Debug" Version="4.3.0" />
<PackageReference Include="System.IO.FileSystem" Version="4.3.0" />
<PackageReference Include="System.IO.FileSystem.Primitives" Version="4.3.0" />
<PackageReference Include="System.Net.NameResolution" Version="4.3.0" />
<PackageReference Include="System.Net.Primitives" Version="4.3.1" />
<PackageReference Include="System.Threading" Version="4.3.0" />
<PackageReference Include="System.Threading.ThreadPool" Version="4.3.0" />
</ItemGroup>
<ItemGroup>
<None Update="bmp\fm10.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="bmp\fm12.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="bmp\fm14.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="bmp\fm16.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="bmp\fm4.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="bmp\fm6.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="bmp\fm8.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="bmp\noimage.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="bmp\top.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="cli-appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
namespace PDFExportOpri_CLI.Modules.PdfExport
{
partial class ReportPrinter
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
this.Detail = new DevExpress.XtraReports.UI.DetailBand();
this.TopMargin = new DevExpress.XtraReports.UI.TopMarginBand();
this.BottomMargin = new DevExpress.XtraReports.UI.BottomMarginBand();
((System.ComponentModel.ISupportInitialize)(this)).BeginInit();
this.TopMargin.Height = 100;
this.BottomMargin.Height = 100;
this.Bands.AddRange(new DevExpress.XtraReports.UI.Band[] {
this.Detail,
this.TopMargin,
this.BottomMargin});
((System.ComponentModel.ISupportInitialize)(this)).EndInit();
}
#endregion
private DevExpress.XtraReports.UI.DetailBand Detail;
private DevExpress.XtraReports.UI.TopMarginBand TopMargin;
private DevExpress.XtraReports.UI.BottomMarginBand BottomMargin;
}
}
{
"Database": {
"Host": "beta.360cbs.com",
"Port": "8100",
"Name": "mtmaster",
"Username": "root",
"Password": "mysql.beta.360cbs"
},
"RPC": {
"WebHost": "http://admin.evaluate.alpha.360cbs.com:9090"
},
"AppSetting": {
"Debug": true
}
}
{
"runtimeOptions": {
"configProperties": { "System.Drawing.EnableUnixSupport": true }
}
}
\ No newline at end of file
{
"version": 1,
"isRoot": true,
"tools": {
"dotnet-ef": {
"version": "6.0.1",
"commands": [
"dotnet-ef"
]
}
}
}
\ No newline at end of file
using System;
using Zircon.Base.Exceptions;
namespace PdfExportOpri.Common
{
public class BaseException : HttpException
{
public void SetException(int code, string number, string message)
{
this.HttpCode = code;
this.Number = number;
this.ErrorMessage = message;
}
}
}
\ No newline at end of file
using System.Collections.Generic;
using System.Data;
using System.Security.Cryptography;
using System.Text;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Mvc.Controllers;
using Zircon.Base.Exceptions;
namespace PdfExportOpri.Common
{
public class CommonClass
{
public static Dictionary<string, object> DataRowToDictioniary(DataRow row)
{
Dictionary<string, object> dic = new Dictionary<string, object>();
for (int i = 0; i < row.ItemArray.Length; i++)
{
dic.Add(row.Table.Columns[i].ColumnName, row[i]);
}
return dic;
}
public static string Md5(string content)
{
//MD5类是抽象类
MD5 md5 = MD5.Create();
//需要将字符串转成字节数组
byte[] buffer = Encoding.Default.GetBytes(content);
//加密后是一个字节类型的数组,这里要注意编码UTF8/Unicode等的选择
byte[] md5buffer = md5.ComputeHash(buffer);
string str = null;
// 通过使用循环,将字节类型的数组转换为字符串,此字符串是常规字符格式化所得
foreach (byte b in md5buffer)
{
//得到的字符串使用十六进制类型格式。格式后的字符是小写的字母,如果使用大写(X)则格式后的字符是大写字符
//但是在和对方测试过程中,发现我这边的MD5加密编码,经常出现少一位或几位的问题;
//后来分析发现是 字符串格式符的问题, X 表示大写, x 表示小写,
//X2和x2表示不省略首位为0的十六进制数字;
str += b.ToString("x2");
}
return str;
}
public static string GetRequest(HttpContext context, string key, object defaultValue, bool isRequired = false)
{
var endpoint = context.Features.Get<IEndpointFeature>()?.Endpoint; ;
var methodInfo = context.GetEndpoint()?.Metadata.GetMetadata<ControllerActionDescriptor>().MethodInfo;
string method = context.Request.Method.ToUpper();
if (method == "POST" || method == "PUT" || method == "PATCH")
{
if (context.Request.HasFormContentType && context.Request.Form.ContainsKey(key)) return context.Request.Form[key].ToString();
}
else
{
if (context.Request.Query.ContainsKey(key)) return context.Request.Query[key].ToString();
}
if (isRequired) throw new ClientException();
return defaultValue.ToString();
}
}
}
using System;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using PdfExportOpri.Common;
using System.Diagnostics;
using System.IO;
using System.Threading.Tasks;
using Microsoft.Net.Http.Headers;
using Zircon.Base.Exceptions;
namespace PdfExportOpri.Modules.PdfExport
{
[ApiController]
public class PdfExportApi : ControllerBase
{
private readonly ILogger<PdfExportApi> _logger;
private readonly IConfiguration _config;
public PdfExportApi(ILogger<PdfExportApi> logger, IConfiguration config)
{
_logger = logger;
_config = config;
}
[HttpGet]
[Route("/pdf/web/api/v1/export")]
public async Task<FileResult> Get()
{
string id = CommonClass.GetRequest(HttpContext, "id", "", true);
ProcessStartInfo info = new ProcessStartInfo(OperatingSystem.IsWindows()?AppDomain.CurrentDomain.BaseDirectory+"./PDFExportOpri-CLI.exe": AppDomain.CurrentDomain.BaseDirectory + "./PDFExportOpri-CLI");
info.Arguments = $"{AppDomain.CurrentDomain.BaseDirectory}./output/ {id}";
info.RedirectStandardOutput = true;
info.RedirectStandardError = true;
Process p = new Process();
p.StartInfo = info;
p.Start();
await p.WaitForExitAsync();
if (p.ExitCode != 0)
throw new HttpException(){ErrorMessage =
p.StandardOutput.ReadToEnd(),
HttpCode = 500,
Number = "500.1"
};
Response.Headers.Add("Content-Disposition", "filename=export.pdf");
using (FileStream fsRead = new FileStream(AppDomain.CurrentDomain.BaseDirectory + $"./output/export_{id}.pdf", FileMode.Open))
{
int fsLen = (int)fsRead.Length;
byte[] heByte = new byte[fsLen];
int r = fsRead.Read(heByte, 0, heByte.Length);
Stream stream = new MemoryStream(heByte);
fsRead.Close();
System.IO.File.Delete(AppDomain.CurrentDomain.BaseDirectory + $"./output/export_{id}.pdf");
return new FileStreamResult(stream, "application/octet-stream");
}
// return new PhysicalFileResult(AppDomain.CurrentDomain.BaseDirectory + $"./output/export_{id}.pdf", "application/octet-stream");
}
}
}
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Sapphire.Core.Utils" Version="1.0.5" />
</ItemGroup>
<ItemGroup>
<Reference Include="Zircon.Base">
<HintPath>..\..\PdfExport\PdfExport\DLL\Zircon.Base.dll</HintPath>
</Reference>
<Reference Include="Zircon.Log">
<HintPath>..\..\PdfExport\PdfExport\DLL\Zircon.Log.dll</HintPath>
</Reference>
<Reference Include="Zircon.Log.File">
<HintPath>..\..\PdfExport\PdfExport\DLL\Zircon.Log.File.dll</HintPath>
</Reference>
<Reference Include="Zircon.Request">
<HintPath>..\..\PdfExport\PdfExport\DLL\Zircon.Request.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Folder Include="Modules\PdfExportAPI\" />
<Folder Include="Common\" />
</ItemGroup>
</Project>
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace PdfExportOpri
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureLogging((hostingContext, builder) =>
{
})
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
}
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Rewrite;
using Zircon.Base.Middlewares;
using Zircon.Request.Middlewares;
namespace PdfExportOpri
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddCors((cors) =>
{
cors.AddPolicy("AllowAll",
builder =>
{
builder.AllowAnyOrigin()
.AllowAnyHeader()
.AllowAnyMethod();
});
});
services.AddControllers();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseCors("AllowAll");
app.UseStaticFiles();
app.UseRewriter(new RewriteOptions()
.Add(context =>
{
if (context.HttpContext.Request.Path.Value.StartsWith("//"))
{
context.HttpContext.Request.Path = context.HttpContext.Request.Path.Value.Substring(1);
}
})
);
app.UseRouting();
app.UseExceptionMiddleware();
app.UseRequestLogMiddleware();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
}
}
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}
{
"Kestrel": {
"EndPoints": {
"Http": {
"Url": "http://0.0.0.0:5000"
}
}
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"Database": {
"Host": "beta.360cbs.com",
"Port": "8100",
"Name": "mtmaster",
"Username": "root",
"Password": "mysql.beta.360cbs"
},
"AppSetting": {
"Debug": true
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!