Browse Source

[add]增加XmlHost

master
贾荣国 3 years ago
parent
commit
64be845c9b
  1. 13
      WebApiService/Win_in.Sfs.Scp.WebApi.sln
  2. 39
      WebApiService/src/TestHost/Controllers/WeatherForecastController.cs
  3. 26
      WebApiService/src/TestHost/Program.cs
  4. 31
      WebApiService/src/TestHost/Properties/launchSettings.json
  5. 29
      WebApiService/src/TestHost/Startup.cs
  6. 17
      WebApiService/src/TestHost/TestHost.csproj
  7. 47
      WebApiService/src/TestHost/TestModule.cs
  8. 15
      WebApiService/src/TestHost/WeatherForecast.cs
  9. 9
      WebApiService/src/TestHost/appsettings.Development.json
  10. 10
      WebApiService/src/TestHost/appsettings.json
  11. 20
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Application.Contracts/Parts/PartCreateDto.cs
  12. 68
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Application.Contracts/Parts/PartDTO.cs
  13. 22
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Application.Contracts/PurchaseOrders/CreatePurchaseOrderDetailValidator.cs
  14. 21
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Application.Contracts/PurchaseOrders/PurchaseOrderCreateDTO.cs
  15. 24
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Application.Contracts/PurchaseOrders/PurchaseOrderDTO.cs
  16. 47
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Application.Contracts/PurchaseOrders/PurchaseOrderDetailDTO.cs
  17. 21
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Application.Contracts/Receipts/ReceiptCreateDTO.cs
  18. 25
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Application.Contracts/Receipts/ReceiptDTO.cs
  19. 11
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Application.Contracts/RouteConsts.cs
  20. 18
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Application.Contracts/Suppliers/SupplierCreateDTO.cs
  21. 23
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Application.Contracts/Suppliers/SupplierDTO.cs
  22. 16
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Application.Contracts/UnplannedReceipts/UnplannedReceiptCreateDTO.cs
  23. 21
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Application.Contracts/UnplannedReceipts/UnplannedReceiptDTO.cs
  24. 4
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/Parts/PartAppService.cs
  25. 2
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/PurchaseOrders/PurchaseOrderAppService.cs
  26. 2
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/Receipts/ReceiptAppService.cs
  27. 2
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/Suppliers/SuppliersAppService.cs
  28. 2
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/UnplannedReceipts/UnplannedReceiptAppService.cs
  29. 16
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/WebApiApplicationAutoMapperProfile.cs
  30. 4
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/EntityBase/EntityDetailDtoBase.cs
  31. 21
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/EntityBase/EntityDtoBase.cs
  32. 11
      WebApiService/src/Win_in.Sfs.Scp.WebApi.HttpApi.Host/WebApiHttpApiHostModule.cs
  33. 5
      WebApiService/src/Win_in.Sfs.Scp.WebApi.HttpApi.Host/appsettings.json
  34. 83
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Xml.Host/BasicAuthHttpModule.cs
  35. 41
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Xml.Host/Controllers/PartController.cs
  36. 33
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Xml.Host/Controllers/PurchaseOrderController.cs
  37. 33
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Xml.Host/Controllers/ReceiptController.cs
  38. 33
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Xml.Host/Controllers/SupplierController.cs
  39. 32
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Xml.Host/Controllers/UnplannedReceiptController.cs
  40. 36
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Xml.Host/HttpClientInvoker.cs
  41. 10
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Xml.Host/IHttpClientInvoker.cs
  42. 5285
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Xml.Host/Logs/logs.txt
  43. 59
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Xml.Host/Program.cs
  44. 15
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Xml.Host/Properties/launchSettings.json
  45. 75
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Xml.Host/Startup.cs
  46. 27
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Xml.Host/Win_in - Backup.Sfs.Scp.WebApi.Xml.Host.csproj
  47. 21
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Xml.Host/Win_in.Sfs.Scp.WebApi.Xml.Host.csproj
  48. 41
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Xml.Host/XDocumentInputFormatter.cs
  49. 9
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Xml.Host/appsettings.Development.json
  50. 20
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Xml.Host/appsettings.json
  51. 3
      WebApiService/test/Win_in.Sfs.Scp.WebApi.HttpApi.Client.ConsoleTestApp/WebApiConsoleApiClientModule.cs

13
WebApiService/Win_in.Sfs.Scp.WebApi.sln

@ -35,11 +35,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Win_in.Sfs.Scp.WebApi.DbMig
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Win_in.Sfs.Scp.WebApi.HttpApi.Host", "src\Win_in.Sfs.Scp.WebApi.HttpApi.Host\Win_in.Sfs.Scp.WebApi.HttpApi.Host.csproj", "{748584B1-BA69-4F6A-81AA-F4BDE6BCE29D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Win_in.Sfs.Scp.v1.Domain", "src\Win_in.Sfs.Scp.v1.Domain\Win_in.Sfs.Scp.v1.Domain.csproj", "{3EE98133-3E7A-4B14-A515-12CB039A9EED}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Win_in.Sfs.Scp.v1.Domain", "src\Win_in.Sfs.Scp.v1.Domain\Win_in.Sfs.Scp.v1.Domain.csproj", "{3EE98133-3E7A-4B14-A515-12CB039A9EED}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Win_in.Sfs.Scp.v1.EntityFrameworkCore", "src\Win_in.Sfs.Scp.v1.EntityFrameworkCore\Win_in.Sfs.Scp.v1.EntityFrameworkCore.csproj", "{77D1D3F8-A04C-4688-AC67-C8372BD268A2}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Win_in.Sfs.Scp.v1.EntityFrameworkCore", "src\Win_in.Sfs.Scp.v1.EntityFrameworkCore\Win_in.Sfs.Scp.v1.EntityFrameworkCore.csproj", "{77D1D3F8-A04C-4688-AC67-C8372BD268A2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Win_in.Sfs.Scp.v1.Event", "src\Win_in.Sfs.Scp.v1.Event\Win_in.Sfs.Scp.v1.Event.csproj", "{45EED43B-B235-4C24-9176-3B7992DA4D6E}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Win_in.Sfs.Scp.v1.Event", "src\Win_in.Sfs.Scp.v1.Event\Win_in.Sfs.Scp.v1.Event.csproj", "{45EED43B-B235-4C24-9176-3B7992DA4D6E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Win_in.Sfs.Scp.WebApi.Xml.Host", "src\Win_in.Sfs.Scp.WebApi.Xml.Host\Win_in.Sfs.Scp.WebApi.Xml.Host.csproj", "{98CDED94-F046-4010-88F4-700B7481169E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -115,6 +117,10 @@ Global
{45EED43B-B235-4C24-9176-3B7992DA4D6E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{45EED43B-B235-4C24-9176-3B7992DA4D6E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{45EED43B-B235-4C24-9176-3B7992DA4D6E}.Release|Any CPU.Build.0 = Release|Any CPU
{98CDED94-F046-4010-88F4-700B7481169E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{98CDED94-F046-4010-88F4-700B7481169E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{98CDED94-F046-4010-88F4-700B7481169E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{98CDED94-F046-4010-88F4-700B7481169E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -137,6 +143,7 @@ Global
{3EE98133-3E7A-4B14-A515-12CB039A9EED} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0}
{77D1D3F8-A04C-4688-AC67-C8372BD268A2} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0}
{45EED43B-B235-4C24-9176-3B7992DA4D6E} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0}
{98CDED94-F046-4010-88F4-700B7481169E} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {28315BFD-90E7-4E14-A2EA-F3D23AF4126F}

39
WebApiService/src/TestHost/Controllers/WeatherForecastController.cs

@ -0,0 +1,39 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace TestHost.Controllers
{
[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
private static readonly string[] Summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};
private readonly ILogger<WeatherForecastController> _logger;
public WeatherForecastController(ILogger<WeatherForecastController> logger)
{
_logger = logger;
}
[HttpGet]
public IEnumerable<WeatherForecast> Get()
{
var rng = new Random();
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
{
Date = DateTime.Now.AddDays(index),
TemperatureC = rng.Next(-20, 55),
Summary = Summaries[rng.Next(Summaries.Length)]
})
.ToArray();
}
}
}

26
WebApiService/src/TestHost/Program.cs

@ -0,0 +1,26 @@
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 TestHost
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
}).UseAutofac();
}
}

31
WebApiService/src/TestHost/Properties/launchSettings.json

@ -0,0 +1,31 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:33955",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"TestHost": {
"commandName": "Project",
"dotnetRunMessages": "true",
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

29
WebApiService/src/TestHost/Startup.cs

@ -0,0 +1,29 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.OpenApi.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace TestHost
{
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddApplication<TestModule>();
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
{
app.InitializeApplication();
}
}
}

17
WebApiService/src/TestHost/TestHost.csproj

@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.1.3" />
<PackageReference Include="Volo.Abp.Core" Version="4.4.2" />
<PackageReference Include="Volo.Abp.Autofac" Version="4.4.2" />
<PackageReference Include="Volo.Abp.Http.Client" Version="4.4.2" />
<PackageReference Include="Volo.Abp.Swashbuckle" Version="4.4.2" />
</ItemGroup>
</Project>

47
WebApiService/src/TestHost/TestModule.cs

@ -0,0 +1,47 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.OpenApi.Models;
using Volo.Abp;
using Volo.Abp.Modularity;
namespace TestHost
{
public class TestModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
var services = context.Services;
services.AddControllers();
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "TestHost", Version = "v1" });
});
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
var app = context.GetApplicationBuilder();
var env = context.GetEnvironment();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseSwagger();
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "TestHost v1"));
}
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
}
}

15
WebApiService/src/TestHost/WeatherForecast.cs

@ -0,0 +1,15 @@
using System;
namespace TestHost
{
public class WeatherForecast
{
public DateTime Date { get; set; }
public int TemperatureC { get; set; }
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
public string Summary { get; set; }
}
}

9
WebApiService/src/TestHost/appsettings.Development.json

@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}

10
WebApiService/src/TestHost/appsettings.json

@ -0,0 +1,10 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*"
}

20
WebApiService/src/Win_in.Sfs.Scp.WebApi.Application.Contracts/Parts/PartCreateDto.cs

@ -1,111 +1,131 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.Xml.Serialization;
using Volo.Abp.Application.Dtos;
using Win_in.Sfs.Scp.WebApi.Domain.Shared;
namespace Win_in.Sfs.Scp.WebApi;
public class PartCreateDto : EntityDto,ICanTrace
{
/// <summary>
/// 代码(Code)
/// </summary>
[XmlElement("code")]
[Display(Name = "代码")]
public string Code { get; set; }
/// <summary>
/// 名称(Name)
/// </summary>
[XmlElement("name")]
[Display(Name = "名称")]
public string Name { get; set; }
/// <summary>
/// 描述(Desc1)
/// </summary>
[XmlElement("desc1")]
[Display(Name = "描述")]
public string Desc1 { get; set; }
/// <summary>
/// 描述2(Desc2)
/// </summary>
[XmlElement("desc2")]
[Display(Name = "描述2")]
public string Desc2 { get; set; }
/// <summary>
/// 状态(Status)
/// </summary>
[XmlElement("status")]
[Display(Name = "状态")]
public string Status { get; set; }
/// <summary>
/// 制造件(Can make)
/// </summary>
[XmlElement("isMakePart")]
[Display(Name = "制造件")]
public bool IsMakePart { get; set; }
/// <summary>
/// 采购件(Can buy)
/// </summary>
[XmlElement("isBuyPart")]
[Display(Name = "采购件")]
public bool IsBuyPart { get; set; }
/// <summary>
/// 计量单位(Uom)
/// </summary>
[XmlElement("uom")]
[Display(Name = "计量单位")]
public string Uom { get; set; }
/// <summary>
/// ABC类(ABC Class)
/// </summary>
[XmlElement("abcClass")]
[Display(Name = "ABC类")]
public string AbcClass { get; set; }
/// <summary>
/// 产品类(Product Line)
/// </summary>
[XmlElement("productLine")]
[Display(Name = "产品类")]
public string ProductLine { get; set; }
/// <summary>
/// 类型(Type)
/// </summary>
[XmlElement("type")]
[Display(Name = "类型")]
public string Type { get; set; }
/// <summary>
/// 种类(Catalog)
/// </summary>
[XmlElement("catalog")]
[Display(Name = "种类")]
public string Catalog { get; set; }
/// <summary>
/// 分组(Group)
/// </summary>
[XmlElement("group")]
[Display(Name = "分组")]
public string Group { get; set; }
/// <summary>
/// 版本(version)
/// </summary>
[XmlElement("version")]
[Display(Name = "版本")]
public string Version { get; set; }
/// <summary>
/// 地点(Site)
/// </summary>
[XmlElement("site")]
[Display(Name = "地点")]
public string Site { get; set; }
/// <summary>
/// 公司(Company)
/// </summary>
[XmlElement("company")]
[Display(Name = "公司")]
public string Company { get; set; }
/// <summary>
/// 跟踪编号(Trace ID)
/// </summary>
[XmlElement("traceId")]
[Display(Name = "跟踪编号")]
public Guid TraceId { get; set; }
}

68
WebApiService/src/Win_in.Sfs.Scp.WebApi.Application.Contracts/Parts/PartDTO.cs

@ -1,5 +1,7 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
using System.Xml.Serialization;
using Volo.Abp.Data;
using Win_in.Sfs.Scp.WebApi.Domain.Shared;
@ -8,154 +10,124 @@ namespace Win_in.Sfs.Scp.WebApi
/// <summary>
/// 零件DTO(Part DTO)
/// </summary>
[Serializable,DataContract]
public class PartDTO : EntityDtoBase<Guid>
{
/// <summary>
/// 代码(Code)
/// </summary>
[DataMember,XmlElement("code")]
[Display(Name = "代码")]
public string Code { get; set; }
/// <summary>
/// 名称(Name)
/// </summary>
[DataMember,XmlElement("name")]
[Display(Name = "名称")]
public string Name { get; set; }
/// <summary>
/// 描述(Desc1)
/// </summary>
[DataMember,XmlElement("desc1")]
[Display(Name = "描述")]
public string Desc1 { get; set; }
/// <summary>
/// 描述2(Desc2)
/// </summary>
[DataMember,XmlElement("desc2")]
[Display(Name = "描述2")]
public string Desc2 { get; set; }
/// <summary>
/// 状态(Status)
/// </summary>
[DataMember,XmlElement("status")]
[Display(Name = "状态")]
public string Status { get; set; }
/// <summary>
/// 制造件(Can make)
/// </summary>
[DataMember,XmlElement("isMakePart")]
[Display(Name = "制造件")]
public bool IsMakePart { get; set; }
/// <summary>
/// 采购件(Can buy)
/// </summary>
[DataMember,XmlElement("isBuyPart")]
[Display(Name = "采购件")]
public bool IsBuyPart { get; set; }
/// <summary>
/// 计量单位(Uom)
/// </summary>
[DataMember,XmlElement("uom")]
[Display(Name = "计量单位")]
public string Uom { get; set; }
/// <summary>
/// ABC类(ABC Class)
/// </summary>
[DataMember,XmlElement("abcClass")]
[Display(Name = "ABC类")]
public string AbcClass { get; set; }
/// <summary>
/// 产品类(Product Line)
/// </summary>
[DataMember,XmlElement("productLine")]
[Display(Name = "产品类")]
public string ProductLine { get; set; }
/// <summary>
/// 类型(Type)
/// </summary>
[DataMember,XmlElement("type")]
[Display(Name = "类型")]
public string Type { get; set; }
/// <summary>
/// 种类(Catalog)
/// </summary>
[DataMember,XmlElement("catalog")]
[Display(Name = "种类")]
public string Catalog { get; set; }
/// <summary>
/// 分组(Group)
/// </summary>
[DataMember,XmlElement("group")]
[Display(Name = "分组")]
public string Group { get; set; }
/// <summary>
/// 版本(version)
/// </summary>
[DataMember,XmlElement("version")]
[Display(Name = "版本")]
public string Version { get; set; }
/// <summary>
/// 地点(Site)
/// </summary>
[DataMember,XmlElement("site")]
[Display(Name = "地点")]
public string Site { get; set; }
/// <summary>
/// 公司(Company)
/// </summary>
[DataMember,XmlElement("company")]
[Display(Name = "公司")]
public string Company { get; set; }
/*
/// <summary>
/// 颜色(Color)
/// </summary>
[Display(Name = "颜色")]
public string Color { get; set; }
/// <summary>
/// 配置(Configuration)
/// </summary>
[Display(Name = "配置")]
public string Configuration { get; set; }
/// <summary>
/// 项目(Project)
/// </summary>
[Display(Name = "项目")]
public string Project { get; set; }
/// <summary>
/// 工程变更通知单(Engineering change order)
/// </summary>
[Display(Name = "工程变更通知单")]
public string Eco { get; set; }
/// <summary>
/// 标包计量单位(Standard Pack Uom)
/// </summary>
[Display(Name = "标包计量单位")]
public string StdPackUom { get; set; }
/// <summary>
/// 标包数量(Standard Pack Qty)
/// </summary>
[Display(Name = "标包数量")]
public decimal StdPackQty { get; set; }
/// <summary>
/// 替代计量单位(Extra Pack UM)
/// </summary>
[Display(Name = "替代计量单位")]
public string ExtPackUom { get; set; }
/// <summary>
/// 替代包装数量(Extra Pack Qty)
/// </summary>
[Display(Name = "替代包装数量")]
public decimal ExtPackQty { get; set; }
*/
}
}

22
WebApiService/src/Win_in.Sfs.Scp.WebApi.Application.Contracts/PurchaseOrders/CreatePurchaseOrderDetailValidator.cs

@ -0,0 +1,22 @@
using FluentValidation;
namespace Win_in.Sfs.Scp.WebApi;
public class CreatePurchaseOrderDetailValidator : AbstractValidator<PurchaseOrderDetailDTO>
{
public CreatePurchaseOrderDetailValidator()
{
RuleFor(q => q.PoNumber).NotEmpty().MaximumLength(64);
RuleFor(q => q.PoLine).NotEmpty().MaximumLength(64);
RuleFor(q => q.PartCode).NotEmpty().MaximumLength(64);
RuleFor(q => q.Uom).NotEmpty().MaximumLength(64);
RuleFor(q => q.OrderQty).NotEmpty();
RuleFor(q => q.StdPackQty).NotEmpty();
RuleFor(q => q.SupplierPackConvertRate);
RuleFor(q => q.IsConsignment).NotEmpty();
RuleFor(q => q.LineStatus).NotEmpty();
RuleFor(q => q.Remark).MaximumLength(4096);
}
}

21
WebApiService/src/Win_in.Sfs.Scp.WebApi.Application.Contracts/PurchaseOrders/PurchaseOrderCreateDTO.cs

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Xml.Serialization;
using Volo.Abp.Application.Dtos;
using Win_in.Sfs.Scp.WebApi.Domain.Shared;
@ -16,94 +17,110 @@ public class PurchaseOrderCreateDTO : EntityDto,ICanTrace
/// <summary>
/// 订单号(PoNumber)
/// </summary>
[XmlElement("poNumber")]
[Display(Name = "订单号(PoNumber)")]
public string PoNumber { set; get; }
/// <summary>
/// 供应商代码(SupplierCode)
/// </summary>
[XmlElement("supplierCode")]
[Display(Name = "供应商代码(SupplierCode)")]
public string SupplierCode { set; get; }
/// <summary>
/// 订单类型(PoType)
/// </summary>
[XmlElement("poType")]
[Display(Name = "订单类型(PoType)")]
public string PoType { set; get; }
/// <summary>
/// 订单状态(Status)
/// </summary>
[XmlElement("status")]
[Display(Name = "订单状态(Status)")]
public int Status { set; get; }
/// <summary>
/// 是否寄存订单(IsConsignment)
/// </summary>
[XmlElement("isCosignment")]
[Display(Name = "是否寄存订单(IsConsignment)")]
public bool IsConsignment { set; get; }
/// <summary>
/// 订单日期(OrderDate)
/// </summary>
[XmlElement("orderDate")]
[Display(Name = "订单日期(OrderDate)")]
public DateTime OrderDate { set; get; }
/// <summary>
/// 截止日期(DueDate)
/// </summary>
[XmlElement("dueDate")]
[Display(Name = "截止日期(DueDate)")]
public DateTime DueDate { set; get; }
/// <summary>
/// 税率(TaxRate)
/// </summary>
[XmlElement("taxRate")]
[Display(Name = "税率(TaxRate)")]
public decimal TaxRate { set; get; }
/// <summary>
/// 版本(version)
/// </summary>
[XmlElement("version")]
[Display(Name = "版本")]
public string Version { get; set; }
/// <summary>
/// 联系人(ContactName)
/// </summary>
[XmlElement("contactName")]
[Display(Name = "联系人(ContactName)")]
public string ContactName { set; get; }
/// <summary>
/// 联系电话(ContactPhone)
/// </summary>
[XmlElement("contactPhone")]
[Display(Name = "联系电话(ContactPhone)")]
public string ContactPhone { set; get; }
/// <summary>
/// 备注(Remark)
/// </summary>
[XmlElement("remark")]
[Display(Name = "备注(Remark)")]
public string Remark { set; get; }
/// <summary>
/// 地点(Site)
/// </summary>
[XmlElement("site")]
[Display(Name = "地点(Site)")]
public string Site { set; get; }
/// <summary>
/// 公司(Company)
/// </summary>
[XmlElement("company")]
[Display(Name = "公司(Company)")]
public string Company { set; get; }
public virtual ICollection<PurchaseOrderDetailDTO> Details { get; set; }
[XmlArray(elementName: "poDetails")]
[XmlArrayItem(elementName: "poDetail")]
public virtual List<PurchaseOrderDetailDTO> Details { get; set; }
/// <summary>
/// 跟踪编号(Trace ID)
/// </summary>
[Display(Name = "跟踪编号")]
[XmlElement("traceId")]
public Guid TraceId { get; set; }
}

24
WebApiService/src/Win_in.Sfs.Scp.WebApi.Application.Contracts/PurchaseOrders/PurchaseOrderDTO.cs

@ -1,6 +1,10 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
using System.Xml.Serialization;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Domain.Entities;
using Win_in.Sfs.Scp.WebApi.Domain.Shared;
namespace Win_in.Sfs.Scp.WebApi
@ -8,94 +12,112 @@ namespace Win_in.Sfs.Scp.WebApi
/// <summary>
/// 采购订单DTO(Purchase order DTO)
/// </summary>
[Serializable, DataContract]
public class PurchaseOrderDTO : EntityDtoBase<Guid>
{
/// <summary>
/// 订单号(PoNumber)
/// </summary>
[DataMember,XmlElement("poNumber")]
[Display(Name = "订单号(PoNumber)")]
public string PoNumber { set; get; }
/// <summary>
/// 供应商代码(SupplierCode)
/// </summary>
[DataMember,XmlElement("supplierCode")]
[Display(Name = "供应商代码(SupplierCode)")]
public string SupplierCode { set; get; }
/// <summary>
/// 订单类型(PoType)
/// </summary>
[DataMember,XmlElement("poType")]
[Display(Name = "订单类型(PoType)")]
public string PoType { set; get; }
/// <summary>
/// 订单状态(Status)
/// </summary>
[DataMember,XmlElement("status")]
[Display(Name = "订单状态(Status)")]
public int Status { set; get; }
/// <summary>
/// 是否寄存订单(IsConsignment)
/// </summary>
[DataMember,XmlElement("isCosignment")]
[Display(Name = "是否寄存订单(IsConsignment)")]
public bool IsConsignment { set; get; }
/// <summary>
/// 订单日期(OrderDate)
/// </summary>
[DataMember,XmlElement("orderDate")]
[Display(Name = "订单日期(OrderDate)")]
public DateTime OrderDate { set; get; }
/// <summary>
/// 截止日期(DueDate)
/// </summary>
[DataMember,XmlElement("dueDate")]
[Display(Name = "截止日期(DueDate)")]
public DateTime DueDate { set; get; }
/// <summary>
/// 税率(TaxRate)
/// </summary>
[DataMember,XmlElement("taxRate")]
[Display(Name = "税率(TaxRate)")]
public decimal TaxRate { set; get; }
/// <summary>
/// 版本(version)
/// </summary>
[DataMember,XmlElement("version")]
[Display(Name = "版本")]
public string Version { get; set; }
/// <summary>
/// 联系人(ContactName)
/// </summary>
[DataMember,XmlElement("contactName")]
[Display(Name = "联系人(ContactName)")]
public string ContactName { set; get; }
/// <summary>
/// 联系电话(ContactPhone)
/// </summary>
[DataMember,XmlElement("contactPhone")]
[Display(Name = "联系电话(ContactPhone)")]
public string ContactPhone { set; get; }
/// <summary>
/// 备注(Remark)
/// </summary>
[DataMember,XmlElement("remark")]
[Display(Name = "备注(Remark)")]
public string Remark { set; get; }
/// <summary>
/// 地点(Site)
/// </summary>
[DataMember,XmlElement("site")]
[Display(Name = "地点(Site)")]
public string Site { set; get; }
/// <summary>
/// 公司(Company)
/// </summary>
[DataMember,XmlElement("company")]
[Display(Name = "公司(Company)")]
public string Company { set; get; }
[XmlArrayItem("poDetail")]
[DataMember,XmlArray("poDetails")]
public virtual List<PurchaseOrderDetailDTO> Details { get; set; }
public virtual ICollection<PurchaseOrderDetailDTO> Details { get; set; }
}
}

47
WebApiService/src/Win_in.Sfs.Scp.WebApi.Application.Contracts/PurchaseOrders/PurchaseOrderDetailDTO.cs

@ -1,6 +1,7 @@
using System;
using System.ComponentModel.DataAnnotations;
using FluentValidation;
using System.Runtime.Serialization;
using System.Xml.Serialization;
using Volo.Abp.Application.Dtos;
using Win_in.Sfs.Scp.WebApi.Domain.Shared;
@ -9,85 +10,89 @@ namespace Win_in.Sfs.Scp.WebApi
/// <summary>
/// 采购订单明细DTO(Purchase order detail DTO)
/// </summary>
public class PurchaseOrderDetailDTO : EntityDetailDtoBase<Guid>
[Serializable, DataContract]
[XmlType("poDetail")]
public class PurchaseOrderDetailDTO : EntityDetailDtoBase
{
/// <summary>
/// 订单号(PoNumber)
/// </summary>
[DataMember]
[XmlElement("poNumber")]
[Display(Name = "订单号(PoNumber)")]
public string PoNumber { set; get; }
/// <summary>
/// 订单行(PoLine)
/// </summary>
[DataMember]
[XmlElement("poLine")]
[Display(Name = "订单行(PoLine)")]
public string PoLine { set; get; }
/// <summary>
/// 零件号(PartCode)
/// </summary>
[DataMember]
[XmlElement("partCode")]
[Display(Name = "零件号(PartCode)")]
public string PartCode { set; get; }
/// <summary>
/// 计量单位(Uom)
/// </summary>
[DataMember]
[XmlElement("uom")]
[Display(Name = "计量单位(Uom)")]
public string Uom { set; get; }
/// <summary>
/// 订单数量(Order Qty)
/// </summary>
[DataMember]
[XmlElement("orderQty")]
[Display(Name = "订单数量(OrderQty)")]
public decimal OrderQty { set; get; }
/// <summary>
/// 标包数量(Standard Pack Qty)
/// </summary>
[DataMember]
[XmlElement("stdPackQty")]
[Display(Name = "标包数量(Standard Pack Qty)")]
public decimal StdPackQty { set; get; }
/// <summary>
/// 供应商包装转换率(SupplierPackConvertRate)
/// </summary>
[DataMember]
[XmlElement("supplierPackConvertRate")]
[Display(Name = "供应商包装转换率(SupplierPackConvertRate)")]
public decimal SupplierPackConvertRate { set; get; }
/// <summary>
/// 是否寄存订单(IsConsignment)
/// </summary>
[DataMember]
[XmlElement("isConsignment")]
[Display(Name = "是否寄存订单(IsConsignment)")]
public bool IsConsignment { set; get; }
/// <summary>
/// 订单行状态(LineStatus)
/// </summary>
[DataMember]
[XmlElement("lineStatus")]
[Display(Name = "订单行状态(LineStatus)")]
public int LineStatus { set; get; }
/// <summary>
/// 备注(Remark)
/// </summary>
[DataMember]
[XmlElement("remark")]
[Display(Name = "备注(Remark)")]
public string Remark { set; get; }
}
public class CreatePurchaseOrderDetailValidator : AbstractValidator<PurchaseOrderDetailDTO>
{
public CreatePurchaseOrderDetailValidator()
{
RuleFor(q => q.PoNumber).NotEmpty().MaximumLength(64);
RuleFor(q => q.PoLine).NotEmpty().MaximumLength(64);
RuleFor(q => q.PartCode).NotEmpty().MaximumLength(64);
RuleFor(q => q.Uom).NotEmpty().MaximumLength(64);
RuleFor(q => q.OrderQty).NotEmpty();
RuleFor(q => q.StdPackQty).NotEmpty();
RuleFor(q => q.SupplierPackConvertRate);
RuleFor(q => q.IsConsignment).NotEmpty();
RuleFor(q => q.LineStatus).NotEmpty();
RuleFor(q => q.Remark).MaximumLength(4096);
}
}
}

21
WebApiService/src/Win_in.Sfs.Scp.WebApi.Application.Contracts/Receipts/ReceiptCreateDTO.cs

@ -1,5 +1,6 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.Xml.Serialization;
using Volo.Abp.Application.Dtos;
using Win_in.Sfs.Scp.WebApi.Domain.Shared;
@ -13,30 +14,35 @@ public class ReceiptCreateDTO : EntityDto,ICanTrace
/// <summary>
/// 收货单号(RcNumber)
/// </summary>
[XmlElement("rcNumber")]
[Display(Name = "收货单号(RcNumber)")]
public string RcNumber { set; get; }
/// <summary>
/// 发货单号(AsnNumber)
/// </summary>
[XmlElement("asnNumber")]
[Display(Name = "发货单号(AsnNumber)")]
public string AsnNumber { set; get; }
/// <summary>
/// 订单号(PoNumber)
/// </summary>
[XmlElement("poNumber")]
[Display(Name = "订单号(PoNumber)")]
public string PoNumber { set; get; }
/// <summary>
/// 供应商代码(PoNumber)
/// </summary>
[XmlElement("supplierCode")]
[Display(Name = "供应商代码(SupplierCode)")]
public string SupplierCode { set; get; }
/// <summary>
/// 收货单类型(RcType)
/// </summary>
[XmlElement("rcType")]
[Display(Name = "收货单类型(RcType)")]
public string RcType { set; get; }
@ -44,90 +50,105 @@ public class ReceiptCreateDTO : EntityDto,ICanTrace
/// <summary>
/// 仓库(Warehouse)
/// </summary>
[XmlElement("warehouse")]
[Display(Name = "仓库(Warehouse)")]
public string Warehouse { set; get; }
/// <summary>
/// 收货口(Dock)
/// </summary>
[XmlElement("dock")]
[Display(Name = "收货口(Dock)")]
public string Dock { set; get; }
/// <summary>
/// 收货日期(ReceiveDate)
/// </summary>
[XmlElement("receiveDate")]
[Display(Name = "收货日期(ReceiveDate)")]
public DateTime ReceiveDate { set; get; }
/// <summary>
/// 收货时间(ReceiveTime)
/// </summary>
[XmlElement("receiveTime")]
[Display(Name = "收货时间(ReceiveTime)")]
public DateTime ReceiveTime { set; get; }
/// <summary>
/// 订单行(PoLine)
/// </summary>
[XmlElement("poLine")]
[Display(Name = "订单行(PoLine)")]
public string PoLine { set; get; }
/// <summary>
/// 零件号(PartCode)
/// </summary>
[XmlElement("partCode")]
[Display(Name = "零件号(PartCode)")]
public string PartCode { set; get; }
/// <summary>
/// 批次(Lot)
/// </summary>
[XmlElement("lot")]
[Display(Name = "批次(Lot)")]
public string Lot { set; get; }
/// <summary>
/// 供应商批次(SupplierLot)
/// </summary>
[XmlElement("supplierLot")]
[Display(Name = "供应商批次(SupplierLot)")]
public string SupplierLot { set; get; }
/// <summary>
/// 计量单位(Uom)
/// </summary>
[XmlElement("uom")]
[Display(Name = "计量单位(Uom)")]
public string Uom { set; get; }
/// <summary>
/// 收货数量(ReceiveQty)
/// </summary>
[XmlElement("receiveQty")]
[Display(Name = "收货数量(ReceiveQty)")]
public decimal ReceiveQty { set; get; }
/// <summary>
/// 供应商包装转换率(SupplierPackConvertRate)
/// </summary>
[XmlElement("supplierPackConvertRate")]
[Display(Name = "供应商包装转换率(SupplierPackConvertRate)")]
public decimal SupplierPackConvertRate { set; get; }
/// <summary>
/// 备注(Remark)
/// </summary>
[XmlElement("remark")]
[Display(Name = "备注(Remark)")]
public string Remark { set; get; }
/// <summary>
/// 地点(Site)
/// </summary>
[XmlElement("site")]
[Display(Name = "地点(Site)")]
public string Site { set; get; }
/// <summary>
/// 公司(Company)
/// </summary>
[XmlElement("company")]
[Display(Name = "公司(Company)")]
public string Company { set; get; }
/// <summary>
/// 跟踪编号(Trace ID)
/// </summary>
[XmlElement("traceId")]
[Display(Name = "跟踪编号")]
public Guid TraceId { get; set; }

25
WebApiService/src/Win_in.Sfs.Scp.WebApi.Application.Contracts/Receipts/ReceiptDTO.cs

@ -1,5 +1,7 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
using System.Xml.Serialization;
using Win_in.Sfs.Scp.WebApi.Domain.Shared;
namespace Win_in.Sfs.Scp.WebApi
@ -7,35 +9,42 @@ namespace Win_in.Sfs.Scp.WebApi
/// <summary>
/// 收货单DTO(Receipt DTO)
/// </summary>
public class ReceiptDTO : EntityDtoBase<Guid>
[Serializable, DataContract]
public class ReceiptDTO : EntityDtoBase<Guid>
{
/// <summary>
/// 收货单号(RcNumber)
/// </summary>
[DataMember,XmlElement("rcNumber")]
[Display(Name = "收货单号(RcNumber)")]
public string RcNumber { set; get; }
/// <summary>
/// 发货单号(AsnNumber)
/// </summary>
[DataMember,XmlElement("asnNumber")]
[Display(Name = "发货单号(AsnNumber)")]
public string AsnNumber { set; get; }
/// <summary>
/// 订单号(PoNumber)
/// </summary>
[DataMember,XmlElement("poNumber")]
[Display(Name = "订单号(PoNumber)")]
public string PoNumber { set; get; }
/// <summary>
/// 供应商代码(PoNumber)
/// </summary>
[DataMember,XmlElement("supplierCode")]
[Display(Name = "供应商代码(SupplierCode)")]
public string SupplierCode { set; get; }
/// <summary>
/// 收货单类型(RcType)
/// </summary>
[DataMember,XmlElement("rcType")]
[Display(Name = "收货单类型(RcType)")]
public string RcType { set; get; }
@ -43,84 +52,98 @@ namespace Win_in.Sfs.Scp.WebApi
/// <summary>
/// 仓库(Warehouse)
/// </summary>
[DataMember,XmlElement("warehouse")]
[Display(Name = "仓库(Warehouse)")]
public string Warehouse { set; get; }
/// <summary>
/// 收货口(Dock)
/// </summary>
[DataMember,XmlElement("dock")]
[Display(Name = "收货口(Dock)")]
public string Dock { set; get; }
/// <summary>
/// 收货日期(ReceiveDate)
/// </summary>
[DataMember,XmlElement("receiveDate")]
[Display(Name = "收货日期(ReceiveDate)")]
public DateTime ReceiveDate { set; get; }
/// <summary>
/// 收货时间(ReceiveTime)
/// </summary>
[DataMember,XmlElement("receiveTime")]
[Display(Name = "收货时间(ReceiveTime)")]
public DateTime ReceiveTime { set; get; }
/// <summary>
/// 订单行(PoLine)
/// </summary>
[DataMember,XmlElement("poLine")]
[Display(Name = "订单行(PoLine)")]
public string PoLine { set; get; }
/// <summary>
/// 零件号(PartCode)
/// </summary>
[DataMember,XmlElement("partCode")]
[Display(Name = "零件号(PartCode)")]
public string PartCode { set; get; }
/// <summary>
/// 批次(Lot)
/// </summary>
[DataMember,XmlElement("lot")]
[Display(Name = "批次(Lot)")]
public string Lot { set; get; }
/// <summary>
/// 供应商批次(SupplierLot)
/// </summary>
[DataMember,XmlElement("supplierLot")]
[Display(Name = "供应商批次(SupplierLot)")]
public string SupplierLot { set; get; }
/// <summary>
/// 计量单位(Uom)
/// </summary>
[DataMember,XmlElement("uom")]
[Display(Name = "计量单位(Uom)")]
public string Uom { set; get; }
/// <summary>
/// 收货数量(ReceiveQty)
/// </summary>
[DataMember,XmlElement("receiveQty")]
[Display(Name = "收货数量(ReceiveQty)")]
public decimal ReceiveQty { set; get; }
/// <summary>
/// 供应商包装转换率(SupplierPackConvertRate)
/// </summary>
[DataMember,XmlElement("supplierPackConvertRate")]
[Display(Name = "供应商包装转换率(SupplierPackConvertRate)")]
public decimal SupplierPackConvertRate { set; get; }
/// <summary>
/// 备注(Remark)
/// </summary>
[DataMember,XmlElement("remark")]
[Display(Name = "备注(Remark)")]
public string Remark { set; get; }
/// <summary>
/// 地点(Site)
/// </summary>
[DataMember,XmlElement("site")]
[Display(Name = "地点(Site)")]
public string Site { set; get; }
/// <summary>
/// 公司(Company)
/// </summary>
[DataMember,XmlElement("company")]
[Display(Name = "公司(Company)")]
public string Company { set; get; }
}

11
WebApiService/src/Win_in.Sfs.Scp.WebApi.Application.Contracts/RouteConsts.cs

@ -0,0 +1,11 @@
namespace Win_in.Sfs.Scp.WebApi
{
public class RouteConsts
{
public const string Part = "api/scp/part";
public const string PurchaseOrder = "api/scp/po";
public const string Receipt = "api/scp/receipt";
public const string Supplier = "api/scp/supplier";
public const string UnplannedReceipt = "api/scp/unplanned-receipt";
}
}

18
WebApiService/src/Win_in.Sfs.Scp.WebApi.Application.Contracts/Suppliers/SupplierCreateDTO.cs

@ -1,5 +1,6 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.Xml.Serialization;
using Volo.Abp.Application.Dtos;
using Win_in.Sfs.Scp.WebApi.Domain.Shared;
@ -13,102 +14,119 @@ public class SupplierCreateDTO : EntityDto,ICanTrace
/// <summary>
/// 代码(Code)
/// </summary>
[XmlElement("code")]
[Display(Name = "代码(Code)")]
public string Code { set; get; }
/// <summary>
/// 简称(Name)
/// </summary>
[XmlElement("name")]
[Display(Name = "简称(Name)")]
public string Name { set; get; }
/// <summary>
/// 描述(Description)
/// </summary>
[XmlElement("desc")]
[Display(Name = "描述(Description)")]
public string Desc { set; get; }
/// <summary>
/// 级别(Rank)
/// </summary>
[XmlElement("rank")]
[Display(Name = "级别(Rank)")]
public string Rank { get; set; }
/// <summary>
/// 地址
/// </summary>
[XmlElement("address")]
[Display(Name = "地址(Address)")]
public string Address { get; set; }
/// <summary>
/// 国家(Country)
/// </summary>
[XmlElement("country")]
[Display(Name = "国家(Country)")]
public string Country { get; set; }
/// <summary>
/// 城市(City)
/// </summary>
[XmlElement("city")]
[Display(Name = "城市(City)")]
public string City { get; set; }
/// <summary>
/// 电话(Phone)
/// </summary>
[XmlElement("phone")]
[Display(Name = "电话(Phone)")]
public string Phone { set; get; }
/// <summary>
/// 传真(Fax)
/// </summary>
[XmlElement("fax")]
[Display(Name = "传真(Fax)")]
public string Fax { set; get; }
/// <summary>
/// 邮编(PostId)
/// </summary>
[XmlElement("postId")]
[Display(Name = "邮编(PostId)")]
public string PostId { set; get; }
/// <summary>
/// 联系人(ContactName)
/// </summary>
[XmlElement("contactName")]
[Display(Name = "联系人(ContactName)")]
public string ContactName { set; get; }
/// <summary>
/// 银行(Bank)
/// </summary>
[XmlElement("bank")]
[Display(Name = "银行(Bank)")]
public string Bank { set; get; }
/// <summary>
/// 货币(Currency)
/// </summary>
[XmlElement("currency")]
[Display(Name = "货币(Currency)")]
public string Currency { set; get; }
/// <summary>
/// 是否激活(IsActive)
/// </summary>
[XmlElement("isActive")]
[Display(Name = "是否激活(IsActive)")]
public bool IsActive { set; get; }
/// <summary>
/// 公司(Company)
/// </summary>
[XmlElement("company")]
[Display(Name = "公司(Company)")]
public string Company { set; get; }
/// <summary>
/// 备注(Remark)
/// </summary>
[XmlElement("remark")]
[Display(Name = "备注(Remark)")]
public string Remark { set; get; }
/// <summary>
/// 跟踪编号(Trace ID)
/// </summary>
[XmlElement("traceId")]
[Display(Name = "跟踪编号")]
public Guid TraceId { get; set; }

23
WebApiService/src/Win_in.Sfs.Scp.WebApi.Application.Contracts/Suppliers/SupplierDTO.cs

@ -1,5 +1,7 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
using System.Xml.Serialization;
using Volo.Abp.Data;
using Win_in.Sfs.Scp.WebApi.Domain.Shared;
@ -8,104 +10,123 @@ namespace Win_in.Sfs.Scp.WebApi
/// <summary>
/// 供应商DTO(Supplier DTO)
/// </summary>
public class SupplierDTO : EntityDtoBase<Guid>
[Serializable, DataContract]
public class SupplierDTO : EntityDtoBase<Guid>
{
/// <summary>
/// 代码(Code)
/// </summary>
[DataMember,XmlElement("code")]
[Display(Name = "代码(Code)")]
public string Code { set; get; }
/// <summary>
/// 简称(Name)
/// </summary>
[DataMember,XmlElement("name")]
[Display(Name = "简称(Name)")]
public string Name { set; get; }
/// <summary>
/// 描述(Description)
/// </summary>
[DataMember,XmlElement("desc")]
[Display(Name = "描述(Description)")]
public string Desc { set; get; }
/// <summary>
/// 级别(Rank)
/// </summary>
[DataMember,XmlElement("rank")]
[Display(Name = "级别(Rank)")]
public string Rank { get; set; }
/// <summary>
/// 地址
/// </summary>
[DataMember,XmlElement("address")]
[Display(Name = "地址(Address)")]
public string Address { get; set; }
/// <summary>
/// 国家(Country)
/// </summary>
[DataMember,XmlElement("country")]
[Display(Name = "国家(Country)")]
public string Country { get; set; }
/// <summary>
/// 城市(City)
/// </summary>
[DataMember,XmlElement("city")]
[Display(Name = "城市(City)")]
public string City { get; set; }
/// <summary>
/// 电话(Phone)
/// </summary>
[DataMember,XmlElement("phone")]
[Display(Name = "电话(Phone)")]
public string Phone { set; get; }
/// <summary>
/// 传真(Fax)
/// </summary>
[DataMember,XmlElement("fax")]
[Display(Name = "传真(Fax)")]
public string Fax { set; get; }
/// <summary>
/// 邮编(PostId)
/// </summary>
[DataMember,XmlElement("postId")]
[Display(Name = "邮编(PostId)")]
public string PostId { set; get; }
/// <summary>
/// 联系人(ContactName)
/// </summary>
[DataMember,XmlElement("contactName")]
[Display(Name = "联系人(ContactName)")]
public string ContactName { set; get; }
/// <summary>
/// 银行(Bank)
/// </summary>
[DataMember,XmlElement("bank")]
[Display(Name = "银行(Bank)")]
public string Bank { set; get; }
/// <summary>
/// 货币(Currency)
/// </summary>
[DataMember,XmlElement("currency")]
[Display(Name = "货币(Currency)")]
public string Currency { set; get; }
/// <summary>
/// 是否激活(IsActive)
/// </summary>
[DataMember,XmlElement("isActive")]
[Display(Name = "是否激活(IsActive)")]
public bool IsActive { set; get; }
/// <summary>
/// 公司(Company)
/// </summary>
[DataMember,XmlElement("company")]
[Display(Name = "公司(Company)")]
public string Company { set; get; }
/// <summary>
/// 备注(Remark)
/// </summary>
[DataMember,XmlElement("remark")]
[Display(Name = "备注(Remark)")]
public string Remark { set; get; }
}
}

16
WebApiService/src/Win_in.Sfs.Scp.WebApi.Application.Contracts/UnplannedReceipts/UnplannedReceiptCreateDTO.cs

@ -1,5 +1,6 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.Xml.Serialization;
using Volo.Abp.Application.Dtos;
using Win_in.Sfs.Scp.WebApi.Domain.Shared;
@ -13,30 +14,35 @@ public class UnplannedReceiptCreateDTO : EntityDto,ICanTrace
/// <summary>
/// 单号(TrNbr)
/// </summary>
[XmlElement("trNbr")]
[Display(Name = "单号(TrNbr)")]
public long TrNbr { set; get; }
/// <summary>
/// 事务类型(TrType)
/// </summary>
[XmlElement("trType")]
[Display(Name = "事务类型(TrType)")]
public string TrType { set; get; }
/// <summary>
/// 订单号(Order)
/// </summary>
[XmlElement("order")]
[Display(Name = "订单号(Order)")]
public string Order { set; get; }
/// <summary>
/// 零件号(PartCode)
/// </summary>
[XmlElement("partCode")]
[Display(Name = "零件号(PartCode)")]
public string PartCode { set; get; }
/// <summary>
/// 批次(Lot)
/// </summary>
[XmlElement("lot")]
[Display(Name = "批次(Lot)")]
public string Lot { set; get; }
@ -44,36 +50,42 @@ public class UnplannedReceiptCreateDTO : EntityDto,ICanTrace
/// <summary>
/// 计量单位(Uom)
/// </summary>
[XmlElement("uom")]
[Display(Name = "计量单位(Uom)")]
public string Uom { set; get; }
/// <summary>
/// 数量(Qty)
/// </summary>
[XmlElement("qty")]
[Display(Name = "数量(Qty)")]
public decimal Qty { set; get; }
/// <summary>
/// 库位(Location)
/// </summary>
[XmlElement("location")]
[Display(Name = "库位(Location)")]
public string Location { set; get; }
/// <summary>
/// 生效日期(EffectiveDate)
/// </summary>
[XmlElement("effectiveDate")]
[Display(Name = "生效日期(EffectiveDate)")]
public DateTime EffectiveDate { set; get; }
/// <summary>
/// 系统日期(SystemDate)
/// </summary>
[XmlElement("systemDate")]
[Display(Name = "系统日期(SystemDate)")]
public DateTime SystemDate { set; get; }
/// <summary>
/// 客户单(so job)
/// </summary>
[XmlElement("soJob")]
[Display(Name = "客户单(so job)")]
public string SoJob { get; set; }
@ -82,24 +94,28 @@ public class UnplannedReceiptCreateDTO : EntityDto,ICanTrace
/// <summary>
/// 备注(Remark)
/// </summary>
[XmlElement("remark")]
[Display(Name = "备注(Remark)")]
public string Remark { set; get; }
/// <summary>
/// 地点(Site)
/// </summary>
[XmlElement("site")]
[Display(Name = "地点(Site)")]
public string Site { set; get; }
/// <summary>
/// 公司(Company)
/// </summary>
[XmlElement("company")]
[Display(Name = "公司(Company)")]
public string Company { set; get; }
/// <summary>
/// 跟踪编号(Trace ID)
/// </summary>
[XmlElement("traceId")]
[Display(Name = "跟踪编号")]
public Guid TraceId { get; set; }

21
WebApiService/src/Win_in.Sfs.Scp.WebApi.Application.Contracts/UnplannedReceipts/UnplannedReceiptDTO.cs

@ -1,5 +1,7 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
using System.Xml.Serialization;
using Win_in.Sfs.Scp.WebApi.Domain.Shared;
namespace Win_in.Sfs.Scp.WebApi
@ -7,35 +9,42 @@ namespace Win_in.Sfs.Scp.WebApi
/// <summary>
/// 计划外入库单DTO(Unplanned Receipt DTO)
/// </summary>
public class UnplannedReceiptDTO : EntityDtoBase<Guid>
[Serializable, DataContract]
public class UnplannedReceiptDTO : EntityDtoBase<Guid>
{
/// <summary>
/// 单号(TrNbr)
/// </summary>
[DataMember,XmlElement("trNbr")]
[Display(Name = "单号(TrNbr)")]
public long TrNbr { set; get; }
/// <summary>
/// 事务类型(TrType)
/// </summary>
[DataMember,XmlElement("trType")]
[Display(Name = "事务类型(TrType)")]
public string TrType { set; get; }
/// <summary>
/// 订单号(Order)
/// </summary>
[DataMember,XmlElement("order")]
[Display(Name = "订单号(Order)")]
public string Order { set; get; }
/// <summary>
/// 零件号(PartCode)
/// </summary>
[DataMember,XmlElement("partCode")]
[Display(Name = "零件号(PartCode)")]
public string PartCode { set; get; }
/// <summary>
/// 批次(Lot)
/// </summary>
[DataMember,XmlElement("lot")]
[Display(Name = "批次(Lot)")]
public string Lot { set; get; }
@ -43,36 +52,42 @@ namespace Win_in.Sfs.Scp.WebApi
/// <summary>
/// 计量单位(Uom)
/// </summary>
[DataMember,XmlElement("uom")]
[Display(Name = "计量单位(Uom)")]
public string Uom { set; get; }
/// <summary>
/// 数量(Qty)
/// </summary>
[DataMember,XmlElement("qty")]
[Display(Name = "数量(Qty)")]
public decimal Qty { set; get; }
/// <summary>
/// 库位(Location)
/// </summary>
[DataMember,XmlElement("location")]
[Display(Name = "库位(Location)")]
public string Location { set; get; }
/// <summary>
/// 生效日期(EffectiveDate)
/// </summary>
[DataMember,XmlElement("effectiveDate")]
[Display(Name = "生效日期(EffectiveDate)")]
public DateTime EffectiveDate { set; get; }
/// <summary>
/// 系统日期(SystemDate)
/// </summary>
[DataMember,XmlElement("systemDate")]
[Display(Name = "系统日期(SystemDate)")]
public DateTime SystemDate { set; get; }
/// <summary>
/// 客户单(so job)
/// </summary>
[DataMember,XmlElement("soJob")]
[Display(Name = "客户单(so job)")]
public string SoJob { get; set; }
@ -81,19 +96,23 @@ namespace Win_in.Sfs.Scp.WebApi
/// <summary>
/// 备注(Remark)
/// </summary>
[DataMember,XmlElement("remark")]
[Display(Name = "备注(Remark)")]
public string Remark { set; get; }
/// <summary>
/// 地点(Site)
/// </summary>
[DataMember,XmlElement("site")]
[Display(Name = "地点(Site)")]
public string Site { set; get; }
/// <summary>
/// 公司(Company)
/// </summary>
[DataMember,XmlElement("company")]
[Display(Name = "公司(Company)")]
public string Company { set; get; }
}
}

4
WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/Parts/PartAppService.cs

@ -15,7 +15,7 @@ namespace Win_in.Sfs.Scp.WebApi
/// 零件服务
/// </summary>
[Authorize]
[Route("api/scp/part")]
[Route(RouteConsts.Part)]
[ApiExplorerSettings(GroupName = SwaggerGroupConsts.ScpWebApi)]
public class PartAppService :ReadOnlyAppService<Part,PartDTO,Guid, RequestDTO>, IPartAppService
@ -70,5 +70,7 @@ namespace Win_in.Sfs.Scp.WebApi
return dto;
}
}
}

2
WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/PurchaseOrders/PurchaseOrderAppService.cs

@ -12,7 +12,7 @@ namespace Win_in.Sfs.Scp.WebApi
/// 采购订单服务
/// </summary>
[Authorize]
[Route("api/scp/po")]
[Route(RouteConsts.PurchaseOrder)]
[ApiExplorerSettings(GroupName = SwaggerGroupConsts.ScpWebApi)]
public class PurchaseOrderAppService : ReadOnlyAppService<PurchaseOrder, PurchaseOrderDTO, Guid,RequestDTO>, IPurchaseOrderAppService
{

2
WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/Receipts/ReceiptAppService.cs

@ -12,7 +12,7 @@ namespace Win_in.Sfs.Scp.WebApi
/// 收货单服务
/// </summary>
[Authorize]
[Route("api/scp/receipt")]
[Route(RouteConsts.Receipt)]
[ApiExplorerSettings(GroupName = SwaggerGroupConsts.ScpWebApi)]
public class ReceiptAppService : ReadOnlyAppService<Receipt, ReceiptDTO, Guid,RequestDTO>, IReceiptAppService
{

2
WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/Suppliers/SuppliersAppService.cs

@ -13,7 +13,7 @@ namespace Win_in.Sfs.Scp.WebApi
/// 供应商服务
/// </summary>
[Authorize]
[Route("api/scp/supplier")]
[Route(RouteConsts.Supplier)]
[ApiExplorerSettings(GroupName = SwaggerGroupConsts.ScpWebApi)]
public class SuppliersAppService : ReadOnlyAppService<Supplier, SupplierDTO, Guid,RequestDTO>, ISupplierAppService
{

2
WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/UnplannedReceipts/UnplannedReceiptAppService.cs

@ -12,7 +12,7 @@ namespace Win_in.Sfs.Scp.WebApi
/// 计划外入库单服务
/// </summary>
[Authorize]
[Route("api/scp/unplanned-receipt")]
[Route(RouteConsts.UnplannedReceipt)]
[ApiExplorerSettings(GroupName = SwaggerGroupConsts.ScpWebApi)]
public class UnplannedReceiptAppService : ReadOnlyAppService<UnplannedReceipt, UnplannedReceiptDTO, Guid,RequestDTO>, IUnplannedReceiptAppService
{

16
WebApiService/src/Win_in.Sfs.Scp.WebApi.Application/WebApiApplicationAutoMapperProfile.cs

@ -25,7 +25,7 @@ namespace Win_in.Sfs.Scp.WebApi
private void CreateMapPart()
{
CreateMap<Part, PartDTO>().ReverseMap();
CreateMap<Part, PartDTO>();
CreateMap<PartCreateDto, Part>()
.Ignore(p=>p.Id)
.Ignore(p=>p.CreatorId)
@ -38,7 +38,7 @@ namespace Win_in.Sfs.Scp.WebApi
private void CreateMapSupplier()
{
CreateMap<Supplier, SupplierDTO>().ReverseMap();
CreateMap<Supplier, SupplierDTO>();
CreateMap<SupplierCreateDTO,Supplier>()
.Ignore(p => p.Id)
.Ignore(p => p.CreatorId)
@ -52,7 +52,7 @@ namespace Win_in.Sfs.Scp.WebApi
private void CreateMapReceipt()
{
CreateMap<Receipt, ReceiptDTO>().ReverseMap();
CreateMap<Receipt, ReceiptDTO>();
CreateMap<ReceiptCreateDTO, Receipt>()
.Ignore(p => p.Id)
.Ignore(p => p.CreatorId)
@ -66,7 +66,7 @@ namespace Win_in.Sfs.Scp.WebApi
private void CreateMapPurchaseOrder()
{
CreateMap<PurchaseOrder, PurchaseOrderDTO>().ReverseMap();
CreateMap<PurchaseOrder, PurchaseOrderDTO>();
CreateMap<PurchaseOrderCreateDTO, PurchaseOrder>()
.Ignore(p => p.Id)
.Ignore(p => p.CreatorId)
@ -79,12 +79,16 @@ namespace Win_in.Sfs.Scp.WebApi
private void CreateMapPurchaseOrderDetail()
{
CreateMap<PurchaseOrderDetail, PurchaseOrderDetailDTO>().ReverseMap();
CreateMap<PurchaseOrderDetail, PurchaseOrderDetailDTO>();
CreateMap<PurchaseOrderDetailDTO,PurchaseOrderDetail>()
.Ignore(p => p.Id)
.Ignore(p => p.CreatorId)
.Ignore(p => p.CreationTime);
}
private void CreateMapUnplannedReceipt()
{
CreateMap<UnplannedReceipt, UnplannedReceiptDTO>().ReverseMap();
CreateMap<UnplannedReceipt, UnplannedReceiptDTO>();
CreateMap<UnplannedReceiptCreateDTO, UnplannedReceipt>()
.Ignore(p => p.Id)
.Ignore(p => p.CreatorId)

4
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/EntityBase/EntityDetailDtoBase.cs

@ -1,11 +1,13 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Domain.Entities.Auditing;
namespace Win_in.Sfs.Scp.WebApi.Domain.Shared
{
public class EntityDetailDtoBase<TKey> : CreationAuditedEntityDto<TKey>
[Serializable, DataContract]
public class EntityDetailDtoBase :IEntityDto
{
}

21
WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain.Shared/EntityBase/EntityDtoBase.cs

@ -1,12 +1,31 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
using System.Xml.Serialization;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Domain.Entities.Auditing;
namespace Win_in.Sfs.Scp.WebApi.Domain.Shared
{
public class EntityDtoBase<TKey> : CreationAuditedEntityDto<TKey>, ICanTrace
[Serializable,DataContract]
public class EntityDtoBase<TKey> :IEntityDto<TKey>, ICanTrace
{
[DataMember]
public TKey Id { get; set; }
[DataMember]
public DateTime CreationTime { get; set; }
[DataMember]
public Guid? CreatorId { get; set; }
/// <summary>
/// 跟踪编号(Trace ID)
/// </summary>
[DataMember]
[Display(Name = "跟踪编号")]
public Guid TraceId { get; set; }
}
}

11
WebApiService/src/Win_in.Sfs.Scp.WebApi.HttpApi.Host/WebApiHttpApiHostModule.cs

@ -8,6 +8,7 @@ using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ApiExplorer;
using Microsoft.AspNetCore.Mvc.Formatters;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
@ -55,6 +56,8 @@ namespace Win_in.Sfs.Scp.WebApi
var configuration = context.Services.GetConfiguration();
var hostingEnvironment = context.Services.GetHostingEnvironment();
ConfigureBundles();
ConfigureUrls(configuration);
ConfigureConventionalControllers();
@ -64,14 +67,18 @@ namespace Win_in.Sfs.Scp.WebApi
ConfigureCors(context, configuration);
ConfigureSwaggerServices(context, configuration);
ConfigureAuthorization(context);
ConfigureAuthorization(context,configuration);
}
private static void ConfigureAuthorization(ServiceConfigurationContext context)
private static void ConfigureAuthorization(ServiceConfigurationContext context, IConfiguration configuration)
{
var alwaysAllowAuthorization = Convert.ToBoolean(configuration["AlwaysAllowAuthorization"]);
if (alwaysAllowAuthorization)
{
//绕过授权服务
context.Services.AddAlwaysAllowAuthorization();
}
}
private void ConfigureBundles()
{

5
WebApiService/src/Win_in.Sfs.Scp.WebApi.HttpApi.Host/appsettings.json

@ -1,7 +1,7 @@
{
"App": {
"SelfUrl": "https://localhost:9988",
"CorsOrigins": "http://*.WebApi.com",
"CorsOrigins": "https://scp.iacchina.net:9977,https://localhost:9977,https://localhost:9988,https://scp.iacchina.net:9988",
"RedirectAllowedUrls": "http://localhost:4200,https://localhost:9988"
},
"ConnectionStrings": {
@ -37,5 +37,6 @@
"RootUrl": "https://localhost:9988"
}
}
}
},
"AlwaysAllowAuthorization": true
}

83
WebApiService/src/Win_in.Sfs.Scp.WebApi.Xml.Host/BasicAuthHttpModule.cs

@ -0,0 +1,83 @@
using Microsoft.AspNetCore.Authentication;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http.Headers;
using System.Security.Claims;
using System.Text;
using System.Text.Encodings.Web;
using System.Threading.Tasks;
namespace ApiBasicAuth.Security
{
public class BasicAuthenticationHandler : AuthenticationHandler<AuthenticationSchemeOptions>
{
private readonly BasicAuthenticationOptions _basicOptions;
public BasicAuthenticationHandler(
IOptions<BasicAuthenticationOptions> basicOptions,
IOptionsMonitor<AuthenticationSchemeOptions> options,
ILoggerFactory logger,
UrlEncoder encoder,
ISystemClock clock)
: base(options, logger, encoder, clock)
{
_basicOptions = basicOptions.Value;
}
protected override async Task<AuthenticateResult> HandleAuthenticateAsync()
{
if (!Request.Headers.ContainsKey("Authorization"))
{
Response.Headers.Add("WWW-Authenticate", @"Basic realm='Secure Area'");
return AuthenticateResult.Fail("Missing Authorization Header");
}
User user = null;
try
{
var authHeader = AuthenticationHeaderValue.Parse(Request.Headers["Authorization"]);
var credentialBytes = Convert.FromBase64String(authHeader.Parameter);
var credentials = Encoding.UTF8.GetString(credentialBytes).Split(new[] { ':' }, 2);
var username = credentials[0];
var password = credentials[1];
if (username.Equals(_basicOptions.Username) && password.Equals(_basicOptions.Password))
{
user = new User { Id = 1, Username = "admin", Birthday = DateTime.Now };
}
}
catch
{
// Base64×Ö·û´®½âÂëʧ°Ü
return AuthenticateResult.Fail("Invalid Authorization Header");
}
if (user == null)
return AuthenticateResult.Fail("Invalid Username or Password");
var claims = new[] {
new Claim(ClaimTypes.NameIdentifier, user.Id.ToString()),
new Claim(ClaimTypes.Name, user.Username),
};
var identity = new ClaimsIdentity(claims, Scheme.Name);
var principal = new ClaimsPrincipal(identity);
var ticket = new AuthenticationTicket(principal, Scheme.Name);
return AuthenticateResult.Success(ticket);
}
}
public class BasicAuthenticationOptions
{
public string Username { get; set; } = "admin";
public string Password { get; set; } = "3edc$RFV";
}
public class User
{
public int Id { get; set; }
public string Username { get; set; }
public DateTime Birthday { get; set; }
}
}

41
WebApiService/src/Win_in.Sfs.Scp.WebApi.Xml.Host/Controllers/PartController.cs

@ -0,0 +1,41 @@
using System;
using System.Diagnostics.Eventing.Reader;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Net.Http.Json;
using System.Net.Mime;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using RestSharp;
namespace Win_in.Sfs.Scp.WebApi.XmlHost.Controllers
{
[Authorize]
[Route(RouteConsts.Part)]
public class PartController : ControllerBase
{
private readonly IHttpClientInvoker<PartCreateDto, PartDTO> _httpClientInvoker;
public PartController(IHttpClientInvoker<PartCreateDto,PartDTO> httpClientInvoker)
{
_httpClientInvoker = httpClientInvoker;
}
/// <summary>
/// 新增零件(Add part)
/// </summary>
/// <returns></returns>
[HttpPost]
[Route("")]
[Consumes(MediaTypeNames.Application.Xml)]
[Produces(MediaTypeNames.Application.Xml)]
public virtual async Task<ActionResult<PartDTO>> CreateAsync([FromBody]PartCreateDto input)
{
var dto = await _httpClientInvoker.InvokeAsync(input, RouteConsts.Part);
return Ok(dto);
}
}
}

33
WebApiService/src/Win_in.Sfs.Scp.WebApi.Xml.Host/Controllers/PurchaseOrderController.cs

@ -0,0 +1,33 @@
using System.Net.Mime;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
namespace Win_in.Sfs.Scp.WebApi.XmlHost.Controllers
{
[Route(RouteConsts.PurchaseOrder)]
public class PurchaseOrderController : ControllerBase
{
private readonly IHttpClientInvoker<PurchaseOrderCreateDTO, PurchaseOrderDTO> _httpClientInvoker;
public PurchaseOrderController(IHttpClientInvoker<PurchaseOrderCreateDTO, PurchaseOrderDTO> httpClientInvoker)
{
_httpClientInvoker = httpClientInvoker;
}
/// <summary>
/// 新增采购订单(Add purchase order)
/// </summary>
/// <returns></returns>
[HttpPost]
[Route("")]
[Consumes(MediaTypeNames.Application.Xml)]
[Produces(MediaTypeNames.Application.Xml)]
public virtual async Task<ActionResult<PurchaseOrderDTO>> CreateAsync([FromBody] PurchaseOrderCreateDTO input)
{
var dto = await _httpClientInvoker.InvokeAsync(input, RouteConsts.PurchaseOrder);
return Ok(dto);
}
}
}

33
WebApiService/src/Win_in.Sfs.Scp.WebApi.Xml.Host/Controllers/ReceiptController.cs

@ -0,0 +1,33 @@
using System.Net.Mime;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
namespace Win_in.Sfs.Scp.WebApi.XmlHost.Controllers
{
[Route(RouteConsts.Receipt)]
public class ReceiptController : ControllerBase
{
private readonly IHttpClientInvoker<ReceiptCreateDTO, ReceiptDTO> _httpClientInvoker;
public ReceiptController(IHttpClientInvoker<ReceiptCreateDTO, ReceiptDTO> httpClientInvoker)
{
_httpClientInvoker = httpClientInvoker;
}
/// <summary>
/// 新增收货/退货单(Add receipt/return receipt)
/// </summary>
/// <returns></returns>
[HttpPost]
[Route("")]
[Consumes(MediaTypeNames.Application.Xml)]
[Produces(MediaTypeNames.Application.Xml)]
public virtual async Task<ActionResult<ReceiptDTO>> CreateAsync([FromBody] ReceiptCreateDTO input)
{
var dto = await _httpClientInvoker.InvokeAsync(input, RouteConsts.Receipt);
return Ok(dto);
}
}
}

33
WebApiService/src/Win_in.Sfs.Scp.WebApi.Xml.Host/Controllers/SupplierController.cs

@ -0,0 +1,33 @@
using System.Net.Mime;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
namespace Win_in.Sfs.Scp.WebApi.XmlHost.Controllers
{
[Route(RouteConsts.Supplier)]
public class SupplierController : ControllerBase
{
private readonly IHttpClientInvoker<SupplierCreateDTO, SupplierDTO> _httpClientInvoker;
public SupplierController(IHttpClientInvoker<SupplierCreateDTO, SupplierDTO> httpClientInvoker)
{
_httpClientInvoker = httpClientInvoker;
}
/// <summary>
/// 新增供应商(Add supplier)
/// </summary>
/// <returns></returns>
[HttpPost]
[Route("")]
[Consumes(MediaTypeNames.Application.Xml)]
[Produces(MediaTypeNames.Application.Xml)]
public virtual async Task<ActionResult<SupplierDTO>> CreateAsync([FromBody] SupplierCreateDTO input)
{
var dto = await _httpClientInvoker.InvokeAsync(input, RouteConsts.Supplier);
return Ok(dto);
}
}
}

32
WebApiService/src/Win_in.Sfs.Scp.WebApi.Xml.Host/Controllers/UnplannedReceiptController.cs

@ -0,0 +1,32 @@
using System.Net.Mime;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
namespace Win_in.Sfs.Scp.WebApi.XmlHost.Controllers
{
[Route(RouteConsts.UnplannedReceipt)]
public class UnplannedReceiptController : ControllerBase
{
private readonly IHttpClientInvoker<UnplannedReceiptCreateDTO, UnplannedReceiptDTO> _httpClientInvoker;
public UnplannedReceiptController(IHttpClientInvoker<UnplannedReceiptCreateDTO, UnplannedReceiptDTO> httpClientInvoker)
{
_httpClientInvoker = httpClientInvoker;
}
/// <summary>
/// 新增计划外入库单(Add unplanned receipt)
/// </summary>
/// <returns></returns>
[HttpPost]
[Route("")]
[Consumes(MediaTypeNames.Application.Xml)]
[Produces(MediaTypeNames.Application.Xml)]
public virtual async Task<ActionResult<UnplannedReceiptDTO>> CreateAsync([FromBody] UnplannedReceiptCreateDTO input)
{
var dto = await _httpClientInvoker.InvokeAsync(input, RouteConsts.UnplannedReceipt);
return Ok(dto);
}
}
}

36
WebApiService/src/Win_in.Sfs.Scp.WebApi.Xml.Host/HttpClientInvoker.cs

@ -0,0 +1,36 @@
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Net.Http.Json;
using System.Runtime.Serialization;
using System.Threading.Tasks;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Options;
namespace Win_in.Sfs.Scp.WebApi.XmlHost
{
public class HttpClientInvoker<TInput, TOutput> : IHttpClientInvoker<TInput, TOutput>
{
private readonly IConfiguration _configuration;
public HttpClientInvoker(IConfiguration configuration)
{
_configuration = configuration;
}
public async Task<TOutput> InvokeAsync(TInput input,string routeString)
{
var baseUrl = _configuration["RemoteServices:Default:BaseUrl"];
var client = new HttpClient();
client.BaseAddress = new Uri(baseUrl);
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
var response = await client.PostAsJsonAsync(routeString, input);
response.EnsureSuccessStatusCode();
var dto = await response.Content.ReadFromJsonAsync<TOutput>();
return dto;
}
}
}

10
WebApiService/src/Win_in.Sfs.Scp.WebApi.Xml.Host/IHttpClientInvoker.cs

@ -0,0 +1,10 @@
using System.Runtime.Serialization;
using System.Threading.Tasks;
namespace Win_in.Sfs.Scp.WebApi.XmlHost
{
public interface IHttpClientInvoker<TInput,TOutput>
{
Task<TOutput> InvokeAsync(TInput input,string routeString);
}
}

5285
WebApiService/src/Win_in.Sfs.Scp.WebApi.Xml.Host/Logs/logs.txt

File diff suppressed because it is too large

59
WebApiService/src/Win_in.Sfs.Scp.WebApi.Xml.Host/Program.cs

@ -0,0 +1,59 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using System;
using Serilog;
using Serilog.Events;
namespace Win_in.Sfs.Scp.WebApi.XmlHost
{
public class Program
{
public static int Main(string[] args)
{
InitLogger();
try
{
Log.Information("Starting Win_in.Sfs.Scp.WebApi.Xml.Host.");
CreateHostBuilder(args).Build().Run();
return 0;
}
catch (Exception ex)
{
Log.Fatal(ex, "Host terminated unexpectedly!");
return 1;
}
finally
{
Log.CloseAndFlush();
}
}
private static void InitLogger()
{
Log.Logger = new LoggerConfiguration()
#if DEBUG
.MinimumLevel.Debug()
#else
.MinimumLevel.Information()
#endif
.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
.MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning)
.Enrich.FromLogContext()
.WriteTo.Async(c => c.File("Logs/logs.txt"))
#if DEBUG
.WriteTo.Async(c => c.Console())
#endif
.CreateLogger();
}
internal static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
})
.UseSerilog();
}
}

15
WebApiService/src/Win_in.Sfs.Scp.WebApi.Xml.Host/Properties/launchSettings.json

@ -0,0 +1,15 @@
{
"profiles": {
"Win_in.Sfs.Scp.WebApi.Xml.Host": {
"commandName": "Project",
"dotnetRunMessages": "true",
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:9977",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

75
WebApiService/src/Win_in.Sfs.Scp.WebApi.Xml.Host/Startup.cs

@ -0,0 +1,75 @@
using ApiBasicAuth.Security;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.AspNetCore.Mvc.ModelBinding.Metadata;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.OpenApi.Models;
namespace Win_in.Sfs.Scp.WebApi.XmlHost
{
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
// services.AddControllers()
// .AddXmlDataContractSerializerFormatters();
var configuration = services.GetConfiguration();
services.AddControllers()
.AddMvcOptions(options =>
{
// options.ModelMetadataDetailsProviders.Add(
// new ExcludeBindingMetadataProvider(typeof(System.Version)));
// options.ModelMetadataDetailsProviders.Add(
// new SuppressChildValidationMetadataProvider(typeof(System.Guid)));
options.InputFormatters.Insert(0, new XDocumentInputFormatter());
// options.OutputFormatters.Insert(0,new XDocumentOutputFormatter());
})
.AddXmlDataContractSerializerFormatters()
.AddXmlSerializerFormatters();
// services.AddControllers();
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "Win_in.Sfs.Scp.WebApi.Xml.Host", Version = "v1" });
});
services.AddAuthentication("BasicAuthentication")
.AddScheme<AuthenticationSchemeOptions, BasicAuthenticationHandler>("BasicAuthentication", null);
services.Configure<BasicAuthenticationOptions>(configuration.GetSection("BasicAuthentication"));
services.AddSingleton(typeof(IHttpClientInvoker<,>),typeof(HttpClientInvoker<,>));
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseSwagger();
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "Win_in.Sfs.Scp.WebApi.Xml.Host v1"));
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
}
}

27
WebApiService/src/Win_in.Sfs.Scp.WebApi.Xml.Host/Win_in - Backup.Sfs.Scp.WebApi.Xml.Host.csproj

@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<RootNamespace>Win_in.Sfs.Scp.WebApi.XmlHost</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.1.3" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Serilog.AspNetCore" Version="4.1.0" />
<PackageReference Include="Serilog.Sinks.Async" Version="1.4.0" />
<PackageReference Include="Volo.Abp.Autofac" Version="4.4.2" />
<PackageReference Include="Volo.Abp.AspNetCore.Serilog" Version="4.4.2" />
<PackageReference Include="Volo.Abp.Swashbuckle" Version="4.4.2" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Win_in.Sfs.Scp.WebApi.Application.Contracts\Win_in.Sfs.Scp.WebApi.Application.Contracts.csproj" />
<ProjectReference Include="..\Win_in.Sfs.Scp.WebApi.HttpApi.Client\Win_in.Sfs.Scp.WebApi.HttpApi.Client.csproj" />
</ItemGroup>
</Project>

21
WebApiService/src/Win_in.Sfs.Scp.WebApi.Xml.Host/Win_in.Sfs.Scp.WebApi.Xml.Host.csproj

@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<RootNamespace>Win_in.Sfs.Scp.WebApi.XmlHost</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Formatters.Xml" Version="2.2.0" />
<PackageReference Include="RestSharp" Version="107.0.3" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.1.3" />
<PackageReference Include="Serilog.AspNetCore" Version="4.1.0" />
<PackageReference Include="Serilog.Sinks.Async" Version="1.4.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Win_in.Sfs.Scp.WebApi.Application.Contracts\Win_in.Sfs.Scp.WebApi.Application.Contracts.csproj" />
</ItemGroup>
</Project>

41
WebApiService/src/Win_in.Sfs.Scp.WebApi.Xml.Host/XDocumentInputFormatter.cs

@ -0,0 +1,41 @@
using System;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Linq;
using System.Xml.Serialization;
using Microsoft.AspNetCore.Mvc.ApiExplorer;
using Microsoft.AspNetCore.Mvc.Formatters;
namespace Win_in.Sfs.Scp.WebApi.XmlHost
{
public class XDocumentInputFormatter : InputFormatter, IInputFormatter, IApiRequestFormatMetadataProvider
{
private Type currentType { get; set; }
public XDocumentInputFormatter()
{
SupportedMediaTypes.Add("application/xml");
}
protected override bool CanReadType(Type type)
{
currentType = type;
if (type.IsAssignableFrom(typeof(XDocument))) return true;
return base.CanReadType(type);
}
public override async Task<InputFormatterResult> ReadRequestBodyAsync(InputFormatterContext context)
{
// Use StreamReader to convert any encoding to UTF-16 (default C# and sql Server).
using var streamReader = new StreamReader(context.HttpContext.Request.Body);
var xmlDoc = await XDocument.LoadAsync(streamReader, LoadOptions.None, CancellationToken.None);
var model = new XmlSerializer(currentType).Deserialize(xmlDoc.CreateReader());
return await InputFormatterResult.SuccessAsync(model);
}
}
}

9
WebApiService/src/Win_in.Sfs.Scp.WebApi.Xml.Host/appsettings.Development.json

@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}

20
WebApiService/src/Win_in.Sfs.Scp.WebApi.Xml.Host/appsettings.json

@ -0,0 +1,20 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"RemoteServices": {
"Default": {
"BaseUrl": "https://scp.iacchina.net:9988/"
}
},
"BasicAuthentication": {
"Username": "admin",
"Password": "admin"
}
}

3
WebApiService/test/Win_in.Sfs.Scp.WebApi.HttpApi.Client.ConsoleTestApp/WebApiConsoleApiClientModule.cs

@ -9,7 +9,8 @@ namespace Win_in.Sfs.Scp.WebApi.HttpApi.Client.ConsoleTestApp
{
[DependsOn(
typeof(WebApiHttpApiClientModule),
typeof(AbpHttpClientIdentityModelModule)
typeof(AbpHttpClientIdentityModelModule),
typeof(WebApiApplicationContractsModule)
)]
public class WebApiConsoleApiClientModule : AbpModule
{

Loading…
Cancel
Save