You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

618 lines
23 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using Microsoft.AspNetCore.Builder;
  6. using Microsoft.AspNetCore.Cors;
  7. using Microsoft.AspNetCore.Extensions.DependencyInjection;
  8. using Microsoft.Extensions.Configuration;
  9. using Microsoft.Extensions.DependencyInjection;
  10. using Microsoft.Extensions.Hosting;
  11. using Shentun.Peis.EntityFrameworkCore;
  12. using Shentun.Peis.MultiTenancy;
  13. using Volo.Abp.AspNetCore.Mvc.UI.Theme.LeptonXLite;
  14. using Volo.Abp.AspNetCore.Mvc.UI.Theme.LeptonXLite.Bundling;
  15. using Microsoft.OpenApi.Models;
  16. using OpenIddict.Validation.AspNetCore;
  17. using Volo.Abp;
  18. using Volo.Abp.Account;
  19. using Volo.Abp.Account.Web;
  20. using Volo.Abp.AspNetCore.MultiTenancy;
  21. using Volo.Abp.AspNetCore.Mvc;
  22. using Volo.Abp.AspNetCore.Mvc.UI.Bundling;
  23. using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared;
  24. using Volo.Abp.AspNetCore.Serilog;
  25. using Volo.Abp.Autofac;
  26. using Volo.Abp.Localization;
  27. using Volo.Abp.Modularity;
  28. using Volo.Abp.Swashbuckle;
  29. using Volo.Abp.UI.Navigation.Urls;
  30. using Volo.Abp.VirtualFileSystem;
  31. using Microsoft.AspNetCore.Mvc;
  32. using Microsoft.Extensions.Options;
  33. using System.Reflection;
  34. using Swashbuckle.AspNetCore.SwaggerGen;
  35. using Microsoft.AspNetCore.Mvc.Filters;
  36. using Volo.Abp.AspNetCore.Mvc.Validation;
  37. using Microsoft.Extensions.DependencyInjection.Extensions;
  38. using Volo.Abp.Identity;
  39. using Microsoft.Extensions.FileProviders;
  40. using Microsoft.AspNetCore.Mvc.ApplicationModels;
  41. using Volo.Abp.Settings;
  42. using Volo.Abp.Identity.Settings;
  43. using Microsoft.AspNetCore.Identity;
  44. using Volo.Abp.AspNetCore.Mvc.AntiForgery;
  45. using Microsoft.AspNetCore.Authentication;
  46. using Nito.Disposables.Internals;
  47. using Volo.Abp.AspNetCore.Mvc.ExceptionHandling;
  48. using static IdentityModel.ClaimComparer;
  49. using Microsoft.AspNetCore.Authorization;
  50. using Microsoft.AspNetCore.Diagnostics;
  51. using Microsoft.AspNetCore.Http;
  52. using Shentun.Peis.Filter;
  53. using Shentun.Peis.VirtualPath;
  54. using System.Text.Encodings.Web;
  55. using System.Text.Unicode;
  56. using Volo.Abp.Json;
  57. using Shentun.Utilities;
  58. using Volo.Abp.SecurityLog;
  59. using Volo.Abp.Auditing;
  60. using Volo.Abp.BackgroundWorkers.Hangfire;
  61. using Hangfire;
  62. using Hangfire.PostgreSql;
  63. using Volo.Abp.BackgroundWorkers;
  64. using Shentun.Peis.Schedulers;
  65. using System.Threading.Tasks;
  66. using Shentun.Peis.ThirdInterfaces;
  67. namespace Shentun.Peis;
  68. [DependsOn(
  69. typeof(PeisHttpApiModule),
  70. typeof(AbpAutofacModule),
  71. typeof(AbpAspNetCoreMultiTenancyModule),
  72. typeof(PeisApplicationModule),
  73. typeof(PeisEntityFrameworkCoreModule),
  74. typeof(AbpAspNetCoreMvcUiLeptonXLiteThemeModule),
  75. typeof(AbpAccountWebOpenIddictModule),
  76. typeof(AbpAspNetCoreSerilogModule),
  77. typeof(AbpSwashbuckleModule),
  78. typeof(AbpBackgroundWorkersHangfireModule)
  79. )]
  80. public class PeisHttpApiHostModule : AbpModule
  81. {
  82. public override void PreConfigureServices(ServiceConfigurationContext context)
  83. {
  84. PreConfigure<OpenIddictBuilder>(builder =>
  85. {
  86. builder.AddValidation(options =>
  87. {
  88. options.AddAudiences("Peis");
  89. options.UseLocalServer();
  90. options.UseAspNetCore();
  91. });
  92. });
  93. //重写定义token失效时间 接口返回的是秒
  94. PreConfigure<OpenIddictServerBuilder>(builder =>
  95. {
  96. //builder.SetAccessTokenLifetime(TimeSpan.FromHours(8)).SetRefreshTokenLifetime(TimeSpan.FromDays(15));
  97. builder.SetAccessTokenLifetime(TimeSpan.FromDays(30)).SetRefreshTokenLifetime(TimeSpan.FromDays(60));
  98. });
  99. }
  100. public override void ConfigureServices(ServiceConfigurationContext context)
  101. {
  102. var configuration = context.Services.GetConfiguration();
  103. var hostingEnvironment = context.Services.GetHostingEnvironment();
  104. ConfigureAuthentication(context);
  105. ConfigureBundles();
  106. ConfigureUrls(configuration);
  107. ConfigureConventionalControllers();
  108. ConfigureLocalization();
  109. ConfigureVirtualFileSystem(context);
  110. ConfigureCors(context, configuration);
  111. ConfigureSwaggerServices(context, configuration);
  112. ConfigureJsonOptions(); //全局配置api返回值中的日期默认格式
  113. //密码策略配置
  114. context.Services.Configure<IdentityOptions>(opt =>
  115. {
  116. opt.Password.RequireDigit = false;
  117. opt.Password.RequireLowercase = false;
  118. opt.Password.RequireUppercase = false;
  119. opt.Password.RequireNonAlphanumeric = false;
  120. opt.Password.RequiredLength = 1;
  121. });
  122. ////密码策略配置
  123. //context.Services.Configure<IdentityOptions>(opt =>
  124. //{
  125. // opt.Password.RequireDigit = false;
  126. // opt.Password.RequireLowercase = false;
  127. // opt.Password.RequireUppercase = false;
  128. // opt.Password.RequireNonAlphanumeric = false;
  129. // opt.Password.RequiredLength = 1;
  130. //});
  131. #region 临时去掉日志
  132. ////关闭审计日志
  133. //Configure<AbpAuditingOptions>(options =>
  134. //{
  135. // options.IsEnabled = false;
  136. //});
  137. ////关闭安全日志
  138. //Configure<AbpSecurityLogOptions>(options =>
  139. //{
  140. // options.IsEnabled = false;
  141. //});
  142. #endregion
  143. //防伪令牌
  144. //context.Services.Configure<AbpAntiForgeryOptions>(opt =>
  145. //{
  146. // opt.AutoValidate = false;
  147. //});
  148. context.Services.AddMvc(options =>
  149. {
  150. var filterMetadata = options.Filters.FirstOrDefault(x => x is ServiceFilterAttribute attribute && attribute.ServiceType.Equals(typeof(AbpValidationActionFilter)));
  151. options.Filters.Remove(filterMetadata);
  152. options.Filters.Add(typeof(ValidateFilter));
  153. options.Filters.Add(typeof(CustomerExceptionFilterAttribute));
  154. options.Filters.Add(typeof(CustomerActionFilterAttribute));
  155. // options.Filters.ReplaceOne(x => (x as ServiceFilterAttribute)?.ServiceType?.Name == nameof(ExceptionFilterAttribute), new ServiceFilterAttribute(typeof(ABCExceptionFilterAttribute)));
  156. // options.Filters.ReplaceOne(x => (x as ServiceFilterAttribute)?.ServiceType?.Name == nameof(AbpExceptionFilter), new ServiceFilterAttribute(typeof(MyExceptionFilter)));
  157. });
  158. //context.Services.TryAddTransient<IAuthorizationMiddlewareResultHandler, AuthorizationMiddlewareResultHandler>();
  159. ///解除https限制
  160. context.Services.AddOpenIddict()
  161. .AddServer(option =>
  162. {
  163. option.UseAspNetCore().DisableTransportSecurityRequirement();
  164. });
  165. //虚拟目录
  166. context.Services.AddSingleton(new MyFileProvider(configuration["VirtualPath:RealPath"], configuration["VirtualPath:Alias"]));
  167. /*
  168. Configure<AbpAspNetCoreMvcOptions>(options =>
  169. {
  170. options.ConventionalControllers
  171. .Create(typeof(PeisApplicationModule).Assembly, opts =>
  172. {
  173. opts.RootPath = "api/app";
  174. opts.UrlControllerNameNormalizer = (controller) =>
  175. {
  176. return controller.ControllerName;
  177. };
  178. opts.UrlActionNameNormalizer = (action) =>
  179. {
  180. return action.Action.ActionName;
  181. };
  182. });
  183. });
  184. */
  185. //后台计划任务
  186. ConfigureHangfire(context, configuration);
  187. }
  188. /// <summary>
  189. /// 全局转换日期格式
  190. /// </summary>
  191. private void ConfigureJsonOptions()
  192. {
  193. //context.Services.AddControllers().AddJsonOptions(options =>
  194. //{
  195. // options.JsonSerializerOptions.Encoder = JavaScriptEncoder.Create(UnicodeRanges.All);
  196. // options.JsonSerializerOptions.PropertyNamingPolicy = null;
  197. //});
  198. Configure<JsonOptions>(x =>
  199. {
  200. //x.JsonSerializerOptions.Encoder = JavaScriptEncoder.Create(UnicodeRanges.All);
  201. x.JsonSerializerOptions.Converters.Add(new DateTimeJsonConverter());
  202. x.JsonSerializerOptions.PropertyNameCaseInsensitive = true;
  203. });
  204. //Configure<AbpJsonOptions>(x =>
  205. //{
  206. // x.DefaultDateTimeFormat = "yyyy-MM-dd HH:mm:ss";
  207. //});
  208. }
  209. private void ConfigureAuthentication(ServiceConfigurationContext context)
  210. {
  211. context.Services.ForwardIdentityAuthenticationForBearer(OpenIddictValidationAspNetCoreDefaults.AuthenticationScheme);
  212. }
  213. private void ConfigureBundles()
  214. {
  215. Configure<AbpBundlingOptions>(options =>
  216. {
  217. options.StyleBundles.Configure(
  218. LeptonXLiteThemeBundles.Styles.Global,
  219. bundle =>
  220. {
  221. bundle.AddFiles("/global-styles.css");
  222. }
  223. );
  224. });
  225. }
  226. private void ConfigureUrls(IConfiguration configuration)
  227. {
  228. Configure<AppUrlOptions>(options =>
  229. {
  230. options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"];
  231. options.RedirectAllowedUrls.AddRange(configuration["App:RedirectAllowedUrls"].Split(','));
  232. options.Applications["Angular"].RootUrl = configuration["App:ClientUrl"];
  233. options.Applications["Angular"].Urls[AccountUrlNames.PasswordReset] = "account/reset-password";
  234. });
  235. }
  236. private void ConfigureVirtualFileSystem(ServiceConfigurationContext context)
  237. {
  238. var hostingEnvironment = context.Services.GetHostingEnvironment();
  239. if (hostingEnvironment.IsDevelopment())
  240. {
  241. Configure<AbpVirtualFileSystemOptions>(options =>
  242. {
  243. options.FileSets.ReplaceEmbeddedByPhysical<PeisDomainSharedModule>(
  244. Path.Combine(hostingEnvironment.ContentRootPath,
  245. $"..{Path.DirectorySeparatorChar}Shentun.Peis.Domain.Shared"));
  246. options.FileSets.ReplaceEmbeddedByPhysical<PeisDomainModule>(
  247. Path.Combine(hostingEnvironment.ContentRootPath,
  248. $"..{Path.DirectorySeparatorChar}Shentun.Peis.Domain"));
  249. options.FileSets.ReplaceEmbeddedByPhysical<PeisApplicationContractsModule>(
  250. Path.Combine(hostingEnvironment.ContentRootPath,
  251. $"..{Path.DirectorySeparatorChar}Shentun.Peis.Application.Contracts"));
  252. options.FileSets.ReplaceEmbeddedByPhysical<PeisApplicationModule>(
  253. Path.Combine(hostingEnvironment.ContentRootPath,
  254. $"..{Path.DirectorySeparatorChar}Shentun.Peis.Application"));
  255. });
  256. }
  257. }
  258. private void ConfigureConventionalControllers()
  259. {
  260. #region 配置隐藏api
  261. Configure<MvcOptions>(options =>
  262. {
  263. options.Conventions.Add(new ApplicationDescription());
  264. });
  265. #endregion
  266. Configure<AbpAspNetCoreMvcOptions>(options =>
  267. {
  268. options.ConventionalControllers.Create(typeof(PeisApplicationModule).Assembly);
  269. });
  270. }
  271. private static void ConfigureSwaggerServices(ServiceConfigurationContext context, IConfiguration configuration)
  272. {
  273. context.Services.AddAbpSwaggerGenWithOAuth(
  274. configuration["AuthServer:Authority"],
  275. new Dictionary<string, string>
  276. {
  277. {"Peis", "Peis API"}
  278. },
  279. options =>
  280. {
  281. //options.SwaggerDoc("v1", new OpenApiInfo { Title = "Peis API", Version = "v1" });
  282. //options.DocInclusionPredicate((docName, description) => true);
  283. //options.CustomSchemaIds(type => type.FullName);
  284. options.SwaggerDoc("Work", new OpenApiInfo { Title = "业务API", Version = "V1", Description = "业务API" });
  285. options.SwaggerDoc("Sys", new OpenApiInfo { Title = "底层API", Version = "V1", Description = "底层API" });
  286. options.DocInclusionPredicate((docName, description) =>
  287. {
  288. if (!description.TryGetMethodInfo(out MethodInfo method))
  289. {
  290. return false;
  291. }
  292. /*使ApiExplorerSettingsAttribute里面的GroupName进行特性标识
  293. * DeclaringType只能获取controller上的特性
  294. * action的特性为主
  295. * */
  296. var version = method.DeclaringType.GetCustomAttributes(true).OfType<ApiExplorerSettingsAttribute>().Select(m => m.GroupName);
  297. if (version.Any())
  298. {
  299. if (version.Any(v => v == docName))
  300. //选择了sys,并且分组不为User
  301. return true;
  302. }
  303. else
  304. {
  305. if (docName == "Sys")
  306. {
  307. return true;
  308. }
  309. }
  310. //这里获取action的特性
  311. var actionVersion = method.GetCustomAttributes(true).OfType<ApiExplorerSettingsAttribute>().Select(m => m.GroupName);
  312. if (actionVersion.Any())
  313. {
  314. return actionVersion.Any(v => v == docName);
  315. }
  316. return false;
  317. });
  318. });
  319. }
  320. private void ConfigureLocalization()
  321. {
  322. Configure<AbpLocalizationOptions>(options =>
  323. {
  324. options.Languages.Add(new LanguageInfo("ar", "ar", "العربية"));
  325. options.Languages.Add(new LanguageInfo("cs", "cs", "Čeština"));
  326. options.Languages.Add(new LanguageInfo("en", "en", "English"));
  327. options.Languages.Add(new LanguageInfo("en-GB", "en-GB", "English (UK)"));
  328. options.Languages.Add(new LanguageInfo("fi", "fi", "Finnish"));
  329. options.Languages.Add(new LanguageInfo("fr", "fr", "Français"));
  330. options.Languages.Add(new LanguageInfo("hi", "hi", "Hindi", "in"));
  331. options.Languages.Add(new LanguageInfo("is", "is", "Icelandic", "is"));
  332. options.Languages.Add(new LanguageInfo("it", "it", "Italiano", "it"));
  333. options.Languages.Add(new LanguageInfo("hu", "hu", "Magyar"));
  334. options.Languages.Add(new LanguageInfo("pt-BR", "pt-BR", "Português"));
  335. options.Languages.Add(new LanguageInfo("ro-RO", "ro-RO", "Română"));
  336. options.Languages.Add(new LanguageInfo("ru", "ru", "Русский"));
  337. options.Languages.Add(new LanguageInfo("sk", "sk", "Slovak"));
  338. options.Languages.Add(new LanguageInfo("tr", "tr", "Türkçe"));
  339. options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文"));
  340. options.Languages.Add(new LanguageInfo("zh-Hant", "zh-Hant", "繁體中文"));
  341. options.Languages.Add(new LanguageInfo("de-DE", "de-DE", "Deutsch", "de"));
  342. options.Languages.Add(new LanguageInfo("es", "es", "Español", "es"));
  343. options.Languages.Add(new LanguageInfo("el", "el", "Ελληνικά"));
  344. });
  345. }
  346. private void ConfigureCors(ServiceConfigurationContext context, IConfiguration configuration)
  347. {
  348. context.Services.AddCors(options =>
  349. {
  350. options.AddDefaultPolicy(builder =>
  351. {
  352. builder
  353. .WithOrigins(
  354. configuration["App:CorsOrigins"]
  355. .Split(",", StringSplitOptions.RemoveEmptyEntries)
  356. .Select(o => o.RemovePostFix("/"))
  357. .ToArray()
  358. )
  359. .WithAbpExposedHeaders()
  360. .SetIsOriginAllowedToAllowWildcardSubdomains()
  361. .AllowAnyHeader()
  362. .AllowAnyMethod()
  363. .AllowCredentials();
  364. });
  365. });
  366. //添加swagger中文注释
  367. context.Services.AddSwaggerGen(options =>
  368. {
  369. //var baseDirectory = AppDomain.CurrentDomain.BaseDirectory;
  370. var baseDirectory = AppContext.BaseDirectory;
  371. //Serilog.Log.Information("swagger地址1:" + baseDirectory);
  372. //var baseDirectory2 = Path.GetDirectoryName(typeof(Program).Assembly.Location);
  373. //Serilog.Log.Information("swagger地址2:" + baseDirectory2);
  374. //var baseDirectory3 = AppDomain.CurrentDomain.BaseDirectory;
  375. //Serilog.Log.Information("swagger地址3:" + baseDirectory3);
  376. var commentsFile = Path.Combine(baseDirectory, "Shentun.Peis.Application.xml");
  377. options.IncludeXmlComments(commentsFile, true);
  378. var commentsFileDro = Path.Combine(baseDirectory, "Shentun.Peis.Application.Contracts.xml");
  379. options.IncludeXmlComments(commentsFileDro, true);
  380. var commentsFileapi = Path.Combine(baseDirectory, "Shentun.Peis.HttpApi.xml");
  381. options.IncludeXmlComments(commentsFileapi, true);
  382. });
  383. }
  384. private void ConfigureHangfire(ServiceConfigurationContext context, IConfiguration configuration)
  385. {
  386. context.Services.AddHangfire(config =>
  387. {
  388. config.UsePostgreSqlStorage(configuration.GetConnectionString("Default"));
  389. });
  390. }
  391. public override async void OnApplicationInitialization(ApplicationInitializationContext context)
  392. {
  393. var app = context.GetApplicationBuilder();
  394. var env = context.GetEnvironment();
  395. var configuration = context.GetConfiguration();
  396. //请求错误提示配置
  397. // app.UseErrorHandling();
  398. if (env.IsDevelopment())
  399. {
  400. app.UseDeveloperExceptionPage();
  401. }
  402. app.UseAbpRequestLocalization();
  403. if (!env.IsDevelopment())
  404. {
  405. app.UseErrorPage();
  406. }
  407. app.UseCorrelationId();
  408. //var staticFile = new StaticFileOptions();
  409. //var filePath = env.ContentRootPath+"UpLoad\\";
  410. ////var filePath = env.ContentRootPath ;
  411. //staticFile.FileProvider = new PhysicalFileProvider(filePath);
  412. //app.UseStaticFiles(new StaticFileOptions
  413. //{
  414. // FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), "UpLoad")),
  415. // RequestPath="/UpLoad"
  416. //});
  417. app.UseStaticFiles();
  418. app.UseStaticFiles(new StaticFileOptions
  419. {
  420. FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), "ReportFile")),
  421. RequestPath = "/ReportFile"
  422. });
  423. app.UseStaticFiles(new StaticFileOptions
  424. {
  425. FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), "photo")),
  426. RequestPath = "/photo"
  427. });
  428. //虚拟目录
  429. app.UseStaticFiles(new StaticFileOptions
  430. {
  431. FileProvider = new PhysicalFileProvider(configuration["VirtualPath:RealPath"]),
  432. RequestPath = configuration["VirtualPath:RequestPath"]
  433. });
  434. app.UseRouting();
  435. app.UseCors();
  436. app.UseAuthentication();
  437. app.UseAbpOpenIddictValidation();
  438. if (MultiTenancyConsts.IsEnabled)
  439. {
  440. app.UseMultiTenancy();
  441. }
  442. app.UseUnitOfWork();
  443. app.UseAuthorization();
  444. //app.UseMiddleware(typeof(AuthorizationMiddlewareResultHandler));
  445. app.UseSwagger();
  446. app.UseAbpSwaggerUI(c =>
  447. {
  448. //c.SwaggerEndpoint("/swagger/v1/swagger.json", "Peis API");
  449. c.SwaggerEndpoint($"/swagger/Work/swagger.json", "业务API"); //分组显示
  450. c.SwaggerEndpoint($"/swagger/Sys/swagger.json", "底层API"); //分组显示
  451. //c.RoutePrefix = string.Empty; // url 中不显示swagger
  452. var configuration = context.ServiceProvider.GetRequiredService<IConfiguration>();
  453. c.OAuthClientId(configuration["AuthServer:SwaggerClientId"]);
  454. c.OAuthScopes("Peis");
  455. c.DefaultModelExpandDepth(-1);
  456. });
  457. app.UseAuditing();
  458. app.UseAbpSerilogEnrichers();
  459. app.UseConfiguredEndpoints();
  460. //任务计划
  461. await StartScheduler(context);
  462. }
  463. private async Task StartScheduler(ApplicationInitializationContext context)
  464. {
  465. //await context.AddBackgroundWorkerAsync<ChargeRequestInterfaceQueryWorker>();
  466. //RecurringJob.AddOrUpdate<IChargeRequestInterfaceQueryWorker>("收费接口", o => o.DoWorkAsync(new Guid("")), CheckedBills, TimeZoneInfo.Local);
  467. //BackgroundJob.Enqueue<ChargeRequestInterfaceQueryWorker>(x => x.DoWorkWithArgAsync(new Guid("")));
  468. var appServiceHelper = new AppServiceHelper();
  469. await appServiceHelper.LoginAsync();
  470. var thirdInterFaceForHostOutDto = await appServiceHelper.CallAppServiceAsync<object, ThirdInterFaceForHostOutDto>("api/app/ThirdInterface/GetList", null);
  471. if (thirdInterFaceForHostOutDto != null)
  472. {
  473. foreach (var thirdInterfaceDto in thirdInterFaceForHostOutDto.Data)
  474. {
  475. if (thirdInterfaceDto.IsActive != 'Y')
  476. {
  477. continue;
  478. }
  479. var parmValue = thirdInterfaceDto.ParmValue;
  480. if (!string.IsNullOrWhiteSpace(parmValue))
  481. {
  482. var configurationBuilder = new ConfigurationBuilder()
  483. .AddJsonStream(new MemoryStream(System.Text.Encoding.UTF8.GetBytes(parmValue)));
  484. IConfigurationRoot interfaceConfig;
  485. try
  486. {
  487. interfaceConfig = configurationBuilder.Build();
  488. }
  489. catch (Exception ex)
  490. {
  491. continue;
  492. }
  493. var isActive = interfaceConfig.GetSection("Interface").GetSection("Scheduler")
  494. .GetSection("IsActive").Value;
  495. var corn = interfaceConfig.GetSection("Interface").GetSection("Scheduler")
  496. .GetSection("Corn").Value;
  497. if (isActive == "Y")
  498. {
  499. if (thirdInterfaceDto.ThirdInterfaceType == "02")
  500. {
  501. RecurringJob.AddOrUpdate<IChargeRequestInterfaceQueryWorker>("收费接口", o => o.DoWork(thirdInterfaceDto.Id), corn, TimeZoneInfo.Local);
  502. }
  503. else if (thirdInterfaceDto.ThirdInterfaceType == "03")
  504. {
  505. RecurringJob.AddOrUpdate<IImportLisResultInterfaceWorker>("导入检验结果接口", o => o.DoWork(thirdInterfaceDto.Id), corn, TimeZoneInfo.Local);
  506. }
  507. }
  508. }
  509. }
  510. }
  511. }
  512. }