Skip to content

Commit

Permalink
1修正参数联动错误
Browse files Browse the repository at this point in the history
  • Loading branch information
NoneDay committed Mar 19, 2022
1 parent c2c5ca2 commit f8c79d5
Show file tree
Hide file tree
Showing 14 changed files with 545 additions and 112 deletions.
10 changes: 5 additions & 5 deletions end/reportWeb/Controllers/DesignController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private String getQueryValue(string name)
return null;
}
public async Task<IActionResult> Preview(String _content,String _ConnectionId,string reportName,
String _fresh_ds,String _fresh_params,bool _createFormParam,String _param_name)
String _fresh_ds,String _fresh_params,bool _createFormParam,String _param_name_)
{
List<String> calcDsNames = null;
List<String> calcGridNames = null;
Expand Down Expand Up @@ -178,7 +178,7 @@ public async Task<IActionResult> Preview(String _content,String _ConnectionId,st
if (_createFormParam == true)
{
exprFaced.addVariable("_createFormParam_", _createFormParam);
exprFaced.addVariable("_param_name_", _param_name);
exprFaced.addVariable("_param_name_", _param_name_);
}
exprFaced.addVariable("__page__", HttpContext.Request);
Engine engine = new Engine(reportDefine);
Expand Down Expand Up @@ -215,12 +215,12 @@ public async Task<IActionResult> Preview(String _content,String _ConnectionId,st
{
reportWeb.Pages.ReportModel.output_expection(cur_exception, Report.getEnv().logger, Report.getEnv());
StringBuilder sb = new StringBuilder();
while (cur_exception.InnerException != null)
do
{
sb.AppendLine(cur_exception.Message);
cur_exception = cur_exception.InnerException;
}
jsonWriter.Write(",\"error\":");
} while (cur_exception != null);
jsonWriter.Write(",\"errcode\":1,\"message\":");
jsonWriter.Write(JsonSerializer.Serialize(sb.ToString(), json_option));
}

Expand Down
379 changes: 379 additions & 0 deletions end/reportWeb/Controllers/PdfController.cs

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions end/reportWeb/Controllers/UserController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ public IActionResult test_login(String login_script,string test_user, string tes
ef.addVariable("__env__", new Env());
ef.addVariable("userid", test_user);
ef.addVariable("password", test_password);
var result = ef.addNewScopeForScript(login_script) as IDictionary<Object, Object>;
if (result == null)
return Json(new { errcode = 1, message = "测试失败", result = "不是正常返回对象,请仔细看说明要求" }, json_option);
var result = ef.addNewScopeForScript(login_script) as IDictionary<Object, Object>;
if(result == null)
return Json(new { errcode = 1, message = "测试失败", result="不是正常返回对象,请仔细看说明要求" }, json_option);
if (!"0".Equals(result["errcode"]?.ToString()))
{
return Json(new { errcode = 0, message = "测试成功", result }, json_option);
return Json(new { errcode = 1, message = "测试成功", result }, json_option);
}
return Json(new { errcode = 0, message = "测试成功", result }, json_option);
}
Expand Down
96 changes: 57 additions & 39 deletions end/reportWeb/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,24 @@

namespace reportWeb
{
public class Startup
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)
{

try
{//奇怪,会报错,但不影响
iText.Kernel.Font.PdfFontFactory.RegisterSystemDirectories();
}
catch {
}
//services.AddSingleton(HtmlEncoder.Create(System.Text.Unicode.UnicodeRanges.All));
CellReport.core.expr.ExprHelper.buildFuncMap();
//CellReport.core.expr.ExprHelper.AddFunc(typeof(CellReport.function.Func_md5));
Expand All @@ -81,24 +86,24 @@ public void ConfigureServices(IServiceCollection services)
})*/
.AddJwtBearer(JwtBearerDefaults.AuthenticationScheme, option =>
{
option.SaveToken = true;
option.SaveToken = true;
option.Events = new JwtBearerEvents()
{
OnMessageReceived = context =>
{
if(context.Request.Headers["Authorization"].ToString()=="" && context.Request.Cookies["access_token"]!=null)
context.Token = context.Request.Cookies["access_token"];
if (context.Request.Headers["Authorization"].ToString() == "" && context.Request.Cookies["access_token"] != null)
context.Token = context.Request.Cookies["access_token"];
return Task.CompletedTask;
},
OnChallenge= context =>
OnChallenge = context =>
{
context.HandleResponse();
context.Response.WriteAsJsonAsync(new { code = -1, message = "token过期" });
return Task.CompletedTask;
},
OnAuthenticationFailed = context =>
{

//ASP.NET Core Web Api之JWT刷新Token(三)
//https://blog.csdn.net/weixin_30483013/article/details/99642627?utm_medium=distribute.pc_relevant_download.none-task-blog-baidujs-1.nonecase&depth_1-utm_source=distribute.pc_relevant_download.none-task-blog-baidujs-1.nonecase
// 如果过期,则把<是否过期>添加到,返回头信息中
Expand All @@ -113,8 +118,21 @@ public void ConfigureServices(IServiceCollection services)
raw_token = raw_token.Substring("Bearer ".Length);
var tokenHandler = new System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler();
var token = tokenHandler.ReadJwtToken(raw_token);
if("refresh" != token.Claims.FirstOrDefault(x => x.Type == "token_type")?.Value)
context.Response.Headers.Add("Token-Expired", "true");
//var jwtConfig = context.HttpContext.RequestServices.GetService<JwtConfig>();
//tokenHandler.ValidateToken(raw_token, new TokenValidationParameters
//{
// ValidIssuer = jwtConfig.Issuer,
// ValidAudience = jwtConfig.Audience,
// ValidateAudience = false,
// ValidateIssuer = false,
// ValidateLifetime = true,//jwtConfig.ValidateLifetime,
// IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(jwtConfig.SigningKey)),
// //缓冲过期时间,总的有效时间等于这个时间加上jwt的过期时间
// ClockSkew = TimeSpan.FromSeconds(0)
//}, out SecurityToken validatedToken);

if ("refresh" != token.Claims.FirstOrDefault(x => x.Type == "token_type")?.Value)
context.Response.Headers.Add("token-expired", "true");
}
return Task.CompletedTask;
},
Expand All @@ -127,14 +145,14 @@ public void ConfigureServices(IServiceCollection services)
{
ValidIssuer = jwtConfig.Issuer,
ValidAudience = jwtConfig.Audience,
ValidateAudience=false,
ValidateIssuer = false,
ValidateAudience = false,
ValidateIssuer = false,
ValidateLifetime = true,//jwtConfig.ValidateLifetime,
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(jwtConfig.SigningKey)),
//缓冲过期时间,总的有效时间等于这个时间加上jwt的过期时间
ClockSkew = TimeSpan.FromSeconds(0)
};
});
});
//================================
// If using Kestrel:
services.Configure<KestrelServerOptions>(options =>
Expand All @@ -143,7 +161,7 @@ public void ConfigureServices(IServiceCollection services)
});
services.AddScoped<ScopedObj>();
services.AddSingleton<JwtConfig>(jwtConfig);

// If using IIS:
services.Configure<IISServerOptions>(options =>
{
Expand All @@ -161,10 +179,10 @@ public void ConfigureServices(IServiceCollection services)
services.AddCors(op => {
op.AddPolicy("CorsTest",
set => {
set.SetIsOriginAllowed(origin => true)
.AllowAnyHeader()
.AllowAnyMethod()
.AllowCredentials();//这是是重要的,没有他就会有跨域问题
set.SetIsOriginAllowed(origin => true)
.AllowAnyHeader()
.AllowAnyMethod()
.AllowCredentials();//这是是重要的,没有他就会有跨域问题
});
});
services.AddSignalR();
Expand All @@ -178,26 +196,25 @@ public void ConfigureServices(IServiceCollection services)
services.AddDataProtection().PersistKeysToFileSystem(new DirectoryInfo(Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + "DataProtection"));

CellReport.Redis_Cache.redis_str = Configuration["redis_str"];
if(!String.IsNullOrEmpty( CellReport.Redis_Cache.redis_str ))
if (!String.IsNullOrEmpty(CellReport.Redis_Cache.redis_str))
{
CSRedisClient redisClient = new CSRedisClient(CellReport.Redis_Cache.redis_str);
RedisHelper.Initialization(redisClient);
}
DbProviderFactories.RegisterFactory("Microsoft.Data.Sqlite", SqliteFactory.Instance);
foreach (var one in Configuration.GetSection("DbProviderFactories").Get<DbProviderCfg[]>())
{
//var ass = System.Reflection.Assembly.LoadFile(Path.Combine((new DirectoryInfo(Environment.ProcessPath)).Parent.FullName, one.DllName + ".dll"));
var ass = System.Reflection.Assembly.Load( one.DllName);
var ass = System.Reflection.Assembly.Load(one.DllName);
DbProviderFactory f = ass.GetType(one.FactoryClass).GetField(one.InstanceName).GetValue(null) as DbProviderFactory;
DbProviderFactories.RegisterFactory(one.Name, f );
DbProviderFactories.RegisterFactory(one.Name, f);

}
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env,ReportDbContext _reportDbContext)
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ReportDbContext _reportDbContext)
{

_reportDbContext.Database.EnsureCreated();//数据库不存在的话,会自动创建
if (_reportDbContext.Rpt_group.Count() == 0)
{
Expand All @@ -220,8 +237,8 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env,ReportDbC
default_page = "default",
name = "例子",
report_path = main_path,
db_connection_list=new List<Rpt_db_connection>()
{
db_connection_list = new List<Rpt_db_connection>()
{
new Rpt_db_connection() { conn_str=$"Data Source={main_path}/test.db", db_type="Microsoft.Data.Sqlite", name="testsqlite"},
}
});
Expand All @@ -235,6 +252,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env,ReportDbC
});
_reportDbContext.SaveChanges();
}

if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
Expand Down Expand Up @@ -280,11 +298,11 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env,ReportDbC
});
//app.UseHttpsRedirection();
app.UseStaticFiles();

app.Use(next => context =>
{
var cur_path = context.Request.Path.Value;
if (cur_path.Contains("/design/"))
if (cur_path.Contains("/design"))
{
cur_path = cur_path.Substring(cur_path.IndexOf("/design/"));
}
Expand All @@ -294,19 +312,19 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env,ReportDbC
}
var seg_arr = cur_path.Split(":");
string grp = "default";
if (seg_arr.Length>=2)
if (seg_arr.Length >= 2)
{
grp=seg_arr[1];
grp = seg_arr[1];
}

var scopedObj = context.RequestServices.GetService<ScopedObj>();
//scopedObj.rpt_group = context.RequestServices.GetService<ReportDb>().findGroupById(grp);
scopedObj.rpt_group = context.RequestServices.GetService <ReportDbContext>().Rpt_group.AsNoTracking()
.Include(x=>x.db_connection_list)
scopedObj.rpt_group = context.RequestServices.GetService<ReportDbContext>().Rpt_group.AsNoTracking()
.Include(x => x.db_connection_list)
.Where(i => i.Id == grp)
.FirstOrDefault();
scopedObj.WebHostEnvironment = env;

context.Request.Path = seg_arr[0];
if (context.Request.Path == "/run")
{
Expand All @@ -316,7 +334,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env,ReportDbC
context.Response.ContentType = "application/json";
return context.Response.WriteAsync("{ \"errcode\":1, \"message\":\"grp没有定义\" }");
}
var rn=context.Request.Query["reportName"];
var rn = context.Request.Query["reportName"];
if (rn.Count == 1)
{
context.Request.Path = "/" + scopedObj.rpt_group.getPageNameByReportName(rn[0]);
Expand All @@ -334,13 +352,13 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env,ReportDbC
app.UseAuthentication();//认证(Authentication)
app.UseAuthorization(); //授权 (Authorization)

app.UseSession();
app.UseSession();

app.UseEndpoints(endpoints =>
{
endpoints.MapRazorPages();
endpoints.MapHub<ChatHub>("/chathub");
endpoints.MapControllerRoute(name: "default",pattern: "{controller=user}/{action=Index}/{id?}");
endpoints.MapControllerRoute(name: "default", pattern: "{controller=user}/{action=Index}/{id?}");
//endpoints.MapDynamicPageRoute<GrpRouteTransformer>("{page}/{**grp}");
//endpoints.MapDynamicControllerRoute<GrpRouteTransformer>("{area}/{controller=Home}/{action=Index}/{id:int?}");
//endpoints.Map(RoutePatternFactory.Parse("/run/{act}/{grp}/{a0}/{a1}"), rpt_execute);
Expand All @@ -354,7 +372,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env,ReportDbC
{
var m = MessageQueueBlock<DemoMessage>.Take();//Client(m.ConnectionId)
if (m.ConnectionId != null)
await m.hubContext.Clients.Client(m.ConnectionId)?.SendAsync("ReceiveMessage",m.ConnectionId,m.Body);
await m.hubContext.Clients.Client(m.ConnectionId)?.SendAsync("ReceiveMessage", m.ConnectionId, m.Body);
}
catch (Exception ex)
{
Expand Down
4 changes: 3 additions & 1 deletion end/reportWeb/reportWeb.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@

<ItemGroup>
<PackageReference Include="Antlr3.Runtime" Version="3.5.2-rc1" />
<PackageReference Include="CellReport" Version="1.0.4" />
<PackageReference Include="CellReport" Version="1.0.6" />
<PackageReference Include="CSRedisCore" Version="3.6.6" />
<PackageReference Include="itext7" Version="7.2.1" />
<PackageReference Include="itext7.pdfhtml" Version="4.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="6.0.0" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="3.0.1" />
Expand Down
15 changes: 15 additions & 0 deletions front/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,21 @@ export default {
height: 100%;
overflow: hidden;
}
.el-button{
padding: 5px 10px !important;
}
.el-button.is-circle{
padding:7px !important;
}
.el-dialog__headerbtn{
top:10px !important;
}
.el-tabs__item{
font-size: 12px !important;
}
.cr_run_title { line-height: 28px; border-bottom: 1px solid gray;font-weight: 500; margin-bottom: 5px; }
.vue-codemirror{border: 1px solid black;}
.el-table td, .el-table th {
Expand Down
Loading

0 comments on commit f8c79d5

Please sign in to comment.