chore: 初始化合力差速器MES采集程序
This commit is contained in:
119
Common/02WebApiCall/02_02WebApiCallPLC.csproj
Normal file
119
Common/02WebApiCall/02_02WebApiCallPLC.csproj
Normal file
@@ -0,0 +1,119 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{3E6D1DD5-01C9-435F-9941-61F906CE35BB}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>WebApiCall</RootNamespace>
|
||||
<AssemblyName>02WebApiCall</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Deterministic>true</Deterministic>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\dll\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<StartupObject />
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="BasicData, Version=20.20.2.2, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\dll_common\BasicData.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="DataLinkMesWork">
|
||||
<HintPath>..\..\dll_common\DataLinkMesWork.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Deployment" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Form1.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Form1.Designer.cs">
|
||||
<DependentUpon>Form1.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="WebApi\AGVWebApiCall.cs" />
|
||||
<Compile Include="WebApi\Helpers\LogHelper.cs" />
|
||||
<Compile Include="WebApi\Helpers\ValidationHelper.cs" />
|
||||
<Compile Include="WebApi\Models\AGV_To_MES_AgvPass_Req.cs" />
|
||||
<Compile Include="WebApi\Models\MES_To_AGV_CallGoods_Req.cs" />
|
||||
<Compile Include="WebApi\Models\MES_To_AGV_ReturnGoods_Req.cs" />
|
||||
<Compile Include="WebApi\Models\msgResHeader.cs" />
|
||||
<Compile Include="WebApi\Models\WmsApiResponse.cs" />
|
||||
<EmbeddedResource Include="Form1.resx">
|
||||
<DependentUpon>Form1.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
<DesignTime>True</DesignTime>
|
||||
</Compile>
|
||||
<None Include="packages.config" />
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\00-1Json8.3\Json8.3\00-0Json8.3.1.csproj">
|
||||
<Project>{1a10fdb2-1a6a-44a8-ab4d-33387563247e}</Project>
|
||||
<Name>00-0Json8.3.1</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\01DoWhatPlc\01_01DoWhatPlc.csproj">
|
||||
<Project>{0d1af432-439a-4920-8692-43ae139f5530}</Project>
|
||||
<Name>01_01DoWhatPlc</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\MyLog4Net\00_MyLog4Net.csproj">
|
||||
<Project>{1dc48c83-1842-4de8-acaf-26e1e7f7c58f}</Project>
|
||||
<Name>00_MyLog4Net</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
25
Common/02WebApiCall/02_02WebApiCallPLC.sln
Normal file
25
Common/02WebApiCall/02_02WebApiCallPLC.sln
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.32901.82
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "02_02WebApiCallPLC", "02_02WebApiCallPLC.csproj", "{3E6D1DD5-01C9-435F-9941-61F906CE35BB}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{3E6D1DD5-01C9-435F-9941-61F906CE35BB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{3E6D1DD5-01C9-435F-9941-61F906CE35BB}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3E6D1DD5-01C9-435F-9941-61F906CE35BB}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3E6D1DD5-01C9-435F-9941-61F906CE35BB}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {C034F50A-F3DF-47DC-ADB2-3724C1B74818}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
11
Common/02WebApiCall/App.config
Normal file
11
Common/02WebApiCall/App.config
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
|
||||
</startup>
|
||||
<appSettings>
|
||||
|
||||
<add key="Url_WebApi" value="http://localhost:41181"/>
|
||||
|
||||
</appSettings>
|
||||
</configuration>
|
||||
48
Common/02WebApiCall/Form1.Designer.cs
generated
Normal file
48
Common/02WebApiCall/Form1.Designer.cs
generated
Normal file
@@ -0,0 +1,48 @@
|
||||
|
||||
namespace WebApiCall
|
||||
{
|
||||
partial class Form1
|
||||
{
|
||||
/// <summary>
|
||||
/// 必需的设计器变量。
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// 清理所有正在使用的资源。
|
||||
/// </summary>
|
||||
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows 窗体设计器生成的代码
|
||||
|
||||
/// <summary>
|
||||
/// 设计器支持所需的方法 - 不要修改
|
||||
/// 使用代码编辑器修改此方法的内容。
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 525);
|
||||
this.Name = "Form1";
|
||||
this.Text = "Form1";
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
20
Common/02WebApiCall/Form1.cs
Normal file
20
Common/02WebApiCall/Form1.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace WebApiCall
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
120
Common/02WebApiCall/Form1.resx
Normal file
120
Common/02WebApiCall/Form1.resx
Normal file
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
22
Common/02WebApiCall/Program.cs
Normal file
22
Common/02WebApiCall/Program.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace WebApiCall
|
||||
{
|
||||
static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// 应用程序的主入口点。
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new Form1());
|
||||
}
|
||||
}
|
||||
}
|
||||
36
Common/02WebApiCall/Properties/AssemblyInfo.cs
Normal file
36
Common/02WebApiCall/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// 有关程序集的一般信息由以下
|
||||
// 控制。更改这些特性值可修改
|
||||
// 与程序集关联的信息。
|
||||
[assembly: AssemblyTitle("WebApiCall")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("WebApiCall")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2022")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// 将 ComVisible 设置为 false 会使此程序集中的类型
|
||||
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
|
||||
//请将此类型的 ComVisible 特性设置为 true。
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
|
||||
[assembly: Guid("3e6d1dd5-01c9-435f-9941-61f906ce35bb")]
|
||||
|
||||
// 程序集的版本信息由下列四个值组成:
|
||||
//
|
||||
// 主版本
|
||||
// 次版本
|
||||
// 生成号
|
||||
// 修订号
|
||||
//
|
||||
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
|
||||
//通过使用 "*",如下所示:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
63
Common/02WebApiCall/Properties/Resources.Designer.cs
generated
Normal file
63
Common/02WebApiCall/Properties/Resources.Designer.cs
generated
Normal file
@@ -0,0 +1,63 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 此代码由工具生成。
|
||||
// 运行时版本:4.0.30319.42000
|
||||
//
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果
|
||||
// 重新生成代码,这些更改将会丢失。
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace WebApiCall.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 一个强类型的资源类,用于查找本地化的字符串等。
|
||||
/// </summary>
|
||||
// 此类是由 StronglyTypedResourceBuilder
|
||||
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
|
||||
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
|
||||
// (以 /str 作为命令选项),或重新生成 VS 项目。
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 返回此类使用的缓存的 ResourceManager 实例。
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WebApiCall.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重写当前线程的 CurrentUICulture 属性,对
|
||||
/// 使用此强类型资源类的所有资源查找执行重写。
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
117
Common/02WebApiCall/Properties/Resources.resx
Normal file
117
Common/02WebApiCall/Properties/Resources.resx
Normal file
@@ -0,0 +1,117 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
26
Common/02WebApiCall/Properties/Settings.Designer.cs
generated
Normal file
26
Common/02WebApiCall/Properties/Settings.Designer.cs
generated
Normal file
@@ -0,0 +1,26 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 此代码由工具生成。
|
||||
// 运行时版本:4.0.30319.42000
|
||||
//
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果
|
||||
// 重新生成代码,这些更改将会丢失。
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace WebApiCall.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.0.3.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default {
|
||||
get {
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
7
Common/02WebApiCall/Properties/Settings.settings
Normal file
7
Common/02WebApiCall/Properties/Settings.settings
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
</SettingsFile>
|
||||
211
Common/02WebApiCall/WebApi/AGVWebApiCall.cs
Normal file
211
Common/02WebApiCall/WebApi/AGVWebApiCall.cs
Normal file
@@ -0,0 +1,211 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Configuration;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WebApi.Helpers;
|
||||
using WebApi.Models;
|
||||
|
||||
|
||||
namespace WebApiCall
|
||||
{
|
||||
/// <summary>
|
||||
/// WMS WebApi调用类
|
||||
/// </summary>
|
||||
public class AGVWebApiCall
|
||||
{
|
||||
private static readonly HttpClient httpClient;
|
||||
|
||||
static AGVWebApiCall()
|
||||
{
|
||||
httpClient = new HttpClient();
|
||||
httpClient.Timeout = TimeSpan.FromSeconds(20); // 设置超时时间为20秒
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// MES叫料接口 - 同步版本,返回bool结果
|
||||
/// </summary>
|
||||
/// <param name="storageCode">叫料位置(库位号)</param>
|
||||
/// <param name="goodsCode">物料号(型号)</param>
|
||||
/// <returns>是否成功</returns>
|
||||
public static bool MES_To_AGV_CallGoods(string storageCode, string goodsCode)
|
||||
{
|
||||
try
|
||||
{
|
||||
var task = MES_To_AGV_CallGoods_Async(storageCode, goodsCode);
|
||||
task.Wait(); // 同步等待异步任务完成
|
||||
return task.Result;
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
string errorMsg = $"叫料同步调用异常 - 库位: {storageCode}, 物料号: {goodsCode}, 异常: {err.Message}";
|
||||
LogHelper.ShowMsg(errorMsg);
|
||||
Console.WriteLine($"错误: {MethodBase.GetCurrentMethod().Name} - {errorMsg}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// MES叫料接口 - 内部异步实现
|
||||
/// </summary>
|
||||
private static async Task<bool> MES_To_AGV_CallGoods_Async(string storageCode, string goodsCode)
|
||||
{
|
||||
int AID = -1;
|
||||
try
|
||||
{
|
||||
string WMSIPPort = ConfigurationManager.AppSettings["AGVIPPort"];
|
||||
string url = $"http://{WMSIPPort}/wms/apiForThirdPartySys/callGoods";
|
||||
|
||||
var requestData = new MES_To_AGV_CallGoods_Req
|
||||
{
|
||||
storageCode = storageCode,
|
||||
goodsCode = goodsCode
|
||||
};
|
||||
|
||||
string json = JsonConvert.SerializeObject(requestData);
|
||||
LogHelper.ShowMsg($"发起叫料请求 - 库位: {storageCode}, 物料号: {goodsCode} -> Send【{url}】{json}");
|
||||
AID = LogHelper.SaveWebApiReqLogo(url, json);
|
||||
|
||||
var content = new StringContent(json, Encoding.UTF8, "application/json");
|
||||
var response = await httpClient.PostAsync(url, content);
|
||||
var responseContent = await response.Content.ReadAsStringAsync();
|
||||
|
||||
LogHelper.ShowMsg($"叫料响应 - 库位: {storageCode}, 物料号: {goodsCode} -> Response【{url}】{responseContent}");
|
||||
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
// 解析WMS响应
|
||||
var wmsResponse = JsonConvert.DeserializeObject<WmsApiResponse>(responseContent);
|
||||
|
||||
if (wmsResponse != null && wmsResponse.code == 200)
|
||||
{
|
||||
LogHelper.ShowMsg($"叫料成功 - 库位: {storageCode}, 物料号: {goodsCode}, 响应消息: {wmsResponse.msg}");
|
||||
LogHelper.SaveWebApiResLogo(AID, JsonConvert.SerializeObject(wmsResponse));
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.ShowMsg($"叫料失败 - 库位: {storageCode}, 物料号: {goodsCode}, 错误信息: {wmsResponse?.msg ?? "未知错误"}");
|
||||
LogHelper.SaveWebApiResLogo(AID, JsonConvert.SerializeObject(wmsResponse));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string msg = $"叫料HTTP请求失败 - 库位: {storageCode}, 物料号: {goodsCode}, 状态码: {response.StatusCode}, 响应: {responseContent}";
|
||||
LogHelper.ShowMsg(msg);
|
||||
LogHelper.SaveWebApiResLogo(AID, msg);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
string errorMsg = $"叫料异常 - 库位: {storageCode}, 物料号: {goodsCode}, 异常详情: {err.Message}";
|
||||
LogHelper.ShowMsg(errorMsg);
|
||||
Console.WriteLine($"错误: {MethodBase.GetCurrentMethod().Name} - {errorMsg}");
|
||||
if (AID > 0)
|
||||
{
|
||||
LogHelper.SaveWebApiResLogo(AID, errorMsg);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// MES退料接口 - 同步版本,返回bool结果
|
||||
/// </summary>
|
||||
/// <param name="storageCode">退料位置(库位号)</param>
|
||||
/// <param name="goodsCode">物料号(型号)</param>
|
||||
/// <param name="isEmpty">是否为空 0.空托 1.余料</param>
|
||||
/// <returns>是否成功</returns>
|
||||
public static bool MES_To_AGV_ReturnGoods(string storageCode, string goodsCode, int isEmpty)
|
||||
{
|
||||
try
|
||||
{
|
||||
var task = MES_To_AGV_ReturnGoods_Async(storageCode, goodsCode, isEmpty);
|
||||
task.Wait(); // 同步等待异步任务完成
|
||||
return task.Result;
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
string emptyTypeDesc = isEmpty == 0 ? "空托" : "余料";
|
||||
string errorMsg = $"退料同步调用异常 - 库位: {storageCode}, 物料号: {goodsCode}, 类型: {emptyTypeDesc}({isEmpty}), 异常: {err.Message}";
|
||||
LogHelper.ShowMsg(errorMsg);
|
||||
Console.WriteLine($"错误: {MethodBase.GetCurrentMethod().Name} - {errorMsg}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// MES退料接口 - 内部异步实现
|
||||
/// </summary>
|
||||
private static async Task<bool> MES_To_AGV_ReturnGoods_Async(string storageCode, string goodsCode, int isEmpty)
|
||||
{
|
||||
int AID = -1;
|
||||
try
|
||||
{
|
||||
string emptyTypeDesc = isEmpty == 0 ? "空托" : "余料";
|
||||
string WMSIPPort = ConfigurationManager.AppSettings["AGVIPPort"];
|
||||
string url = $"http://{WMSIPPort}/wms/apiForThirdPartySys/returnGoods";
|
||||
|
||||
var requestData = new MES_To_AGV_ReturnGoods_Req
|
||||
{
|
||||
storageCode = storageCode,
|
||||
goodsCode = goodsCode,
|
||||
isEmpty = isEmpty
|
||||
};
|
||||
|
||||
string json = JsonConvert.SerializeObject(requestData);
|
||||
LogHelper.ShowMsg($"发起退料请求 - 库位: {storageCode}, 物料号: {goodsCode}, 类型: {emptyTypeDesc}({isEmpty}) -> Send【{url}】{json}");
|
||||
AID = LogHelper.SaveWebApiReqLogo(url, json);
|
||||
|
||||
var content = new StringContent(json, Encoding.UTF8, "application/json");
|
||||
var response = await httpClient.PostAsync(url, content);
|
||||
var responseContent = await response.Content.ReadAsStringAsync();
|
||||
|
||||
LogHelper.ShowMsg($"退料响应 - 库位: {storageCode}, 物料号: {goodsCode}, 类型: {emptyTypeDesc}({isEmpty}) -> Response【{url}】{responseContent}");
|
||||
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
// 解析WMS响应
|
||||
var wmsResponse = JsonConvert.DeserializeObject<WmsApiResponse>(responseContent);
|
||||
|
||||
if (wmsResponse != null && wmsResponse.code == 200)
|
||||
{
|
||||
LogHelper.ShowMsg($"退料成功 - 库位: {storageCode}, 物料号: {goodsCode}, 类型: {emptyTypeDesc}({isEmpty}), 响应消息: {wmsResponse.msg}");
|
||||
LogHelper.SaveWebApiResLogo(AID, JsonConvert.SerializeObject(wmsResponse));
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.ShowMsg($"退料失败 - 库位: {storageCode}, 物料号: {goodsCode}, 类型: {emptyTypeDesc}({isEmpty}), 错误信息: {wmsResponse?.msg ?? "未知错误"}");
|
||||
LogHelper.SaveWebApiResLogo(AID, JsonConvert.SerializeObject(wmsResponse));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string msg = $"退料HTTP请求失败 - 库位: {storageCode}, 物料号: {goodsCode}, 类型: {emptyTypeDesc}({isEmpty}), 状态码: {response.StatusCode}, 响应: {responseContent}";
|
||||
LogHelper.ShowMsg(msg);
|
||||
LogHelper.SaveWebApiResLogo(AID, msg);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
string emptyTypeDesc = isEmpty == 0 ? "空托" : "余料";
|
||||
string errorMsg = $"退料异常 - 库位: {storageCode}, 物料号: {goodsCode}, 类型: {emptyTypeDesc}({isEmpty}), 异常详情: {err.Message}";
|
||||
LogHelper.ShowMsg(errorMsg);
|
||||
Console.WriteLine($"错误: {MethodBase.GetCurrentMethod().Name} - {errorMsg}");
|
||||
if (AID > 0)
|
||||
{
|
||||
LogHelper.SaveWebApiResLogo(AID, errorMsg);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
76
Common/02WebApiCall/WebApi/Helpers/LogHelper.cs
Normal file
76
Common/02WebApiCall/WebApi/Helpers/LogHelper.cs
Normal file
@@ -0,0 +1,76 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using DataLinkMesWork;
|
||||
|
||||
|
||||
namespace WebApi.Helpers
|
||||
{
|
||||
public class LogHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// UUID生成
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static string UuidUtil()
|
||||
{
|
||||
string result = Guid.NewGuid().ToString();
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void ShowMsg(string msg)
|
||||
{
|
||||
MyLog4Net.MyLogHelper.Error("WebApi", msg);
|
||||
}
|
||||
|
||||
public static int SaveWebApiReqLogo(string url, string JSON)
|
||||
{
|
||||
int AID = -1;
|
||||
try
|
||||
{
|
||||
//存储日志
|
||||
var CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
|
||||
|
||||
string procedureName = "接口_IOT接口交互日志_请求记录";
|
||||
SqlParameter[] thisParms = new SqlParameter[4];
|
||||
thisParms[0] = new System.Data.SqlClient.SqlParameter("@接口地址", url);
|
||||
thisParms[1] = new System.Data.SqlClient.SqlParameter("@接口类型", 2);
|
||||
thisParms[2] = new System.Data.SqlClient.SqlParameter("@请求内容", JSON);
|
||||
thisParms[3] = new System.Data.SqlClient.SqlParameter("@请求时间", CreateTime);
|
||||
SQLCommon.ExecuteStoredProcedure(procedureName, ApplicationConfig.ConnectionString_MES, out DataTable dt, out string errorMessage);
|
||||
// DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms, out DataTable dt);
|
||||
if (dt.Rows.Count > 0)
|
||||
{
|
||||
AID = Convert.ToInt32(dt.Rows[0]["AID"]);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
return AID;
|
||||
}
|
||||
|
||||
public static void SaveWebApiResLogo(int AID, string JSON)
|
||||
{
|
||||
try
|
||||
{
|
||||
//存储日志
|
||||
var CreateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
|
||||
string procedureName = "接口_IOT接口交互日志_响应记录";
|
||||
SqlParameter[] thisParms = new SqlParameter[3];
|
||||
thisParms[0] = new System.Data.SqlClient.SqlParameter("@AID", AID);
|
||||
thisParms[1] = new System.Data.SqlClient.SqlParameter("@响应时间", CreateTime);
|
||||
thisParms[2] = new System.Data.SqlClient.SqlParameter("@响应内容", JSON);
|
||||
DataAccess.ExecuteStoredProcedure(procedureName, ref thisParms, out DataTable dt);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
98
Common/02WebApiCall/WebApi/Helpers/ValidationHelper.cs
Normal file
98
Common/02WebApiCall/WebApi/Helpers/ValidationHelper.cs
Normal file
@@ -0,0 +1,98 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
namespace WebApi.Helpers
|
||||
{
|
||||
public class ValidationHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 验证对象的必填字段
|
||||
/// </summary>
|
||||
/// <typeparam name="T">要验证的对象类型</typeparam>
|
||||
/// <param name="obj">要验证的对象</param>
|
||||
/// <param name="errorMessage">错误信息</param>
|
||||
/// <returns>验证是否通过</returns>
|
||||
public static bool ValidateRequired<T>(T obj, out string errorMessage)
|
||||
{
|
||||
errorMessage = string.Empty;
|
||||
if (obj == null)
|
||||
{
|
||||
errorMessage = "对象不能为空";
|
||||
return false;
|
||||
}
|
||||
|
||||
var properties = typeof(T).GetProperties();
|
||||
foreach (var prop in properties)
|
||||
{
|
||||
var value = prop.GetValue(obj);
|
||||
if (value == null)
|
||||
{
|
||||
errorMessage = $"【{prop.Name}不能为空】";
|
||||
return false;
|
||||
}
|
||||
//else if (prop.PropertyType == typeof(int) && (int)value == 0)
|
||||
//{
|
||||
// errorMessage = $"【{prop.Name}不能为0】";
|
||||
// return false;
|
||||
//}
|
||||
else if (prop.PropertyType == typeof(string) && string.IsNullOrEmpty((string)value))
|
||||
{
|
||||
errorMessage = $"【{prop.Name}不能为空】";
|
||||
return false;
|
||||
}
|
||||
else if (prop.PropertyType == typeof(object) && (object)value == null)
|
||||
{
|
||||
errorMessage = $"【{prop.Name}不能为空】";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 验证对象的指定字段
|
||||
/// </summary>
|
||||
/// <typeparam name="T">要验证的对象类型</typeparam>
|
||||
/// <param name="obj">要验证的对象</param>
|
||||
/// <param name="propertyNames">要验证的属性名列表</param>
|
||||
/// <param name="errorMessage">错误信息</param>
|
||||
/// <returns>验证是否通过</returns>
|
||||
public static bool ValidateProperties<T>(T obj, string[] propertyNames, out string errorMessage)
|
||||
{
|
||||
errorMessage = string.Empty;
|
||||
if (obj == null)
|
||||
{
|
||||
errorMessage = "对象不能为空";
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach (var propName in propertyNames)
|
||||
{
|
||||
var prop = typeof(T).GetProperty(propName);
|
||||
if (prop == null) continue;
|
||||
|
||||
var value = prop.GetValue(obj);
|
||||
if (value == null)
|
||||
{
|
||||
errorMessage = $"【{propName}不能为空】";
|
||||
return false;
|
||||
}
|
||||
//else if (prop.PropertyType == typeof(int) && (int)value == 0)
|
||||
//{
|
||||
// errorMessage = $"【{propName}不能为0】";
|
||||
// return false;
|
||||
//}
|
||||
else if (prop.PropertyType == typeof(string) && string.IsNullOrEmpty((string)value))
|
||||
{
|
||||
errorMessage = $"【{propName}不能为空】";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Common/02WebApiCall/WebApi/Models/AGV_To_MES_AgvPass_Req.cs
Normal file
12
Common/02WebApiCall/WebApi/Models/AGV_To_MES_AgvPass_Req.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
|
||||
namespace WebApi.Models
|
||||
{
|
||||
public class AGV_To_MES_AgvPass_Req
|
||||
{
|
||||
/// <summary>
|
||||
/// 进入或离开
|
||||
/// </summary>
|
||||
public string agvStatus { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
namespace WebApi.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// MES叫料请求
|
||||
/// </summary>
|
||||
public class MES_To_AGV_CallGoods_Req
|
||||
{
|
||||
/// <summary>
|
||||
/// 叫料位置(库位号)
|
||||
/// </summary>
|
||||
public string storageCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料号(型号)
|
||||
/// </summary>
|
||||
public string goodsCode { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
namespace WebApi.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// MES退料请求
|
||||
/// </summary>
|
||||
public class MES_To_AGV_ReturnGoods_Req
|
||||
{
|
||||
/// <summary>
|
||||
/// 退料位置(库位号)
|
||||
/// </summary>
|
||||
public string storageCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料号(型号)
|
||||
/// </summary>
|
||||
public string goodsCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否为空 0.空托 1.余料
|
||||
/// </summary>
|
||||
public int isEmpty { get; set; }
|
||||
}
|
||||
}
|
||||
23
Common/02WebApiCall/WebApi/Models/WmsApiResponse.cs
Normal file
23
Common/02WebApiCall/WebApi/Models/WmsApiResponse.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
namespace WebApi.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// WMS接口响应
|
||||
/// </summary>
|
||||
public class WmsApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// 状态码 200:成功 500:失败
|
||||
/// </summary>
|
||||
public int code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 消息
|
||||
/// </summary>
|
||||
public string msg { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 返回数据
|
||||
/// </summary>
|
||||
public object data { get; set; }
|
||||
}
|
||||
}
|
||||
23
Common/02WebApiCall/WebApi/Models/msgResHeader.cs
Normal file
23
Common/02WebApiCall/WebApi/Models/msgResHeader.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
|
||||
namespace WebApi.Models
|
||||
{
|
||||
public class msgResHeader
|
||||
{
|
||||
/// <summary>
|
||||
/// 成功时反馈“200”;失败时反馈“500”
|
||||
/// </summary>
|
||||
public string code
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
/// <summary>
|
||||
/// 返回消息
|
||||
/// </summary>
|
||||
public string message
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
}
|
||||
}
|
||||
4
Common/02WebApiCall/packages.config
Normal file
4
Common/02WebApiCall/packages.config
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net461" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user