chore: initial commit
This commit is contained in:
62
Interface_WebAPI/CallWebApi/03_CallWebApi.csproj
Normal file
62
Interface_WebAPI/CallWebApi/03_CallWebApi.csproj
Normal file
@@ -0,0 +1,62 @@
|
||||
<?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>{727A1B50-D83A-4319-BDF6-E923F4BD41B3}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>CallWebApi</RootNamespace>
|
||||
<AssemblyName>CallWebApi</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>bin\Debug\</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>
|
||||
<ItemGroup>
|
||||
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<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.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="CallWebApi.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<WCFMetadata Include="Connected Services\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
57
Interface_WebAPI/CallWebApi/App.config
Normal file
57
Interface_WebAPI/CallWebApi/App.config
Normal file
@@ -0,0 +1,57 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<appSettings>
|
||||
|
||||
<!--<add key="MqttUrl" value="124.220.32.217:1883,MES/InstantMessaging/MisServer" />-->
|
||||
<add key="MqttUrl" value="124.220.15.242:1883,MES/InstantMessaging/SY/MisServer"/>
|
||||
<add key="MqttTargetTopic" value="MES/InstantMessaging/SY"/>
|
||||
<add key="MqttTargetTopicPLC" value="MES/InstantMessaging/SY/MisServer"/>
|
||||
<add key="MqttTargetTopicTagTypeCodeID" value="MES/TagTypeCodeID"/>
|
||||
<add key="Url_WebApi" value="http://localhost:41186"/>
|
||||
|
||||
<add key="ConnectionString_MES" value="server=124.220.15.242\MSSQLSERVER2012,1433;User ID=meswork;Password=126.com;database=MacroinfBasicDB_SY;Connection Reset=FALSE"/>
|
||||
|
||||
<!-- ERP数据库连接-->
|
||||
<add key="ConnectionString_ERP" value="server=124.220.15.242\MSSQLSERVER2012,1433;User ID=meswork;Password=126.com;database=MacroinfBasicDB_SY;Connection Reset=FALSE"/>
|
||||
<!-- 订单查询脚本-->
|
||||
<add key="ConnectionString_ERP_Sql_OrderForm" value="select a.fbillno'工单号',a.FID '工单内码',b.FENTRYID '工单分录',bt.FNAME '单据类型',a.fdate '单据日期',org.fname '生产组织',m.FNUMBER '物料代码',m1.FNAME '物料名称',m1.FSPECIFICATION '规格型号',de.FNAME '生产车间',un.FNAME '单位',FBASEUNITQTY '数量',bom.FNUMBER 'BOM版本',b1.FSTATUS '业务状态',b.FPLANSTARTDATE '计划开工时间',b.FPLANFINISHDATE '计划完工时间',
|
||||
b1.FSTARTDATE '开工时间',b1.FFINISHDATE'完工时间',b1.FREPQUAQTY '基本单位汇报合格数量',b1.FREPQUAAUXQTY '单据单位汇报合格数量 ',b1.FBASERPTFINISHQTY '基本单位汇报完成数量',b1.FRPTFINISHQTY'单据单位汇报完成数量' ,b2.FREMWORKSHOPID '产线'
|
||||
from T_PRD_MO a
|
||||
left join T_PRD_MOENTRY b on a.fid=b.fid --生产订单表体
|
||||
left join T_PRD_MOENTRY_A b1 on b.FID=b1.FID and b.FENTRYID=b1.FENTRYID --生产订单表体
|
||||
LEFT join T_PRD_MOENTRY_Q b2 on b.FID=b2.FID and b.FENTRYID=b2.FENTRYID --生产订单明细数量表
|
||||
left join T_ORG_ORGANIZATIONS_L org on org.FORGID=a.FPRDORGID --组织
|
||||
left join T_BD_MATERIAL m on m.FMATERIALID=b.FMATERIALID --生产订单表体物料信息
|
||||
left join T_BD_MATERIAL_L m1 on m.FMATERIALID=m1.FMATERIALID
|
||||
left join T_BD_DEPARTMENT_L de on de.FDEPTID=b.FWORKSHOPID --部门:生产车间
|
||||
left join T_BD_UNIT_L un on un.FUNITID=b.FBASEUNITID --单位表
|
||||
left join T_ENG_BOM bom on bom.FID=b.FBOMID --BOM信息
|
||||
left join T_BAS_BILLTYPE_L bt on bt.FBILLTYPEID=a.FBILLTYPE and bt.FLOCALEID=2052--单据类型"/>
|
||||
<!-- 配送物料查询脚本-->
|
||||
<add key="ConnectionString_ERP_Sql_DistributeMaterials" value="server=124.220.15.242\MSSQLSERVER2012,1433;User ID=meswork;Password=126.com;database=MacroinfBasicDB_SY;Connection Reset=FALSE"/>
|
||||
<!-- 补充物料查询脚本-->
|
||||
<add key="ConnectionString_ERP_Sql_SupplementaryMaterials" value="server=124.220.15.242\MSSQLSERVER2012,1433;User ID=meswork;Password=126.com;database=MacroinfBasicDB_SY;Connection Reset=FALSE"/>
|
||||
|
||||
<add key="ConnectionString_MES0" value="server=124.220.15.242\MSSQLSERVER2012,1433;User ID=meswork;Password=126.com;database=MacroinfBasicDB_SY;Connection Reset=FALSE"/>
|
||||
<add key="ConnectionString_MES1" value="server=124.220.15.242\MSSQLSERVER2012,1433;User ID=meswork;Password=126.com;database=MacroinfBasicDB_SY;Connection Reset=FALSE"/>
|
||||
<add key="ConnectionString_MES2" value="server=124.220.15.242\MSSQLSERVER2012,1433;User ID=meswork;Password=126.com;database=MacroinfBasicDB_SY;Connection Reset=FALSE"/>
|
||||
<add key="ConnectionString_MES3" value="server=124.220.15.242\MSSQLSERVER2012,1433;User ID=meswork;Password=126.com;database=MacroinfBasicDB_SY;Connection Reset=FALSE"/>
|
||||
<add key="ConnectionString_MES4" value="server=124.220.15.242\MSSQLSERVER2012,1433;User ID=meswork;Password=126.com;database=MacroinfBasicDB_SY;Connection Reset=FALSE"/>
|
||||
<add key="OPName01" value="OP1010|1"/>
|
||||
<add key="OPName02" value="OP0050|2"/>
|
||||
<!--扫描枪COM口-->
|
||||
<add key="PortName" value="COM1"/>
|
||||
<!--读超时,即在1000内未读到数据就引起超时异常-->
|
||||
<add key="ReadTimeout" value="1000"/>
|
||||
<!--比特率-->
|
||||
<add key="BaudRate" value="115200"/>
|
||||
<!--祛除后尾乱码-->
|
||||
<add key="ScannerTrim" value="1"/>
|
||||
|
||||
|
||||
|
||||
</appSettings>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
|
||||
</startup>
|
||||
</configuration>
|
||||
257
Interface_WebAPI/CallWebApi/CallWebApi.cs
Normal file
257
Interface_WebAPI/CallWebApi/CallWebApi.cs
Normal file
@@ -0,0 +1,257 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CallWebApi
|
||||
{
|
||||
public class Post
|
||||
{
|
||||
public static string Postring(string url, Dictionary<string, string> dic)
|
||||
{
|
||||
string result = "";
|
||||
//url = "http://172.16.22.15:8000/" + url;
|
||||
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
|
||||
req.Method = "POST";
|
||||
req.ContentType = "application/x-www-form-urlencoded";
|
||||
req.Proxy = null;
|
||||
|
||||
req.KeepAlive = false;
|
||||
|
||||
#region 添加Post 参数
|
||||
StringBuilder builder = new StringBuilder();
|
||||
int i = 0;
|
||||
foreach (var item in dic)
|
||||
{
|
||||
if (i > 0)
|
||||
builder.Append("&");
|
||||
builder.AppendFormat("{0}={1}", item.Key, item.Value);
|
||||
i++;
|
||||
}
|
||||
byte[] data = Encoding.UTF8.GetBytes(builder.ToString());
|
||||
req.ContentLength = data.Length;
|
||||
using (Stream reqStream = req.GetRequestStream())
|
||||
{
|
||||
reqStream.Write(data, 0, data.Length);
|
||||
reqStream.Close();
|
||||
}
|
||||
#endregion
|
||||
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
|
||||
Stream stream = resp.GetResponseStream();
|
||||
|
||||
//获取响应内容
|
||||
using (StreamReader reader = new StreamReader(stream, Encoding.UTF8))
|
||||
{
|
||||
result = reader.ReadToEnd();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static string Postring1(string url, string token, Dictionary<string, string> dic)
|
||||
{
|
||||
string results = "";
|
||||
//url = "http://172.16.22.15:8000/" + url;
|
||||
|
||||
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
|
||||
req.Method = "POST";
|
||||
req.ContentType = "application/x-www-form-urlencoded";
|
||||
req.Headers.Add("Authorization", "Bearer " + token);
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
int i = 0;
|
||||
foreach (var item in dic)
|
||||
{
|
||||
if (i > 0)
|
||||
builder.Append("&");
|
||||
builder.AppendFormat("{0}={1}", item.Key, item.Value);
|
||||
i++;
|
||||
}
|
||||
byte[] data = Encoding.UTF8.GetBytes(builder.ToString());
|
||||
req.ContentLength = data.Length;
|
||||
try
|
||||
{
|
||||
using (Stream reqStream = req.GetRequestStream())
|
||||
{
|
||||
reqStream.Write(data, 0, data.Length);
|
||||
reqStream.Close();
|
||||
}
|
||||
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
|
||||
Stream stream = resp.GetResponseStream();
|
||||
//获取响应内容
|
||||
using (StreamReader reader = new StreamReader(stream, Encoding.UTF8))
|
||||
{
|
||||
results = reader.ReadToEnd();
|
||||
}
|
||||
return results;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e.Message);
|
||||
return e.Message;
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 西开电器专用
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <param name="dic"></param>
|
||||
/// <returns></returns>
|
||||
public static string Post_XK(string url, string token, Dictionary<string, string> dic)
|
||||
{
|
||||
string results = "";
|
||||
//url = "http://172.16.22.15:8000/" + url;
|
||||
|
||||
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
|
||||
req.Method = "POST";
|
||||
req.ContentType = "application/x-www-form-urlencoded";
|
||||
req.Headers.Add("Authorization", "Bearer " + token);
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
int i = 0;
|
||||
foreach (var item in dic)
|
||||
{
|
||||
if (i > 0)
|
||||
builder.Append("&");
|
||||
builder.AppendFormat("{0}={1}", item.Key, item.Value);
|
||||
i++;
|
||||
}
|
||||
byte[] data = Encoding.UTF8.GetBytes(builder.ToString());
|
||||
req.ContentLength = data.Length;
|
||||
try
|
||||
{
|
||||
using (Stream reqStream = req.GetRequestStream())
|
||||
{
|
||||
reqStream.Write(data, 0, data.Length);
|
||||
reqStream.Close();
|
||||
}
|
||||
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
|
||||
Stream stream = resp.GetResponseStream();
|
||||
//获取响应内容
|
||||
using (StreamReader reader = new StreamReader(stream, Encoding.UTF8))
|
||||
{
|
||||
results = reader.ReadToEnd();
|
||||
}
|
||||
return results;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e.Message);
|
||||
return e.Message;
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static string MyPost()
|
||||
{
|
||||
// var url = "http://192.168.1.224:41190/";
|
||||
var url = "http://127.0.0.1:41190/";
|
||||
var controller = "ZSaveTag";
|
||||
var action = "SelectPage";
|
||||
Dictionary<string, string> dict = new Dictionary<string, string>();
|
||||
dict.Add("OpName","");
|
||||
dict.Add("StartTime", "2022-06-24 00:00:00");
|
||||
dict.Add("EndTime", "2022-06-30 00:00:00");
|
||||
dict.Add("PageCurrent", "1");
|
||||
dict.Add("PageSize", "2");
|
||||
|
||||
|
||||
var reqUrl = url + "/api/" + controller + "/" + action;
|
||||
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(reqUrl);
|
||||
req.Method = "POST";
|
||||
req.ContentType = "application/json";
|
||||
req.Proxy = null;
|
||||
|
||||
req.KeepAlive = false;
|
||||
|
||||
#region 添加Post 参数
|
||||
JObject jObject = new JObject();
|
||||
jObject.Add("OpName", "");
|
||||
jObject.Add("StartTime", "2022-06-24 00:00:00");
|
||||
jObject.Add("EndTime", "2022-06-30 00:00:00");
|
||||
jObject.Add("PageCurrent", "2");
|
||||
jObject.Add("PageSize", "3");
|
||||
var jStr = jObject.ToString();
|
||||
|
||||
//StringBuilder builder = new StringBuilder();
|
||||
//int i = 0;
|
||||
//foreach (var item in dict)
|
||||
//{
|
||||
// if (i > 0)
|
||||
// builder.Append("&");
|
||||
// builder.AppendFormat("{0}={1}", item.Key, item.Value);
|
||||
// i++;
|
||||
//}
|
||||
//byte[] data = Encoding.UTF8.GetBytes(builder.ToString());
|
||||
byte[] data = Encoding.UTF8.GetBytes(jStr);
|
||||
req.ContentLength = data.Length;
|
||||
using (Stream reqStream = req.GetRequestStream())
|
||||
{
|
||||
reqStream.Write(data, 0, data.Length);
|
||||
reqStream.Close();
|
||||
}
|
||||
#endregion
|
||||
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
|
||||
Stream stream = resp.GetResponseStream();
|
||||
|
||||
string result = "";
|
||||
|
||||
//获取响应内容
|
||||
using (StreamReader reader = new StreamReader(stream, Encoding.UTF8))
|
||||
{
|
||||
result = reader.ReadToEnd();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static string MyPost(string url,string jsonStr)
|
||||
{
|
||||
string result = "";
|
||||
|
||||
try
|
||||
{
|
||||
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
|
||||
req.Method = "POST";
|
||||
req.ContentType = "application/json";
|
||||
req.Proxy = null;
|
||||
req.KeepAlive = false;
|
||||
|
||||
byte[] data = Encoding.UTF8.GetBytes(jsonStr);
|
||||
req.ContentLength = data.Length;
|
||||
using (Stream reqStream = req.GetRequestStream())
|
||||
{
|
||||
reqStream.Write(data, 0, data.Length);
|
||||
reqStream.Close();
|
||||
}
|
||||
|
||||
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
|
||||
Stream stream = resp.GetResponseStream();
|
||||
|
||||
|
||||
//获取响应内容
|
||||
using (StreamReader reader = new StreamReader(stream, Encoding.UTF8))
|
||||
{
|
||||
result = reader.ReadToEnd();
|
||||
}
|
||||
Console.WriteLine(result);
|
||||
|
||||
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
Console.WriteLine("<Error> " + err.Message);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
32
Interface_WebAPI/CallWebApi/Program.cs
Normal file
32
Interface_WebAPI/CallWebApi/Program.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CallWebApi
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Post.MyPost();
|
||||
|
||||
var url = "http://localhost:41190/api/ZSaveTag/SelectPage";
|
||||
|
||||
JObject jObject = new JObject();
|
||||
jObject.Add("OpName", "");
|
||||
jObject.Add("StartTime", "2022-06-24 00:00:00");
|
||||
jObject.Add("EndTime", "2022-06-30 00:00:00");
|
||||
jObject.Add("PageCurrent", "2");
|
||||
jObject.Add("PageSize", "3");
|
||||
var jStr = jObject.ToString();
|
||||
|
||||
Post.MyPost(url, jStr);
|
||||
|
||||
Console.ReadKey();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
36
Interface_WebAPI/CallWebApi/Properties/AssemblyInfo.cs
Normal file
36
Interface_WebAPI/CallWebApi/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("CallWebApi")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("CallWebApi")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2022")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("727a1b50-d83a-4319-bdf6-e923f4bd41b3")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
4
Interface_WebAPI/CallWebApi/packages.config
Normal file
4
Interface_WebAPI/CallWebApi/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