添加项目文件。
This commit is contained in:
+364
@@ -0,0 +1,364 @@
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
##
|
||||
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
||||
|
||||
# User-specific files
|
||||
*.rsuser
|
||||
*.suo
|
||||
*.user
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
*.userprefs
|
||||
|
||||
# Mono auto generated files
|
||||
mono_crash.*
|
||||
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
[Dd]ebugPublic/
|
||||
[Rr]elease/
|
||||
[Rr]eleases/
|
||||
x64/
|
||||
x86/
|
||||
[Ww][Ii][Nn]32/
|
||||
[Aa][Rr][Mm]/
|
||||
[Aa][Rr][Mm]64/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
[Ll]og/
|
||||
[Ll]ogs/
|
||||
|
||||
# Visual Studio 2015/2017 cache/options directory
|
||||
.vs/
|
||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||
#wwwroot/
|
||||
|
||||
# Visual Studio 2017 auto generated files
|
||||
Generated\ Files/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
||||
# NUnit
|
||||
*.VisualState.xml
|
||||
TestResult.xml
|
||||
nunit-*.xml
|
||||
|
||||
# Build Results of an ATL Project
|
||||
[Dd]ebugPS/
|
||||
[Rr]eleasePS/
|
||||
dlldata.c
|
||||
|
||||
# Benchmark Results
|
||||
BenchmarkDotNet.Artifacts/
|
||||
|
||||
# .NET Core
|
||||
project.lock.json
|
||||
project.fragment.lock.json
|
||||
artifacts/
|
||||
|
||||
# ASP.NET Scaffolding
|
||||
ScaffoldingReadMe.txt
|
||||
|
||||
# StyleCop
|
||||
StyleCopReport.xml
|
||||
|
||||
# Files built by Visual Studio
|
||||
*_i.c
|
||||
*_p.c
|
||||
*_h.h
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.iobj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.ipdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*_wpftmp.csproj
|
||||
*.log
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
*.pidb
|
||||
*.svclog
|
||||
*.scc
|
||||
|
||||
# Chutzpah Test files
|
||||
_Chutzpah*
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opendb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
*.VC.db
|
||||
*.VC.VC.opendb
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
*.sap
|
||||
|
||||
# Visual Studio Trace Files
|
||||
*.e2e
|
||||
|
||||
# TFS 2012 Local Workspace
|
||||
$tf/
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
*.DotSettings.user
|
||||
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# AxoCover is a Code Coverage Tool
|
||||
.axoCover/*
|
||||
!.axoCover/settings.json
|
||||
|
||||
# Coverlet is a free, cross platform Code Coverage Tool
|
||||
coverage*.json
|
||||
coverage*.xml
|
||||
coverage*.info
|
||||
|
||||
# Visual Studio code coverage results
|
||||
*.coverage
|
||||
*.coveragexml
|
||||
|
||||
# NCrunch
|
||||
_NCrunch_*
|
||||
.*crunch*.local.xml
|
||||
nCrunchTemp_*
|
||||
|
||||
# MightyMoose
|
||||
*.mm.*
|
||||
AutoTest.Net/
|
||||
|
||||
# Web workbench (sass)
|
||||
.sass-cache/
|
||||
|
||||
# Installshield output folder
|
||||
[Ee]xpress/
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
DocProject/Help/*.HxC
|
||||
DocProject/Help/*.hhc
|
||||
DocProject/Help/*.hhk
|
||||
DocProject/Help/*.hhp
|
||||
DocProject/Help/Html2
|
||||
DocProject/Help/html
|
||||
|
||||
# Click-Once directory
|
||||
publish/
|
||||
|
||||
# Publish Web Output
|
||||
*.[Pp]ublish.xml
|
||||
*.azurePubxml
|
||||
# Note: Comment the next line if you want to checkin your web deploy settings,
|
||||
# but database connection strings (with potential passwords) will be unencrypted
|
||||
*.pubxml
|
||||
*.publishproj
|
||||
|
||||
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||
# in these scripts will be unencrypted
|
||||
PublishScripts/
|
||||
|
||||
# NuGet Packages
|
||||
*.nupkg
|
||||
# NuGet Symbol Packages
|
||||
*.snupkg
|
||||
# The packages folder can be ignored because of Package Restore
|
||||
**/[Pp]ackages/*
|
||||
# except build/, which is used as an MSBuild target.
|
||||
!**/[Pp]ackages/build/
|
||||
# Uncomment if necessary however generally it will be regenerated when needed
|
||||
#!**/[Pp]ackages/repositories.config
|
||||
# NuGet v3's project.json files produces more ignorable files
|
||||
*.nuget.props
|
||||
*.nuget.targets
|
||||
|
||||
# Microsoft Azure Build Output
|
||||
csx/
|
||||
*.build.csdef
|
||||
|
||||
# Microsoft Azure Emulator
|
||||
ecf/
|
||||
rcf/
|
||||
|
||||
# Windows Store app package directories and files
|
||||
AppPackages/
|
||||
BundleArtifacts/
|
||||
Package.StoreAssociation.xml
|
||||
_pkginfo.txt
|
||||
*.appx
|
||||
*.appxbundle
|
||||
*.appxupload
|
||||
|
||||
# Visual Studio cache files
|
||||
# files ending in .cache can be ignored
|
||||
*.[Cc]ache
|
||||
# but keep track of directories ending in .cache
|
||||
!?*.[Cc]ache/
|
||||
|
||||
# Others
|
||||
ClientBin/
|
||||
~$*
|
||||
*~
|
||||
*.dbmdl
|
||||
*.dbproj.schemaview
|
||||
*.jfm
|
||||
*.pfx
|
||||
*.publishsettings
|
||||
orleans.codegen.cs
|
||||
|
||||
# Including strong name files can present a security risk
|
||||
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
||||
#*.snk
|
||||
|
||||
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||
#bower_components/
|
||||
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
|
||||
# Backup & report files from converting an old project file
|
||||
# to a newer Visual Studio version. Backup files are not needed,
|
||||
# because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
ServiceFabricBackup/
|
||||
*.rptproj.bak
|
||||
|
||||
# SQL Server files
|
||||
*.mdf
|
||||
*.ldf
|
||||
*.ndf
|
||||
|
||||
# Business Intelligence projects
|
||||
*.rdl.data
|
||||
*.bim.layout
|
||||
*.bim_*.settings
|
||||
*.rptproj.rsuser
|
||||
*- [Bb]ackup.rdl
|
||||
*- [Bb]ackup ([0-9]).rdl
|
||||
*- [Bb]ackup ([0-9][0-9]).rdl
|
||||
|
||||
# Microsoft Fakes
|
||||
FakesAssemblies/
|
||||
|
||||
# GhostDoc plugin setting file
|
||||
*.GhostDoc.xml
|
||||
|
||||
# Node.js Tools for Visual Studio
|
||||
.ntvs_analysis.dat
|
||||
node_modules/
|
||||
|
||||
# Visual Studio 6 build log
|
||||
*.plg
|
||||
|
||||
# Visual Studio 6 workspace options file
|
||||
*.opt
|
||||
|
||||
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||
*.vbw
|
||||
|
||||
# Visual Studio LightSwitch build output
|
||||
**/*.HTMLClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/ModelManifest.xml
|
||||
**/*.Server/GeneratedArtifacts
|
||||
**/*.Server/ModelManifest.xml
|
||||
_Pvt_Extensions
|
||||
|
||||
# Paket dependency manager
|
||||
.paket/paket.exe
|
||||
paket-files/
|
||||
|
||||
# FAKE - F# Make
|
||||
.fake/
|
||||
|
||||
# CodeRush personal settings
|
||||
.cr/personal
|
||||
|
||||
# Python Tools for Visual Studio (PTVS)
|
||||
__pycache__/
|
||||
*.pyc
|
||||
|
||||
# Cake - Uncomment if you are using it
|
||||
# tools/**
|
||||
# !tools/packages.config
|
||||
|
||||
# Tabs Studio
|
||||
*.tss
|
||||
|
||||
# Telerik's JustMock configuration file
|
||||
*.jmconfig
|
||||
|
||||
# BizTalk build output
|
||||
*.btp.cs
|
||||
*.btm.cs
|
||||
*.odx.cs
|
||||
*.xsd.cs
|
||||
|
||||
# OpenCover UI analysis results
|
||||
OpenCover/
|
||||
|
||||
# Azure Stream Analytics local run output
|
||||
ASALocalRun/
|
||||
|
||||
# MSBuild Binary and Structured Log
|
||||
*.binlog
|
||||
|
||||
# NVidia Nsight GPU debugger configuration file
|
||||
*.nvuser
|
||||
|
||||
# MFractors (Xamarin productivity tool) working folder
|
||||
.mfractor/
|
||||
|
||||
# Local History for Visual Studio
|
||||
.localhistory/
|
||||
|
||||
# BeatPulse healthcheck temp database
|
||||
healthchecksdb
|
||||
|
||||
# Backup folder for Package Reference Convert tool in Visual Studio 2017
|
||||
MigrationBackup/
|
||||
|
||||
# Ionide (cross platform F# VS Code tools) working folder
|
||||
.ionide/
|
||||
|
||||
# Fody - auto-generated XML schema
|
||||
FodyWeavers.xsd
|
||||
*.rar
|
||||
/LargeSquareOne/App.config
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,467 @@
|
||||
using HslCommunication.ModBus;
|
||||
using JinYuan.CommunicationLib.Enum;
|
||||
using JinYuan.DataConvertLib;
|
||||
using JinYuan.Helper;
|
||||
using JinYuan.MES.Models;
|
||||
using JinYuan.Models;
|
||||
using JinYuan.VirtualDataLibrary;
|
||||
using PLCCommunication;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace JinYuan.ControlCenters
|
||||
{
|
||||
public partial class ControlCenter
|
||||
{
|
||||
#region 刷新12小时产能
|
||||
public void Refresh12HourProdQty()
|
||||
{
|
||||
List<Chart12HourData> chart12Hours = new List<Chart12HourData>();
|
||||
int j = 0;
|
||||
int m = 0;
|
||||
int n = 0;
|
||||
DateTime dtTime = DateTime.Now;
|
||||
string strDate = dtTime.ToString("yyyy-MM-dd");
|
||||
int Hour = GetHour();
|
||||
var listTotal = CommonMethods.db.QueryWhereList<Hourprod>(t => t.FDate == strDate);// 查询稼动率表中total数据
|
||||
if (listTotal != null && listTotal.Count > 0)
|
||||
{
|
||||
for (int i = 1; i < 13; i++)
|
||||
{
|
||||
#region X轴数据
|
||||
|
||||
if (CommonMethods.strClass != "白班")
|
||||
{
|
||||
j = i + 21;
|
||||
|
||||
if (j >= 25 && j < 26)
|
||||
{
|
||||
m = j - 2;
|
||||
n = j - 25;
|
||||
}
|
||||
else if (j >= 26)
|
||||
{
|
||||
m = j - 26;
|
||||
n = j - 25;
|
||||
}
|
||||
else
|
||||
{
|
||||
m = j - 2;
|
||||
n = j - 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
j = i + 9;
|
||||
m = j - 2;
|
||||
n = j - 1;
|
||||
}
|
||||
#endregion
|
||||
|
||||
int Fhour = Convert.ToInt32(m);
|
||||
var hour1 = listTotal.Where(p => p.FHour == Fhour).FirstOrDefault();
|
||||
int ProdALLQty = 0;
|
||||
int ProdOKQty = 0;
|
||||
int ProdNGQty = 0;
|
||||
string strOkRatio = "0.00";
|
||||
|
||||
if (hour1 != null)
|
||||
{
|
||||
ProdALLQty += hour1.ProdIn;
|
||||
ProdOKQty += hour1.ProdOut;
|
||||
}
|
||||
|
||||
ProdNGQty = ProdALLQty - ProdOKQty;
|
||||
if (ProdOKQty >= 0 && ProdALLQty > 0)
|
||||
{
|
||||
strOkRatio = (Math.Round(decimal.Parse(ProdOKQty.ToString()) / decimal.Parse(ProdALLQty.ToString()), 4)).ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
strOkRatio = "0.00";
|
||||
}
|
||||
|
||||
chart12Hours.Add(new Chart12HourData()
|
||||
{
|
||||
DisplayTime = m + ":30~" + (n) + ":30",
|
||||
ProdIn = ProdALLQty,
|
||||
ProdOut = ProdOKQty,
|
||||
ProdNg = ProdNGQty,
|
||||
OKRatio = strOkRatio
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 1; i < 13; i++)
|
||||
{
|
||||
#region X轴数据
|
||||
|
||||
if (CommonMethods.strClass != "白班")
|
||||
{
|
||||
j = i + 21;
|
||||
|
||||
if (j >= 25 && j < 26)
|
||||
{
|
||||
m = j - 2;
|
||||
n = j - 25;
|
||||
}
|
||||
else if (j >= 26)
|
||||
{
|
||||
m = j - 26;
|
||||
n = j - 25;
|
||||
}
|
||||
else
|
||||
{
|
||||
m = j - 2;
|
||||
n = j - 1;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
j = i + 9;
|
||||
m = j - 2;
|
||||
n = j - 1;
|
||||
}
|
||||
#endregion
|
||||
|
||||
Random rand = new Random();
|
||||
int ranOK = rand.Next(1000, 3000);
|
||||
int ranNG = rand.Next(400, 1200);
|
||||
int total = ranOK + ranNG;
|
||||
|
||||
chart12Hours.Add(new Chart12HourData()
|
||||
{
|
||||
DisplayTime = m + ":30~" + n + ":30",
|
||||
ProdIn = ranOK + ranNG,
|
||||
ProdOut = ranOK,
|
||||
ProdNg = ranNG,
|
||||
OKRatio = (Math.Round(decimal.Parse(ranOK.ToString()) / decimal.Parse(total.ToString()) * 0.01m, 2) * 100).ToString()
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (chart12Hours != null)
|
||||
{
|
||||
CommonMethods.Lst_Prod12HourData = chart12Hours;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public int GetHour()
|
||||
{
|
||||
DateTime now = DateTime.Now;
|
||||
int nowHour = Convert.ToInt32($"{now.Hour}30");
|
||||
int hour = 0;
|
||||
if (CommonMethods.LastHour != nowHour)
|
||||
{
|
||||
hour = Convert.ToInt32($"{now.Hour - 1}30");
|
||||
if (now.Hour == 0)
|
||||
{
|
||||
hour = 2330;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
hour = Convert.ToInt32($"{now.Hour}30");
|
||||
}
|
||||
return hour;
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region 检测项不良
|
||||
/// <summary>
|
||||
/// 读取检测项不良
|
||||
/// </summary>
|
||||
private void GetDefectTypeQty()
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
if (CommonMethods.Lst_DefectTypeQty.Count <= 0)
|
||||
{
|
||||
//CommonMethods.Lst_DefectTypeQty.Add(new ChartDataType { DataType = "极性检测不良", DataCount = 0 });
|
||||
//CommonMethods.Lst_DefectTypeQty.Add(new ChartDataType { DataType = "称重不良", DataCount = 0 });
|
||||
//CommonMethods.Lst_DefectTypeQty.Add(new ChartDataType { DataType = "铜极耳剪切不良", DataCount = 0 });
|
||||
//CommonMethods.Lst_DefectTypeQty.Add(new ChartDataType { DataType = "铝极耳剪切不良", DataCount = 0 });
|
||||
|
||||
CommonMethods.Lst_DefectTypeQty.Add(new ChartDataType { DataType = "扫码不良", DataCount = 0 });
|
||||
CommonMethods.Lst_DefectTypeQty.Add(new ChartDataType { DataType = "MES不良", DataCount = 0 });
|
||||
CommonMethods.Lst_DefectTypeQty.Add(new ChartDataType { DataType = "其他不良", DataCount = 0 });
|
||||
|
||||
}
|
||||
else //读取PLC数据
|
||||
{
|
||||
if (CommonMethods.plcDevice != null && CommonMethods.plcDevice.IsConnected)
|
||||
{
|
||||
Task.Run(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
int ProdDRFIDNgQty = CommonMethods.PlcLink.ReadInt16("D1000");//扫码不良
|
||||
int ProdDXNgQty = CommonMethods.PlcLink.ReadInt16("D1001");//MES不良
|
||||
int ProdGRFIDNgQty = CommonMethods.PlcLink.ReadInt16("D1002");//其他不良
|
||||
|
||||
////從PLC讀取數據賦值給到NGList
|
||||
//CommonMethods.Lst_DefectTypeQty.Where(p => p.DataType == "极性检测不良").FirstOrDefault().DataCount = ProdDRFIDNgQty;
|
||||
//CommonMethods.Lst_DefectTypeQty.Where(p => p.DataType == "称重不良").FirstOrDefault().DataCount = ProdDXNgQty;
|
||||
//CommonMethods.Lst_DefectTypeQty.Where(p => p.DataType == "铜极耳剪切不良").FirstOrDefault().DataCount = ProdGRFIDNgQty;
|
||||
//CommonMethods.Lst_DefectTypeQty.Where(p => p.DataType == "铝极耳剪切不良").FirstOrDefault().DataCount = ProdYLZNgQty;
|
||||
//從PLC讀取數據賦值給到NGList
|
||||
CommonMethods.Lst_DefectTypeQty.Where(p => p.DataType == "扫码不良").FirstOrDefault().DataCount = ProdDRFIDNgQty;
|
||||
CommonMethods.Lst_DefectTypeQty.Where(p => p.DataType == "MES不良").FirstOrDefault().DataCount = ProdDXNgQty;
|
||||
CommonMethods.Lst_DefectTypeQty.Where(p => p.DataType == "其他不良").FirstOrDefault().DataCount = ProdGRFIDNgQty;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LoggerHelp.WriteEX(ex);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LoggerHelp.WriteEX(ex);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 智能电表 ---默认D1100开始
|
||||
public void GetEnergyData()
|
||||
{
|
||||
ModbusRtu busRtuClient = new ModbusRtu();
|
||||
if (CommonMethods.plcDevice != null && CommonMethods.plcDevice.IsConnected)
|
||||
{
|
||||
|
||||
List<ElectricEnergy> listM = new List<ElectricEnergy>();
|
||||
List<float> ListF = new List<float>();
|
||||
List<string> listAddre = new List<string>()
|
||||
{
|
||||
"D1100","D1102","D1104","D1106","D1108","D1110","D1112","D1114","D1116","D1118","D1120","D1122","D1124","D1126"
|
||||
};
|
||||
try
|
||||
{
|
||||
busRtuClient.SerialPortInni(sp =>
|
||||
{
|
||||
sp.PortName = "COM1";
|
||||
sp.BaudRate = 9600;
|
||||
sp.DataBits = 8;
|
||||
sp.StopBits = System.IO.Ports.StopBits.One;
|
||||
sp.Parity = System.IO.Ports.Parity.None;
|
||||
});
|
||||
busRtuClient.DataFormat = HslCommunication.Core.DataFormat.CDAB;
|
||||
busRtuClient.Open(); // 打开
|
||||
if (busRtuClient.IsOpen())
|
||||
{
|
||||
// 读取数据
|
||||
HslCommunication.OperateResult<byte[]> readResult = busRtuClient.Read("35", 30);
|
||||
HslCommunication.OperateResult<byte[]> readResult1 = busRtuClient.Read("3", 2);
|
||||
if (readResult.IsSuccess && readResult1.IsSuccess)
|
||||
{
|
||||
//DPT
|
||||
Byte DptH = busRtuClient.ByteTransform.TransByte(readResult.Content, 0);//高8位
|
||||
Byte DptL = busRtuClient.ByteTransform.TransByte(readResult.Content, 1);//低8位
|
||||
//DPQ
|
||||
Byte DpqH = busRtuClient.ByteTransform.TransByte(readResult.Content, 2);//高8位
|
||||
Byte DpqL = busRtuClient.ByteTransform.TransByte(readResult.Content, 3);//低8位
|
||||
|
||||
ElectricEnergy m = new ElectricEnergy();
|
||||
Decimal q = busRtuClient.ByteTransform.TransUInt16(readResult.Content, 56);
|
||||
Decimal w = busRtuClient.ByteTransform.TransUInt16(readResult.Content, 58);
|
||||
|
||||
m.pt = Convert.ToDecimal(busRtuClient.ByteTransform.TransInt16(readResult1.Content, 0)); //电压变比 D1124
|
||||
m.ct = Convert.ToDecimal(busRtuClient.ByteTransform.TransInt16(readResult1.Content, 2)); //电流变比 D1126
|
||||
Decimal Power = (q * 65536 + w) / 1000;
|
||||
m.AccumulatedElectricity = Convert.ToDecimal(Power * m.pt * m.ct); //有功电能(累计电能)D1100
|
||||
ListF.Add((float)m.AccumulatedElectricity.Value);
|
||||
//电压
|
||||
m.PhaseVoltageA = Convert.ToDecimal(busRtuClient.ByteTransform.TransUInt16(readResult.Content, 4) * Math.Pow(10, DptH - 4)); //A相电压 D1102
|
||||
m.PhaseVoltageB = Convert.ToDecimal(busRtuClient.ByteTransform.TransUInt16(readResult.Content, 6) * Math.Pow(10, DptH - 4));//B相电压 D1104
|
||||
m.PhaseVoltageC = Convert.ToDecimal(busRtuClient.ByteTransform.TransUInt16(readResult.Content, 8) * Math.Pow(10, DptH - 4));//C相电压 D1106
|
||||
ListF.Add((float)m.PhaseVoltageA.Value);
|
||||
ListF.Add((float)m.PhaseVoltageB.Value);
|
||||
ListF.Add((float)m.PhaseVoltageC.Value);
|
||||
|
||||
//电流
|
||||
m.PhaseCurrentA = Convert.ToDecimal(busRtuClient.ByteTransform.TransUInt16(readResult.Content, 16) * Math.Pow(10, DptL - 4)); //电流IA D1108
|
||||
m.PhaseCurrentB = Convert.ToDecimal(busRtuClient.ByteTransform.TransUInt16(readResult.Content, 18) * Math.Pow(10, DptL - 4));//电流IB D1110
|
||||
m.PhaseCurrentC = Convert.ToDecimal(busRtuClient.ByteTransform.TransUInt16(readResult.Content, 20) * Math.Pow(10, DptL - 4));//电流IC D1112
|
||||
ListF.Add((float)m.PhaseCurrentA.Value);
|
||||
ListF.Add((float)m.PhaseCurrentB.Value);
|
||||
ListF.Add((float)m.PhaseCurrentC.Value);
|
||||
|
||||
//有功功率
|
||||
m.PhasePowerA = Convert.ToDecimal(busRtuClient.ByteTransform.TransInt16(readResult.Content, 22) * Math.Pow(10, DpqH - 4)); //A相有功功率 D1114
|
||||
m.PhasePowerB = Convert.ToDecimal(busRtuClient.ByteTransform.TransInt16(readResult.Content, 24) * Math.Pow(10, DpqH - 4)); //B相有功功率 D1116
|
||||
m.PhasePowerC = Convert.ToDecimal(busRtuClient.ByteTransform.TransInt16(readResult.Content, 26) * Math.Pow(10, DpqH - 4));//C相有功功率 D1118
|
||||
m.ActivePower = Convert.ToDecimal(busRtuClient.ByteTransform.TransInt16(readResult.Content, 28) * Math.Pow(10, DpqH - 4)); //总有功功率 D1120
|
||||
ListF.Add((float)m.PhasePowerA.Value);
|
||||
ListF.Add((float)m.PhasePowerB.Value);
|
||||
ListF.Add((float)m.PhasePowerC.Value);
|
||||
ListF.Add((float)m.ActivePower.Value);
|
||||
m.PowerFactor = Convert.ToDecimal(busRtuClient.ByteTransform.TransInt16(readResult.Content, 44)) / 1000; //总功率因数 D1122
|
||||
ListF.Add((float)m.PowerFactor.Value);
|
||||
ListF.Add((float)m.pt.Value);
|
||||
ListF.Add((float)m.ct.Value);
|
||||
|
||||
for (int i = 0; i < ListF.Count; i++)
|
||||
{
|
||||
CommonMethods.PlcLink.WriteFloat(listAddre[i], ListF[i]);
|
||||
}
|
||||
listM.Add(m);
|
||||
CommonMethods.listElectricEnergy = listM;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
TxtHelper.WriteTxt($@"D:\APILog\Logs\智能电表信息\{DateTime.Now.ToString("yyyy-MM-dd")}.txt", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "智能电表:读取数据失败");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
TxtHelper.WriteTxt($@"D:\APILog\Logs\智能电表信息\{DateTime.Now.ToString("yyyy-MM-dd")}.txt", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "智能电表:串口打开失败");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TxtHelper.WriteTxt($@"D:\APILog\Logs\智能电表信息\{DateTime.Now.ToString("yyyy-MM-dd")}.txt", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + $"智能电表:{ex}");
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (busRtuClient.IsOpen())
|
||||
{
|
||||
busRtuClient.Close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 能耗上传MES
|
||||
/// </summary>
|
||||
public void UploadEquEnergy()
|
||||
{
|
||||
if (CommonMethods.listElectricEnergy.Count > 0)
|
||||
{
|
||||
if (CommonMethods.mesConfig.isUpMes)
|
||||
{
|
||||
string msg = string.Empty;
|
||||
DateTime nowDate = DateTime.Now;
|
||||
string filePath = string.Empty;
|
||||
string fileName = string.Empty;
|
||||
string fileTitle = string.Empty;
|
||||
string fileContent = string.Empty;
|
||||
List<WattrMeter> listP = new List<WattrMeter>();
|
||||
int i = 0;
|
||||
foreach (ElectricEnergy m in CommonMethods.listElectricEnergy)
|
||||
{
|
||||
WattrMeter param = new WattrMeter();
|
||||
param.siteCode = CommonMethods.mesConfig.siteCode;
|
||||
param.lineCode = CommonMethods.mesConfig.lineCode;
|
||||
param.equipNum = CommonMethods.mesConfig.equipNum;
|
||||
param.userName = CommonMethods.mesConfig.mesUserName;
|
||||
param.electricMeterNum = CommonMethods.mesConfig.electricMeterNum[i];
|
||||
param.recordDate = nowDate.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
param.accumulatedElectricity = (decimal)m.AccumulatedElectricity;
|
||||
param.phaseVoltageA = (decimal)m.PhaseVoltageA;
|
||||
param.phaseVoltageB = (decimal)m.PhaseVoltageB;
|
||||
param.phaseVoltageC = (decimal)m.PhaseVoltageC;
|
||||
param.phaseCurrentA = (decimal)m.PhaseCurrentA;
|
||||
param.phaseCurrentB = (decimal)m.PhaseCurrentB;
|
||||
param.phaseCurrentC = (decimal)m.PhaseCurrentC;
|
||||
param.phasePowerA = (decimal)m.PhasePowerA;
|
||||
param.phasePowerB = (decimal)m.PhasePowerB;
|
||||
param.phasePowerC = (decimal)m.PhasePowerC;
|
||||
param.activePower = (decimal)m.ActivePower;
|
||||
param.powerFactor = (decimal)m.PowerFactor;
|
||||
param.pt = (decimal)m.pt;
|
||||
param.ct = (decimal)m.ct;
|
||||
|
||||
listP.Add(param);
|
||||
i++;
|
||||
|
||||
// 写csv文件
|
||||
string productName = string.Empty;
|
||||
|
||||
filePath = $@"{CommonMethods.strWattrMeterpath}\{nowDate.Year}\{nowDate.Month}";
|
||||
fileName = $@"{nowDate.Day}.csv";
|
||||
fileTitle = "工序名称,生产机台编号,拉线,型号,物料编号,操作人员,班次,电表编号,采集时间,有功电能(累计电能)KwH,A相电压 V,B相电压 V,C相电压 V,A相电流 A,B相电流 A,C相电流 A,A相功率 Kw,B相功率 Kw,C相功率 Kw,总有功功率 Kw,总功率因数 %,电压变比,电流变比";
|
||||
fileContent = $"外观检工序,{CommonMethods.mesConfig.equipNum},{CommonMethods.mesConfig.lineCode},{productName},{CommonMethods.mesConfig.MaterialCode},{CommonMethods.mesConfig.mesUserName},{CommonMethods.strClass},{param.electricMeterNum},{nowDate.ToString("yyyy-MM-dd HH:mm:ss")}," +
|
||||
$"{param.accumulatedElectricity},{param.phaseVoltageA},{param.phaseVoltageB},{param.phaseVoltageC},{param.phaseCurrentA},{param.phaseCurrentB},{param.phaseCurrentC}," +
|
||||
$"{param.phasePowerA},{param.phasePowerB},{param.phasePowerC},{param.activePower},{param.powerFactor},{param.pt},{param.ct}";
|
||||
CSVHelper<object>.WriterCSV(filePath, fileName, fileTitle, fileContent);
|
||||
}
|
||||
//上传MES
|
||||
string Mesage = "";
|
||||
bool b = CommonMethods.hbgMes.UploadEquEnergy(CommonMethods.mesConfig.WattrMeterUrl, CommonMethods.mesConfig.equipNum, CommonMethods.mesConfig.siteCode, CommonMethods.mesConfig.lineCode,
|
||||
CommonMethods.mesConfig.mesUserName, CommonMethods.mesConfig.electricMeterNum, listP, ref Mesage);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 风速仪数据采集
|
||||
/// </summary>
|
||||
public void UPloadAnemograph()
|
||||
{
|
||||
int _anemometerNumber = 34;//风速仪的个数
|
||||
string _anemometerAddress = "D15000";//风速仪起始地址
|
||||
if (CommonMethods.mesConfig.isUpMes)
|
||||
{
|
||||
JYResult<byte[]> jYResult = CommonMethods.PlcLink.ReadValue<JYResult<byte[]>>(_anemometerAddress, Data_Type.ArrByte, 150);
|
||||
List<float> _anemograph = GetList<float>(_anemometerNumber, 0);//初始化列表
|
||||
List<string> _anemometerName = new List<string>();
|
||||
string _mesage = "";
|
||||
for (int i = 0; i < _anemometerNumber; i++)
|
||||
{
|
||||
//初始化风速仪名称
|
||||
int _temple = i + 1;
|
||||
string _name = "风速仪" + _temple.ToString();
|
||||
_anemometerName.Add(_name);
|
||||
|
||||
//解析数据
|
||||
_anemograph[i] = FloatLib.GetFloatFromByteArray(jYResult.Content, i * 4, DataFormat.CDAB);
|
||||
}
|
||||
//
|
||||
// 写csv文件
|
||||
string productName = string.Empty;
|
||||
string fileName = string.Empty;
|
||||
string filePath = string.Empty;
|
||||
DateTime nowDate = DateTime.Now;
|
||||
string fileTitle = "工序名称,生产机台编号,拉线,型号,物料编号,操作人员,班次,采集时间,";
|
||||
string fileContent = $"预焊工序,{CommonMethods.mesConfig.equipNum},{CommonMethods.mesConfig.lineCode},{productName},{CommonMethods.mesConfig.MaterialCode},{CommonMethods.mesConfig.mesUserName},{CommonMethods.strClass},{nowDate.ToString("yyyy-MM-dd HH:mm:ss")},";
|
||||
filePath = $@"{CommonMethods.strAnemographpath}\{nowDate.Year}\{nowDate.Month}";
|
||||
fileName = $@"{nowDate.Day}.csv";
|
||||
|
||||
for (int j = 0; j < _anemometerNumber; j++)
|
||||
{
|
||||
fileTitle = fileTitle + "," + _anemometerName[j];
|
||||
fileContent = fileContent + "," + _anemograph[j];
|
||||
}
|
||||
CSVHelper<object>.WriterCSV(filePath, fileName, fileTitle, fileContent);
|
||||
|
||||
|
||||
|
||||
if (false)//待确认接口
|
||||
{
|
||||
string ur = CommonMethods.mesConfig.CollectData;
|
||||
string equipNum = CommonMethods.mesConfig.equipNum;
|
||||
bool isResult = CommonMethods.hbgMes.UploadDeviceCollectData(ur, equipNum, _anemometerName, _anemograph, ref _mesage);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,105 @@
|
||||
<?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>{1D0FA5A4-07F0-4621-B6BB-683AEC91E658}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>JinYuan.ControlCenters</RootNamespace>
|
||||
<AssemblyName>JinYuan.ControlCenters</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<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' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="DataConvertLib, Version=6.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\LargeSquareOne\Lib\DataConvertLib.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="HslCommunication">
|
||||
<HintPath>.\HslCommunication.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="JinYuan.CommunicationLib, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\LargeSquareOne\Lib\JinYuan.CommunicationLib.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MiniExcel, Version=1.31.2.0, Culture=neutral, PublicKeyToken=e7310002a53eac39, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MiniExcel.1.31.2\lib\net45\MiniExcel.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="PLCCommunication, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\HBG_NegativeElectrodeWeld\Lib\PLCCommunication.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SqlSugar, Version=5.1.4.94, Culture=neutral, PublicKeyToken=null" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Diagnostics.Tracing" />
|
||||
<Reference Include="System.IO.Compression" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<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="ControlCenter_Plc.cs" />
|
||||
<Compile Include="MES\MESDataCombin.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ControlCenter_Total.cs" />
|
||||
<Compile Include="ControlCenter.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\JinYuan.DAL\JinYuan.DAL.csproj">
|
||||
<Project>{114aa012-29c9-418c-a2d6-3173c5341f51}</Project>
|
||||
<Name>JinYuan.DAL</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\JinYuan.Helper\JinYuan.Helper.csproj">
|
||||
<Project>{258D0AB7-2B4F-4D8F-A3CD-7A8CB4A85360}</Project>
|
||||
<Name>JinYuan.Helper</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\JinYuan.MES\JinYuan.MES.csproj">
|
||||
<Project>{530B6426-08E7-461C-91DC-787F876620FC}</Project>
|
||||
<Name>JinYuan.MES</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\JinYuan.Models\JinYuan.Models.csproj">
|
||||
<Project>{4c0bcb84-5cd7-4846-8363-c4c10d46e391}</Project>
|
||||
<Name>JinYuan.Models</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\JinYuan.VirtualDataLibrary\JinYuan.VirtualDataLibrary.csproj">
|
||||
<Project>{2ab7e380-7795-448a-933c-0f6a081b5e7e}</Project>
|
||||
<Name>JinYuan.VirtualDataLibrary</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -0,0 +1,155 @@
|
||||
using JinYuan.Helper;
|
||||
using JinYuan.MES;
|
||||
using JinYuan.MES.Models;
|
||||
using JinYuan.Models;
|
||||
using JinYuan.VirtualDataLibrary;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace JinYuan.ControlCenters
|
||||
{
|
||||
public class MESDataCombin
|
||||
{
|
||||
#region 9、报警信息
|
||||
/// <summary>
|
||||
/// 报警信息
|
||||
/// </summary>
|
||||
/// <param name="alarmObj">报警内容</param>
|
||||
/// <param name="alarmFlag">报警标志 1:报警开始 0:报警结束</param>
|
||||
/// <returns></returns>
|
||||
public static string EquAlarm(AlarmData alarmObj, int alarmFlag)
|
||||
{
|
||||
DateTime nowTime = DateTime.Now;
|
||||
string resJson = "";
|
||||
string josnTxtMsg = string.Empty;
|
||||
try
|
||||
{
|
||||
UploadAlarmParam alarmParam = new UploadAlarmParam();
|
||||
alarmParam.siteCode = CommonMethods.mesConfig.siteCode;
|
||||
alarmParam.lineCode = CommonMethods.mesConfig.lineCode;
|
||||
alarmParam.equipNum = CommonMethods.mesConfig.equipNum;
|
||||
alarmParam.materialCode = CommonMethods.mesConfig.MaterialCode;
|
||||
alarmParam.userName = CommonMethods.mesConfig.mesUserName;
|
||||
alarmParam.recordDate = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
|
||||
alarmParam.guid = alarmObj.AlarmGuid;
|
||||
alarmParam.seatId = "";
|
||||
List<AlarmLineListItem> alarmLineList = new List<AlarmLineListItem>();
|
||||
|
||||
AlarmLineListItem alarmList = new AlarmLineListItem();
|
||||
alarmList.alarmEndTime = alarmFlag == 1 ? "" : alarmObj.EndTime.ToString();
|
||||
alarmList.alarmType = alarmObj.AlarmType;
|
||||
alarmList.alarmName = alarmObj.AlarmContent;
|
||||
alarmList.alarmStartTime = alarmObj.StartTime.ToString();
|
||||
alarmList.faultCode = alarmObj.AlarmCode;
|
||||
alarmLineList.Add(alarmList);
|
||||
alarmParam.alarmLineList = alarmLineList;
|
||||
string SendJosn = JsonConvert.SerializeObject(alarmParam);
|
||||
var sw = new Stopwatch();
|
||||
sw.Start();
|
||||
resJson = MESApiHelper.HttpPostJsonAPI(CommonMethods.mesConfig.AlarmCurrencyMesUrl, SendJosn);
|
||||
sw.Stop();
|
||||
josnTxtMsg = $"{nowTime.ToString("yyyy-MM-dd HH:mm:ss.fff")}:调用MES设备报警接口:{CommonMethods.mesConfig.AlarmCurrencyMesUrl},请求数据为:{SendJosn},\n{nowTime.AddMilliseconds(sw.ElapsedMilliseconds).ToString("yyyy-MM-dd HH:mm:ss.fff")}:接口耗时:{sw.ElapsedMilliseconds}ms,返回结果:{resJson}";
|
||||
TxtHelper.WriteTxt($@"{CommonMethods.strMesLogspath}\{nowTime.ToString("yyyyMMdd")}\设备报警\{nowTime.ToString("HH")}.txt", josnTxtMsg);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LoggerHelp.WriteEX("调用MES设备报警接口", ex);
|
||||
}
|
||||
return resJson;
|
||||
|
||||
}
|
||||
#endregion
|
||||
#region 10、设备状态
|
||||
/// <summary>
|
||||
/// 设备状态
|
||||
/// </summary>
|
||||
/// <param name="strStatus"></param>
|
||||
/// <returns></returns>
|
||||
public static string EqpStatusParam(string strStatus, string StartDate, string strGuid, List<FaultCodeList> FaultCodeLists = null)
|
||||
{
|
||||
var nowTime = DateTime.Now;
|
||||
string resJson = "";
|
||||
string josnTxtMsg = string.Empty;
|
||||
string Date = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
|
||||
try
|
||||
{
|
||||
EqpStatusParam statusParam = new EqpStatusParam();
|
||||
statusParam.siteCode = CommonMethods.mesConfig.siteCode;
|
||||
statusParam.lineCode = CommonMethods.mesConfig.lineCode;
|
||||
statusParam.equipNum = CommonMethods.mesConfig.equipNum;
|
||||
statusParam.userName = CommonMethods.mesConfig.mesUserName;
|
||||
statusParam.seatId = "";
|
||||
statusParam.recordDate = StartDate;
|
||||
statusParam.statusCode = strStatus;
|
||||
statusParam.uploadTime = Date;
|
||||
statusParam.guid = strGuid;
|
||||
statusParam.faultCodeList = FaultCodeLists;
|
||||
string SendJosn = JsonConvert.SerializeObject(statusParam);
|
||||
|
||||
var sw = new Stopwatch();
|
||||
sw.Start();
|
||||
resJson = MESApiHelper.HttpPostJsonAPI(CommonMethods.mesConfig.StatusMesUrl, SendJosn);
|
||||
sw.Stop();
|
||||
josnTxtMsg = $"{nowTime.ToString("yyyy-MM-dd HH:mm:ss.fff")}:调用MES设备运行状态接口:{CommonMethods.mesConfig.StatusMesUrl},请求数据为:{SendJosn},\n{nowTime.AddMilliseconds(sw.ElapsedMilliseconds).ToString("yyyy-MM-dd HH:mm:ss.fff")}:接口耗时:{sw.ElapsedMilliseconds}ms,返回结果:{resJson}";
|
||||
TxtHelper.WriteTxt($@"{CommonMethods.strMesLogspath}\{nowTime.ToString("yyyyMMdd")}\设备运行状态\{nowTime.ToString("HH")}.txt", josnTxtMsg);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LoggerHelp.WriteEX("调用MES设备运行状态接口", ex);
|
||||
}
|
||||
return resJson;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 11、安全装置状态
|
||||
/// <summary>
|
||||
/// 安全装置状态
|
||||
/// </summary>
|
||||
/// <param name="strStatus"></param>
|
||||
/// <returns></returns>
|
||||
public static string SafeEqptAlarm(string StartDate, List<SafeEqptCode> safeEqptCodeLists = null)
|
||||
{
|
||||
var nowTime = DateTime.Now;
|
||||
string resJson = "";
|
||||
string josnTxtMsg = string.Empty;
|
||||
string Date = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
|
||||
try
|
||||
{
|
||||
//SafeEqptStatusParam statusParam = new SafeEqptStatusParam();
|
||||
//statusParam.siteCode = CommonMethods.mesConfig.siteCode;
|
||||
//statusParam.lineCode = CommonMethods.mesConfig.lineCode;
|
||||
//statusParam.equipNum = CommonMethods.mesConfig.equipNum;
|
||||
//statusParam.userName = CommonMethods.mesConfig.mesUserName;
|
||||
//statusParam.seatId = "";
|
||||
//statusParam.recordDate = StartDate;
|
||||
//statusParam.uploadTime = Date;
|
||||
//statusParam.safeEqptCodeList = safeEqptCodeLists;
|
||||
//string SendJosn = JsonConvert.SerializeObject(statusParam);
|
||||
|
||||
var sw = new Stopwatch();
|
||||
|
||||
for (int i = 0; i < safeEqptCodeLists.Count; i++)
|
||||
{
|
||||
string SendJosn = JsonConvert.SerializeObject(safeEqptCodeLists[i]);
|
||||
sw.Start();
|
||||
resJson = MESApiHelper.HttpPostJsonAPI(CommonMethods.mesConfig.SafeEqptStatusMesUrl, SendJosn);
|
||||
sw.Stop();
|
||||
josnTxtMsg = $"{nowTime.ToString("yyyy-MM-dd HH:mm:ss.fff")}:调用MES安全设备运行状态接口:{CommonMethods.mesConfig.SafeEqptStatusMesUrl},请求数据为:{SendJosn},\n{nowTime.AddMilliseconds(sw.ElapsedMilliseconds).ToString("yyyy-MM-dd HH:mm:ss.fff")}:接口耗时:{sw.ElapsedMilliseconds}ms,返回结果:{resJson}";
|
||||
TxtHelper.WriteTxt($@"{CommonMethods.strMesLogspath}\{nowTime.ToString("yyyyMMdd")}\设备运行状态\{nowTime.ToString("HH")}.txt", josnTxtMsg);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LoggerHelp.WriteEX("调用MES安全设备运行状态接口", ex);
|
||||
}
|
||||
return resJson;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,35 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// 有关程序集的一般信息由以下
|
||||
// 控制。更改这些特性值可修改
|
||||
// 与程序集关联的信息。
|
||||
[assembly: AssemblyTitle("JinYuan.ControlCenters")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("JinYuan.ControlCenters")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2023")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// 将 ComVisible 设置为 false 会使此程序集中的类型
|
||||
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
|
||||
//请将此类型的 ComVisible 特性设置为 true。
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
|
||||
[assembly: Guid("1d0fa5a4-07f0-4621-b6bb-683aec91e658")]
|
||||
|
||||
// 程序集的版本信息由下列四个值组成:
|
||||
//
|
||||
// 主版本
|
||||
// 次版本
|
||||
// 生成号
|
||||
// 修订号
|
||||
//
|
||||
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
|
||||
//通过使用 "*",如下所示:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@@ -0,0 +1,63 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="MySql.Data" publicKeyToken="c5687fc88969c44d" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-8.1.0.0" newVersion="8.1.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.1.2" newVersion="4.0.1.2" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.1.4.0" newVersion="4.1.4.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Text.Encoding.CodePages" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Security.Cryptography.Xml" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-6.0.0.1" newVersion="6.0.0.1" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.IO.Pipelines" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.2.0.1" newVersion="4.2.0.1" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Google.Protobuf" publicKeyToken="a7d26565bac4d604" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-3.23.4.0" newVersion="3.23.4.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="ZstdSharp" publicKeyToken="8d151af33a4ad5cf" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-0.7.2.0" newVersion="0.7.2.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.Bcl.AsyncInterfaces" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Configuration.ConfigurationManager" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
||||
Binary file not shown.
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="MiniExcel" version="1.31.2" targetFramework="net472" />
|
||||
</packages>
|
||||
@@ -0,0 +1,100 @@
|
||||
namespace JinYuan.DAL.Enums
|
||||
{
|
||||
/// <summary>
|
||||
/// 查询条件枚举
|
||||
/// </summary>
|
||||
public enum QueryOperator
|
||||
{
|
||||
/// <summary>
|
||||
/// 相等
|
||||
/// </summary>
|
||||
Equal,
|
||||
/// <summary>
|
||||
/// 匹配
|
||||
/// </summary>
|
||||
Like,
|
||||
/// <summary>
|
||||
/// 大于
|
||||
/// </summary>
|
||||
GreaterThan,
|
||||
/// <summary>
|
||||
/// 大于或等于
|
||||
/// </summary>
|
||||
GreaterThanOrEqual,
|
||||
/// <summary>
|
||||
/// 小于
|
||||
/// </summary>
|
||||
LessThan,
|
||||
/// <summary>
|
||||
/// 小于或等于
|
||||
/// </summary>
|
||||
LessThanOrEqual,
|
||||
/// <summary>
|
||||
/// 等于集合
|
||||
/// </summary>
|
||||
In,
|
||||
/// <summary>
|
||||
/// 不等于集合
|
||||
/// </summary>
|
||||
NotIn,
|
||||
/// <summary>
|
||||
/// 左边匹配
|
||||
/// </summary>
|
||||
LikeLeft,
|
||||
/// <summary>
|
||||
/// 右边匹配
|
||||
/// </summary>
|
||||
LikeRight,
|
||||
/// <summary>
|
||||
/// 不相等
|
||||
/// </summary>
|
||||
NoEqual,
|
||||
/// <summary>
|
||||
/// 为空或空
|
||||
/// </summary>
|
||||
IsNullOrEmpty,
|
||||
/// <summary>
|
||||
/// 不为空
|
||||
/// </summary>
|
||||
IsNot,
|
||||
/// <summary>
|
||||
/// 不匹配
|
||||
/// </summary>
|
||||
NoLike,
|
||||
/// <summary>
|
||||
/// 时间段 值用 "|" 隔开
|
||||
/// </summary>
|
||||
DateRange
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 查询条件运算符
|
||||
/// </summary>
|
||||
public enum QueryCharacter
|
||||
{
|
||||
/// <summary>
|
||||
/// 且
|
||||
/// </summary>
|
||||
And,
|
||||
/// <summary>
|
||||
/// 或
|
||||
/// </summary>
|
||||
Or,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 排序枚举
|
||||
/// </summary>
|
||||
public enum OrderSequence
|
||||
{
|
||||
/// <summary>
|
||||
/// 正序
|
||||
/// </summary>
|
||||
Asc,
|
||||
/// <summary>
|
||||
/// 倒序
|
||||
/// </summary>
|
||||
Desc
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,547 @@
|
||||
using JinYuan.DAL.Models;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace JinYuan.DAL
|
||||
{
|
||||
public interface ISugarHepler : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// 初始化数据库连接
|
||||
/// </summary>
|
||||
/// <param name="connectionStr"></param>
|
||||
void SetConnectionStr(string connectionStr, SqlSugar.DbType dbType);
|
||||
|
||||
#region 数据库管理
|
||||
/// <summary>
|
||||
/// 添加列
|
||||
/// </summary>
|
||||
/// <param name="tableName">表名</param>
|
||||
/// <param name="column">列信息</param>
|
||||
/// <returns></returns>
|
||||
bool AddColumn(string tableName, DbColumnInfo column);
|
||||
/// <summary>
|
||||
/// 添加主键
|
||||
/// </summary>
|
||||
/// <param name="tableName">表名</param>
|
||||
/// <param name="columnName">列名</param>
|
||||
/// <returns></returns>
|
||||
bool AddPrimaryKey(string tableName, string columnName);
|
||||
/// <summary>
|
||||
/// 备份数据库
|
||||
/// </summary>
|
||||
/// <param name="databaseName">数据库名</param>
|
||||
/// <param name="fullFileName">文件名</param>
|
||||
/// <returns></returns>
|
||||
bool BackupDataBase(string databaseName, string fullFileName);
|
||||
/// <summary>
|
||||
/// 备份表
|
||||
/// </summary>
|
||||
/// <param name="oldTableName">旧表名</param>
|
||||
/// <param name="newTableName">行表名</param>
|
||||
/// <param name="maxBackupDataRows">行数</param>
|
||||
/// <returns></returns>
|
||||
bool BackupTable(string oldTableName, string newTableName, int maxBackupDataRows = int.MaxValue);
|
||||
/// <summary>
|
||||
/// 创建表
|
||||
/// </summary>
|
||||
/// <param name="tableName">表名</param>
|
||||
/// <param name="columns">列集合</param>
|
||||
/// <param name="isCreatePrimaryKey">是否创建主键</param>
|
||||
/// <returns></returns>
|
||||
bool CreateTable(string tableName, List<DbColumnInfo> columns, bool isCreatePrimaryKey = true);
|
||||
/// <summary>
|
||||
/// 删除列
|
||||
/// </summary>
|
||||
/// <param name="tableName">表名</param>
|
||||
/// <param name="columnName">列名</param>
|
||||
/// <returns></returns>
|
||||
bool DropColumn(string tableName, string columnName);
|
||||
/// <summary>
|
||||
/// 删除约束
|
||||
/// </summary>
|
||||
/// <param name="tableName">表名</param>
|
||||
/// <param name="constraintName">约束名</param>
|
||||
/// <returns></returns>
|
||||
bool DropConstraint(string tableName, string constraintName);
|
||||
/// <summary>
|
||||
/// 删除表
|
||||
/// </summary>
|
||||
/// <param name="tableName"></param>
|
||||
/// <returns></returns>
|
||||
bool DropTable(string tableName);
|
||||
/// <summary>
|
||||
/// 获取列信息
|
||||
/// </summary>
|
||||
/// <param name="tableName">表名</param>
|
||||
/// <param name="isCache">是否缓存</param>
|
||||
/// <returns></returns>
|
||||
List<DbColumnInfo> GetColumnInfosByTableName(string tableName, bool isCache = true);
|
||||
/// <summary>
|
||||
/// 获取自增列
|
||||
/// </summary>
|
||||
/// <param name="tableName">表名</param>
|
||||
/// <returns></returns>
|
||||
List<string> GetIsIdentities(string tableName);
|
||||
/// <summary>
|
||||
/// 获取主键
|
||||
/// </summary>
|
||||
/// <param name="tableName">表名</param>
|
||||
/// <returns></returns>
|
||||
List<string> GetPrimaries(string tableName);
|
||||
/// <summary>
|
||||
/// 获取表集合
|
||||
/// </summary>
|
||||
/// <param name="isCache">是否缓存</param>
|
||||
/// <returns></returns>
|
||||
List<DbTableInfo> GetTableInfoList(bool isCache = true);
|
||||
/// <summary>
|
||||
/// 获取视图集合
|
||||
/// </summary>
|
||||
/// <param name="isCache">是否缓存</param>
|
||||
/// <returns></returns>
|
||||
List<DbTableInfo> GetViewInfoList(bool isCache = true);
|
||||
/// <summary>
|
||||
/// 检测列是否存在
|
||||
/// </summary>
|
||||
/// <param name="tableName">表名</param>
|
||||
/// <param name="column">列名</param>
|
||||
/// <returns></returns>
|
||||
bool IsAnyColumn(string tableName, string column);
|
||||
/// <summary>
|
||||
/// 检测约束
|
||||
/// </summary>
|
||||
/// <param name="constraintName">约束名称</param>
|
||||
/// <returns></returns>
|
||||
bool IsAnyConstraint(string constraintName);
|
||||
/// <summary>
|
||||
/// 检测是否有任何系统表权限
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsAnySystemTablePermissions();
|
||||
/// <summary>
|
||||
/// 检测表是否存在
|
||||
/// </summary>
|
||||
/// <param name="tableName">表名</param>
|
||||
/// <param name="isCache">是否缓存</param>
|
||||
/// <returns></returns>
|
||||
bool IsAnyTable(string tableName, bool isCache = true);
|
||||
/// <summary>
|
||||
/// 检测列是否自增列
|
||||
/// </summary>
|
||||
/// <param name="tableName">表名</param>
|
||||
/// <param name="column">列名</param>
|
||||
/// <returns></returns>
|
||||
bool IsIdentity(string tableName, string column);
|
||||
/// <summary>
|
||||
/// 检测列是否主键
|
||||
/// </summary>
|
||||
/// <param name="tableName">表名</param>
|
||||
/// <param name="column">列名</param>
|
||||
/// <returns></returns>
|
||||
bool IsPrimaryKey(string tableName, string column);
|
||||
/// <summary>
|
||||
/// 重置列名
|
||||
/// </summary>
|
||||
/// <param name="tableName">表名</param>
|
||||
/// <param name="oldColumnName">旧列名</param>
|
||||
/// <param name="newColumnName">新列名</param>
|
||||
/// <returns></returns>
|
||||
bool RenameColumn(string tableName, string oldColumnName, string newColumnName);
|
||||
/// <summary>
|
||||
/// 重置表数据
|
||||
/// </summary>
|
||||
/// <param name="tableName">表名</param>
|
||||
/// <returns></returns>
|
||||
bool TruncateTable(string tableName);
|
||||
/// <summary>
|
||||
/// 修改列信息
|
||||
/// </summary>
|
||||
/// <param name="tableName">表名</param>
|
||||
/// <param name="column">列信息</param>
|
||||
/// <returns></returns>
|
||||
bool UpdateColumn(string tableName, DbColumnInfo column);
|
||||
|
||||
/// <summary>
|
||||
/// 获取数据库时间
|
||||
/// </summary>
|
||||
/// <returns>返回值</returns>
|
||||
DateTime GetDataBaseTime();
|
||||
#endregion
|
||||
|
||||
#region 查询
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 查询所有
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <returns></returns>
|
||||
List<T> QueryAll<T>() where T : class, new();
|
||||
/// <summary>
|
||||
/// 查询-返回自定义数据
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型参数(集合成员的类型)</typeparam>
|
||||
/// <typeparam name="TResult">返回值类型</typeparam>
|
||||
/// <param name="expression">返回值表达式</param>
|
||||
/// <param name="whereLambda">查询表达式</param>
|
||||
/// <returns>值</returns>
|
||||
TResult QuerySelect<T, TResult>(Expression<Func<T, TResult>> expression, Expression<Func<T, bool>> whereLambda = null) where T : class, new();
|
||||
|
||||
/// <summary>
|
||||
/// 查询-返回自定义数据
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型参数(集合成员的类型)</typeparam>
|
||||
/// <typeparam name="TResult">返回值类型</typeparam>
|
||||
/// <param name="expression">返回值表达式</param>
|
||||
/// <param name="whereLambda">查询表达式</param>
|
||||
/// <returns>值</returns>
|
||||
List<TResult> QuerySelectList<T, TResult>(Expression<Func<T, TResult>> expression, Expression<Func<T, bool>> whereLambda = null) where T : class, new();
|
||||
|
||||
/// <summary>
|
||||
/// 根据条件查询单条数据
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型参数(集合成员的类型)</typeparam>
|
||||
/// <param name="whereLambda">查询表达式</param>
|
||||
/// <returns></returns>
|
||||
T Query<T>(Expression<Func<T, bool>> whereLambda = null) where T : class, new();
|
||||
|
||||
/// <summary>
|
||||
/// 根据条件异步查询单条数据
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="whereLambda"></param>
|
||||
/// <returns></returns>
|
||||
Task<T> QueryAsync<T>(Expression<Func<T, bool>> whereLambda = null) where T : class, new();
|
||||
|
||||
/// <summary>
|
||||
/// 根据条件查询排序数据
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="whereLambda"></param>
|
||||
/// <param name="query"></param>
|
||||
/// <returns></returns>
|
||||
T Query<T>(Expression<Func<T, bool>> whereLambda = null, Expression<Func<T, object>> whereLambda2 = null, OrderByType byType = OrderByType.Desc) where T : class, new();
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 根据条件查询集合
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型参数(集合成员的类型)</typeparam>
|
||||
/// <param name="whereLambda">过滤条件</param>
|
||||
/// <returns>实体</returns>
|
||||
List<T> QueryWhereList<T>(Expression<Func<T, bool>> whereLambda = null) where T : class, new();
|
||||
/// <summary>
|
||||
/// 查询排序数据
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="query"></param>
|
||||
/// <returns></returns>
|
||||
List<T> QueryList<T>(QueryDescriptor query = null) where T : class, new();
|
||||
/// <summary>
|
||||
/// 查询前N条数据
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="sort">排序列名</param>
|
||||
/// <param name="Take">前N条数据</param>
|
||||
/// <param name="whereLambda">条件</param>
|
||||
/// <param name="byType">升序/降序</param>
|
||||
/// <returns></returns>
|
||||
List<T> QueryList<T>(string sort, int Take, Expression<Func<T, bool>> whereLambda = null, OrderByType byType = OrderByType.Desc) where T : class, new();
|
||||
/// <summary>
|
||||
/// 根据字段查询排列
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="whereLambda"></param>
|
||||
/// <param name="sort"></param>
|
||||
/// <param name="byType"></param>
|
||||
/// <returns></returns>
|
||||
List<T> QueryList<T>(string sort, Expression<Func<T, bool>> whereLambda = null, OrderByType byType = OrderByType.Asc) where T : class, new();
|
||||
/// <summary>
|
||||
/// 查询集合
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型参数(集合成员的类型)</typeparam>
|
||||
/// <param name="sql">sql</param>
|
||||
/// <returns>实体</returns>
|
||||
List<T> QuerySqlList<T>(string sql) where T : class, new();
|
||||
|
||||
/// <summary>
|
||||
/// 分页查询
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型参数(集合成员的类型)</typeparam>
|
||||
/// <param name="query">过滤条件</param>
|
||||
/// <param name="totalCount">总行数</param>
|
||||
/// <returns>实体</returns>
|
||||
List<T> QueryPageList<T>(QueryDescriptor query, out int totalCount) where T : class, new();
|
||||
|
||||
/// <summary>
|
||||
/// 通过多值查询数据集
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型参数(集合成员的类型)</typeparam>
|
||||
/// <param name="inFieldName">字段名</param>
|
||||
/// <param name="inValues">数据集合</param>
|
||||
/// <returns></returns>
|
||||
List<T> In<T>(string inFieldName, List<dynamic> inValues) where T : class, new();
|
||||
|
||||
/// <summary>
|
||||
/// 通过多值(主键)查询数据集
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型参数(集合成员的类型)</typeparam>
|
||||
/// <param name="values">主键数据集合</param>
|
||||
/// <returns></returns>
|
||||
List<T> In<T>(List<dynamic> values) where T : class, new();
|
||||
|
||||
/// <summary>
|
||||
/// 条件查询DataTable
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型参数(集合成员的类型)</typeparam>
|
||||
/// <param name="whereLambda">查询表达式</param>
|
||||
/// <returns>实体</returns>
|
||||
DataTable QueryDataTable<T>(Expression<Func<T, bool>> whereLambda = null) where T : class, new();
|
||||
|
||||
/// <summary>
|
||||
/// 查询DataTable
|
||||
/// </summary>
|
||||
/// <param name="sql">sql</param>
|
||||
/// <returns>实体</returns>
|
||||
DataTable QueryDataTable(string sql);
|
||||
/// <summary>
|
||||
/// 查询单个值
|
||||
/// </summary>
|
||||
/// <param name="sql">sql</param>
|
||||
/// <returns>单个值</returns>
|
||||
object QuerySqlScalar(string sql);
|
||||
|
||||
/// <summary>
|
||||
/// 分页查询
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型参数(集合成员的类型)</typeparam>
|
||||
/// <param name="query">过滤条件</param>
|
||||
/// <param name="totalCount">总行数</param>
|
||||
/// <returns>DataTable</returns>
|
||||
DataTable QueryDataTablePageList<T>(QueryDescriptor query, out int totalCount) where T : class, new();
|
||||
|
||||
#endregion
|
||||
|
||||
#region 新增
|
||||
/// <summary>
|
||||
/// 新增
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型参数(集合成员的类型)</typeparam>
|
||||
/// <param name="entity"> 实体对象 </param>
|
||||
/// <returns>操作影响的行数</returns>
|
||||
int Add<T>(T entity) where T : class, new();
|
||||
|
||||
/// <summary>
|
||||
/// 新增
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型参数(集合成员的类型)</typeparam>
|
||||
/// <param name="entitys">泛型集合</param>
|
||||
/// <returns>操作影响的行数</returns>
|
||||
int Add<T>(List<T> entitys) where T : class, new();
|
||||
|
||||
/// <summary>
|
||||
/// 新增
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型参数(集合成员的类型)</typeparam>
|
||||
/// <param name="keyValues">字典集合(Key:列名 Value:值)</param>
|
||||
/// <returns>操作影响的行数</returns>
|
||||
int Add<T>(Dictionary<string, object> keyValues) where T : class, new();
|
||||
|
||||
/// <summary>
|
||||
/// 新增
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型参数(集合成员的类型)</typeparam>
|
||||
/// <param name="entity"> 实体对象 </param>
|
||||
/// <returns>返回实体</returns>
|
||||
T AddReturnEntity<T>(T entity) where T : class, new();
|
||||
|
||||
/// <summary>
|
||||
/// 新增
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型参数(集合成员的类型)</typeparam>
|
||||
/// <param name="entity"> 实体对象 </param>
|
||||
/// <returns>返回自增列</returns>
|
||||
int AddReturnIdentity<T>(T entity) where T : class, new();
|
||||
/// <summary>
|
||||
/// 新增
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型参数(集合成员的类型)</typeparam>
|
||||
/// <param name="entity"> 实体对象 </param>
|
||||
/// <returns>返回bool</returns>
|
||||
bool AddReturnBool<T>(T entity) where T : class, new();
|
||||
|
||||
/// <summary>
|
||||
/// 新增
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型参数(集合成员的类型)</typeparam>
|
||||
/// <param name="entitys">泛型集合</param>
|
||||
/// <returns>返回bool</returns>
|
||||
bool AddReturnBool<T>(List<T> entitys) where T : class, new();
|
||||
#endregion
|
||||
|
||||
#region 修改
|
||||
/// <summary>
|
||||
/// 修改(主键是更新条件)
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型参数(集合成员的类型)</typeparam>
|
||||
/// <param name="entity"> 实体对象(必须指定主键特性 [SugarColumn(IsPrimaryKey=true)]),如果是联合主键,请使用Where条件 </param>
|
||||
/// <param name="lstIgnoreColumns">不更新的列</param>
|
||||
/// <param name="isLock"> 是否加锁 </param>
|
||||
/// <returns>操作影响的行数</returns>
|
||||
int Update<T>(T entity, List<string> lstIgnoreColumns = null, bool isLock = true) where T : class, new();
|
||||
|
||||
/// <summary>
|
||||
/// 修改(主键是更新条件)
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型参数(集合成员的类型)</typeparam>
|
||||
/// <param name="entitys"> 实体对象集合(必须指定主键特性 [SugarColumn(IsPrimaryKey=true)]),如果是联合主键,请使用Where条件 </param>
|
||||
/// <param name="lstIgnoreColumns">不更新的列</param>
|
||||
/// <param name="isLock"> 是否加锁 </param>
|
||||
/// <returns>操作影响的行数</returns>
|
||||
int Update<T>(List<T> entitys, List<string> lstIgnoreColumns = null, bool isLock = true) where T : class, new();
|
||||
|
||||
/// <summary>
|
||||
/// 修改
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型参数(集合成员的类型)</typeparam>
|
||||
/// <param name="entity"> 实体对象 </param>
|
||||
/// <param name="where"> 条件 </param>
|
||||
/// <param name="lstIgnoreColumns">不更新的列</param>
|
||||
/// <param name="isLock"> 是否加锁 </param>
|
||||
/// <returns>操作影响的行数</returns>
|
||||
int Update<T>(T entity, Expression<Func<T, bool>> where, List<string> lstIgnoreColumns = null,
|
||||
bool isLock = true) where T : class, new();
|
||||
|
||||
/// <summary>
|
||||
/// 修改
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型参数(集合成员的类型)</typeparam>
|
||||
/// <param name="update"> 实体对象 </param>
|
||||
/// <param name="where"> 条件 </param>
|
||||
/// <param name="isLock"> 是否加锁 </param>
|
||||
/// <returns>操作影响的行数</returns>
|
||||
int Update<T>(Expression<Func<T, object>> update, Expression<Func<T, bool>> where = null, bool isLock = true) where T : class, new();
|
||||
/// <summary>
|
||||
/// 修改+1
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型参数(集合成员的类型)</typeparam>
|
||||
/// <param name="update"> 实体对象 </param>
|
||||
/// <param name="where"> 条件 </param>
|
||||
/// <param name="isLock"> 是否加锁 </param>
|
||||
/// <returns>操作影响的行数</returns>
|
||||
int Update<T>(Expression<Func<T, bool>> update, Expression<Func<T, bool>> where = null, bool isLock = true) where T : class, new();
|
||||
/// <summary>
|
||||
/// 修改单条数据
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="where"></param>
|
||||
/// <param name="isLock"></param>
|
||||
/// <returns></returns>
|
||||
int UpdateSingle<T>(T entity, Expression<Func<T, object>> where = null, Expression<Func<T, bool>> where2 = null, bool isLock = true) where T : class, new();
|
||||
|
||||
/// <summary>
|
||||
/// 修改
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型参数(集合成员的类型)</typeparam>
|
||||
/// <param name="keyValues">字典集合(Key:列名 Value:值)</param>
|
||||
/// <param name="where"> 条件 </param>
|
||||
/// <param name="isLock"> 是否加锁 </param>
|
||||
/// <returns>操作影响的行数</returns>
|
||||
int Update<T>(Dictionary<string, T> keyValues, Expression<Func<T, bool>> where = null, bool isLock = true)
|
||||
where T : class, new();
|
||||
|
||||
/// <summary>
|
||||
/// 批量修改需要更新的列
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型参数(集合成员的类型)</typeparam>
|
||||
/// <param name="entitys"> 实体对象(必须指定主键特性 [SugarColumn(IsPrimaryKey=true)]),如果是联合主键,请使用Where条件 </param>
|
||||
/// <param name="updateColumns">更新指定列</param>
|
||||
/// <param name="wherecolumns">条件(为空则以主键更新,反之需要把wherecolumns中的列加到UpdateColumns中)</param>
|
||||
/// <param name="isLock"> 是否加锁 </param>
|
||||
/// <returns>操作影响的行数</returns>
|
||||
int UpdateColumns<T>(List<T> entitys, Expression<Func<T, object>> updateColumns,
|
||||
Expression<Func<T, object>> wherecolumns = null, bool isLock = true) where T : class, new();
|
||||
|
||||
/// <summary>
|
||||
/// 修改 通过RowVer及主键Code 更新
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型参数(集合成员的类型)</typeparam>
|
||||
/// <param name="entity"> 实体对象 </param>
|
||||
/// <param name="lstIgnoreColumns">不更新的列</param>
|
||||
/// <param name="isLock"> 是否加锁 </param>
|
||||
/// <returns>操作影响的行数</returns>
|
||||
int UpdateRowVer<T>(T entity, List<string> lstIgnoreColumns = null, bool isLock = true) where T : class, new();
|
||||
|
||||
/// <summary>
|
||||
/// 修改 通过RowVer及主键Code 更新
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型参数(集合成员的类型)</typeparam>
|
||||
/// <param name="update"> 实体对象 </param>
|
||||
/// <param name="where"> 更新条件 </param>
|
||||
/// <param name="isLock"> 是否加锁 </param>
|
||||
/// <returns>操作影响的行数</returns>
|
||||
int UpdateRowVer<T>(Expression<Func<T, object>> update, Dictionary<string, object> where, bool isLock = true) where T : class, new();
|
||||
#endregion
|
||||
|
||||
|
||||
#region 删除
|
||||
|
||||
/// <summary>
|
||||
/// 删除 通过主键数据
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型参数(集合成员的类型)</typeparam>
|
||||
/// <param name="primaryKeyValues">主键值</param>
|
||||
/// <param name="isLock"> 是否加锁 </param>
|
||||
/// <returns>操作影响的行数</returns>
|
||||
int DeleteByPrimary<T>(List<object> primaryKeyValues, bool isLock = true) where T : class, new();
|
||||
|
||||
/// <summary>
|
||||
/// 根据实体类删除
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型参数(集合成员的类型)</typeparam>
|
||||
/// <param name="entity"> 实体对象(必须指定主键特性 [SugarColumn(IsPrimaryKey=true)]),如果是联合主键,请使用Where条件 </param>
|
||||
/// <param name="isLock"> 是否加锁 </param>
|
||||
/// <returns>操作影响的行数</returns>
|
||||
int Delete<T>(T entity, bool isLock = true) where T : class, new();
|
||||
|
||||
/// <summary>
|
||||
/// 初始化表
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
void Delete<T>() where T : class, new();
|
||||
|
||||
/// <summary>
|
||||
/// 根据实体类集合删除
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型参数(集合成员的类型)</typeparam>
|
||||
/// <param name="entity"> 实体对象 (必须指定主键特性 [SugarColumn(IsPrimaryKey=true)]),如果是联合主键,请使用Where条件</param>
|
||||
/// <param name="isLock"> 是否加锁 </param>
|
||||
/// <returns>操作影响的行数</returns>
|
||||
int Delete<T>(List<T> entity, bool isLock = true) where T : class, new();
|
||||
|
||||
/// <summary>
|
||||
/// 删除
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型参数(集合成员的类型)</typeparam>
|
||||
/// <param name="where"> 条件 </param>
|
||||
/// <param name="isLock"> 是否加锁 </param>
|
||||
/// <returns>操作影响的行数</returns>
|
||||
int Delete<T>(Expression<Func<T, bool>> where, bool isLock = true) where T : class, new();
|
||||
|
||||
/// <summary>
|
||||
/// 通过多值(主键)删除数据集
|
||||
/// </summary>
|
||||
/// <typeparam name="T">泛型参数(集合成员的类型)</typeparam>
|
||||
/// <param name="inValues">数据集合</param>
|
||||
/// <returns></returns>
|
||||
int DeleteIn<T>(List<dynamic> inValues) where T : class, new();
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
<?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>{114AA012-29C9-418C-A2D6-3173C5341F51}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>JinYuan.DAL</RootNamespace>
|
||||
<AssemblyName>JinYuan.DAL</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<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' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="BouncyCastle.Crypto, Version=1.9.0.0, Culture=neutral, PublicKeyToken=0e99375e54769942, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Portable.BouncyCastle.1.9.0\lib\net40\BouncyCastle.Crypto.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Google.Protobuf, Version=3.23.4.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Google.Protobuf.3.23.4\lib\net45\Google.Protobuf.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="K4os.Compression.LZ4, Version=1.3.5.0, Culture=neutral, PublicKeyToken=2186fa9121ef231d, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\K4os.Compression.LZ4.1.3.5\lib\net462\K4os.Compression.LZ4.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="K4os.Compression.LZ4.Streams, Version=1.3.5.0, Culture=neutral, PublicKeyToken=2186fa9121ef231d, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\K4os.Compression.LZ4.Streams.1.3.5\lib\net462\K4os.Compression.LZ4.Streams.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="K4os.Hash.xxHash, Version=1.0.8.0, Culture=neutral, PublicKeyToken=32cd54395057cec3, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\K4os.Hash.xxHash.1.0.8\lib\net462\K4os.Hash.xxHash.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.7.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MySql.Data, Version=8.1.0.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MySql.Data.8.1.0\lib\net462\MySql.Data.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NLog, Version=6.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NLog.6.0.2\lib\net46\NLog.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NLog.Windows.Forms, Version=6.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NLog.Windows.Forms.6.0.0\lib\net35\NLog.Windows.Forms.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SqlSugar, Version=5.1.4.94, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\SqlSugar.5.1.4.94\lib\SqlSugar.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Configuration.ConfigurationManager, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Configuration.ConfigurationManager.7.0.0\lib\net462\System.Configuration.ConfigurationManager.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Data.OracleClient" />
|
||||
<Reference Include="System.Diagnostics.DiagnosticSource, Version=7.0.0.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Diagnostics.DiagnosticSource.7.0.2\lib\net462\System.Diagnostics.DiagnosticSource.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.IO.Pipelines, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.IO.Pipelines.7.0.0\lib\net462\System.IO.Pipelines.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Management" />
|
||||
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Net" />
|
||||
<Reference Include="System.Numerics" />
|
||||
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Security" />
|
||||
<Reference Include="System.Security.AccessControl, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Security.AccessControl.6.0.0\lib\net461\System.Security.AccessControl.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Security.Permissions, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Security.Permissions.7.0.0\lib\net462\System.Security.Permissions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Security.Principal.Windows, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Security.Principal.Windows.5.0.0\lib\net461\System.Security.Principal.Windows.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.ServiceProcess" />
|
||||
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Transactions" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<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" />
|
||||
<Reference Include="WindowsBase" />
|
||||
<Reference Include="ZstdSharp, Version=0.7.2.0, Culture=neutral, PublicKeyToken=8d151af33a4ad5cf, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\ZstdSharp.Port.0.7.2\lib\net461\ZstdSharp.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Enums\Enums.cs" />
|
||||
<Compile Include="ISugarHepler.cs" />
|
||||
<Compile Include="Models\OrderSortEntity.cs" />
|
||||
<Compile Include="Models\QueryCondition.cs" />
|
||||
<Compile Include="Models\QueryDescriptor.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="SQLSugarHelper.cs" />
|
||||
<Compile Include="SQLSugarService.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\JinYuan.Helper\JinYuan.Helper.csproj">
|
||||
<Project>{258D0AB7-2B4F-4D8F-A3CD-7A8CB4A85360}</Project>
|
||||
<Name>JinYuan.Helper</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -0,0 +1,19 @@
|
||||
using JinYuan.DAL.Enums;
|
||||
|
||||
namespace JinYuan.DAL.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 排序实体
|
||||
/// </summary>
|
||||
public class OrderSortEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// 排序字段
|
||||
/// </summary>
|
||||
public string Sort { get; set; }
|
||||
/// <summary>
|
||||
/// 排序类型
|
||||
/// </summary>
|
||||
public OrderSequence Order { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using JinYuan.DAL.Enums;
|
||||
|
||||
namespace JinYuan.DAL.Models
|
||||
{
|
||||
public class QueryCondition
|
||||
{
|
||||
/// <summary>
|
||||
/// 字段名称
|
||||
/// </summary>
|
||||
public string Key { get; set; }
|
||||
/// <summary>
|
||||
/// 查询操作
|
||||
/// </summary>
|
||||
public QueryOperator Operator { get; set; }
|
||||
/// <summary>
|
||||
/// 值
|
||||
/// </summary>
|
||||
public object Value { get; set; }
|
||||
/// <summary>
|
||||
/// 运算符
|
||||
/// </summary>
|
||||
public QueryCharacter Character { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace JinYuan.DAL.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 查询集合
|
||||
/// </summary>
|
||||
public class QueryDescriptor
|
||||
{
|
||||
/// <summary>
|
||||
/// 行数
|
||||
/// </summary>
|
||||
public int PageSize { get; set; }
|
||||
/// <summary>
|
||||
/// 页码
|
||||
/// </summary>
|
||||
public int PageIndex { get; set; }
|
||||
/// <summary>
|
||||
/// 排序
|
||||
/// </summary>
|
||||
public List<OrderSortEntity> OrderBys { get; set; }
|
||||
/// <summary>
|
||||
/// 条件
|
||||
/// </summary>
|
||||
public List<QueryCondition> Conditions { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// 有关程序集的一般信息由以下
|
||||
// 控制。更改这些特性值可修改
|
||||
// 与程序集关联的信息。
|
||||
[assembly: AssemblyTitle("JinYuan.DAL")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("JinYuan.DAL")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2023")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// 将 ComVisible 设置为 false 会使此程序集中的类型
|
||||
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
|
||||
//请将此类型的 ComVisible 特性设置为 true。
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
|
||||
[assembly: Guid("114aa012-29c9-418c-a2d6-3173c5341f51")]
|
||||
|
||||
// 程序集的版本信息由下列四个值组成:
|
||||
//
|
||||
// 主版本
|
||||
// 次版本
|
||||
// 生成号
|
||||
// 修订号
|
||||
//
|
||||
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
|
||||
//通过使用 "*",如下所示:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@@ -0,0 +1,83 @@
|
||||
|
||||
using JinYuan.Helper;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace JinYuan.DAL
|
||||
{
|
||||
public class SQLSugarHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 数据库连接字符串
|
||||
/// </summary>
|
||||
public static string connString = string.Empty;
|
||||
private static LoggerHelp _logger = new LoggerHelp();
|
||||
/// <summary>
|
||||
/// 数据库类型
|
||||
/// </summary>
|
||||
public static SqlSugar.DbType dbType = SqlSugar.DbType.SqlServer;
|
||||
|
||||
public static SqlSugarScope SqlSugarClient
|
||||
{
|
||||
get
|
||||
{
|
||||
//如果配置了 SlaveConnectionConfigs那就是主从模式,所有的写入删除更新都走主库,查询走从库,
|
||||
var db = new SqlSugarScope(new ConnectionConfig()
|
||||
{
|
||||
ConnectionString = connString,
|
||||
DbType = dbType, //数据库类型
|
||||
IsAutoCloseConnection = true, //默认false,自动释放和关闭数据库连接,设置为true无需使用using或者close操作
|
||||
InitKeyType = InitKeyType.Attribute //默认SystemTable,该属性是不是主键,是不是标识列等等信息
|
||||
|
||||
});
|
||||
db.Ado.CommandTimeOut = 3000;//设置执行语法超时时间
|
||||
db.Aop.OnLogExecuted = (sql, pars) => //SQL执行完事件
|
||||
{
|
||||
LoggerHelp.WriteLog($"执行时间:{db.Ado.SqlExecutionTime.TotalMilliseconds}毫秒 \r\nSQL如下:{sql} \r\n参数:{GetParams(pars)} ", "SQL执行");
|
||||
};
|
||||
db.Aop.OnLogExecuting = (sql, pars) => //SQL执行前事件
|
||||
{
|
||||
if (db.TempItems == null) db.TempItems = new Dictionary<string, object>();
|
||||
};
|
||||
db.Aop.OnError = (exp) =>//执行SQL 错误事件
|
||||
{
|
||||
LoggerHelp.WriteLog($"SQL错误:{exp.Message}\r\nSQL如下:{exp.Sql}", "SQL执行");
|
||||
throw new Exception(exp.Message);
|
||||
};
|
||||
db.Aop.OnDiffLogEvent = (it) => //可以方便拿到 数据库操作前和操作后的数据变化。
|
||||
{
|
||||
var editBeforeData = it.BeforeData; //变化前数据
|
||||
var editAfterData = it.AfterData; //变化后数据
|
||||
var sql = it.Sql; //SQL
|
||||
var parameter = it.Parameters; //参数
|
||||
var data = it.BusinessData; //业务数据
|
||||
var time = it.Time ?? new TimeSpan(); //时间
|
||||
var diffType = it.DiffType; //枚举值 insert 、update 和 delete 用来作业务区分
|
||||
|
||||
//你可以在这里面写日志方法
|
||||
var log = $"时间:{time.TotalMilliseconds}\r\n";
|
||||
log += $"类型:{diffType.ToString()}\r\n";
|
||||
log += $"SQL:{sql}\r\n";
|
||||
log += $"参数:{GetParams(parameter)}\r\n";
|
||||
log += $"业务数据:{JsonHelper.EntityToJson(data)}\r\n";
|
||||
log += $"变化前数据:{JsonHelper.EntityToJson(editBeforeData)}\r\n";
|
||||
log += $"变化后数据:{JsonHelper.EntityToJson(editAfterData)}\r\n";
|
||||
//SqlLogHelper.WriteLog(log, "数据变化前后");
|
||||
};
|
||||
return db;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取参数信息
|
||||
/// </summary>
|
||||
/// <param name="pars"></param>
|
||||
/// <returns></returns>
|
||||
private static string GetParams(SugarParameter[] pars)
|
||||
{
|
||||
return pars.Aggregate("", (current, p) => current + $"{p.ParameterName}:{p.Value}, ");
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,63 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="MySql.Data" publicKeyToken="c5687fc88969c44d" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-8.1.0.0" newVersion="8.1.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.1.2" newVersion="4.0.1.2" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.IO.Pipelines" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Google.Protobuf" publicKeyToken="a7d26565bac4d604" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-3.23.4.0" newVersion="3.23.4.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="ZstdSharp" publicKeyToken="8d151af33a4ad5cf" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-0.7.2.0" newVersion="0.7.2.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.Bcl.AsyncInterfaces" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.2.0.1" newVersion="4.2.0.1" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Text.Encoding.CodePages" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Configuration.ConfigurationManager" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Security.Cryptography.Xml" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-6.0.0.1" newVersion="6.0.0.1" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.1.4.0" newVersion="4.1.4.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" /></startup></configuration>
|
||||
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Google.Protobuf" version="3.23.4" targetFramework="net472" />
|
||||
<package id="K4os.Compression.LZ4" version="1.3.5" targetFramework="net462" />
|
||||
<package id="K4os.Compression.LZ4.Streams" version="1.3.5" targetFramework="net462" />
|
||||
<package id="K4os.Hash.xxHash" version="1.0.8" targetFramework="net462" />
|
||||
<package id="Microsoft.Bcl.AsyncInterfaces" version="7.0.0" targetFramework="net472" />
|
||||
<package id="MySql.Data" version="8.1.0" targetFramework="net472" />
|
||||
<package id="NLog" version="6.0.2" targetFramework="net472" />
|
||||
<package id="NLog.Windows.Forms" version="6.0.0" targetFramework="net472" />
|
||||
<package id="Portable.BouncyCastle" version="1.9.0" targetFramework="net462" />
|
||||
<package id="SqlSugar" version="5.1.4.94" targetFramework="net472" />
|
||||
<package id="System.Buffers" version="4.5.1" targetFramework="net462" />
|
||||
<package id="System.Configuration.ConfigurationManager" version="7.0.0" targetFramework="net472" />
|
||||
<package id="System.Diagnostics.DiagnosticSource" version="7.0.2" targetFramework="net462" />
|
||||
<package id="System.IO.Pipelines" version="7.0.0" targetFramework="net472" />
|
||||
<package id="System.Memory" version="4.5.5" targetFramework="net462" />
|
||||
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net462" />
|
||||
<package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net462" />
|
||||
<package id="System.Security.AccessControl" version="6.0.0" targetFramework="net472" />
|
||||
<package id="System.Security.Permissions" version="7.0.0" targetFramework="net472" />
|
||||
<package id="System.Security.Principal.Windows" version="5.0.0" targetFramework="net472" />
|
||||
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net462" />
|
||||
<package id="ZstdSharp.Port" version="0.7.2" targetFramework="net472" />
|
||||
</packages>
|
||||
@@ -0,0 +1,122 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace JinYuan.Helper
|
||||
{
|
||||
public class ArrayHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 判断两个数组的元素是否相等
|
||||
/// </summary>
|
||||
/// <param name="arr1"></param>
|
||||
/// <param name="arr2"></param>
|
||||
/// <returns></returns>
|
||||
public static bool Equal<T>(T[] arr1, T[] arr2)
|
||||
{
|
||||
bool res = false;
|
||||
if (arr1 == null || arr2 == null)
|
||||
{
|
||||
return res;
|
||||
}
|
||||
if (arr1.Length == arr2.Length)
|
||||
{
|
||||
res = true;
|
||||
for (int index = 0; index < arr1.Length; ++index)
|
||||
{
|
||||
if (!arr1[index].Equals(arr2[index]))
|
||||
{
|
||||
res = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取数组的子数组
|
||||
/// </summary>
|
||||
/// <typeparam name="T">类型</typeparam>
|
||||
/// <param name="arr">数组</param>
|
||||
/// <param name="startIndex">起始索引</param>
|
||||
/// <param name="length">长度</param>
|
||||
/// <returns></returns>
|
||||
public static T[] GetSubArray<T>(T[] arr, int startIndex, int length)
|
||||
{
|
||||
T[] res = new T[length];
|
||||
for (int index = 0; index < length; ++index)
|
||||
{
|
||||
res[index] = arr[startIndex + index];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 数组合并
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="t1"></param>
|
||||
/// <param name="t2"></param>
|
||||
/// <returns></returns>
|
||||
public static byte[] Combine(IEnumerable<byte[]> tList)
|
||||
{
|
||||
int allLength = 0;
|
||||
foreach (byte[] t in tList)
|
||||
{
|
||||
allLength += t.Length;
|
||||
}
|
||||
byte[] res = new byte[allLength];
|
||||
int lenIndex = 0;
|
||||
foreach (byte[] t in tList)
|
||||
{
|
||||
Array.Copy(t, 0, res, lenIndex, t.Length);
|
||||
lenIndex += t.Length;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 数组格式化输出字符串
|
||||
/// </summary>
|
||||
/// <param name="arr">待处理数据</param>
|
||||
/// <returns></returns>
|
||||
public static string ArrayFormatOutput<T>(T[] arr)
|
||||
{
|
||||
StringBuilder res = new StringBuilder();
|
||||
for (int index = 0; index < arr.Count() - 1; ++index)
|
||||
{
|
||||
res.Append(string.Format("{0}-", arr[index].ToString()));
|
||||
}
|
||||
if (arr.Count() - 1 > 0)
|
||||
{
|
||||
res.Append(arr[arr.Count() - 1]);
|
||||
}
|
||||
return res.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 数组格式化输出字符串
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="arr">待处理数据</param>
|
||||
/// <param name="offset">buffer 参数中开始发送数据的位置,该位置从零开始计数。</param>
|
||||
/// <param name="size">要发送的字节数。</param>
|
||||
/// <returns></returns>
|
||||
public static string ArrayFormatOutput<T>(T[] arr, int offset, int size)
|
||||
{
|
||||
StringBuilder res = new StringBuilder();
|
||||
for (int index = offset; index < size; ++index)
|
||||
{
|
||||
res.Append(string.Format("{0}-", arr[index].ToString()));
|
||||
}
|
||||
if (size - 1 > 0)
|
||||
{
|
||||
res.Append(arr[size]);
|
||||
}
|
||||
return res.ToString();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,345 @@
|
||||
using CsvHelper;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace JinYuan.Helper
|
||||
{
|
||||
public class CSVHelper<T>
|
||||
{
|
||||
/// <summary>
|
||||
/// 读取CSV文件
|
||||
/// </summary>
|
||||
/// <param name="fileName">csv文件名</param>
|
||||
/// <returns></returns>
|
||||
public static List<T> ReadCSV(string fileName, string strSeparator = "\t")
|
||||
{
|
||||
if (!File.Exists(fileName)) return null;
|
||||
//Nuget获取CsvHelper
|
||||
using (var reader = new StreamReader(fileName, Encoding.Default))
|
||||
{
|
||||
var cfg = new CsvHelper.Configuration.CsvConfiguration(CultureInfo.InvariantCulture)
|
||||
{
|
||||
|
||||
Mode = CsvMode.Escape,
|
||||
Escape = '\\',
|
||||
Delimiter = strSeparator//设置分隔符号
|
||||
};
|
||||
using (var csv = new CsvReader(reader, cfg))
|
||||
{
|
||||
|
||||
var list = csv.GetRecords<T>().ToList();
|
||||
return list;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 写入CSV文件
|
||||
/// </summary>
|
||||
/// <param name="fileName">csv文件名</param>
|
||||
/// <returns></returns>
|
||||
public static bool WriterCSV(string fileName, List<T> records)
|
||||
{
|
||||
try
|
||||
{
|
||||
FileStream Log = null;
|
||||
if (!Directory.Exists(fileName))
|
||||
Directory.CreateDirectory(fileName);
|
||||
string file = (fileName + DateTime.Now.ToString("yyyyMMdd")) + ".csv";
|
||||
var cfg = new CsvHelper.Configuration.CsvConfiguration(CultureInfo.InvariantCulture);
|
||||
if (!File.Exists(file))
|
||||
{
|
||||
Log = new FileStream(file, FileMode.Create);
|
||||
}
|
||||
else
|
||||
{
|
||||
cfg.HasHeaderRecord = false;//是否将第一行作为标题
|
||||
}
|
||||
if (Log != null)
|
||||
{
|
||||
Log.Close();
|
||||
}
|
||||
//Nuget获取CsvHelper
|
||||
using (var writer = new StreamWriter(file, true, Encoding.Default))
|
||||
{
|
||||
using (var csv = new CsvWriter(writer, cfg))
|
||||
{
|
||||
csv.WriteRecords(records);
|
||||
writer.Flush();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 写入指定列表CSV文件
|
||||
/// </summary>
|
||||
/// <param name="directory"></param>
|
||||
/// <param name="fileName"></param>
|
||||
/// <param name="title"></param>
|
||||
/// <param name="content"></param>
|
||||
/// <returns></returns>
|
||||
public static bool WriterCSV(string directory, string fileName, string title, string content)
|
||||
{
|
||||
FileStream fs = null;
|
||||
StreamWriter sw = null;
|
||||
|
||||
try
|
||||
{
|
||||
if (!Directory.Exists(directory))
|
||||
{
|
||||
Directory.CreateDirectory(directory);
|
||||
}
|
||||
|
||||
string fullFileName = $@"{directory}\{fileName}";
|
||||
if (!File.Exists(fullFileName))
|
||||
{
|
||||
fs = new FileStream(fullFileName, FileMode.Create, FileAccess.Write);
|
||||
sw = new StreamWriter(fs, Encoding.UTF8);
|
||||
sw.WriteLine(title);
|
||||
}
|
||||
else
|
||||
{
|
||||
fs = new FileStream(fullFileName, FileMode.Append, FileAccess.Write);
|
||||
sw = new StreamWriter(fs, Encoding.UTF8);
|
||||
}
|
||||
|
||||
sw.WriteLine(content);
|
||||
|
||||
sw.Close();
|
||||
fs.Close();
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
sw?.Close();
|
||||
fs?.Close();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取当天的日期的文件
|
||||
/// </summary>
|
||||
/// <param name="CurrPath"></param>
|
||||
/// <returns></returns>
|
||||
public static List<string> FindTodayFile(string CurrPath)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!Directory.Exists(CurrPath))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
DirectoryInfo di = new DirectoryInfo(CurrPath);
|
||||
FileInfo[] ffis = di.GetFiles();
|
||||
string today = DateTime.Now.Year.ToString().Substring(0, 4) + DateTime.Now.Month.ToString("0#") + DateTime.Now.Day.ToString("0#");
|
||||
List<string> listFilePath = new List<string>();
|
||||
|
||||
for (int i = 0; i < ffis.Length; i++)
|
||||
{
|
||||
FileInfo tmp = ffis[i];
|
||||
if (tmp.Name.Substring(0, 8) == today)
|
||||
{
|
||||
listFilePath.Add(tmp.FullName);
|
||||
}
|
||||
}
|
||||
return (listFilePath.Count > 0) ? listFilePath : null;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
throw ex;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="CurrPath"></param>
|
||||
/// <returns></returns>
|
||||
public static List<string> FindHostFile(string CurrPath, DateTime date)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!Directory.Exists(CurrPath))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
DirectoryInfo di = new DirectoryInfo(CurrPath);
|
||||
FileInfo[] ffis = di.GetFiles();
|
||||
string today = date.ToString().Substring(0, 4) + date.Month.ToString("0#") + date.Day.ToString("0#");
|
||||
//var result1 = Regex.Replace(date, @"[^0-9]+", "");
|
||||
//string today = result1.Substring(0,8);
|
||||
List<string> listFilePath = new List<string>();
|
||||
|
||||
for (int i = 0; i < ffis.Length; i++)
|
||||
{
|
||||
FileInfo tmp = ffis[i];
|
||||
if (tmp.Name.Substring(0, 8) == today)
|
||||
{
|
||||
listFilePath.Add(tmp.FullName);
|
||||
}
|
||||
}
|
||||
return (listFilePath.Count > 0) ? listFilePath : null;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
throw ex;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 导出到CSV文件
|
||||
/// </summary>
|
||||
/// <param name="table">报表DataTable</param>
|
||||
/// <param name="filePath">导出路径</param>
|
||||
/// <param name="msg">输出信息</param>
|
||||
/// <param name="columnName">自定义的列名称,以','英文逗号分隔</param>
|
||||
/// <param name="tableHeader">表名,一般为空</param>
|
||||
/// <returns>是否导出成功</returns>
|
||||
public static bool ExportDataTableToCSV(DataTable table, string filePath, out string msg, string columnName = null, string tableHeader = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
string dirPath = Path.GetDirectoryName(filePath);
|
||||
if (!Directory.Exists(dirPath))
|
||||
{
|
||||
Directory.CreateDirectory(dirPath);//文件的父目录不存在就创建新目录
|
||||
}
|
||||
bool IsAppend = false; //false为创建 true为追加
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
IsAppend = true;//如果文件存在就不写入表头
|
||||
}
|
||||
using (FileStream _stream = new FileStream(filePath, FileMode.Create | FileMode.Append, FileAccess.Write))
|
||||
{
|
||||
StreamWriter _writer = new StreamWriter(_stream, Encoding.UTF8);
|
||||
if (tableHeader != null)
|
||||
{
|
||||
_writer.WriteLine(tableHeader);
|
||||
}
|
||||
|
||||
if (columnName != null && !IsAppend)
|
||||
{
|
||||
_writer.WriteLine(columnName);
|
||||
}
|
||||
else if (columnName == null && !IsAppend)
|
||||
{
|
||||
List<string> columnNameList = new List<string>();
|
||||
foreach (DataColumn dc in table.Columns)
|
||||
{
|
||||
columnNameList.Add(dc.ColumnName);
|
||||
}
|
||||
_writer.WriteLine(string.Join(",", columnNameList));
|
||||
}
|
||||
|
||||
for (int i = 0; i < table.Rows.Count; i++)
|
||||
{
|
||||
for (int j = 0; j < table.Columns.Count; j++)
|
||||
{
|
||||
_writer.Write(table.Rows[i][j].ToString());
|
||||
_writer.Write(",");
|
||||
}
|
||||
_writer.WriteLine();
|
||||
}
|
||||
_writer.Close();
|
||||
msg = "导出CSV文件成功";
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
msg = string.Format("导出CSV文件失败,原因:{0}", ex.Message);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 导出报表为Csv
|
||||
/// </summary>
|
||||
/// <param name="dt">DataTable</param>
|
||||
/// <param name="strFilePath">物理路径</param>
|
||||
/// <param name="tableheader">表头</param>
|
||||
/// <param name="columname">字段标题,逗号分隔</param>
|
||||
public static bool dt2csv(DataTable dt, string strFilePath, string tableheader, string columname)
|
||||
{
|
||||
try
|
||||
{
|
||||
string strBufferLine = "";
|
||||
StreamWriter strmWriterObj = new StreamWriter(strFilePath, false, System.Text.Encoding.UTF8);
|
||||
strmWriterObj.WriteLine(tableheader);
|
||||
strmWriterObj.WriteLine(columname);
|
||||
for (int i = 0; i < dt.Rows.Count; i++)
|
||||
{
|
||||
strBufferLine = "";
|
||||
for (int j = 0; j < dt.Columns.Count; j++)
|
||||
{
|
||||
if (j > 0)
|
||||
strBufferLine += ",";
|
||||
strBufferLine += dt.Rows[i][j].ToString();
|
||||
}
|
||||
strmWriterObj.WriteLine(strBufferLine);
|
||||
}
|
||||
strmWriterObj.Close();
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将Csv读入DataTable
|
||||
/// </summary>
|
||||
/// <param name="filePath">csv文件路径</param>
|
||||
/// <param name="n">表示第n行是字段title,第n+1行是记录开始</param>
|
||||
public static DataTable csv2dt(string filePath, int n, DataTable dt)
|
||||
{
|
||||
StreamReader reader = new StreamReader(filePath, System.Text.Encoding.UTF8, false);
|
||||
int i = 0, m = 0;
|
||||
reader.Peek();
|
||||
while (reader.Peek() > 0)
|
||||
{
|
||||
m = m + 1;
|
||||
string str = reader.ReadLine();
|
||||
if (m >= n + 1)
|
||||
{
|
||||
string[] split = str.Split(',');
|
||||
|
||||
System.Data.DataRow dr = dt.NewRow();
|
||||
for (i = 0; i < split.Length; i++)
|
||||
{
|
||||
dr[i] = split[i];
|
||||
}
|
||||
dt.Rows.Add(dr);
|
||||
}
|
||||
}
|
||||
return dt;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,213 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Text;
|
||||
using System.Windows.Forms.DataVisualization.Charting;
|
||||
|
||||
namespace JinYuan.Helper
|
||||
{
|
||||
public class ChartHelper
|
||||
{
|
||||
static PrivateFontCollection font = new PrivateFontCollection();
|
||||
/// <summary>
|
||||
/// Name:添加序列
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="chart">图表对象</param>
|
||||
/// <param name="seriesName">序列名称</param>
|
||||
/// <param name="chartType">图表类型</param>
|
||||
/// <param name="seriesColor">颜色</param>
|
||||
/// <param name="markColor">标记点颜色</param>
|
||||
/// <param name="showValue">是否显示数值</param>
|
||||
public static void AddSeries(Chart chart, string seriesName, SeriesChartType chartType, ChartValueType chartValueType, MarkerStyle markerStyle, int markerSize, Color seriesColor, Color markColor, string LabelStyle, bool isShowBFH, bool showValue = false)
|
||||
{
|
||||
// 加载字体文件 Zen圓体-Regular
|
||||
font.AddFontFile(Environment.CurrentDirectory + "\\Assts\\Fonts\\Zen圓体-Regular.ttf");
|
||||
//定义成新的字体对象
|
||||
FontFamily myFontFamily = new FontFamily(font.Families[0].Name, font);
|
||||
Font myFont = new Font(myFontFamily, 9.0f, FontStyle.Bold);
|
||||
|
||||
chart.Series.Add(seriesName);
|
||||
chart.Series[seriesName].ChartType = chartType;
|
||||
chart.Series[seriesName].Color = seriesColor;
|
||||
if (showValue)
|
||||
{
|
||||
chart.Series[seriesName].IsValueShownAsLabel = showValue;
|
||||
chart.Series[seriesName].XValueType = chartValueType;
|
||||
chart.Series[seriesName].Label = LabelStyle;
|
||||
chart.Series[seriesName].Font = myFont;
|
||||
chart.Series[seriesName].MarkerStyle = markerStyle;
|
||||
chart.Series[seriesName].MarkerColor = markColor;
|
||||
chart.Series[seriesName].MarkerStyle = MarkerStyle.Circle; //线条上的数据点标志类型
|
||||
chart.Series[seriesName].MarkerSize = markerSize; //标志大小
|
||||
chart.Series[seriesName].LabelToolTip = "#VALX: #VALY";
|
||||
chart.Series[seriesName].LabelForeColor = markColor;
|
||||
chart.Series[seriesName].LabelAngle = -75;
|
||||
chart.Series[seriesName].BorderWidth = 3;
|
||||
chart.Series[seriesName].LabelBorderWidth = 5;
|
||||
|
||||
if (isShowBFH)
|
||||
{
|
||||
chart.Series[seriesName].YAxisType = AxisType.Secondary;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Name:设置标题
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="chart">图表对象</param>
|
||||
/// <param name="chartName">图表名称</param>
|
||||
public static void SetTitle(Chart chart, string chartName, Font font, Docking docking, Color foreColor)
|
||||
{
|
||||
chart.Titles.Add(chartName);
|
||||
chart.Titles[0].Font = font;
|
||||
chart.Titles[0].Docking = docking;
|
||||
chart.Titles[0].ForeColor = foreColor;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Name:设置样式
|
||||
/// 2019-04-23 14:04
|
||||
/// </summary>
|
||||
/// <param name="chart">图表对象</param>
|
||||
/// <param name="backColor">背景颜色</param>
|
||||
/// <param name="foreColor">字体颜色</param>
|
||||
public static void SetStyle(Chart chart, Color backColor, Color foreColor)
|
||||
{
|
||||
chart.BackColor = backColor;
|
||||
chart.ChartAreas[0].BackColor = backColor;
|
||||
chart.ForeColor = Color.Red;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Name:设置图例
|
||||
/// Author:
|
||||
/// </summary>
|
||||
/// <param name="chart">图表对象</param>
|
||||
/// <param name="docking">停靠位置</param>
|
||||
/// <param name="align">对齐方式</param>
|
||||
/// <param name="backColor">背景颜色</param>
|
||||
/// <param name="foreColor">字体颜色</param>
|
||||
public static void SetLegend(Chart chart, Docking docking, StringAlignment align, Color backColor, Color foreColor)
|
||||
{
|
||||
// 加载字体文件
|
||||
font.AddFontFile(Environment.CurrentDirectory + "\\Assts\\Fonts\\Zen圓体-Regular.ttf");
|
||||
//定义成新的字体对象
|
||||
FontFamily myFontFamily = new FontFamily(font.Families[0].Name, font);
|
||||
Font myFont = new Font(myFontFamily, 9.0f, FontStyle.Regular);
|
||||
|
||||
chart.Legends[0].Docking = docking;
|
||||
chart.Legends[0].Alignment = align;
|
||||
chart.Legends[0].BackColor = backColor;
|
||||
chart.Legends[0].ForeColor = foreColor;
|
||||
chart.Legends[0].Font = myFont;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Name:设置XY轴
|
||||
/// Author:
|
||||
/// </summary>
|
||||
/// <param name="chart">图表对象</param>
|
||||
/// <param name="xTitle">X轴标题</param>
|
||||
/// <param name="yTitle">Y轴标题</param>
|
||||
/// <param name="align">坐标轴标题对齐方式</param>
|
||||
/// <param name="foreColor">坐标轴字体颜色</param>
|
||||
/// <param name="lineColor">坐标轴颜色</param>
|
||||
/// <param name="arrowStyle">坐标轴箭头样式</param>
|
||||
/// <param name="xInterval">X轴的间距</param>
|
||||
/// <param name="yInterval">Y轴的间距</param>
|
||||
public static void SetXY(Chart chart, string xTitle, string yTitle, int Angle, StringAlignment align, Color foreColor, Color lineColor, AxisArrowStyle arrowStyle, double xInterval, bool isShowBFH, bool isShowTime = false)
|
||||
{
|
||||
// 加载字体文件
|
||||
font.AddFontFile(Environment.CurrentDirectory + "\\Assts\\Fonts\\Zen圓体-Regular.ttf");
|
||||
//定义成新的字体对象
|
||||
FontFamily myFontFamily = new FontFamily(font.Families[0].Name, font);
|
||||
Font myFont = new Font(myFontFamily, 15f, FontStyle.Regular);
|
||||
|
||||
|
||||
chart.ChartAreas[0].AxisX.TitleForeColor = foreColor;
|
||||
chart.ChartAreas[0].AxisX.LabelStyle = new LabelStyle() { ForeColor = foreColor };
|
||||
chart.ChartAreas[0].AxisX.LabelStyle.Angle = Angle;
|
||||
chart.ChartAreas[0].AxisX.LineColor = lineColor;
|
||||
chart.ChartAreas[0].AxisX.LabelStyle.ForeColor = lineColor;
|
||||
chart.ChartAreas[0].AxisX.ArrowStyle = arrowStyle;
|
||||
chart.ChartAreas[0].AxisX.Interval = xInterval;
|
||||
chart.ChartAreas[0].AxisX.Title = xTitle;
|
||||
chart.ChartAreas[0].AxisX.TitleAlignment = align;
|
||||
|
||||
chart.ChartAreas[0].AxisY.TitleForeColor = foreColor;
|
||||
chart.ChartAreas[0].AxisY.LabelStyle = new LabelStyle() { ForeColor = foreColor };
|
||||
chart.ChartAreas[0].AxisY.LineColor = lineColor;
|
||||
chart.ChartAreas[0].AxisY.LabelStyle.ForeColor = lineColor;
|
||||
chart.ChartAreas[0].AxisY.ArrowStyle = arrowStyle;
|
||||
chart.ChartAreas[0].AxisY.Title = yTitle;
|
||||
chart.ChartAreas[0].AxisY.TitleAlignment = align;
|
||||
|
||||
if (isShowBFH)
|
||||
{
|
||||
chart.ChartAreas[0].AxisY2.Minimum = 0;
|
||||
chart.ChartAreas[0].AxisY2.Maximum = 1.2;
|
||||
chart.ChartAreas[0].AxisY2.Interval = 0.2;
|
||||
chart.ChartAreas[0].AxisY2.LabelStyle = new LabelStyle() { ForeColor = foreColor };
|
||||
chart.ChartAreas[0].AxisY2.LineColor = lineColor;
|
||||
chart.ChartAreas[0].AxisY2.LabelStyle.ForeColor = lineColor;
|
||||
chart.ChartAreas[0].AxisY2.LabelStyle.Format = "0.00%";
|
||||
}
|
||||
|
||||
////设置图表显示样式
|
||||
if (isShowTime)
|
||||
{
|
||||
chart.ChartAreas[0].AxisX.LabelStyle.Format = "HH:mm:ss"; //毫秒格式: hh:mm:ss.fff ,后面几个f则保留几位毫秒小数,此时要注意轴的最大值和最小值不要差太大
|
||||
chart.ChartAreas[0].AxisX.LabelStyle.IntervalType = DateTimeIntervalType.Seconds;
|
||||
chart.ChartAreas[0].AxisX.Interval = xInterval; //坐标值间隔1S
|
||||
chart.ChartAreas[0].AxisX.LabelStyle.IsEndLabelVisible = false; //防止X轴坐标跳跃
|
||||
chart.ChartAreas[0].AxisX.MajorGrid.IntervalType = DateTimeIntervalType.Seconds;
|
||||
|
||||
//chart.ChartAreas[0].AxisY.L = 1; //网格间隔
|
||||
|
||||
chart.ChartAreas[0].AxisX.Minimum = DateTime.Now.ToOADate(); //当前时间
|
||||
chart.ChartAreas[0].AxisX.Maximum = DateTime.Now.ToOADate();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Name:设置网格
|
||||
/// Author:
|
||||
/// </summary>
|
||||
/// <param name="chart">图表对象</param>
|
||||
/// <param name="lineColor">网格线颜色</param>
|
||||
/// <param name="xInterval">X轴网格的间距</param>
|
||||
/// <param name="yInterval">Y轴网格的间距</param>
|
||||
public static void SetMajorGrid(Chart chart, Color lineColor, double xInterval, double yInterval, bool isMajorGridX = false, bool isMajorGridY = false)
|
||||
{
|
||||
chart.ChartAreas[0].AxisX.MajorGrid.Enabled = isMajorGridX;
|
||||
chart.ChartAreas[0].AxisY.MajorGrid.Enabled = isMajorGridY;
|
||||
chart.ChartAreas[0].AxisY2.MajorGrid.Enabled = isMajorGridY;
|
||||
if (isMajorGridX)
|
||||
{
|
||||
chart.ChartAreas[0].AxisX.MajorGrid.LineColor = lineColor;
|
||||
|
||||
chart.ChartAreas[0].AxisX.MajorGrid.Interval = xInterval;
|
||||
|
||||
chart.ChartAreas[0].AxisX.MajorGrid.LineDashStyle = ChartDashStyle.Dash;
|
||||
|
||||
}
|
||||
|
||||
if (isMajorGridY)
|
||||
{
|
||||
chart.ChartAreas[0].AxisY.MajorGrid.LineColor = lineColor;
|
||||
chart.ChartAreas[0].AxisY.MajorGrid.Interval = yInterval;
|
||||
chart.ChartAreas[0].AxisY.MajorGrid.LineDashStyle = ChartDashStyle.Dash;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using System.Linq;
|
||||
|
||||
namespace JinYuan.Helper
|
||||
{
|
||||
public static class ConvertHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 字节数组高低位转换
|
||||
/// </summary>
|
||||
/// <param name="Arrbyte"></param>
|
||||
/// <returns></returns>
|
||||
public static byte[] ByteReverse(this byte[] Arrbyte)
|
||||
{
|
||||
byte[] ArrByte = Arrbyte.Select((x, i) => new { x, i }).GroupBy(x => x.i / 2).SelectMany(x => new byte[] { x.Last().x, x.First().x }).ToArray();
|
||||
return ArrByte;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Reflection;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace JinYuan.Helper
|
||||
{
|
||||
public static class DataGridViewHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 给DataGridView添加行号
|
||||
/// </summary>
|
||||
/// <param name="dgv">dgv控件</param>
|
||||
/// <param name="e">dgv参数</param>
|
||||
public static void DgvRowPostPaint(DataGridView dgv, DataGridViewRowPostPaintEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
//添加行号
|
||||
SolidBrush solidBrush = new SolidBrush(dgv.RowHeadersDefaultCellStyle.ForeColor);
|
||||
string lineNo = (e.RowIndex + 1).ToString();
|
||||
e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
|
||||
|
||||
StringFormat sf = new StringFormat();
|
||||
sf.LineAlignment = StringAlignment.Center;
|
||||
sf.Alignment = StringAlignment.Center;
|
||||
e.Graphics.DrawString(lineNo, e.InheritedRowStyle.Font, solidBrush, new Rectangle(e.RowBounds.Location.X, e.RowBounds.Location.Y, dgv.RowHeadersWidth, dgv.RowTemplate.Height), sf);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show("添加行号时发生错误,错误信息:" + ex.Message, "操作失败");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 给DataGridView指定列改变前景色
|
||||
/// </summary>
|
||||
/// <param name="dgv"></param>
|
||||
/// <param name="e"></param>
|
||||
public static void DgvRowPrePaint(DataGridView dgv, string Column, object sender, DataGridViewRowPrePaintEventArgs e)
|
||||
{
|
||||
|
||||
if (e.RowIndex >= dgv.Rows.Count - 1)
|
||||
return;
|
||||
DataGridViewRow dr = (sender as DataGridView).Rows[e.RowIndex];
|
||||
|
||||
try
|
||||
{
|
||||
if (dr.Cells[Column].Value != null)
|
||||
{
|
||||
if (dr.Cells[Column].Value.Equals("OK"))
|
||||
{
|
||||
// 设置单元格的背景色
|
||||
//dr.Cells[Column].Style.BackColor = Color.LightGreen;
|
||||
|
||||
// 设置单元格的前景色
|
||||
dr.Cells[Column].Style.ForeColor = Color.LightGreen;
|
||||
}
|
||||
else
|
||||
{
|
||||
//dr.Cells[Column].Style.BackColor = Color.Red;
|
||||
dr.Cells[Column].Style.ForeColor = Color.Red;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show("更改状态时发生错误,错误信息:" + ex.Message, "操作失败");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 给DataGridView绘制边框
|
||||
/// </summary>
|
||||
/// <param name="dgv">dgv控件</param>
|
||||
/// <param name="e">dgv参数</param>
|
||||
public static void DgvRowPaint(DataGridView dgv, PaintEventArgs e, Color borderColor)
|
||||
{
|
||||
e.Graphics.DrawRectangle(new Pen(borderColor), new Rectangle(0, 0, dgv.Width - 1, dgv.Height - 1));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 奇偶换色
|
||||
/// </summary>
|
||||
public static void DgvStyle(DataGridView dgv, Color defaultBackColor, Color alternatingBackColor, Color gridColor)
|
||||
{
|
||||
//奇数行的背景色
|
||||
dgv.AlternatingRowsDefaultCellStyle.BackColor = alternatingBackColor;
|
||||
dgv.AlternatingRowsDefaultCellStyle.SelectionBackColor = alternatingBackColor;
|
||||
|
||||
//默认的行样式
|
||||
dgv.RowsDefaultCellStyle.BackColor = defaultBackColor;
|
||||
dgv.RowsDefaultCellStyle.SelectionBackColor = defaultBackColor;
|
||||
|
||||
|
||||
dgv.RowHeadersDefaultCellStyle.BackColor = defaultBackColor;
|
||||
dgv.RowHeadersDefaultCellStyle.SelectionBackColor = defaultBackColor;
|
||||
|
||||
//数据网格颜色
|
||||
dgv.GridColor = gridColor;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 双缓冲,解决闪烁问题
|
||||
/// </summary>
|
||||
/// <param name="dgv"></param>
|
||||
/// <param name="flag"></param>
|
||||
public static void DoubleBufferedDataGirdView(this DataGridView dgv, bool flag)
|
||||
{
|
||||
Type dgvType = dgv.GetType();
|
||||
PropertyInfo pi = dgvType.GetProperty("DoubleBuffered", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
pi.SetValue(dgv, flag, null);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 双缓冲,解决闪烁问题
|
||||
/// </summary>
|
||||
/// <param name="lv"></param>
|
||||
/// <param name="flag"></param>
|
||||
public static void DoubleBufferedListView(this ListView lv, bool flag)
|
||||
{
|
||||
Type lvType = lv.GetType();
|
||||
PropertyInfo pi = lvType.GetProperty("DoubleBuffered", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
pi.SetValue(lv, flag, null);
|
||||
}
|
||||
|
||||
public static void DoubleBufferedListBox(this ListBox lb, bool flag)
|
||||
{
|
||||
Type lvType = lb.GetType();
|
||||
PropertyInfo pi = lvType.GetProperty("DoubleBuffered", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
pi.SetValue(lb, flag, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Reflection;
|
||||
|
||||
namespace JinYuan.Helper
|
||||
{
|
||||
/// <summary>
|
||||
/// DataTable扩展方法类
|
||||
/// </summary>
|
||||
public static class DataTableExtend
|
||||
{
|
||||
/// <summary>
|
||||
/// DataTable转成List
|
||||
/// </summary>
|
||||
public static List<T> ToDataList<T>(this DataTable dt)
|
||||
{
|
||||
var list = new List<T>();
|
||||
var plist = new List<PropertyInfo>(typeof(T).GetProperties());
|
||||
|
||||
if (dt == null || dt.Rows.Count == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
foreach (DataRow item in dt.Rows)
|
||||
{
|
||||
T s = Activator.CreateInstance<T>();
|
||||
for (int i = 0; i < dt.Columns.Count; i++)
|
||||
{
|
||||
PropertyInfo info = plist.Find(p => p.Name == dt.Columns[i].ColumnName);
|
||||
if (info != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!Convert.IsDBNull(item[i]))
|
||||
{
|
||||
object v = null;
|
||||
if (info.PropertyType.ToString().Contains("System.Nullable"))
|
||||
{
|
||||
v = Convert.ChangeType(item[i], Nullable.GetUnderlyingType(info.PropertyType));
|
||||
}
|
||||
else
|
||||
{
|
||||
v = Convert.ChangeType(item[i], info.PropertyType);
|
||||
}
|
||||
info.SetValue(s, v, null);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("字段[" + info.Name + "]转换出错," + ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
list.Add(s);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// DataTable转成实体对象
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="dt"></param>
|
||||
/// <returns></returns>
|
||||
public static T ToDataEntity<T>(this DataTable dt)
|
||||
{
|
||||
T s = Activator.CreateInstance<T>();
|
||||
if (dt == null || dt.Rows.Count == 0)
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
var plist = new List<PropertyInfo>(typeof(T).GetProperties());
|
||||
for (int i = 0; i < dt.Columns.Count; i++)
|
||||
{
|
||||
PropertyInfo info = plist.Find(p => p.Name == dt.Columns[i].ColumnName);
|
||||
if (info != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!Convert.IsDBNull(dt.Rows[0][i]))
|
||||
{
|
||||
object v = null;
|
||||
if (info.PropertyType.ToString().Contains("System.Nullable"))
|
||||
{
|
||||
v = Convert.ChangeType(dt.Rows[0][i], Nullable.GetUnderlyingType(info.PropertyType));
|
||||
}
|
||||
else
|
||||
{
|
||||
v = Convert.ChangeType(dt.Rows[0][i], info.PropertyType);
|
||||
}
|
||||
info.SetValue(s, v, null);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("字段[" + info.Name + "]转换出错," + ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// List转成DataTable
|
||||
/// </summary>
|
||||
/// <typeparam name="T">实体类型</typeparam>
|
||||
/// <param name="entities">实体集合</param>
|
||||
public static DataTable ToDataTable<T>(List<T> entities)
|
||||
{
|
||||
if (entities == null || entities.Count == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var result = CreateTable<T>();
|
||||
FillData(result, entities);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建表
|
||||
/// </summary>
|
||||
private static DataTable CreateTable<T>()
|
||||
{
|
||||
var result = new DataTable();
|
||||
var type = typeof(T);
|
||||
foreach (var property in type.GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance))
|
||||
{
|
||||
var propertyType = property.PropertyType;
|
||||
if ((propertyType.IsGenericType) && (propertyType.GetGenericTypeDefinition() == typeof(Nullable<>)))
|
||||
propertyType = propertyType.GetGenericArguments()[0];
|
||||
result.Columns.Add(property.Name, propertyType);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 填充数据
|
||||
/// </summary>
|
||||
private static void FillData<T>(DataTable dt, IEnumerable<T> entities)
|
||||
{
|
||||
foreach (var entity in entities)
|
||||
{
|
||||
dt.Rows.Add(CreateRow(dt, entity));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建行
|
||||
/// </summary>
|
||||
private static DataRow CreateRow<T>(DataTable dt, T entity)
|
||||
{
|
||||
DataRow row = dt.NewRow();
|
||||
var type = typeof(T);
|
||||
foreach (var property in type.GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance))
|
||||
{
|
||||
row[property.Name] = property.GetValue(entity) ?? DBNull.Value;
|
||||
}
|
||||
return row;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace JinYuan.Helper
|
||||
{
|
||||
public class DeleteLog
|
||||
{
|
||||
public static void Start(string strPata)
|
||||
{
|
||||
Init(strPata);
|
||||
}
|
||||
|
||||
private static void Init(string strPata)
|
||||
{
|
||||
Task.Run(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
bool b = DeleteFile(strPata, 30); //删除该目录下 超过 30天的文件
|
||||
if (b)
|
||||
LoggerHelp.WriteLog("已清除30天内过期日志");
|
||||
//24小时清一次
|
||||
Thread.Sleep(1000 * 60 * 60 * 24);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Thread.Sleep(1000 * 60 * 60 * 28);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void DeleteDirectory(string target_dir)
|
||||
{
|
||||
string[] files = Directory.GetFiles(target_dir);
|
||||
string[] dirs = Directory.GetDirectories(target_dir);
|
||||
foreach (string file in files)
|
||||
{
|
||||
File.SetAttributes(file, FileAttributes.Normal);
|
||||
File.Delete(file);
|
||||
}
|
||||
foreach (string dir in dirs)
|
||||
{
|
||||
DeleteDirectory(dir);
|
||||
}
|
||||
Directory.Delete(target_dir, false);
|
||||
}
|
||||
|
||||
private static bool DeleteFile(string fileDirect, int saveDay)
|
||||
{
|
||||
try
|
||||
{
|
||||
DateTime nowTime = DateTime.Now;
|
||||
string[] files = Directory.GetFiles(fileDirect, "*.*", SearchOption.AllDirectories); //获取该目录下所有 .txt文件
|
||||
foreach (string file in files)
|
||||
{
|
||||
FileInfo fileInfo = new FileInfo(file);
|
||||
TimeSpan t = DateTime.Now - fileInfo.CreationTime; //当前时间 减去 文件创建时间
|
||||
int day = t.Days;
|
||||
if (day > saveDay) //保存的时间,单位:天
|
||||
{
|
||||
if (IsOccupy(fileInfo.FullName)) //判断文件是否被占用
|
||||
{
|
||||
System.IO.File.Delete(fileInfo.FullName); //删除文件
|
||||
Directory.Delete(fileDirect, true);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
LoggerHelp.WriteLog("文件被占用,无法操作!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
LoggerHelp.WriteLog($"文件被占用,无法操作!{err}");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
public static extern IntPtr _lopen(string lpPathName, int iReadWrite);
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
public static extern bool CloseHandle(IntPtr hObject);
|
||||
|
||||
public const int OF_READWRITE = 2;
|
||||
public const int OF_SHARE_DENY_NONE = 0x40;
|
||||
public static readonly IntPtr HFILE_ERROR = new IntPtr(-1);
|
||||
|
||||
/// <summary>
|
||||
/// 判断文件是否被占用
|
||||
/// </summary>
|
||||
/// <param name="file"></param>
|
||||
/// <returns></returns>
|
||||
private static bool IsOccupy(string file)
|
||||
{
|
||||
bool result = true; //默认状态此文件未被占用
|
||||
try
|
||||
{
|
||||
//string vFileName = @"c:\temp\temp.bmp";
|
||||
string vFileName = file;
|
||||
if (!System.IO.File.Exists(vFileName))
|
||||
{
|
||||
//Logger.Info("文件都不存在!");
|
||||
result = false;
|
||||
}
|
||||
IntPtr vHandle = _lopen(vFileName, OF_READWRITE | OF_SHARE_DENY_NONE);
|
||||
if (vHandle == HFILE_ERROR)
|
||||
{
|
||||
|
||||
//Log4Helper.WriteLog("文件被占用!", "错误提示");
|
||||
result = false;
|
||||
}
|
||||
CloseHandle(vHandle);
|
||||
// Log4Helper.WriteLog("没有被占用!", "错误提示");
|
||||
|
||||
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
result = false;
|
||||
//Log4Helper.WriteLog("判断文件是否被占用", err);
|
||||
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,267 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
|
||||
namespace JinYuan.Helper
|
||||
{
|
||||
public class FileHelper
|
||||
{
|
||||
#region 1.文本文件读写
|
||||
|
||||
|
||||
public static void WriteToTxt(string path, string content, bool isAppend = false)
|
||||
{
|
||||
//【1】创建文件流
|
||||
FileStream fileStream = new FileStream(path, isAppend ? FileMode.Append : FileMode.Create);
|
||||
|
||||
//【2】创建写入器
|
||||
StreamWriter streamWriter = new StreamWriter(fileStream);
|
||||
|
||||
//【3】以流的形式写入数据
|
||||
streamWriter.Write(content);
|
||||
|
||||
//【4】关闭写入器
|
||||
streamWriter.Close();
|
||||
|
||||
//【5】关闭文件流
|
||||
fileStream.Close();
|
||||
}
|
||||
|
||||
|
||||
public static string ReadFromTxt(string path)
|
||||
{
|
||||
//判断文件是否存在
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
//【1】创建文件流
|
||||
FileStream fileStream = new FileStream(path, FileMode.Open);
|
||||
|
||||
//【2】创建读取器
|
||||
StreamReader streamReader = new StreamReader(fileStream);
|
||||
|
||||
//【3】以流的方式读取
|
||||
string content = streamReader.ReadToEnd();
|
||||
|
||||
//【4】关闭读取器
|
||||
streamReader.Close();
|
||||
|
||||
//【5】关闭文件流
|
||||
fileStream.Close();
|
||||
|
||||
return content;
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 2.对象序列化文件
|
||||
|
||||
/// <summary>
|
||||
/// 序列化一个对象到一个文件中
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
/// <param name="path"></param>
|
||||
public static void SerializeObject(object obj, string path)
|
||||
{
|
||||
FileStream fileStream = null;
|
||||
|
||||
try
|
||||
{
|
||||
fileStream = new FileStream(path, FileMode.Create);
|
||||
|
||||
BinaryFormatter binaryFormatter = new BinaryFormatter();
|
||||
|
||||
binaryFormatter.Serialize(fileStream, obj);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("序列化对象出错:" + ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
fileStream.Close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static T DeSerializeObject<T>(string path)
|
||||
{
|
||||
FileStream fileStream = null;
|
||||
|
||||
try
|
||||
{
|
||||
fileStream = new FileStream(path, FileMode.Open);
|
||||
|
||||
BinaryFormatter binaryFormatter = new BinaryFormatter();
|
||||
|
||||
return (T)binaryFormatter.Deserialize(fileStream);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("反序列化对象出错:" + ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
fileStream.Close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region 3.对象序列化字符串
|
||||
|
||||
/// <summary>
|
||||
/// 将对象序列化成字符串
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
/// <returns></returns>
|
||||
public static string SerializeObjToString(object obj)
|
||||
{
|
||||
IFormatter formatter = new BinaryFormatter();
|
||||
|
||||
string result = string.Empty;
|
||||
|
||||
using (MemoryStream stream = new MemoryStream())
|
||||
{
|
||||
formatter.Serialize(stream, obj);
|
||||
|
||||
byte[] bytes = stream.ToArray();
|
||||
|
||||
result = Convert.ToBase64String(bytes);
|
||||
|
||||
stream.Flush();
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将字符串反序列化成对象
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="str"></param>
|
||||
/// <returns></returns>
|
||||
public static T DeSerializeObjFromString<T>(string str) where T : class
|
||||
{
|
||||
IFormatter formatter = new BinaryFormatter();
|
||||
|
||||
byte[] bytes = Convert.FromBase64String(str);
|
||||
|
||||
T obj = null;
|
||||
|
||||
using (MemoryStream stream = new MemoryStream(bytes, 0, bytes.Length))
|
||||
{
|
||||
obj = (T)formatter.Deserialize(stream);
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 4.文件的基本操作
|
||||
|
||||
/// <summary>
|
||||
/// 文件复制
|
||||
/// </summary>
|
||||
/// <param name="srcFileName"></param>
|
||||
/// <param name="desFileName"></param>
|
||||
public static void CopyFile(string srcFileName, string desFileName)
|
||||
{
|
||||
if (File.Exists(desFileName))
|
||||
{
|
||||
File.Delete(desFileName);
|
||||
}
|
||||
|
||||
File.Copy(srcFileName, desFileName);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 文件移动
|
||||
/// </summary>
|
||||
/// <param name="srcFileName"></param>
|
||||
/// <param name="desFileName"></param>
|
||||
public static void MoveFile(string srcFileName, string desFileName)
|
||||
{
|
||||
if (File.Exists(srcFileName))
|
||||
{
|
||||
if (File.Exists(desFileName))
|
||||
{
|
||||
File.Delete(desFileName);
|
||||
}
|
||||
|
||||
File.Move(srcFileName, desFileName);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 文件删除
|
||||
/// </summary>
|
||||
/// <param name="fileName"></param>
|
||||
public static void DeleteFile(string fileName)
|
||||
{
|
||||
if (File.Exists(fileName))
|
||||
{
|
||||
File.Delete(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 5.文件夹的相关操作
|
||||
|
||||
/// <summary>
|
||||
/// 获取指定目录下的所有文件
|
||||
/// </summary>
|
||||
/// <param name="path"></param>
|
||||
/// <returns></returns>
|
||||
public static string[] GetFiles(string path)
|
||||
{
|
||||
return Directory.GetFiles(path);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取指定目录下的所有子目录
|
||||
/// </summary>
|
||||
/// <param name="path"></param>
|
||||
/// <returns></returns>
|
||||
public static string[] GetDirectories(string path)
|
||||
{
|
||||
return Directory.GetDirectories(path);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建文件夹
|
||||
/// </summary>
|
||||
/// <param name="path"></param>
|
||||
public static void CreateDirectory(string path)
|
||||
{
|
||||
Directory.CreateDirectory(path);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除指定目录下的所有子目录和文件
|
||||
/// </summary>
|
||||
/// <param name="path"></param>
|
||||
public static void DeleteFiles(string path)
|
||||
{
|
||||
DirectoryInfo directory = new DirectoryInfo(path);
|
||||
|
||||
directory.Delete(true);
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,254 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace JinYuan.Helper
|
||||
{
|
||||
public class IniConfigHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 文件路径
|
||||
/// </summary>
|
||||
public static string iniFilePath = string.Empty;
|
||||
|
||||
|
||||
#region API函数声明
|
||||
|
||||
[DllImport("kernel32")]
|
||||
private static extern long WritePrivateProfileString(string section, string key,
|
||||
string val, string filePath);
|
||||
|
||||
//需要调用GetPrivateProfileString的重载
|
||||
[DllImport("kernel32", EntryPoint = "GetPrivateProfileString")]
|
||||
private static extern long GetPrivateProfileString(string section, string key,
|
||||
string def, StringBuilder retVal, int size, string filePath);
|
||||
|
||||
[DllImport("kernel32", EntryPoint = "GetPrivateProfileString")]
|
||||
private static extern uint GetPrivateProfileStringA(string section, string key,
|
||||
string def, Byte[] retVal, int size, string filePath);
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="StartupPath"></param>
|
||||
/// <param name="AppName"></param>
|
||||
public static void CreateIniFile(string StartupPath, string AppName)
|
||||
{
|
||||
iniFilePath = StartupPath + AppName;
|
||||
if (!Directory.Exists(StartupPath))
|
||||
{
|
||||
Directory.CreateDirectory(StartupPath);
|
||||
}
|
||||
if (!File.Exists(iniFilePath))
|
||||
{
|
||||
File.Create(iniFilePath).Close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#region 读取INI文件
|
||||
/// <summary>
|
||||
/// 根据节点及Key的值返回数据
|
||||
/// </summary>
|
||||
/// <param name="Section">节点</param>
|
||||
/// <param name="Key">键</param>
|
||||
/// <param name="defaultValue">默认值</param>
|
||||
/// <param name="path">路径</param>
|
||||
/// <returns>返回值</returns>
|
||||
public static string ReadIniData(string Section, string Key, string NoText, string iniFilePath)
|
||||
{
|
||||
if (File.Exists(iniFilePath))
|
||||
{
|
||||
StringBuilder stringBuilder = new StringBuilder(10240);
|
||||
|
||||
GetPrivateProfileString(Section, Key, NoText, stringBuilder, 10240, iniFilePath);
|
||||
|
||||
return stringBuilder.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 根据节点及Key的值返回数据
|
||||
/// </summary>
|
||||
/// <param name="Section">节点</param>
|
||||
/// <param name="Key">键</param>
|
||||
/// <param name="NoText">默认值</param>
|
||||
/// <returns>返回值</returns>
|
||||
public static string ReadIniData(string Section, string Key, string NoText)
|
||||
{
|
||||
return ReadIniData(Section, Key, NoText, iniFilePath);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 写入Ini文件
|
||||
|
||||
/// <summary>
|
||||
/// 根据节点及Key的值写入数据
|
||||
/// </summary>
|
||||
/// <param name="Section">节点</param>
|
||||
/// <param name="Key">键</param>
|
||||
/// <param name="Value">值</param>
|
||||
/// <param name="path">路径</param>
|
||||
/// <returns>操作结果</returns>
|
||||
public static bool WriteIniData(string Section, string Key, string Value, string path)
|
||||
{
|
||||
long result = WritePrivateProfileString(Section, Key, Value, path);
|
||||
|
||||
if (result == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据节点及Key的值写入数据
|
||||
/// </summary>
|
||||
/// <param name="Section">节点</param>
|
||||
/// <param name="Key">键</param>
|
||||
/// <param name="Value">值</param>
|
||||
/// <returns>操作结果</returns>
|
||||
public static bool WriteIniData(string Section, string Key, string Value)
|
||||
{
|
||||
return WriteIniData(Section, Key, Value, iniFilePath);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 读取所有的Sections
|
||||
|
||||
/// <summary>
|
||||
/// 读取所有的Section
|
||||
/// </summary>
|
||||
/// <param name="path">路径</param>
|
||||
/// <returns>Section集合</returns>
|
||||
public static List<string> ReadSections(string path)
|
||||
{
|
||||
byte[] buffer = new byte[65536];
|
||||
|
||||
uint length = GetPrivateProfileStringA(null, null, null, buffer, buffer.Length, path);
|
||||
|
||||
int startIndex = 0;
|
||||
|
||||
List<string> sections = new List<string>();
|
||||
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
if (buffer[i] == 0)
|
||||
{
|
||||
sections.Add(Encoding.Default.GetString(buffer, startIndex, i - startIndex));
|
||||
startIndex = i + 1;
|
||||
}
|
||||
}
|
||||
|
||||
return sections;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 读取所有的Section
|
||||
/// </summary>
|
||||
/// <param name="path">路径</param>
|
||||
/// <returns>Section集合</returns>
|
||||
public static List<string> ReadSections()
|
||||
{
|
||||
byte[] buffer = new byte[65536];
|
||||
|
||||
uint length = GetPrivateProfileStringA(null, null, null, buffer, buffer.Length, iniFilePath);
|
||||
|
||||
int startIndex = 0;
|
||||
|
||||
List<string> sections = new List<string>();
|
||||
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
if (buffer[i] == 0)
|
||||
{
|
||||
sections.Add(Encoding.Default.GetString(buffer, startIndex, i - startIndex));
|
||||
startIndex = i + 1;
|
||||
}
|
||||
}
|
||||
|
||||
return sections;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region 根据某个Section读取所有的Keys
|
||||
|
||||
/// <summary>
|
||||
/// 根据某个Section读取所有的Keys
|
||||
/// </summary>
|
||||
/// <param name="section">某个section</param>
|
||||
/// <param name="path">路径</param>
|
||||
/// <returns>key的集合</returns>
|
||||
public static List<string> ReadKeys(string section, string path)
|
||||
{
|
||||
byte[] buffer = new byte[65536];
|
||||
|
||||
uint length = GetPrivateProfileStringA(section, null, null, buffer, buffer.Length, path);
|
||||
|
||||
int startIndex = 0;
|
||||
|
||||
List<string> keys = new List<string>();
|
||||
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
if (buffer[i] == 0)
|
||||
{
|
||||
keys.Add(Encoding.Default.GetString(buffer, startIndex, i - startIndex));
|
||||
startIndex = i + 1;
|
||||
}
|
||||
}
|
||||
|
||||
return keys;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据某个Section读取所有的Keys
|
||||
/// </summary>
|
||||
/// <param name="section">某个section</param>
|
||||
/// <param name="path">路径</param>
|
||||
/// <returns>key的集合</returns>
|
||||
public static List<string> ReadKeys(string section)
|
||||
{
|
||||
byte[] buffer = new byte[65536];
|
||||
|
||||
uint length = GetPrivateProfileStringA(section, null, null, buffer, buffer.Length, iniFilePath);
|
||||
|
||||
int startIndex = 0;
|
||||
|
||||
List<string> keys = new List<string>();
|
||||
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
if (buffer[i] == 0)
|
||||
{
|
||||
keys.Add(Encoding.Default.GetString(buffer, startIndex, i - startIndex));
|
||||
startIndex = i + 1;
|
||||
}
|
||||
}
|
||||
|
||||
return keys;
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace JinYuan.Helper
|
||||
{
|
||||
public class IniFileHelper
|
||||
{
|
||||
private static string iniFilePath = "Configure.ini";
|
||||
|
||||
[DllImport("kernel32")]
|
||||
private static extern long WritePrivateProfileString(string section, string key, string val, string filePath);
|
||||
|
||||
[DllImport("kernel32")]
|
||||
private static extern long GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath);
|
||||
|
||||
public static string ReadIniData(string Section, string Key)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (File.Exists(iniFilePath))
|
||||
{
|
||||
StringBuilder temp = new StringBuilder(1024);
|
||||
GetPrivateProfileString(Section, Key, "", temp, 1024, iniFilePath);
|
||||
return temp.ToString();
|
||||
}
|
||||
MessageBox.Show("节点:" + Section + ",键名:" + Key + ":读取配置文件错误!");
|
||||
return null;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool WriteIniData(string Section, string Key, string Value)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (File.Exists(iniFilePath))
|
||||
{
|
||||
if (WritePrivateProfileString(Section, Key, Value, iniFilePath) == 0L)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
File.Create(iniFilePath).Close();
|
||||
if (WritePrivateProfileString(Section, Key, Value, iniFilePath) == 0L)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public static void CreateIniFile(string StartupPath, string AppName)
|
||||
{
|
||||
iniFilePath = StartupPath + AppName;
|
||||
if (!Directory.Exists(StartupPath))
|
||||
{
|
||||
Directory.CreateDirectory(StartupPath);
|
||||
}
|
||||
if (!File.Exists(iniFilePath))
|
||||
{
|
||||
File.Create(iniFilePath).Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
<?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>{258D0AB7-2B4F-4D8F-A3CD-7A8CB4A85360}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>JinYuan.Helper</RootNamespace>
|
||||
<AssemblyName>JinYuan.Helper</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<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' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="BouncyCastle.Cryptography, Version=2.0.0.0, Culture=neutral, PublicKeyToken=072edcf4a5328938, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\BouncyCastle.Cryptography.2.2.1\lib\net461\BouncyCastle.Cryptography.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="CsvHelper, Version=30.0.0.0, Culture=neutral, PublicKeyToken=8c4959082be5c823, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\CsvHelper.30.0.1\lib\net47\CsvHelper.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Enums.NET, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7ea1c1650d506225, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Enums.NET.4.0.1\lib\net45\Enums.NET.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="HslCommunication">
|
||||
<HintPath>..\JinYuan.ControlCenter\HslCommunication.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="ICSharpCode.SharpZipLib, Version=1.3.3.11, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\SharpZipLib.1.3.3\lib\net45\ICSharpCode.SharpZipLib.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MathNet.Numerics, Version=4.15.0.0, Culture=neutral, PublicKeyToken=cd8b63ad3d691a37, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MathNet.Numerics.Signed.4.15.0\lib\net461\MathNet.Numerics.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.1.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Bcl.HashCode, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Bcl.HashCode.1.0.0\lib\net461\Microsoft.Bcl.HashCode.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.IO.RecyclableMemoryStream, Version=2.3.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.IO.RecyclableMemoryStream.2.3.2\lib\net462\Microsoft.IO.RecyclableMemoryStream.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NLog, Version=6.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NLog.6.0.2\lib\net46\NLog.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NPOI.Core, Version=2.6.1.0, Culture=neutral, PublicKeyToken=0df73ec7942b34e1, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NPOI.2.6.1\lib\netstandard2.0\NPOI.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NPOI.OOXML, Version=2.6.1.0, Culture=neutral, PublicKeyToken=0df73ec7942b34e1, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NPOI.2.6.1\lib\netstandard2.0\NPOI.OOXML.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NPOI.OpenXml4Net, Version=2.6.1.0, Culture=neutral, PublicKeyToken=0df73ec7942b34e1, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NPOI.2.6.1\lib\netstandard2.0\NPOI.OpenXml4Net.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NPOI.OpenXmlFormats, Version=2.6.1.0, Culture=neutral, PublicKeyToken=0df73ec7942b34e1, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NPOI.2.6.1\lib\netstandard2.0\NPOI.OpenXmlFormats.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SixLabors.Fonts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d998eea7b14cab13, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\SixLabors.Fonts.1.0.0\lib\netstandard2.0\SixLabors.Fonts.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SixLabors.ImageSharp, Version=2.0.0.0, Culture=neutral, PublicKeyToken=d998eea7b14cab13, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\SixLabors.ImageSharp.2.1.4\lib\net472\SixLabors.ImageSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Configuration.ConfigurationManager, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Configuration.ConfigurationManager.6.0.0\lib\net461\System.Configuration.ConfigurationManager.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Data.OracleClient" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Net" />
|
||||
<Reference Include="System.Numerics" />
|
||||
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="System.Security" />
|
||||
<Reference Include="System.Security.AccessControl, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Security.AccessControl.6.0.0\lib\net461\System.Security.AccessControl.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Security.Cryptography.Xml, Version=6.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Security.Cryptography.Xml.6.0.1\lib\net461\System.Security.Cryptography.Xml.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Security.Permissions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Security.Permissions.6.0.0\lib\net461\System.Security.Permissions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Security.Principal.Windows, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Security.Principal.Windows.5.0.0\lib\net461\System.Security.Principal.Windows.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.ServiceProcess" />
|
||||
<Reference Include="System.Text.Encoding.CodePages, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Text.Encoding.CodePages.6.0.0\lib\net461\System.Text.Encoding.CodePages.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.2\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Transactions" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Windows.Forms.DataVisualization" />
|
||||
<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" />
|
||||
<Reference Include="WindowsBase" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ArrayHelper.cs" />
|
||||
<Compile Include="ChartHelper.cs" />
|
||||
<Compile Include="DataTableExtend.cs" />
|
||||
<Compile Include="ConvertHelper.cs" />
|
||||
<Compile Include="CSVHelper.cs" />
|
||||
<Compile Include="DataGridViewHelper.cs" />
|
||||
<Compile Include="DeleteLog.cs" />
|
||||
<Compile Include="ExcelHelper.cs" />
|
||||
<Compile Include="FileHelper.cs" />
|
||||
<Compile Include="IniConfigHelper.cs" />
|
||||
<Compile Include="IniFileHelper.cs" />
|
||||
<Compile Include="JsonHelper.cs" />
|
||||
<Compile Include="LoggerHelp.cs" />
|
||||
<Compile Include="PLCAlarmParseHelper.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ScanerHook.cs" />
|
||||
<Compile Include="SendDateMQTT.cs" />
|
||||
<Compile Include="StreamIOHelper.cs" />
|
||||
<Compile Include="StringSecurityHelper.cs" />
|
||||
<Compile Include="TimerReset.cs" />
|
||||
<Compile Include="TxtHelper.cs" />
|
||||
<Compile Include="XmlHelper.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\JinYuan.Models\JinYuan.Models.csproj">
|
||||
<Project>{4C0BCB84-5CD7-4846-8363-C4C10D46E391}</Project>
|
||||
<Name>JinYuan.Models</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -0,0 +1,90 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.Serialization.Json;
|
||||
using System.Text;
|
||||
|
||||
namespace JinYuan.Helper
|
||||
{
|
||||
public class JsonHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 使用Newtonsoft.json.dll对象序列化成Json字符串
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="t"></param>
|
||||
/// <returns></returns>
|
||||
public static string EntityToJson<T>(T t)
|
||||
{
|
||||
try
|
||||
{
|
||||
return JsonConvert.SerializeObject(t);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 使用Newtonsoft.json.dll 将Json字符串反序列化成对象
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="json"></param>
|
||||
/// <returns></returns>
|
||||
public static T JsonToEntity<T>(string json)
|
||||
{
|
||||
try
|
||||
{
|
||||
return (T)JsonConvert.DeserializeObject(json, typeof(T));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 实体类转换成JSON字符串
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="obj"></param>
|
||||
/// <returns></returns>
|
||||
public static string EntityToJson2<T>(T obj)
|
||||
{
|
||||
//序列化
|
||||
DataContractJsonSerializer js = new DataContractJsonSerializer(typeof(T));
|
||||
MemoryStream msObj = new MemoryStream();
|
||||
//将序列化之后的Json格式数据写入流中
|
||||
js.WriteObject(msObj, obj);
|
||||
msObj.Position = 0;
|
||||
//从0这个位置开始读取流中的数据
|
||||
StreamReader sr = new StreamReader(msObj, Encoding.Default);
|
||||
string json = sr.ReadToEnd();
|
||||
sr.Close();
|
||||
msObj.Close();
|
||||
return json;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// JSON字符串转换成实体类
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="json"></param>
|
||||
/// <returns></returns>
|
||||
public static T JsonToEntity2<T>(string json) where T : class
|
||||
{
|
||||
//反序列化
|
||||
using (var ms = new MemoryStream(Encoding.Default.GetBytes(json)))
|
||||
{
|
||||
DataContractJsonSerializer deseralizer = new DataContractJsonSerializer(typeof(T));
|
||||
T model = (T)deseralizer.ReadObject(ms);// //反序列化ReadObject
|
||||
return model;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
using NLog;
|
||||
using System;
|
||||
|
||||
public class LoggerHelp
|
||||
{
|
||||
private static readonly NLog.Logger loginfo = LogManager.GetLogger("loginfo");
|
||||
private static readonly NLog.Logger logerror = LogManager.GetLogger("logerror");
|
||||
private static readonly NLog.Logger logmqtt = LogManager.GetLogger("logmqtt");
|
||||
|
||||
private static readonly NLog.Logger logsInfo = LogManager.GetLogger("logsInfo");
|
||||
private static readonly NLog.Logger logsMEStIME = LogManager.GetLogger("logsMEStIME");
|
||||
private static readonly NLog.Logger logsSql = LogManager.GetLogger("logsSql");
|
||||
private static readonly NLog.Logger logsSysErrorLog = LogManager.GetLogger("logsSysErrorLog");
|
||||
private static readonly NLog.Logger logsSysErrorLogcn = LogManager.GetLogger("logsSysErrorLogcn");
|
||||
|
||||
|
||||
public static void WriteInfo(string info) => loginfo.Info(info);
|
||||
|
||||
|
||||
public static void WriteMqtt(string info) => logmqtt.Info(info);
|
||||
|
||||
public static void WriteError(string error) => logerror.Info(error);
|
||||
|
||||
public static void WriteError(string info, Exception ex) => logerror.Error(info, ex);
|
||||
|
||||
|
||||
public static void WriteEX(Exception ex) => logsSysErrorLog.Error(ex.Message + "\r\n" + ex.InnerException + "\r\n" + ex.StackTrace + "\r\n" + ex.Source, "SysErrorLog");
|
||||
|
||||
public static void WriteEX(string ErrorName, Exception ex)
|
||||
{
|
||||
logsSysErrorLog.Error(ErrorName + "\r\n" + ex.Message + "\r\n" + ex.InnerException + "\r\n" + ex.StackTrace + "\r\n" + ex.Source, "SysErrorLog");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 写日志文件数据库日志文件
|
||||
/// </summary>
|
||||
/// <param name="message">消息</param>
|
||||
public static void WriteLog(string message)
|
||||
{
|
||||
// logsInfo.IsInfoEnabled = true;
|
||||
logsInfo.Info(message);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 写日志文件数据库日志文件
|
||||
/// </summary>
|
||||
/// <param name="message">消息</param>
|
||||
/// <param name="direName">日志存储目录名称</param>
|
||||
public static void WriteLog(string message, string direName)
|
||||
{
|
||||
switch (direName)
|
||||
{
|
||||
case "Info":
|
||||
logsInfo.Info(message, "Info");
|
||||
break;
|
||||
case "SysErrorLog":
|
||||
logsSysErrorLog.Info(message, "SysErrorLog");
|
||||
break;
|
||||
case "SQL执行":
|
||||
logsSql.Info(message);
|
||||
break;
|
||||
case "MESTime":
|
||||
logsMEStIME.Info(message, "MESTime");
|
||||
break;
|
||||
case "系统报错":
|
||||
logsSysErrorLogcn.Info(message, "系统报错");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,194 @@
|
||||
using JinYuan.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace JinYuan.Helper
|
||||
{
|
||||
public static class PLCAlarmParseHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 三菱将报警地址值转成报警List
|
||||
/// </summary>
|
||||
/// <param name="plcAddrSuffix">PLC地址值,如100</param>
|
||||
/// <param name="byteData">PLC读取出来的值</param>
|
||||
/// <param name="plcAddrPrefix">PLC地址类型,默认值R</param>
|
||||
/// <returns></returns>
|
||||
public static List<AlarmStatus> MelsecByte2Status(int plcAddrSuffix, byte[] byteData, char plcAddrPrefix = 'R')
|
||||
{
|
||||
var listAlarmStatus = new List<AlarmStatus>();
|
||||
// byte[]转为二进制字符串表示
|
||||
string strResult = "";
|
||||
for (int i = 0; i < byteData.Length; i++)
|
||||
{
|
||||
string strTemp = System.Convert.ToString(byteData[i], 2);
|
||||
strTemp = strTemp.PadLeft(8, '0').StrReverse();
|
||||
strResult += strTemp;
|
||||
}
|
||||
|
||||
for (int i = 0; i < strResult.Length; i++)
|
||||
{
|
||||
var plcByte = i % 16;
|
||||
//如果是16的倍数地址+1
|
||||
if (plcByte % 16 == 0 && i != 0)
|
||||
{
|
||||
plcAddrSuffix++;
|
||||
}
|
||||
//将地址和状态添加到结果集
|
||||
listAlarmStatus.Add(new AlarmStatus()
|
||||
{
|
||||
PLCAdress = $"{plcAddrPrefix}{plcAddrSuffix}.{plcByte.ToString("X")}",
|
||||
Status = strResult[i] == '1'
|
||||
});
|
||||
//if (strResult[i] == '1')
|
||||
// Console.WriteLine($"{plcAddrPrefix}{plcAddrSuffix}.{plcByte.ToString("X")}:{strResult[i]}");
|
||||
}
|
||||
|
||||
return listAlarmStatus;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 欧姆龙NX系列Ethernet/IP通讯时将报警地址值转成报警List {直接读取标签地址/无需高低位互换}
|
||||
/// </summary>
|
||||
/// <param name="plcAddrSuffix">PLC地址值,如100</param>
|
||||
/// <param name="byteData">PLC读取出来的值</param>
|
||||
/// <param name="plcAddrPrefix">PLC地址类型,默认值R</param>
|
||||
/// <returns></returns>
|
||||
public static List<AlarmStatus> OmronEIPByte2Status(int plcAddrSuffix, List<byte> byteData, char plcAddrPrefix = 'W')
|
||||
{
|
||||
var listAlarmStatus = new List<AlarmStatus>();
|
||||
// byte[]转为二进制字符串表示
|
||||
string strResult = "";
|
||||
for (int i = 0; i < byteData.Count; i++)
|
||||
{
|
||||
string strTemp = System.Convert.ToString(byteData[i], 2);
|
||||
strTemp = strTemp.PadLeft(8, '0').StrReverse();
|
||||
strResult += strTemp;
|
||||
}
|
||||
|
||||
for (int i = 0; i < strResult.Length; i++)
|
||||
{
|
||||
var plcByte = i % 16;
|
||||
//如果是16的倍数地址+1
|
||||
if (plcByte % 16 == 0 && i != 0)
|
||||
{
|
||||
plcAddrSuffix++;
|
||||
}
|
||||
//将地址和状态添加到结果集
|
||||
listAlarmStatus.Add(new AlarmStatus()
|
||||
{
|
||||
PLCAdress = $"{plcAddrPrefix}6100[{plcAddrSuffix}].B[{plcByte.ToString()}]",
|
||||
Status = strResult[i] == '1'
|
||||
});
|
||||
|
||||
//if (strResult[i] == '1')
|
||||
// Console.WriteLine($"{plcAddrPrefix}{plcAddrSuffix}.{plcByte.ToString("X")}:{strResult[i]}");
|
||||
}
|
||||
|
||||
return listAlarmStatus;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 欧姆龙FINS通讯读取EM数据寄存器是时将报警地址值转成报警List
|
||||
/// </summary>
|
||||
/// <param name="plcAddrSuffix">PLC地址值,如100</param>
|
||||
/// <param name="byteData">PLC读取出来的值</param>
|
||||
/// <param name="plcAddrPrefix">PLC地址类型,默认值W</param>
|
||||
/// <returns></returns>
|
||||
public static List<AlarmStatus> OmronFinsByte2Status(int plcAddrSuffix, byte[] byteData, char plcAddrPrefix = 'D')
|
||||
{
|
||||
var listAlarmStatus = new List<AlarmStatus>();
|
||||
// byte[]转为二进制字符串表示
|
||||
byte[] revBytes = SWAPbyte(byteData); //字节高低位互换
|
||||
string strResult = "";
|
||||
for (int i = 0; i < revBytes.Length; i++)
|
||||
{
|
||||
string strTemp = System.Convert.ToString(revBytes[i], 2);
|
||||
strTemp = strTemp.PadLeft(8, '0').StrReverse();
|
||||
strResult += strTemp;
|
||||
}
|
||||
|
||||
for (int i = 0; i < strResult.Length; i++)
|
||||
{
|
||||
var plcByte = i % 16;
|
||||
//如果是16的倍数地址+1
|
||||
if (plcByte % 16 == 0 && i != 0)
|
||||
{
|
||||
plcAddrSuffix++;
|
||||
}
|
||||
//将地址和状态添加到结果集
|
||||
listAlarmStatus.Add(new AlarmStatus()
|
||||
{
|
||||
PLCAdress = $"{plcAddrPrefix}{plcAddrSuffix}.{plcByte.ToString()}",
|
||||
Status = strResult[i] == '1'
|
||||
});
|
||||
//if (strResult[i] == '1')
|
||||
// Console.WriteLine($"{plcAddrPrefix}{plcAddrSuffix}.{plcByte.ToString("X")}:{strResult[i]}");
|
||||
}
|
||||
|
||||
return listAlarmStatus;
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 欧姆龙FINS通讯读取W数据寄存器是时将报警地址值转成报警List
|
||||
/// </summary>
|
||||
/// <param name="plcAddrSuffix">PLC地址值,如100</param>
|
||||
/// <param name="byteData">PLC读取出来的值</param>
|
||||
/// <param name="plcAddrPrefix">PLC地址类型,默认值W</param>
|
||||
/// <returns></returns>
|
||||
//public static List<AlarmStatus> OmronByte2Status(int plcAddrSuffix, byte[] byteData, char plcAddrPrefix = 'W')
|
||||
//{
|
||||
// var listAlarmStatus = new List<AlarmStatus>();
|
||||
|
||||
// var addrCount = byteData.Length / 2;
|
||||
// // byte[]每个地址保存的都是bool值,只取双数index位
|
||||
// for (int i = 0; i < addrCount; i++)
|
||||
// {
|
||||
// //将地址和状态添加到结果集
|
||||
// listAlarmStatus.Add(new AlarmStatus()
|
||||
// {
|
||||
// PLCAdress = $"{plcAddrPrefix}{plcAddrSuffix + i}",
|
||||
// Status = byteData[i * 2 + 1] == 1
|
||||
|
||||
// });
|
||||
// //if (byteData[i * 2 + 1] == 1)
|
||||
// // Console.WriteLine($"原始数据 PLC地址:{plcAddrPrefix}{plcAddrSuffix + i} 报警值:{byteData[i * 2 + 1]}");
|
||||
// }
|
||||
|
||||
// return listAlarmStatus;
|
||||
//}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 字符串反转
|
||||
/// </summary>
|
||||
/// <param name="str">需要反转字符串.Reverse()</param>
|
||||
/// <returns></returns>
|
||||
public static string StrReverse(this string str)
|
||||
{
|
||||
return new string(str.Reverse().ToArray());
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///byte字节高低位互换
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public static byte[] SWAPbyte(byte[] data)
|
||||
{
|
||||
byte[] data2 = new byte[data.Length];
|
||||
for (int i = 0; i < data.Length; i += 2)
|
||||
{
|
||||
data2[i] = data[i + 1];
|
||||
data2[i + 1] = data[i];
|
||||
}
|
||||
return data2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// 有关程序集的一般信息由以下
|
||||
// 控制。更改这些特性值可修改
|
||||
// 与程序集关联的信息。
|
||||
[assembly: AssemblyTitle("JinYuan.Helper")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("JinYuan.Helper")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2023")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// 将 ComVisible 设置为 false 会使此程序集中的类型
|
||||
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
|
||||
//请将此类型的 ComVisible 特性设置为 true。
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
|
||||
[assembly: Guid("258d0ab7-2b4f-4d8f-a3cd-7a8cb4a85360")]
|
||||
|
||||
// 程序集的版本信息由下列四个值组成:
|
||||
//
|
||||
// 主版本
|
||||
// 次版本
|
||||
// 生成号
|
||||
// 修订号
|
||||
//
|
||||
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
|
||||
//通过使用 "*",如下所示:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@@ -0,0 +1,291 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace JinYuan.Helper
|
||||
{
|
||||
public class ScanerHook
|
||||
{
|
||||
public delegate void ScanerDelegate(ScanerCodes codes);
|
||||
public event ScanerDelegate ScanerEvent;
|
||||
|
||||
//private const int WM_KEYDOWN = 0x100;//KEYDOWN
|
||||
//private const int WM_KEYUP = 0x101;//KEYUP
|
||||
//private const int WM_SYSKEYDOWN = 0x104;//SYSKEYDOWN
|
||||
//private const int WM_SYSKEYUP = 0x105;//SYSKEYUP
|
||||
//private static int HookProc(int nCode, Int32 wParam, IntPtr lParam);
|
||||
private int hKeyboardHook = 0;//声明键盘钩子处理的初始值
|
||||
private ScanerCodes codes = new ScanerCodes();//13为键盘钩子
|
||||
//定义成静态,这样不会抛出回收异常
|
||||
private static HookProc hookproc;
|
||||
delegate int HookProc(int nCode, Int32 wParam, IntPtr lParam);
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
|
||||
//设置钩子
|
||||
private static extern int SetWindowsHookEx(int idHook, HookProc lpfn, IntPtr hInstance, int threadId);
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
|
||||
//卸载钩子
|
||||
private static extern bool UnhookWindowsHookEx(int idHook);
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
|
||||
//继续下个钩子
|
||||
private static extern int CallNextHookEx(int idHook, int nCode, Int32 wParam, IntPtr lParam);
|
||||
|
||||
[DllImport("user32", EntryPoint = "GetKeyNameText")]
|
||||
private static extern int GetKeyNameText(int IParam, StringBuilder lpBuffer, int nSize);
|
||||
[DllImport("user32", EntryPoint = "GetKeyboardState")]
|
||||
//获取按键的状态
|
||||
private static extern int GetKeyboardState(byte[] pbKeyState);
|
||||
[DllImport("user32", EntryPoint = "ToAscii")]
|
||||
//ToAscii职能的转换指定的虚拟键码和键盘状态的相应字符或字符
|
||||
private static extern bool ToAscii(int VirtualKey, int ScanCode, byte[] lpKeySate, ref uint lpChar, int uFlags);
|
||||
|
||||
//int VirtualKey //[in] 指定虚拟关键代码进行翻译。
|
||||
//int uScanCode, // [in] 指定的硬件扫描码的关键须翻译成英文。高阶位的这个值设定的关键,如果是(不压)
|
||||
//byte[] lpbKeyState, // [in] 指针,以256字节数组,包含当前键盘的状态。每个元素(字节)的数组包含状态的一个关键。如果高阶位的字节是一套,关键是下跌(按下)。在低比特,如/果设置表明,关键是对切换。在此功能,只有肘位的CAPS LOCK键是相关的。在切换状态的NUM个锁和滚动锁定键被忽略。
|
||||
//byte[] lpwTransKey, // [out] 指针的缓冲区收到翻译字符或字符。
|
||||
//uint fuState); // [in] Specifies whether a menu is active. This parameter must be 1 if a menu is active, or 0 otherwise.
|
||||
|
||||
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
//使用WINDOWS API函数代替获取当前实例的函数,防止钩子失效
|
||||
public static extern IntPtr GetModuleHandle(string name);
|
||||
public ScanerHook()
|
||||
{
|
||||
}
|
||||
public bool Start()
|
||||
{
|
||||
if (hKeyboardHook == 0)
|
||||
{
|
||||
hookproc = new HookProc(KeyboardHookProc);
|
||||
//GetModuleHandle 函数 替代 Marshal.GetHINSTANCE
|
||||
//防止在 framework4.0中 注册钩子不成功
|
||||
IntPtr modulePtr = GetModuleHandle(Process.GetCurrentProcess().MainModule.ModuleName);
|
||||
//WH_KEYBOARD_LL=13
|
||||
//全局钩子 WH_KEYBOARD_LL
|
||||
// hKeyboardHook = SetWindowsHookEx(13, hookproc, Marshal.GetHINSTANCE(Assembly.GetExecutingAssembly().GetModules()[0]), 0);
|
||||
hKeyboardHook = SetWindowsHookEx(13, hookproc, modulePtr, 0);
|
||||
}
|
||||
return (hKeyboardHook != 0);
|
||||
}
|
||||
public bool Stop()
|
||||
{
|
||||
if (hKeyboardHook != 0)
|
||||
{
|
||||
bool retKeyboard = UnhookWindowsHookEx(hKeyboardHook);
|
||||
hKeyboardHook = 0;
|
||||
return retKeyboard;
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private int KeyboardHookProc(int nCode, Int32 wParam, IntPtr lParam)
|
||||
{
|
||||
|
||||
|
||||
EventMsg msg = (EventMsg)Marshal.PtrToStructure(lParam, typeof(EventMsg));
|
||||
codes.Add(msg);
|
||||
if (ScanerEvent != null && msg.message == 13 && msg.paramH > 0 && !string.IsNullOrEmpty(codes.Result))
|
||||
{
|
||||
ScanerEvent(codes);
|
||||
}
|
||||
return CallNextHookEx(hKeyboardHook, nCode, wParam, lParam);
|
||||
}
|
||||
public class ScanerCodes
|
||||
{
|
||||
private int ts = 100; // 指定输入间隔为300毫秒以内时为连续输入
|
||||
private List<List<EventMsg>> _keys = new List<List<EventMsg>>();
|
||||
private List<int> _keydown = new List<int>(); // 保存组合键状态
|
||||
private List<string> _result = new List<string>(); // 返回结果集
|
||||
private DateTime _last = DateTime.Now;
|
||||
private byte[] _state = new byte[256];
|
||||
private string _key = string.Empty;
|
||||
private string _cur = string.Empty;
|
||||
public EventMsg Event
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_keys.Count == 0)
|
||||
{
|
||||
return new EventMsg();
|
||||
}
|
||||
else
|
||||
{
|
||||
return _keys[_keys.Count - 1][_keys[_keys.Count - 1].Count - 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
public List<int> KeyDowns
|
||||
{
|
||||
get
|
||||
{
|
||||
return _keydown;
|
||||
}
|
||||
}
|
||||
public DateTime LastInput
|
||||
{
|
||||
get
|
||||
{
|
||||
return _last;
|
||||
}
|
||||
}
|
||||
public byte[] KeyboardState
|
||||
{
|
||||
get
|
||||
{
|
||||
return _state;
|
||||
}
|
||||
}
|
||||
public int KeyDownCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return _keydown.Count;
|
||||
}
|
||||
}
|
||||
public string Result
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_result.Count > 0)
|
||||
{
|
||||
return _result[_result.Count - 1].Trim();
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
public string CurrentKey
|
||||
{
|
||||
get
|
||||
{
|
||||
return _key;
|
||||
}
|
||||
}
|
||||
public string CurrentChar
|
||||
{
|
||||
get
|
||||
{
|
||||
return _cur;
|
||||
}
|
||||
}
|
||||
public bool isShift
|
||||
{
|
||||
get
|
||||
{
|
||||
return _keydown.Contains(160);
|
||||
}
|
||||
}
|
||||
public void Add(EventMsg msg)
|
||||
{
|
||||
#region 记录按键信息
|
||||
|
||||
// 首次按下按键
|
||||
if (_keys.Count == 0)
|
||||
{
|
||||
_keys.Add(new List<EventMsg>());
|
||||
_keys[0].Add(msg);
|
||||
_result.Add(string.Empty);
|
||||
}
|
||||
// 未释放其他按键时按下按键
|
||||
else if (_keydown.Count > 0)
|
||||
{
|
||||
_keys[_keys.Count - 1].Add(msg);
|
||||
}
|
||||
// 单位时间内按下按键
|
||||
else if (((TimeSpan)(DateTime.Now - _last)).TotalMilliseconds < ts)
|
||||
{
|
||||
_keys[_keys.Count - 1].Add(msg);
|
||||
}
|
||||
// 从新记录输入内容
|
||||
else
|
||||
{
|
||||
_keys.Add(new List<EventMsg>());
|
||||
_keys[_keys.Count - 1].Add(msg);
|
||||
_result.Add(string.Empty);
|
||||
}
|
||||
#endregion
|
||||
_last = DateTime.Now;
|
||||
#region 获取键盘状态
|
||||
// 记录正在按下的按键
|
||||
if (msg.paramH == 0 && !_keydown.Contains(msg.message))
|
||||
{
|
||||
_keydown.Add(msg.message);
|
||||
}
|
||||
// 清除已松开的按键
|
||||
if (msg.paramH > 0 && _keydown.Contains(msg.message))
|
||||
{
|
||||
_keydown.Remove(msg.message);
|
||||
}
|
||||
#endregion
|
||||
#region 计算按键信息
|
||||
|
||||
int v = msg.message & 0xff;
|
||||
int c = msg.paramL & 0xff;
|
||||
StringBuilder strKeyName = new StringBuilder(500);
|
||||
if (GetKeyNameText(c * 65536, strKeyName, 255) > 0)
|
||||
{
|
||||
_key = strKeyName.ToString().Trim(new char[] { ' ', '\0' });
|
||||
GetKeyboardState(_state);
|
||||
if (_key.Length == 1 && msg.paramH == 0)// && msg.paramH == 0
|
||||
{
|
||||
// 根据键盘状态和shift缓存判断输出字符
|
||||
_cur = ShiftChar(_key, isShift, _state).ToString();
|
||||
_result[_result.Count - 1] += _cur;
|
||||
}
|
||||
// 备选
|
||||
else
|
||||
{
|
||||
_cur = string.Empty;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
private char ShiftChar(string k, bool isShiftDown, byte[] state)
|
||||
{
|
||||
bool capslock = state[0x14] == 1;
|
||||
bool numlock = state[0x90] == 1;
|
||||
bool scrolllock = state[0x91] == 1;
|
||||
bool shiftdown = state[0xa0] == 1;
|
||||
char chr = (capslock ? k.ToUpper() : k.ToLower()).ToCharArray()[0];
|
||||
if (isShiftDown)
|
||||
{
|
||||
if (chr >= 'a' && chr <= 'z')
|
||||
{
|
||||
chr = (char)((int)chr - 32);
|
||||
}
|
||||
else if (chr >= 'A' && chr <= 'Z')
|
||||
{
|
||||
if (chr == 'Z')
|
||||
{
|
||||
string s = "";
|
||||
}
|
||||
chr = (char)((int)chr + 32);
|
||||
}
|
||||
else
|
||||
{
|
||||
string s = "`1234567890-=[];',./";
|
||||
string u = "~!@#$%^&*()_+{}:\"<>?";
|
||||
if (s.IndexOf(chr) >= 0)
|
||||
{
|
||||
return (u.ToCharArray())[s.IndexOf(chr)];
|
||||
}
|
||||
}
|
||||
}
|
||||
return chr;
|
||||
}
|
||||
}
|
||||
|
||||
public struct EventMsg
|
||||
{
|
||||
public int message;
|
||||
public int paramL;
|
||||
public int paramH;
|
||||
public int Time;
|
||||
public int hwnd;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,355 @@
|
||||
using HslCommunication;
|
||||
using HslCommunication.MQTT;
|
||||
using JinYuan.Models;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace JinYuan.Helper
|
||||
{
|
||||
public class SendDateMQTT
|
||||
{
|
||||
/// <summary>
|
||||
/// 单类
|
||||
/// </summary>
|
||||
private static SendDateMQTT _instance;
|
||||
private static readonly object _lock = new object();
|
||||
public static SendDateMQTT Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
_instance = new SendDateMQTT();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
|
||||
private SendDateMQTT()
|
||||
{
|
||||
|
||||
Connect(MQTTServerAddress, MQTTServerPort, "admin", "123456");
|
||||
//mqttClient.OnMqttMessageReceived += MqttClient_OnMqttMessageReceived; // 调用一次即可
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打印日志方法
|
||||
/// </summary>
|
||||
/// <param name="Message"></param>日志信息
|
||||
/// <param name="FileName"></param>文件夹名字
|
||||
public static void LogMessage(string Message, string FileName)
|
||||
{
|
||||
string filePath = FileName + "//" + DateTime.Now.ToString("yyyy-MM-dd"); // 日志文件存放路径,默认在debug目录下
|
||||
string filePath2 = FileName + "//" + DateTime.Now.ToString("yyyy-MM-dd") + "//Mylog.txt";//也可以加上时间
|
||||
//string file=DateTime.Now+"log.txt";
|
||||
//检查文件夹是否存在,否则新建
|
||||
if (!Directory.Exists(filePath))
|
||||
{
|
||||
Directory.CreateDirectory(filePath);
|
||||
}
|
||||
string logMessage = $"{DateTime.Now}: {Message}";//打印出现的时间
|
||||
// 将消息写入日志文件
|
||||
using (StreamWriter writer = new StreamWriter(filePath2, true))
|
||||
{
|
||||
writer.WriteLine(logMessage);
|
||||
}
|
||||
}
|
||||
|
||||
HslCommunication.MQTT.MqttClient mqttClient = null;
|
||||
//10.22.160.144
|
||||
public string MQTTServerAddress = "127.0.0.1";//"10.22.161.1";
|
||||
public int MQTTServerPort = 2883;
|
||||
public string ClientId = "602VIW01";
|
||||
//PPM主题
|
||||
public string Topic = "EVE/60J/TrackInOut/602VIW01";//进出站
|
||||
public string Topic1 = "EVE/60J/CTPCTQ/602VIW01";
|
||||
public string BU_id = "EVE8BU";
|
||||
public string District_id = "JM";
|
||||
public string Factory_id = "60J";
|
||||
public string Production_line_id = "MW-602";
|
||||
public string Work_center_id = "602VIE01";
|
||||
public string Device_name = "602VIW01";
|
||||
public string Action_time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 发送进出站数据
|
||||
/// </summary>
|
||||
/// <param name="topic"></param>
|
||||
/// <param name="IP"></param>
|
||||
/// <param name="Port"></param>
|
||||
/// <param name="cPQCPTDate"></param>
|
||||
public void EnterandExitSendMessge(int Station = 3)
|
||||
{
|
||||
try
|
||||
{
|
||||
////if (mqttClient != null)
|
||||
//// mqttClient.ConnectClose();
|
||||
if (!mqttClient.IsConnected)
|
||||
{
|
||||
Connect(MQTTServerAddress, MQTTServerPort, "admin", "123456");
|
||||
}
|
||||
SubscribeMessage(Topic);
|
||||
//进站
|
||||
if (Station == 0)
|
||||
{
|
||||
PublishMessage(Topic, EnterandExitMessge("0"));
|
||||
}
|
||||
//出站
|
||||
else if (Station == 1)
|
||||
{
|
||||
|
||||
PublishMessage(Topic, EnterandExitMessge("1"));
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
LoggerHelp.WriteError($"发送进出站数据错误,{err.Message}", err);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 发送采集项数据
|
||||
/// </summary>
|
||||
/// <param name="topic"></param>
|
||||
/// <param name="IP"></param>
|
||||
/// <param name="Port"></param>
|
||||
/// <param name="cPQCPTDate"></param>
|
||||
public void CollectionSendMessge(CPQCPTDate cPQCPTDate)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!mqttClient.IsConnected)
|
||||
{
|
||||
Connect(MQTTServerAddress, MQTTServerPort, "admin", "123456");
|
||||
}
|
||||
SubscribeMessage(Topic1);
|
||||
PublishMessage(Topic1, CollectionMessge(cPQCPTDate));
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
LoggerHelp.WriteError($"发送采集项数据错误,{err.Message}", err);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 连接
|
||||
/// </summary>
|
||||
/// <param name="ip"></param>
|
||||
/// <param name="port"></param>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="pwd"></param>
|
||||
/// <param name="clientId"></param>
|
||||
public void Connect(string ip, int port, string name, string pwd, string clientId = "ClientId")
|
||||
{
|
||||
try
|
||||
{
|
||||
if (mqttClient != null)
|
||||
{
|
||||
LoggerHelp.WriteMqtt("MQTT 服务器关闭失败");
|
||||
mqttClient.ConnectClose();
|
||||
}
|
||||
|
||||
mqttClient = new MqttClient(new MqttConnectionOptions()
|
||||
{
|
||||
ClientId = clientId,
|
||||
IpAddress = ip,
|
||||
Port = port,
|
||||
Credentials = new MqttCredential(name, pwd), // 设置了用户名和密码
|
||||
});
|
||||
|
||||
OperateResult connect = mqttClient.ConnectServer();
|
||||
if (connect.IsSuccess)
|
||||
{
|
||||
LoggerHelp.WriteMqtt("MQTT 连接服务器成功");
|
||||
}
|
||||
else
|
||||
{
|
||||
LoggerHelp.WriteMqtt("MQTT 无法连接到服务器");
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
LoggerHelp.WriteError($"MQTT 无法连接到服务器: {err.Message}");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 发布信息
|
||||
/// </summary>
|
||||
/// <param name="topic"></param>
|
||||
public void PublishMessage(string topic, string Message)
|
||||
{
|
||||
try
|
||||
{
|
||||
OperateResult result = mqttClient.PublishMessage(new MqttApplicationMessage()
|
||||
{
|
||||
Topic = topic, // 主题
|
||||
QualityOfServiceLevel = MqttQualityOfServiceLevel.AtMostOnce, // 消息等级
|
||||
Payload = Encoding.UTF8.GetBytes(Message), // 数据
|
||||
Retain = false, // 是否保留
|
||||
});
|
||||
if (result.IsSuccess)
|
||||
{
|
||||
LoggerHelp.WriteMqtt($"发送消息到主题 [{topic}]: {Message}");
|
||||
}
|
||||
else
|
||||
{
|
||||
LoggerHelp.WriteMqtt($"发送消息到主题 [{topic}] 失败: {result.Message}");
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
LoggerHelp.WriteError($"MQTT 无法连接到服务器: {err.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 订阅主题
|
||||
/// </summary>
|
||||
/// <param name="topic"></param>
|
||||
public void SubscribeMessage(string Topic)
|
||||
{
|
||||
try
|
||||
{
|
||||
//mqttClient.OnMqttMessageReceived += MqttClient_OnMqttMessageReceived; // 调用一次即可
|
||||
OperateResult Result = mqttClient.SubscribeMessage(Topic); // 订阅A的主题
|
||||
if (Result.IsSuccess)
|
||||
{
|
||||
LoggerHelp.WriteMqtt($"订阅成功[{Topic}]");
|
||||
}
|
||||
else
|
||||
{
|
||||
LoggerHelp.WriteMqtt($"订阅失败[{Topic}]");
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
LoggerHelp.WriteError($"订阅失败[{err.Message}]");
|
||||
}
|
||||
}
|
||||
|
||||
private static void MqttClient_OnMqttMessageReceived(MqttClient client, MqttApplicationMessage message)
|
||||
{
|
||||
LoggerHelp.WriteMqtt($"收到服务器信息[{message.ToString()}]");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 拼接进出站json
|
||||
/// </summary>
|
||||
/// <param name="action"></param>
|
||||
/// <returns></returns>
|
||||
public string EnterandExitMessge(string action)
|
||||
{
|
||||
string messgeJson = string.Empty;
|
||||
try
|
||||
{
|
||||
EnterandExit enterandExit = new EnterandExit()
|
||||
{
|
||||
bu_id = BU_id,
|
||||
district_id = District_id,
|
||||
factory_id = Factory_id,
|
||||
production_line_id = Production_line_id,
|
||||
production_processes_id = "",
|
||||
work_center_id = Work_center_id,
|
||||
station_id = "",
|
||||
device_name = Device_name,
|
||||
action = action,
|
||||
action_time = Action_time,
|
||||
};
|
||||
var messageJson = JsonConvert.SerializeObject(enterandExit, new JsonSerializerSettings
|
||||
{
|
||||
NullValueHandling = NullValueHandling.Ignore,
|
||||
Formatting = Formatting.None
|
||||
});
|
||||
messgeJson = messageJson;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LoggerHelp.WriteError($"方法:上传MQTTServer数据,上传失败: {ex.Message}", ex);
|
||||
}
|
||||
return messgeJson;
|
||||
}
|
||||
/// <summary>
|
||||
/// 拼接采集项数据
|
||||
/// </summary>
|
||||
/// <param name="cPQCPTDate"></param>
|
||||
/// <returns></returns>
|
||||
public string CollectionMessge(CPQCPTDate cPQCPTDate)
|
||||
{
|
||||
string messgejson = string.Empty;
|
||||
try
|
||||
{
|
||||
CollectionUpload enterandExit = new CollectionUpload()
|
||||
{
|
||||
bu_id = BU_id,
|
||||
district_id = District_id,
|
||||
factory_id = Factory_id,
|
||||
production_line_id = Production_line_id,
|
||||
production_processes_id = "",
|
||||
work_center_id = Work_center_id,
|
||||
station_id = "",
|
||||
device_name = Device_name,
|
||||
taglist = new List<Collection>
|
||||
{
|
||||
new Collection
|
||||
{
|
||||
device_time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
|
||||
collection_items = new Dictionary<string, string>
|
||||
{
|
||||
{"CTP_PreWeighing_Value",cPQCPTDate.CTP_PreWeighing_Value },
|
||||
{"CTP_Liquid_Retention_Value",cPQCPTDate.CTP_Liquid_Retention_Value },
|
||||
{"CTP_Filling_Value",cPQCPTDate.CTP_Filling_Value},
|
||||
{"CTP_Liquid_Loss_Value", cPQCPTDate.CTP_Liquid_Loss_Value},
|
||||
{"CTP_Helium_Filling_Value",cPQCPTDate.CTP_Helium_Filling_Value},
|
||||
{"CTP_Belljar_Vacuum_Value",cPQCPTDate.CTP_Belljar_Vacuum_Value},
|
||||
{"CTP_Belljar_Vacuum_Time",cPQCPTDate.CTP_Belljar_Vacuum_Time},
|
||||
{"CTP_Belljar_HighPressure_Value",cPQCPTDate.CTP_Belljar_HighPressure_Value},
|
||||
{"CTP_Belljar_HighPressure_Time",cPQCPTDate.CTP_Belljar_HighPressure_Time},
|
||||
{"CTP_Belljar_Cycles_Number",cPQCPTDate.CTP_Belljar_Cycles_Number},
|
||||
{"CTP_Pre_Helium_Value",cPQCPTDate.CTP_Pre_Helium_Value},
|
||||
{"CTP_Post_Helium_Value",cPQCPTDate.CTP_Post_Helium_Value},
|
||||
{"CTP_Flat_Pressure",cPQCPTDate.CTP_Flat_Pressure},
|
||||
{"CTP_Cell_Thickness_Pressure",cPQCPTDate.CTP_Cell_Thickness_Pressure},
|
||||
{"CTQ_PostWeighing_Value",cPQCPTDate.CTQ_PostWeighing_Value},
|
||||
{"CTQ_Cell_Thickness",cPQCPTDate.CTQ_Cell_Thickness},
|
||||
{"CTQ_Finalpress_Rubber_Height",cPQCPTDate.CTQ_Finalpress_Rubber_Height},
|
||||
{"CTP_PreInjection_Pressure",cPQCPTDate.CTP_PreInjection_Pressure},
|
||||
{"CTQ_Electrolyte_Inventory",cPQCPTDate.CTQ_Electrolyte_Inventory},
|
||||
{"CTP_PreNailing_Stroke",cPQCPTDate.CTP_PreNailing_Stroke},
|
||||
{"CTP_PreHelium_Vacuum_Pressure",cPQCPTDate.CTP_PreHelium_Vacuum_Pressure},
|
||||
{"CTP_FinalNailing_Stroke",cPQCPTDate.CTP_FinalNailing_Stroke},
|
||||
{"CTQ_Finalpress_Rubber_Thickness",cPQCPTDate.CTQ_Finalpress_Rubber_Thickness},
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
var messageJson = JsonConvert.SerializeObject(enterandExit, new JsonSerializerSettings
|
||||
{
|
||||
NullValueHandling = NullValueHandling.Ignore,
|
||||
Formatting = Formatting.None
|
||||
});
|
||||
messgejson = messageJson;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LoggerHelp.WriteError($"生成Json数据失败: {ex.Message}", ex);
|
||||
}
|
||||
return messgejson;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace JinYuan.Helper
|
||||
{
|
||||
/// <summary>
|
||||
/// 流读写IO辅助类
|
||||
/// </summary>
|
||||
public class StreamIOHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 写入文件字节流
|
||||
/// </summary>
|
||||
/// <param name="stream">待写入的流</param>
|
||||
/// <param name="bys">写入的文件流</param>
|
||||
/// <param name="isCloseStream">是否在操作后关闭流</param>
|
||||
/// <returns>是否写入成功:true:成功;false:失败</returns>
|
||||
public static bool WriteStreamBytes(Stream stream, byte[] bys, bool isCloseStream = false)
|
||||
{
|
||||
//确保文件支持写入
|
||||
if (stream == null || !stream.CanWrite)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
//单次写入的长度
|
||||
int perWriteByteLen = 1024 * 1024;
|
||||
//单次读取的索引下标
|
||||
int startIndex = 0;
|
||||
//写入的总长度
|
||||
int allLen = bys.Length;
|
||||
while (startIndex < allLen && startIndex >= 0)
|
||||
{
|
||||
stream.Write(bys, startIndex, (startIndex > allLen - perWriteByteLen) ? allLen - startIndex : perWriteByteLen);
|
||||
startIndex += perWriteByteLen;
|
||||
}
|
||||
stream.Flush();
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message + "\t" + ex.StackTrace);
|
||||
return false;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (isCloseStream)
|
||||
{
|
||||
CloseStream(stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 读取文件字节流
|
||||
/// 读取异常或者文件不存在时返回null;
|
||||
/// </summary>
|
||||
/// <param name="stream">读取的字节流</param>
|
||||
/// <param name="isCloseStream">是否在操作后关闭流</param>
|
||||
/// <returns>读取到的文件字节流</returns>
|
||||
public static byte[] ReadStreamBytes(Stream stream, bool isCloseStream = false)
|
||||
{
|
||||
//检测是否支持读操作
|
||||
if (stream == null || !stream.CanRead || stream.Length == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
byte[] resBytes = new byte[stream.Length];
|
||||
int allLen = (int)stream.Length;
|
||||
//单次读取的长度,1024字节即1kb,1024*1024=1M
|
||||
int perReadByteLen = 1024 * 1024;
|
||||
//单次读取的索引下标
|
||||
int startIndex = 0;
|
||||
//单次读取到的长度
|
||||
int readLen = 0;
|
||||
while ((readLen = stream.Read(resBytes, startIndex, (startIndex > allLen - perReadByteLen) ? allLen - startIndex : perReadByteLen)) > 0)
|
||||
{
|
||||
startIndex += readLen;
|
||||
}
|
||||
if (startIndex == allLen)
|
||||
{
|
||||
return resBytes;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ArrayHelper.GetSubArray<byte>(resBytes, 0, startIndex);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message + "\t" + ex.StackTrace);
|
||||
return null;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (isCloseStream)
|
||||
{
|
||||
CloseStream(stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 关闭流
|
||||
/// </summary>
|
||||
/// <param name="fileInfo"></param>
|
||||
public static void CloseStream(Stream fileInfo)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (fileInfo != null)
|
||||
fileInfo.Dispose();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message + "\t" + ex.StackTrace);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace JinYuan.Helper
|
||||
{
|
||||
/// <summary>
|
||||
/// 字符串加密解密类
|
||||
/// </summary>
|
||||
public class StringSecurityHelper
|
||||
{
|
||||
private static string md5Begin = "Hello";
|
||||
private static string md5End = "World";
|
||||
|
||||
#region SHA1 加密
|
||||
|
||||
/// <summary>
|
||||
/// 使用SHA1加密字符串。
|
||||
/// </summary>
|
||||
/// <param name="inputString">输入字符串。</param>
|
||||
/// <returns>加密后的字符串。(40个字符)</returns>
|
||||
public static string SHA1Encrypt(string inputString)
|
||||
{
|
||||
SHA1CryptoServiceProvider sha1 = new SHA1CryptoServiceProvider();
|
||||
byte[] encryptedBytes = sha1.ComputeHash(Encoding.ASCII.GetBytes(inputString));
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < encryptedBytes.Length; i++)
|
||||
{
|
||||
sb.AppendFormat("{0:x2}", encryptedBytes[i]);
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DES 加密/解密
|
||||
|
||||
private static byte[] key = Encoding.ASCII.GetBytes("uiertysd");
|
||||
private static byte[] iv = Encoding.ASCII.GetBytes("99008855");
|
||||
|
||||
/// <summary>
|
||||
/// DES加密。
|
||||
/// </summary>
|
||||
/// <param name="inputString">输入字符串。</param>
|
||||
/// <returns>加密后的字符串。</returns>
|
||||
public static string DESEncrypt(string inputString)
|
||||
{
|
||||
MemoryStream ms = null;
|
||||
CryptoStream cs = null;
|
||||
StreamWriter sw = null;
|
||||
|
||||
DESCryptoServiceProvider des = new DESCryptoServiceProvider();
|
||||
try
|
||||
{
|
||||
ms = new MemoryStream();
|
||||
cs = new CryptoStream(ms, des.CreateEncryptor(key, iv), CryptoStreamMode.Write);
|
||||
sw = new StreamWriter(cs);
|
||||
sw.Write(inputString);
|
||||
sw.Flush();
|
||||
cs.FlushFinalBlock();
|
||||
return Convert.ToBase64String(ms.GetBuffer(), 0, (int)ms.Length);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (sw != null) sw.Close();
|
||||
if (cs != null) cs.Close();
|
||||
if (ms != null) ms.Close();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// DES解密。
|
||||
/// </summary>
|
||||
/// <param name="inputString">输入字符串。</param>
|
||||
/// <returns>解密后的字符串。</returns>
|
||||
public static string DESDecrypt(string inputString)
|
||||
{
|
||||
MemoryStream ms = null;
|
||||
CryptoStream cs = null;
|
||||
StreamReader sr = null;
|
||||
|
||||
DESCryptoServiceProvider des = new DESCryptoServiceProvider();
|
||||
try
|
||||
{
|
||||
ms = new MemoryStream(Convert.FromBase64String(inputString));
|
||||
cs = new CryptoStream(ms, des.CreateDecryptor(key, iv), CryptoStreamMode.Read);
|
||||
sr = new StreamReader(cs);
|
||||
return sr.ReadToEnd();
|
||||
}
|
||||
catch
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (sr != null) sr.Close();
|
||||
if (cs != null) cs.Close();
|
||||
if (ms != null) ms.Close();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// MD5加密
|
||||
/// </summary>
|
||||
/// <param name="str">MD5加密前字符串</param>
|
||||
/// <returns>MD5加密后字符串</returns>
|
||||
public static string MD5Encrypt(string str)
|
||||
{
|
||||
str = string.Concat(md5Begin, str, md5End);
|
||||
MD5 md5 = new MD5CryptoServiceProvider();
|
||||
byte[] fromData = Encoding.Unicode.GetBytes(str);
|
||||
byte[] targetData = md5.ComputeHash(fromData);
|
||||
string md5String = string.Empty;
|
||||
foreach (var b in targetData)
|
||||
md5String += b.ToString("x2");
|
||||
return md5String;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
|
||||
namespace JinYuan.Helper
|
||||
{
|
||||
/// <summary>
|
||||
/// 定时器重置时间间隔,定时器执行未超间隔则设置剩余时间后再次触发,超时则立即触发
|
||||
/// </summary>
|
||||
public class TimerReset : IDisposable
|
||||
{
|
||||
private Timer timer;
|
||||
private DateTime nextTime;
|
||||
|
||||
/// <summary>
|
||||
/// 使用using语句,在定时器TimerCallback中使用
|
||||
/// using语句块内为时间到时的执行代码,dispose计算使用的时间,来重设下次触发时间
|
||||
/// </summary>
|
||||
/// <param name="tim">定时器</param>
|
||||
/// <param name="ep">时间间隔</param>
|
||||
public TimerReset(Timer tim, int ep)
|
||||
{
|
||||
timer = tim;
|
||||
nextTime = DateTime.Now.AddMilliseconds(ep);//设置下次执行时间
|
||||
}
|
||||
public void Dispose()
|
||||
{
|
||||
//执行完后,重新设置定时器下次执行时间.
|
||||
TimeSpan timeout = nextTime.Subtract(DateTime.Now);
|
||||
if (timeout < TimeSpan.Zero)
|
||||
{
|
||||
timeout = TimeSpan.Zero;
|
||||
}
|
||||
|
||||
timer.Change(timeout, Timeout.InfiniteTimeSpan);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
|
||||
namespace JinYuan.Helper
|
||||
{
|
||||
public class TxtHelper
|
||||
{
|
||||
static ReaderWriterLockSlim sucessLogWriteLockSlim = new ReaderWriterLockSlim();
|
||||
|
||||
/// <summary>
|
||||
/// 写入TEXT文本
|
||||
/// </summary>
|
||||
/// <param name="fullName">文件名</param>
|
||||
/// <param name="content">内容</param>
|
||||
/// <returns>保存结果</returns>
|
||||
public static bool WriteTxt(string fullName, string content)
|
||||
{
|
||||
FileStream fs = null;
|
||||
StreamWriter sw = null;
|
||||
|
||||
try
|
||||
{
|
||||
string directory = fullName.Substring(0, fullName.LastIndexOf('\\'));
|
||||
if (!Directory.Exists(directory))
|
||||
{
|
||||
Directory.CreateDirectory(directory);
|
||||
}
|
||||
|
||||
sucessLogWriteLockSlim.EnterWriteLock();//加锁防止抢占
|
||||
if (!File.Exists(fullName))
|
||||
{
|
||||
fs = new FileStream(fullName, FileMode.Create, FileAccess.Write);
|
||||
sw = new StreamWriter(fs, Encoding.UTF8);
|
||||
}
|
||||
else
|
||||
{
|
||||
fs = new FileStream(fullName, FileMode.Append, FileAccess.Write);
|
||||
sw = new StreamWriter(fs, Encoding.UTF8);
|
||||
}
|
||||
|
||||
sw.WriteLine(content);
|
||||
|
||||
sw.Close();
|
||||
fs.Close();
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
sw?.Close();
|
||||
fs?.Close();
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
sucessLogWriteLockSlim.ExitWriteLock();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,230 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace JinYuan.Helper
|
||||
{
|
||||
/// <summary>
|
||||
/// 序列化辅助类
|
||||
/// </summary>
|
||||
public class XmlHelper
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 二进制方式的序列化
|
||||
/// </summary>
|
||||
/// <typeparam name="T">类型</typeparam>
|
||||
/// <param name="obj">序列化对象</param>
|
||||
/// <returns>序列化后的内存</returns>
|
||||
public static Stream BinarySerialize<T>(T obj)
|
||||
{
|
||||
MemoryStream serMs = new MemoryStream();
|
||||
IFormatter iBinaryFormatter = new BinaryFormatter();
|
||||
iBinaryFormatter.Serialize(serMs, obj);
|
||||
if (serMs.Length > 0)
|
||||
serMs.Position = 0;
|
||||
return serMs;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 二进制方式的反序列化
|
||||
/// </summary>
|
||||
/// <typeparam name="T">类型</typeparam>
|
||||
/// <param name="ms">待序列化的内存</param>
|
||||
/// <returns>反序列化后的对象</returns>
|
||||
public static T BinaryDeserializer<T>(Stream ms) where T : class
|
||||
{
|
||||
T res = default(T);
|
||||
if (ms.Length > 0)
|
||||
ms.Position = 0;
|
||||
IFormatter iBinaryFormatter = new BinaryFormatter();
|
||||
res = iBinaryFormatter.Deserialize(ms) as T;
|
||||
return res;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Xml方式的序列化
|
||||
/// </summary>
|
||||
/// <typeparam name="T">类型</typeparam>
|
||||
/// <param name="obj">序列化对象</param>
|
||||
/// <returns>序列化后的内存</returns>
|
||||
public static Stream XmlSerialize<T>(T obj)
|
||||
{
|
||||
MemoryStream serMs = new MemoryStream();
|
||||
XmlSerializer ser = new XmlSerializer(obj.GetType());
|
||||
try
|
||||
{
|
||||
ser.Serialize(serMs, obj);
|
||||
if (serMs.Length > 0)
|
||||
serMs.Position = 0;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//LogHelper.Current.WriteEx(string.Format("序列化对象异常:{0}", obj.ToString()), ex);
|
||||
return null;
|
||||
}
|
||||
|
||||
return serMs;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Xml方式的序列化
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
/// <returns></returns>
|
||||
public static Stream XmlSerializeObj(object obj)
|
||||
{
|
||||
MemoryStream serMs = new MemoryStream();
|
||||
XmlSerializer ser = new XmlSerializer(obj.GetType());
|
||||
ser.Serialize(serMs, obj);
|
||||
if (serMs.Length > 0)
|
||||
serMs.Position = 0;
|
||||
return serMs;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Xml方式的反序列化
|
||||
/// </summary>
|
||||
/// <typeparam name="T">类型</typeparam>
|
||||
/// <param name="ms">待序列化的内存</param>
|
||||
/// <returns>反序列化后的对象</returns>
|
||||
public static T XmlDeserializer<T>(Stream ms) where T : class
|
||||
{
|
||||
T res = default(T);
|
||||
if (ms.Length > 0)
|
||||
ms.Position = 0;
|
||||
XmlSerializer ser = new XmlSerializer(typeof(T));
|
||||
res = ser.Deserialize(ms) as T;
|
||||
return res;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将List集合保存成XML文档
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="lstT"></param>
|
||||
/// <param name="filePath"></param>
|
||||
public static bool SaveListToXML<T>(List<T> lstT, string filePath)
|
||||
{
|
||||
try
|
||||
{
|
||||
FileInfo fInfo = new FileInfo(filePath);
|
||||
if (!fInfo.Directory.Exists)
|
||||
{
|
||||
fInfo.Directory.Create();
|
||||
}
|
||||
Stream stream = XmlSerialize(lstT);
|
||||
if (stream != null)
|
||||
{
|
||||
byte[] bs = StreamIOHelper.ReadStreamBytes(stream);
|
||||
using (FileStream fs = new FileStream(filePath, FileMode.Create))
|
||||
{
|
||||
fs.Write(bs, 0, bs.Length);
|
||||
}
|
||||
stream.Close();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//LogHelper.Current.WriteEx("将List保存成XML文档发生异常", ex, EnumLogType.Error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 读取XML信息成List集合
|
||||
/// </summary>
|
||||
public static List<T> ReadXMLToList<T>(string filePath)
|
||||
{
|
||||
try
|
||||
{
|
||||
FileInfo fInfo = new FileInfo(filePath);
|
||||
if (!fInfo.Directory.Exists)
|
||||
{
|
||||
fInfo.Directory.Create();
|
||||
}
|
||||
using (FileStream fs = new FileStream(filePath, FileMode.Open))
|
||||
{
|
||||
var crList = XmlDeserializer<List<T>>(fs);
|
||||
return crList;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//LogHelper.Current.WriteEx("读取XML转换成List异常", ex, EnumLogType.Error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将类的实例保存成XML文档
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="t"></param>
|
||||
/// <param name="filePath"></param>
|
||||
/// <returns></returns>
|
||||
public static bool SaveModelToXML<T>(T t, string filePath) where T : class
|
||||
{
|
||||
try
|
||||
{
|
||||
FileInfo fInfo = new FileInfo(filePath);
|
||||
if (!fInfo.Directory.Exists)
|
||||
{
|
||||
fInfo.Directory.Create();
|
||||
}
|
||||
using (FileStream fs = new FileStream(filePath, FileMode.Create))
|
||||
{
|
||||
using (Stream stream = XmlSerialize<T>(t))
|
||||
{
|
||||
byte[] bs = StreamIOHelper.ReadStreamBytes(stream);
|
||||
fs.Write(bs, 0, bs.Length);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//LogHelper.Current.WriteEx("将Class保存成XML文档发生异常", ex, EnumLogType.Error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将XML文档中数据读取到类的实例中
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="filePath"></param>
|
||||
/// <returns></returns>
|
||||
public static T ReadXMLToModel<T>(string filePath) where T : class
|
||||
{
|
||||
try
|
||||
{
|
||||
FileInfo fInfo = new FileInfo(filePath);
|
||||
if (!fInfo.Directory.Exists)
|
||||
{
|
||||
fInfo.Directory.Create();
|
||||
}
|
||||
using (FileStream fs = new FileStream(filePath, FileMode.Open))
|
||||
{
|
||||
T model = XmlDeserializer<T>(fs);
|
||||
return model;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//LogHelper.Current.WriteEx("读取XML转换成实例异常", ex, EnumLogType.Error);
|
||||
return default(T);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.1.2" newVersion="4.0.1.2" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.1.4.0" newVersion="4.1.4.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Text.Encoding.CodePages" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Security.Cryptography.Xml" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-6.0.0.1" newVersion="6.0.0.1" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
||||
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="BouncyCastle.Cryptography" version="2.2.1" targetFramework="net472" />
|
||||
<package id="CsvHelper" version="30.0.1" targetFramework="net472" />
|
||||
<package id="Enums.NET" version="4.0.1" targetFramework="net472" />
|
||||
<package id="MathNet.Numerics.Signed" version="4.15.0" targetFramework="net472" />
|
||||
<package id="Microsoft.Bcl.AsyncInterfaces" version="1.0.0" targetFramework="net472" />
|
||||
<package id="Microsoft.Bcl.HashCode" version="1.0.0" targetFramework="net472" />
|
||||
<package id="Microsoft.CSharp" version="4.3.0" targetFramework="net472" />
|
||||
<package id="Microsoft.IO.RecyclableMemoryStream" version="2.3.2" targetFramework="net472" />
|
||||
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net472" />
|
||||
<package id="NLog" version="6.0.2" targetFramework="net472" />
|
||||
<package id="NPOI" version="2.6.1" targetFramework="net472" />
|
||||
<package id="SharpZipLib" version="1.3.3" targetFramework="net472" />
|
||||
<package id="SixLabors.Fonts" version="1.0.0" targetFramework="net472" />
|
||||
<package id="SixLabors.ImageSharp" version="2.1.4" targetFramework="net472" />
|
||||
<package id="System.Buffers" version="4.5.1" targetFramework="net472" />
|
||||
<package id="System.Configuration.ConfigurationManager" version="6.0.0" targetFramework="net472" />
|
||||
<package id="System.Memory" version="4.5.5" targetFramework="net472" />
|
||||
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net472" />
|
||||
<package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net472" />
|
||||
<package id="System.Security.AccessControl" version="6.0.0" targetFramework="net472" />
|
||||
<package id="System.Security.Cryptography.Xml" version="6.0.1" targetFramework="net472" />
|
||||
<package id="System.Security.Permissions" version="6.0.0" targetFramework="net472" />
|
||||
<package id="System.Security.Principal.Windows" version="5.0.0" targetFramework="net472" />
|
||||
<package id="System.Text.Encoding.CodePages" version="6.0.0" targetFramework="net472" />
|
||||
<package id="System.Threading.Tasks.Extensions" version="4.5.2" targetFramework="net472" />
|
||||
</packages>
|
||||
@@ -0,0 +1,21 @@
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace JinYuan.MES.Enums
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public enum MesResType
|
||||
{
|
||||
[Description("停线")]
|
||||
A = 1,
|
||||
[Description("排出")]
|
||||
B = 2,
|
||||
[Description("警示")]
|
||||
C = 3,
|
||||
[Description("OK值")]
|
||||
D = 4,
|
||||
[Description("未知的结果")]
|
||||
UnKnow = 99999
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace JinYuan.MES.Enums
|
||||
{
|
||||
/// <summary>
|
||||
/// MES上传的三种类型
|
||||
/// </summary>
|
||||
public enum MesUploadType
|
||||
{
|
||||
/// <summary>
|
||||
/// 单进整出
|
||||
/// </summary>
|
||||
[Description("DZ")]
|
||||
DZ = 1,
|
||||
/// <summary>
|
||||
/// 整进整出
|
||||
/// </summary>
|
||||
[Description("ZZ")]
|
||||
ZZ = 2,
|
||||
/// <summary>
|
||||
/// 单进单出
|
||||
/// </summary>
|
||||
[Description("DD")]
|
||||
DD = 3,
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,232 @@
|
||||
using JinYuan.MES.Enums;
|
||||
using JinYuan.MES.Models;
|
||||
using JinYuan.Models;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace JinYuan.MES
|
||||
{
|
||||
/// <summary>
|
||||
/// MES接口
|
||||
/// </summary>
|
||||
public interface IMes
|
||||
{
|
||||
/// <summary>
|
||||
/// 登录接口
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="siteCode"></param>
|
||||
/// <param name="lineCode"></param>
|
||||
/// <param name="equipNum"></param>
|
||||
/// <param name="userName"></param>
|
||||
/// <param name="passWord"></param>
|
||||
/// <param name="msg"></param>
|
||||
/// <returns></returns>
|
||||
bool LoginEnyity(string url, string siteCode, string lineCode, string equipNum, string userName, string passWord, string UserCardID, ref string resJson);
|
||||
/// <summary>
|
||||
/// 设备参数设定值请求接口
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="equipNum"></param>
|
||||
/// <param name="siteCode"></param>
|
||||
/// <param name="lineCode"></param>
|
||||
/// <param name="materialCode"></param>
|
||||
/// <param name="userName"></param>
|
||||
/// <param name="resJson"></param>
|
||||
/// <returns></returns>
|
||||
ParamReturnData GetParamSetRequest(string url, string siteCode, string lineCode, string equipNum, string materialCode, string userName, ref string resJson);
|
||||
|
||||
/// <summary>
|
||||
/// 参数设定值变更接口
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="siteCode"></param>
|
||||
/// <param name="lineCode"></param>
|
||||
/// <param name="equipNum"></param>
|
||||
/// <param name="materialCode"></param>
|
||||
/// <param name="userName"></param>
|
||||
/// <param name="paramChangeItems"></param>
|
||||
/// <param name="msg"></param>
|
||||
/// <returns></returns>
|
||||
bool ParamChange(string url, string siteCode, string lineCode, string equipNum, string materialCode, string userName, List<TagListItem> paramChangeItems, ref string resJson);
|
||||
|
||||
/// <summary>
|
||||
/// 单个上传(只上传条码,不上传卷芯码)
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="siteCode"></param>
|
||||
/// <param name="lineCode"></param>
|
||||
/// <param name="equipNum"></param>
|
||||
/// <param name="materialCode"></param>
|
||||
/// <param name="userName"></param>
|
||||
/// <param name="BarCode"></param>
|
||||
/// <param name="resJson"></param>
|
||||
/// <param name="mesResType"></param>
|
||||
/// <returns></returns>
|
||||
bool SingleCellInStation(string url, string siteCode, string lineCode,string modelName, string equipNum, string materialCode, string userName, string BarCode, ref string MesMessage, ref MesResType mesResType);
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 复投单个上传(只上传条码,不上传卷芯码)
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="siteCode"></param>
|
||||
/// <param name="lineCode"></param>
|
||||
/// <param name="equipNum"></param>
|
||||
/// <param name="materialCode"></param>
|
||||
/// <param name="userName"></param>
|
||||
/// <param name="BarCode"></param>
|
||||
/// <param name="resJson"></param>
|
||||
/// <param name="mesResType"></param>
|
||||
/// <returns></returns>
|
||||
bool SingleFTCellInStation(string url, string siteCode, string lineCode, string equipNum, string materialCode, string userName, string BarCode, ref string MesMessage, ref MesResType mesResType);
|
||||
|
||||
/// <summary>
|
||||
/// 电芯进站接口(多个)
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="siteCode"></param>
|
||||
/// <param name="lineCode"></param>
|
||||
/// <param name="equipNum"></param>
|
||||
/// <param name="materialCode"></param>
|
||||
/// <param name="userName"></param>
|
||||
/// <param name="code"></param>
|
||||
/// <param name="scanRes"></param>
|
||||
/// <param name="msg"></param>
|
||||
/// <param name="mesResType"></param>
|
||||
/// <returns></returns>
|
||||
bool ManyCellInStation(string url, string siteCode, string lineCode, string equipNum, string materialCode, string userName, List<string> listBar, ref List<string> MesMessage, ref List<MesResType> mesResType);
|
||||
|
||||
/// <summary>
|
||||
/// 电芯进站接口(多个)
|
||||
/// </summary>
|
||||
/// <param name="list"></param>
|
||||
/// <param name="isWeldingSpotlssue"></param>
|
||||
/// <param name="MesMessage"></param>
|
||||
/// <param name="mesResType"></param>
|
||||
/// <returns></returns>
|
||||
bool OutboundInformations(string url, string siteCode, string lineCode, string equipNum, string modelName, string materialCode, string userName, BGearEntity listBar, ref string MesMessage, ref MesResType mesResType, List<string> NGcodeList,List<string> ngMessage);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 产品过程加工参数接口
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="siteCode"></param>
|
||||
/// <param name="userName"></param>
|
||||
/// <param name="equipNum"></param>
|
||||
/// <param name="lineCode"></param>
|
||||
/// <param name="materialCode"></param>
|
||||
/// <param name="unloadType"></param>
|
||||
/// <param name="productProcessParam"></param>
|
||||
/// <param name="resJson"></param>
|
||||
/// <returns></returns>
|
||||
bool ProductProcessParam(string url, string siteCode, string userName, string equipNum, string lineCode, string materialCode, MesUploadType unloadType, List<ProductProcessParam> productProcessParam, ref string resJson);
|
||||
|
||||
/// <summary>
|
||||
/// 产品结果加工参数接口
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="equipNum"></param>
|
||||
/// <param name="siteCode"></param>
|
||||
/// <param name="lineCode"></param>
|
||||
/// <param name="userName"></param>
|
||||
/// <param name="materialCode"></param>
|
||||
/// <param name="tagDataVOListItem"></param>
|
||||
/// <param name="identificationListItem"></param>
|
||||
/// <param name="unloadType"></param>
|
||||
/// <param name="resJson"></param>
|
||||
/// <returns></returns>
|
||||
bool ProducResultParam(string url, string siteCode, string lineCode, string equipNum, string materialCode, string userName, BGearEntity m, MesUploadType unloadType, ref string resJson);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 单电芯出站
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="siteCode"></param>
|
||||
/// <param name="userName"></param>
|
||||
/// <param name="equipNum"></param>
|
||||
/// <param name="lineCode"></param>
|
||||
/// <param name="materialCode"></param>
|
||||
/// <param name="m"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="mesage"></param>
|
||||
/// <param name="mesResType"></param>
|
||||
/// <returns></returns>
|
||||
bool SingleCellOutStation(string url, string siteCode, string lineCode, string equipNum, string materialCode, string userName, BGearEntity m, int type, string materialLotCodeLocator, ref string mesage, ref MesResType mesResType);
|
||||
|
||||
/// <summary>
|
||||
/// 多电芯出站接口
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="siteCode"></param>
|
||||
/// <param name="userName"></param>
|
||||
/// <param name="equipNum"></param>
|
||||
/// <param name="lineCode"></param>
|
||||
/// <param name="materialCode"></param>
|
||||
/// <param name="cellOutStation"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="resJson"></param>
|
||||
/// <param name="mesResType"></param>
|
||||
/// <returns></returns>
|
||||
//bool ManyCellOutStation(string url, string siteCode, string lineCode, string equipNum, string materialCode, string userName, List<BGearEntity> m, int type, string materialLotCodeLocator, ref List<string> MesMessage, ref List<MesResType> mesResType);
|
||||
|
||||
/// <summary>
|
||||
/// 设备运行状态接口
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="equipNum"></param>
|
||||
/// <param name="siteCode"></param>
|
||||
/// <param name="lineCode"></param>
|
||||
/// <param name="statusCode"></param>
|
||||
/// <param name="materialCode"></param>
|
||||
/// <param name="userName"></param>
|
||||
/// <param name="faultCodes"></param>
|
||||
/// <param name="guid"></param>
|
||||
/// <param name="resJson"></param>
|
||||
/// <returns></returns>
|
||||
bool UploadEquStatus(string url, string siteCode, string lineCode, string equipNum, string materialCode, string userName, string guid, string statusCode, List<FaultCodeList> faultCodes, ref string resJson);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 设备报警接口
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="equipNum"></param>
|
||||
/// <param name="siteCode"></param>
|
||||
/// <param name="lineCode"></param>
|
||||
/// <param name="userName"></param>
|
||||
/// <param name="materialCode"></param>
|
||||
/// <param name="alarmLineListItem"></param>
|
||||
/// <param name="guid"></param>
|
||||
/// <param name="msg"></param>
|
||||
/// <returns></returns>
|
||||
bool UploadEquAlarm(string url, string siteCode, string lineCode, string equipNum, string materialCode, string userName, List<AlarmData> alarmObj, string guid, ref string msg);
|
||||
|
||||
/// <summary>
|
||||
/// 能耗数据上传
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="equipNum"></param>
|
||||
/// <param name="siteCode"></param>
|
||||
/// <param name="lineCode"></param>
|
||||
/// <param name="userName"></param>
|
||||
/// <param name="electricMeterNum"></param>
|
||||
/// <param name="wattrs"></param>
|
||||
/// <param name="msg"></param>
|
||||
/// <returns></returns>
|
||||
bool UploadEquEnergy(string url, string siteCode, string lineCode, string equipNum, string userName, List<string> electricMeterNum, List<WattrMeter> wattrs, ref string msg);
|
||||
|
||||
/// <summary>
|
||||
/// 风速仪数据上传
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="equipNum"></param>
|
||||
/// <param name="antiDustAirSpeedNum"></param>
|
||||
/// <param name="collectData"></param>
|
||||
/// <param name="resJson"></param>
|
||||
/// <returns></returns>
|
||||
bool UploadDeviceCollectData(string url, string equipNum, List<string> antiDustAirSpeedNum, List<float> collectData, ref string msg);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
<?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>{530B6426-08E7-461C-91DC-787F876620FC}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>JinYuan.MES</RootNamespace>
|
||||
<AssemblyName>JinYuan.MES</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<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' ">
|
||||
<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.3\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="Enums\MesResType.cs" />
|
||||
<Compile Include="Enums\MesUploadType.cs" />
|
||||
<Compile Include="IMes.cs" />
|
||||
<Compile Include="MESApiHelper.cs" />
|
||||
<Compile Include="MesDataProcess.cs" />
|
||||
<Compile Include="Models\EqpStatusParam.cs" />
|
||||
<Compile Include="Models\ParamReturnData.cs" />
|
||||
<Compile Include="Models\SingleCellOutStation.cs" />
|
||||
<Compile Include="Models\SingleCellInStation.cs" />
|
||||
<Compile Include="Models\ManyCellInStation.cs" />
|
||||
<Compile Include="Models\ManyCellOutStation.cs" />
|
||||
<Compile Include="Models\LoginEnyity.cs" />
|
||||
<Compile Include="Models\ParamChange.cs" />
|
||||
<Compile Include="Models\ProductProcessParam.cs" />
|
||||
<Compile Include="Models\ProductResultParameters.cs" />
|
||||
<Compile Include="Models\MesResponse.cs" />
|
||||
<Compile Include="Models\UploadAlarmParam.cs" />
|
||||
<Compile Include="Models\UploadDeviceCollectData.cs" />
|
||||
<Compile Include="Models\WattrMeter.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\JinYuan.Helper\JinYuan.Helper.csproj">
|
||||
<Project>{258D0AB7-2B4F-4D8F-A3CD-7A8CB4A85360}</Project>
|
||||
<Name>JinYuan.Helper</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\JinYuan.Models\JinYuan.Models.csproj">
|
||||
<Project>{4C0BCB84-5CD7-4846-8363-C4C10D46E391}</Project>
|
||||
<Name>JinYuan.Models</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -0,0 +1,117 @@
|
||||
using JinYuan.MES.Models;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
|
||||
namespace JinYuan.MES
|
||||
{
|
||||
/// <summary>
|
||||
/// MES接口类
|
||||
/// </summary>
|
||||
public class MESApiHelper
|
||||
{
|
||||
|
||||
static HttpClient httpClient;
|
||||
private static readonly Lazy<HttpClient> _httpClient = new Lazy<HttpClient>(() => new HttpClient());
|
||||
public static HttpClient Instance => _httpClient.Value;
|
||||
|
||||
public MESApiHelper()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public static string WepPostAPIAsync(string url, string strJosnData)
|
||||
{
|
||||
MesResponse mesResponse = new MesResponse();
|
||||
try
|
||||
{
|
||||
StringContent stringContent = new StringContent(strJosnData, Encoding.UTF8, "application/json");
|
||||
string ResponseMessage = new HttpClient()
|
||||
{
|
||||
Timeout = TimeSpan.FromSeconds(3.0)
|
||||
}.PostAsync(url, (HttpContent)stringContent).Result.Content.ReadAsStringAsync().Result;
|
||||
return ResponseMessage;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
mesResponse.success = false;
|
||||
mesResponse.message = ex.Message;
|
||||
return JsonConvert.SerializeObject(mesResponse);
|
||||
}
|
||||
}
|
||||
|
||||
public static string HttpPostJsonAPI(string url, string strJosnData)
|
||||
{
|
||||
MesResponse mesResponse = new MesResponse();
|
||||
try
|
||||
{
|
||||
StringContent stringContent = new StringContent(strJosnData, Encoding.UTF8, "application/json");
|
||||
return new HttpClient()
|
||||
{
|
||||
Timeout = TimeSpan.FromSeconds(5.0)
|
||||
}.PostAsync(url, (HttpContent)stringContent).Result.Content.ReadAsStringAsync().Result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
mesResponse.success = false;
|
||||
mesResponse.message = ex.Message;
|
||||
return JsonConvert.SerializeObject(mesResponse);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="strJosnData"></param>
|
||||
/// <returns></returns>
|
||||
public string WebApiPost(string url, string strJosnData)
|
||||
{
|
||||
MesResponse mesResponse = new MesResponse();
|
||||
try
|
||||
{
|
||||
HttpContent stringContent = new StringContent(strJosnData);
|
||||
stringContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
|
||||
var _response = httpClient.PostAsync(url, stringContent).Result;
|
||||
var _clientResult = _response.Content.ReadAsStringAsync().Result;
|
||||
return _clientResult;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
mesResponse.code = "99";
|
||||
mesResponse.success = false;
|
||||
mesResponse.message = ex.Message;
|
||||
return JsonConvert.SerializeObject(mesResponse);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 同步上传
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="json"></param>
|
||||
/// <returns></returns>
|
||||
public static string WebApiPostTranafer(string url, string json)
|
||||
{
|
||||
try
|
||||
{
|
||||
byte[] bytes = Encoding.UTF8.GetBytes(json);
|
||||
WebClient client = new WebClient();
|
||||
client.Headers.Add("Content-type", "application/json");
|
||||
client.Headers.Add("ContentLength", json.Length.ToString());
|
||||
Encoding enc = Encoding.GetEncoding("UTF-8");
|
||||
byte[] responsedata = client.UploadData(url, "Post", bytes);
|
||||
|
||||
string res = enc.GetString(responsedata);
|
||||
return res;
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,122 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace JinYuan.MES.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 设备状态上传接口参数类
|
||||
/// </summary>
|
||||
public class EqpStatusParam
|
||||
{
|
||||
/// <summary>
|
||||
/// 工厂代码
|
||||
/// </summary>
|
||||
public string siteCode { get; set; }
|
||||
/// <summary>
|
||||
/// 产线编号
|
||||
/// </summary>
|
||||
public string lineCode { get; set; }
|
||||
/// <summary>
|
||||
/// 设备编号
|
||||
/// </summary>
|
||||
public string equipNum { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string materialCode { get; set; }
|
||||
/// <summary>
|
||||
/// 员工账号
|
||||
/// </summary>
|
||||
public string userName { get; set; }
|
||||
/// <summary>
|
||||
/// 库位ID
|
||||
/// </summary>
|
||||
public string seatId { get; set; }
|
||||
/// <summary>
|
||||
/// 采集时间
|
||||
/// </summary>
|
||||
public string recordDate { get; set; }
|
||||
/// <summary>
|
||||
/// 设备状态 。Run:(正常运行)、Alert:(故障调试)、Idle:(闲置待机)、Maintain(停止运行)
|
||||
/// </summary>
|
||||
public string statusCode { get; set; }
|
||||
/// <summary>
|
||||
/// 状态变更时间
|
||||
/// </summary>
|
||||
public string uploadTime { get; set; }
|
||||
/// <summary>
|
||||
/// 唯一标识符号
|
||||
/// </summary>
|
||||
public string guid { get; set; }
|
||||
/// <summary>
|
||||
/// 故障代码数组
|
||||
/// </summary>
|
||||
public List<FaultCodeList> faultCodeList { get; set; }
|
||||
}
|
||||
|
||||
public class FaultCodeList
|
||||
{
|
||||
/// <summary>
|
||||
/// 故障代码
|
||||
/// </summary>
|
||||
public string faultCode { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public class SafeEqptStatusParam
|
||||
{
|
||||
/// <summary>
|
||||
/// 工厂代码
|
||||
/// </summary>
|
||||
public string siteCode { get; set; }
|
||||
/// <summary>
|
||||
/// 产线编号
|
||||
/// </summary>
|
||||
public string lineCode { get; set; }
|
||||
/// <summary>
|
||||
/// 设备编号
|
||||
/// </summary>
|
||||
public string equipNum { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string materialCode { get; set; }
|
||||
/// <summary>
|
||||
/// 员工账号
|
||||
/// </summary>
|
||||
public string userName { get; set; }
|
||||
/// <summary>
|
||||
/// 库位ID
|
||||
/// </summary>
|
||||
public string seatId { get; set; }
|
||||
/// <summary>
|
||||
/// 采集时间
|
||||
/// </summary>
|
||||
public string recordDate { get; set; }
|
||||
/// <summary>
|
||||
/// 设备状态 。Run:(正常运行)、Alert:(故障调试)、Idle:(闲置待机)、Maintain(停止运行)
|
||||
/// </summary>
|
||||
public string statusCode { get; set; }
|
||||
/// <summary>
|
||||
/// 状态变更时间
|
||||
/// </summary>
|
||||
public string uploadTime { get; set; }
|
||||
/// <summary>
|
||||
/// 唯一标识符号
|
||||
/// </summary>
|
||||
public string guid { get; set; }
|
||||
public List<SafeEqptCode> safeEqptCodeList { get; set; }
|
||||
}
|
||||
|
||||
public class SafeEqptCode
|
||||
{
|
||||
/// <summary>
|
||||
/// 安全装置编码
|
||||
/// </summary>
|
||||
public string equipNum { get; set; }
|
||||
/// <summary>
|
||||
/// 设备状态
|
||||
/// </summary>
|
||||
public string status { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
namespace JinYuan.MES.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 登录
|
||||
/// </summary>
|
||||
public class LoginEnyity
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string siteCode { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string lineCode { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string equipNum { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string userName { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string passWord { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
|
||||
public string userCardID { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace JinYuan.MES.Models
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 多个电池进站
|
||||
/// </summary>
|
||||
public class ManyCellInStation
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string siteCode { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string lineCode { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string equipNum { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string materialCode { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string userName { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string identification { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string productType { get; set; }
|
||||
/// <summary>
|
||||
/// 电芯条码
|
||||
/// </summary>
|
||||
public List<string> identificationList { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public List<string> containerCodeList { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,171 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace JinYuan.MES.Models
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 多个电池出站
|
||||
/// </summary>
|
||||
public class ManyCellOutStation
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string siteCode { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string lineCode { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string equipNum { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string materialCode { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string userName { get; set; }
|
||||
/// <summary>
|
||||
/// 产品类型
|
||||
/// </summary>
|
||||
public string productType { get; set; }
|
||||
/// <summary>
|
||||
/// 完工数
|
||||
/// </summary>
|
||||
public string completeQty { get; set; }
|
||||
/// <summary>
|
||||
/// 托盘码
|
||||
/// </summary>
|
||||
public string containerCode { get; set; }
|
||||
/// <summary>
|
||||
/// 1:通用出站;2:合芯出站;3:虚拟码替换出站;4:追溯标识替换出站;5:合芯有顶盖出站
|
||||
/// </summary>
|
||||
public int type { get; set; }
|
||||
|
||||
// public List<identiftyList> identiftyList { get; set; }
|
||||
public List<assembleLineList> assembleLineList { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public class assembleLineList
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 产品条码
|
||||
/// </summary>
|
||||
public string identification { get; set; }
|
||||
/// <summary>
|
||||
/// 原材料信息
|
||||
/// </summary>
|
||||
public List<string> materialLotList = new List<string>();
|
||||
/// <summary>
|
||||
/// 原材料条码
|
||||
/// </summary>
|
||||
public string materialLotCode { get; set; }
|
||||
/// <summary>
|
||||
/// 原材料上料位置
|
||||
/// </summary>
|
||||
public string materialLotCodeLocator { get; set; }
|
||||
/// <summary>
|
||||
/// 质量状态
|
||||
/// </summary>
|
||||
public string qualityStatus { get; set; }
|
||||
/// <summary>
|
||||
/// 关联条码
|
||||
/// </summary>
|
||||
public string qrCode { get; set; }
|
||||
/// <summary>
|
||||
/// NG编码
|
||||
/// </summary>
|
||||
public List<string> ngCode = new List<string>();
|
||||
/// <summary>
|
||||
/// NG错误信息
|
||||
/// </summary>
|
||||
public string ngMessage = "";
|
||||
|
||||
}
|
||||
public class identiftyList
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 产品条码
|
||||
/// </summary>
|
||||
public string identification { get; set; }
|
||||
/// <summary>
|
||||
/// 原材料信息
|
||||
/// </summary>
|
||||
public List<string> materialLotList = new List<string>();
|
||||
/// <summary>
|
||||
/// 原材料条码
|
||||
/// </summary>
|
||||
public string materialLotCode { get; set; }
|
||||
/// <summary>
|
||||
/// 原材料上料位置
|
||||
/// </summary>
|
||||
public string materialLotCodeLocator { get; set; }
|
||||
/// <summary>
|
||||
/// 质量状态
|
||||
/// </summary>
|
||||
public string qualityStatus { get; set; }
|
||||
/// <summary>
|
||||
/// 关联条码
|
||||
/// </summary>
|
||||
public string qrCode { get; set; }
|
||||
/// <summary>
|
||||
/// NG编码
|
||||
/// </summary>
|
||||
public List<string> ngCode = new List<string>();
|
||||
/// <summary>
|
||||
/// NG错误信息
|
||||
/// </summary>
|
||||
public string ngMessage = "";
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 产品条码数组
|
||||
/// </summary>
|
||||
//public class IdentiftyListItems
|
||||
//{
|
||||
// /// <summary>
|
||||
// /// 产品条码
|
||||
// /// </summary>
|
||||
// public string identification { get; set; }
|
||||
// /// <summary>
|
||||
// /// 质量状态
|
||||
// /// </summary>
|
||||
// public string qualityStatus { get; set; }
|
||||
// /// <summary>
|
||||
// /// 关联条码
|
||||
// /// </summary>
|
||||
// public string qrCode { get; set; }
|
||||
// /// <summary>
|
||||
// /// NG错误信息
|
||||
// /// </summary>
|
||||
// public string ngMessage { get; set; }
|
||||
// /// <summary>
|
||||
// /// 原材料信息对象组
|
||||
// /// </summary>
|
||||
// public List<MaterialLotListItems> materialLotList { get; set; }
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// 原材料信息对象组
|
||||
///// </summary>
|
||||
//public class MaterialLotListItems
|
||||
//{
|
||||
// /// <summary>
|
||||
// /// 原材料条码
|
||||
// /// </summary>
|
||||
// public string materialLotCode { get; set; }
|
||||
// /// <summary>
|
||||
// /// 原材料上料位置
|
||||
// /// </summary>
|
||||
// public string materialLotCodeLocator { get; set; }
|
||||
//}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace JinYuan.MES.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 执行结果
|
||||
/// </summary>
|
||||
public class MesResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// 错误代码 错误代码,成功不返回
|
||||
/// </summary>
|
||||
public string code { get; set; }
|
||||
/// <summary>
|
||||
/// 数据处理消息 成功不返回
|
||||
/// </summary>
|
||||
public string message { get; set; }
|
||||
/// <summary>
|
||||
/// 报错消息类型
|
||||
/// </summary>
|
||||
public string category { get; set; }
|
||||
/// <summary>
|
||||
/// 成功标识 false失败 true 成功
|
||||
/// </summary>
|
||||
public bool success { get; set; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 单个上传(只上传条码,不上传卷芯码)
|
||||
/// </summary>
|
||||
public class MesResponseSingle
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string code { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string message { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public bool success { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string category { get; set; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#region 进站反馈
|
||||
public class MesResponseIn
|
||||
{
|
||||
/// <summary>
|
||||
/// 错误代码 错误代码,成功不返回
|
||||
/// </summary>
|
||||
public string code { get; set; }
|
||||
/// <summary>
|
||||
/// 数据处理消息 成功不返回
|
||||
/// </summary>
|
||||
public string message { get; set; }
|
||||
/// <summary>
|
||||
/// 报错消息类型
|
||||
/// </summary>
|
||||
public string category { get; set; }
|
||||
/// <summary>
|
||||
/// 成功标识 false失败 true 成功
|
||||
/// </summary>
|
||||
public bool success { get; set; }
|
||||
}
|
||||
public class RowsItemIn
|
||||
{
|
||||
/// <summary>
|
||||
/// 错误代码 错误代码,成功不返回
|
||||
/// </summary>
|
||||
public string code { get; set; }
|
||||
/// <summary>
|
||||
/// 返回条码成功标识 false失败 true 成功
|
||||
/// </summary>
|
||||
public bool success { get; set; }
|
||||
/// <summary>
|
||||
/// 数据处理消息 成功不返回
|
||||
/// </summary>
|
||||
public string message { get; set; }
|
||||
/// <summary>
|
||||
/// 返回成品条码
|
||||
/// </summary>
|
||||
public string identification { get; set; }
|
||||
/// <summary>
|
||||
/// 返回的容器码
|
||||
/// </summary>
|
||||
public string containerCode { get; set; }
|
||||
/// <summary>
|
||||
/// 报错消息类型 A=停线,B=排出,C=忽略(需警示)
|
||||
/// </summary>
|
||||
public string category { get; set; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region 出站反馈
|
||||
//{"rows":[{"code":null,"success":true,"message":null,"identification":"InsertAt20231218095755934","containerCode":null,"category":null}],"success":true,"total":1}
|
||||
public class MesResponseOut
|
||||
{
|
||||
/// <summary>
|
||||
/// 返回参数
|
||||
/// </summary>
|
||||
public List<RowsItemOut> rows { get; set; }
|
||||
/// <summary>
|
||||
/// MES信息返回成功标识 false失败 true 成功
|
||||
/// </summary>
|
||||
public bool success { get; set; }
|
||||
/// <summary>
|
||||
/// 返回参数条数
|
||||
/// </summary>
|
||||
public int total { get; set; }
|
||||
}
|
||||
public class RowsItemOut
|
||||
{
|
||||
/// <summary>
|
||||
/// 错误代码 错误代码,成功不返回
|
||||
/// </summary>
|
||||
public string code { get; set; }
|
||||
/// <summary>
|
||||
/// 返回条码成功标识 false失败 true 成功
|
||||
/// </summary>
|
||||
public bool success { get; set; }
|
||||
/// <summary>
|
||||
/// 数据处理消息 成功不返回
|
||||
/// </summary>
|
||||
public string message { get; set; }
|
||||
/// <summary>
|
||||
/// 返回成品条码
|
||||
/// </summary>
|
||||
public string identification { get; set; }
|
||||
/// <summary>
|
||||
/// 返回的容器码
|
||||
/// </summary>
|
||||
public string containerCode { get; set; }
|
||||
/// <summary>
|
||||
/// 报错消息类型 A=停线,B=排出,C=忽略(需警示)
|
||||
/// </summary>
|
||||
public string category { get; set; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 执行结果Entity,带返回值
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public class RequestResult<T> : MesResponse
|
||||
{
|
||||
public T Result { get; set; }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 执行结果List,带返回值
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public class RequestResultList<T> : MesResponse
|
||||
{
|
||||
public List<T> Result { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace JinYuan.MES.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 设备参数设定值变更
|
||||
/// </summary>
|
||||
public class ParamChange
|
||||
{
|
||||
/// <summary>
|
||||
/// 工厂代码
|
||||
/// </summary>
|
||||
public string siteCode { get; set; }
|
||||
/// <summary>
|
||||
/// 产线编号
|
||||
/// </summary>
|
||||
public string lineCode { get; set; }
|
||||
/// <summary>
|
||||
/// 设备编号
|
||||
/// </summary>
|
||||
public string equipNum { get; set; }
|
||||
/// <summary>
|
||||
/// 物料编码
|
||||
/// </summary>
|
||||
public string materialCode { get; set; }
|
||||
/// <summary>
|
||||
/// 员工账号
|
||||
/// </summary>
|
||||
public string userName { get; set; }
|
||||
/// <summary>
|
||||
/// 变更时间
|
||||
/// </summary>
|
||||
public string changeTime { get; set; }
|
||||
/// <summary>
|
||||
/// 数据组编码
|
||||
/// </summary>
|
||||
public string tagGroupCode { get; set; }
|
||||
/// <summary>
|
||||
/// 数据组描述
|
||||
/// </summary>
|
||||
public string tagGroupDescription { get; set; }
|
||||
/// <summary>
|
||||
/// 数据项数组
|
||||
/// </summary>
|
||||
public List<TagListItem> tagList { get; set; }
|
||||
}
|
||||
public class TagListItem
|
||||
{
|
||||
/// <summary>
|
||||
/// 数据项编码
|
||||
/// </summary>
|
||||
public string tagCode { get; set; }
|
||||
/// <summary>
|
||||
/// 变更前计量单位
|
||||
/// </summary>
|
||||
public string unitBefore { get; set; }
|
||||
/// <summary>
|
||||
/// 变更前标准值
|
||||
/// </summary>
|
||||
public string standardValueBefore { get; set; }
|
||||
/// <summary>
|
||||
/// 变更前符合值
|
||||
/// </summary>
|
||||
public string trueValueBefore { get; set; }
|
||||
/// <summary>
|
||||
/// 变更前不符合值
|
||||
/// </summary>
|
||||
public string falseValueBefore { get; set; }
|
||||
/// <summary>
|
||||
/// 变更前最小值
|
||||
/// </summary>
|
||||
public int minValueBefore { get; set; }
|
||||
/// <summary>
|
||||
/// 变更前最大值
|
||||
/// </summary>
|
||||
public int maxValueBefore { get; set; }
|
||||
/// <summary>
|
||||
/// 变更后计量单位
|
||||
/// </summary>
|
||||
public string unitAfter { get; set; }
|
||||
/// <summary>
|
||||
/// 变更后标准值
|
||||
/// </summary>
|
||||
public string standardValueAfter { get; set; }
|
||||
/// <summary>
|
||||
/// 变更后符合值
|
||||
/// </summary>
|
||||
public string trueValueAfter { get; set; }
|
||||
/// <summary>
|
||||
/// 变更后不符合值
|
||||
/// </summary>
|
||||
public string falseValueAfter { get; set; }
|
||||
/// <summary>
|
||||
/// 变更后最小值
|
||||
/// </summary>
|
||||
public int minValueAfter { get; set; }
|
||||
/// <summary>
|
||||
/// 变更后最大值
|
||||
/// </summary>
|
||||
public int maxValueAfter { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace JinYuan.MES.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 设备参数设定值返回
|
||||
/// </summary>
|
||||
public class ParamReturnData
|
||||
{
|
||||
/// <summary>
|
||||
/// 返回参数
|
||||
/// </summary>
|
||||
public List<RowsItem> rows { get; set; }
|
||||
/// <summary>
|
||||
/// 成功标识
|
||||
/// </summary>
|
||||
public bool success { get; set; }
|
||||
/// <summary>
|
||||
/// 返回参数条数
|
||||
/// </summary>
|
||||
public int total { get; set; }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 返回参数项
|
||||
/// </summary>
|
||||
public class RowsItem
|
||||
{
|
||||
/// <summary>
|
||||
/// 数据组编码
|
||||
/// </summary>
|
||||
public string tagGroupCode { get; set; }
|
||||
/// <summary>
|
||||
/// 配方0002
|
||||
/// </summary>
|
||||
public string tagGroupDescription { get; set; }
|
||||
/// <summary>
|
||||
/// 数据组描述
|
||||
/// </summary>
|
||||
public List<ReturnDataTagListItem> tagList { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 数据组描述
|
||||
/// </summary>
|
||||
public class ReturnDataTagListItem
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string tagCode { get; set; }
|
||||
/// <summary>
|
||||
/// 真空度设定值
|
||||
/// </summary>
|
||||
public string tagDescription { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string valueType { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string unit { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string standardValue { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string trueValue { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string falseValue { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string minValue { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string maxValue { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string tagRemark { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace JinYuan.MES.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 产品过程加工参数
|
||||
/// </summary>
|
||||
public class ProductProcessParam
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace JinYuan.MES.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 结果加工参数
|
||||
/// </summary>
|
||||
public class ProductResultParameters
|
||||
{
|
||||
/// <summary>
|
||||
/// 设备编号
|
||||
/// </summary>
|
||||
public string equipNum { get; set; }
|
||||
/// <summary>
|
||||
/// 类型单进整出:DZ 整进整出:ZZ 单进单出:DD 未传时默认按照ZZ进行数据解析
|
||||
/// </summary>
|
||||
public string type { get; set; }
|
||||
/// <summary>
|
||||
/// 设备数据
|
||||
/// </summary>
|
||||
public string payload { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 单进整出
|
||||
/// </summary>
|
||||
public class Payload1
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 工厂代码
|
||||
/// </summary>
|
||||
public string siteCode { get; set; }
|
||||
/// <summary>
|
||||
/// 产线编号
|
||||
/// </summary>
|
||||
public string lineCode { get; set; }
|
||||
/// <summary>
|
||||
/// 员工账号
|
||||
/// </summary>
|
||||
public string userName { get; set; }
|
||||
/// <summary>
|
||||
/// 物料编码 工单产成品物料号
|
||||
/// </summary>
|
||||
public string materialCode { get; set; }
|
||||
/// <summary>
|
||||
/// 小车号 装载电池的小车编号
|
||||
/// </summary>
|
||||
public string carCode { get; set; }
|
||||
/// <summary>
|
||||
/// 补录 是否属于补录数据(BL=补录,JS=及时上传)
|
||||
/// </summary>
|
||||
public string collection { get; set; }
|
||||
/// <summary>
|
||||
/// 采集时间 数据的采集时间
|
||||
/// </summary>
|
||||
public string recordDate { get; set; }
|
||||
/// <summary>
|
||||
/// 条码数量 传入条码的个数
|
||||
/// </summary>
|
||||
public int qty { get; set; }
|
||||
/// <summary>
|
||||
/// RFID托杯码
|
||||
/// </summary>
|
||||
public string containerCode { get; set; }
|
||||
/// <summary>
|
||||
/// 条码数组
|
||||
/// </summary>
|
||||
|
||||
public IdentificationListItem identification { get; set; }
|
||||
public List<TagDataVOListItem> tagDataVOList { get; set; }
|
||||
}
|
||||
|
||||
public class IdentificationListItem
|
||||
{
|
||||
/// /// <summary>
|
||||
/// 条码
|
||||
/// </summary>
|
||||
public string identification { get; set; }
|
||||
/// <summary>
|
||||
/// 质量状态 各产品所有参数的整体判断结果(Y/N)
|
||||
/// </summary>
|
||||
public string qualityStatus { get; set; }
|
||||
/// <summary>
|
||||
/// 采集数组
|
||||
/// </summary>
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class TagDataVOListItem
|
||||
{
|
||||
/// <summary>
|
||||
/// 设备每个采集项规定的编号
|
||||
/// </summary>
|
||||
public string tagCode { get; set; }
|
||||
/// <summary>
|
||||
/// 采集值
|
||||
/// </summary>
|
||||
public string tagValue { get; set; }
|
||||
/// <summary>
|
||||
/// 采集项采集时间
|
||||
/// </summary>
|
||||
public string tagTime { get; set; }
|
||||
/// <summary>
|
||||
/// 各产品所有参数的整体判断结果(Y/N)
|
||||
/// </summary>
|
||||
public string tagCalculateResult { get; set; }
|
||||
/// <summary>
|
||||
/// 采集项描述
|
||||
/// </summary>
|
||||
public string tagRemark { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
namespace JinYuan.MES.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 单个电池进站
|
||||
/// </summary>
|
||||
public class SingleCellInStation
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string siteCode { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string lineCode { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string equipNum { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string materialCode { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string userName { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string identification { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string productType { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace JinYuan.MES.Models
|
||||
{
|
||||
|
||||
|
||||
public class MaterialLotListItem
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string materialLotCode { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string materialLotCodeLocator { get; set; }
|
||||
}
|
||||
|
||||
public class IdentiftyListItem
|
||||
{
|
||||
/// <summary>
|
||||
/// 条码
|
||||
/// </summary>
|
||||
public string identification { get; set; }
|
||||
/// <summary>
|
||||
/// 质量状态
|
||||
/// </summary>
|
||||
public string qualityStatus { get; set; }
|
||||
/// <summary>
|
||||
/// 关联条码
|
||||
/// </summary>
|
||||
public string qrCode { get; set; }
|
||||
/// <summary>
|
||||
/// NG2信息,NG1信息
|
||||
/// </summary>
|
||||
public string ngMessage { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public List<string> ngCode { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public List<MaterialLotListItem> materialLotList { get; set; }
|
||||
}
|
||||
|
||||
public class SingleCellOutStation
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string siteCode { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string lineCode { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string equipNum { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string userName { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string productType { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string completeQty { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string containerCode { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int type { get; set; }
|
||||
/// <summary>
|
||||
/// 原材料条码
|
||||
/// </summary>
|
||||
public string materialCode { get; set; }
|
||||
/// <summary>
|
||||
/// 产品条码
|
||||
/// </summary>
|
||||
public List<IdentiftyListItem> identiftyList { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace JinYuan.MES.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 报警数据上传接口参数类
|
||||
/// </summary>
|
||||
public class UploadAlarmParam
|
||||
{
|
||||
/// <summary>
|
||||
/// 工厂代码
|
||||
/// </summary>
|
||||
public string siteCode { get; set; }
|
||||
/// <summary>
|
||||
/// 产线编号
|
||||
/// </summary>
|
||||
public string lineCode { get; set; }
|
||||
/// <summary>
|
||||
/// 设备编号
|
||||
/// </summary>
|
||||
public string equipNum { get; set; }
|
||||
/// <summary>
|
||||
/// 物料编码
|
||||
/// </summary>
|
||||
public string materialCode { get; set; }
|
||||
/// <summary>
|
||||
/// 员工账号
|
||||
/// </summary>
|
||||
public string userName { get; set; }
|
||||
/// <summary>
|
||||
/// 采集时间
|
||||
/// </summary>
|
||||
public string recordDate { get; set; }
|
||||
/// <summary>
|
||||
/// 唯一标识符号
|
||||
/// </summary>
|
||||
public string guid { get; set; }
|
||||
/// <summary>
|
||||
/// 库位ID 库位ID,化成段用
|
||||
/// </summary>
|
||||
public string seatId { get; set; }
|
||||
/// <summary>
|
||||
/// 报警数组
|
||||
/// </summary>
|
||||
public List<AlarmLineListItem> alarmLineList { get; set; }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 报警数组
|
||||
/// </summary>
|
||||
public class AlarmLineListItem
|
||||
{
|
||||
/// <summary>
|
||||
/// 报警消除时间
|
||||
/// </summary>
|
||||
public string alarmEndTime { get; set; }
|
||||
/// <summary>
|
||||
/// 报警类型
|
||||
/// </summary>
|
||||
public string alarmType { get; set; }
|
||||
/// <summary>
|
||||
/// 报警名称
|
||||
/// </summary>
|
||||
public string alarmName { get; set; }
|
||||
/// <summary>
|
||||
/// 报警开始时间
|
||||
/// </summary>
|
||||
public string alarmStartTime { get; set; }
|
||||
/// <summary>
|
||||
/// 故障代码
|
||||
/// </summary>
|
||||
public string faultCode { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace JinYuan.MES.Models
|
||||
{
|
||||
internal class UploadDeviceCollectData
|
||||
{
|
||||
/// <summary>
|
||||
/// 应用id,对应不同系统对接
|
||||
/// </summary>
|
||||
public string appid { get; set; }
|
||||
/// <summary>
|
||||
/// 采集指标类型和具体值的集合
|
||||
/// </summary>
|
||||
public List<Collect_code_value_list> collect_code_value_list { get; set; }
|
||||
/// <summary>
|
||||
/// 采集时间,unix时间戳,整数类型
|
||||
/// </summary>
|
||||
public long collect_time { get; set; }
|
||||
/// <summary>
|
||||
/// 设备编号
|
||||
/// </summary>
|
||||
public string device_code { get; set; }
|
||||
}
|
||||
public class Collect_code_value_list
|
||||
{
|
||||
/// <summary>
|
||||
/// 指标类型,1 温度 2湿度 3露点 4粉尘 5风速,整数类型
|
||||
/// </summary>
|
||||
public int target_code { get; set; }
|
||||
/// <summary>
|
||||
/// 指标对应采集值,若是某个指标或某个指标的某个值未采集到,则传N
|
||||
/// </summary>
|
||||
public string target_value { get; set; }
|
||||
/// <summary>
|
||||
/// 风速仪标签,风速仪值对应target_value
|
||||
/// </summary>
|
||||
public string target_value_tag { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public class UploadDeviceCollectDataResult
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int status { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public Data data { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string message { get; set; }
|
||||
}
|
||||
|
||||
public class Data
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
namespace JinYuan.MES.Models
|
||||
{
|
||||
public class WattrMeter
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 工厂代码
|
||||
/// </summary>
|
||||
public System.String siteCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 产线编号
|
||||
/// </summary>
|
||||
public System.String lineCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 设备编号
|
||||
/// </summary>
|
||||
public System.String equipNum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 电表编号
|
||||
/// </summary>
|
||||
public System.String electricMeterNum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 员工账号
|
||||
/// </summary>
|
||||
public System.String userName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工序编号
|
||||
/// </summary>
|
||||
public System.String specName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 采集时间
|
||||
/// </summary>
|
||||
public System.String recordDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 有功电能(累计电能)KWH
|
||||
/// </summary>
|
||||
public System.Decimal? accumulatedElectricity { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A相电压 V
|
||||
/// </summary>
|
||||
public System.Decimal? phaseVoltageA { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// B相电压 V
|
||||
/// </summary>
|
||||
public System.Decimal? phaseVoltageB { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// C相电压 V
|
||||
/// </summary>
|
||||
public System.Decimal? phaseVoltageC { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A相电流
|
||||
/// </summary>
|
||||
public System.Decimal? phaseCurrentA { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// B相电流
|
||||
/// </summary>
|
||||
public System.Decimal? phaseCurrentB { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// C相电流
|
||||
/// </summary>
|
||||
public System.Decimal? phaseCurrentC { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A相功率
|
||||
/// </summary>
|
||||
public System.Decimal? phasePowerA { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// B相功率
|
||||
/// </summary>
|
||||
public System.Decimal? phasePowerB { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// C相功率
|
||||
/// </summary>
|
||||
public System.Decimal? phasePowerC { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 总有功功率
|
||||
/// </summary>
|
||||
public System.Decimal? activePower { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 总功率因数
|
||||
/// </summary>
|
||||
public System.Decimal? powerFactor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 电流变比
|
||||
/// </summary>
|
||||
public System.Decimal? pt { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 电压变比
|
||||
/// </summary>
|
||||
public System.Decimal? ct { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// 有关程序集的一般信息由以下
|
||||
// 控制。更改这些特性值可修改
|
||||
// 与程序集关联的信息。
|
||||
[assembly: AssemblyTitle("JinYuan.MES")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("JinYuan.MES")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2023")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// 将 ComVisible 设置为 false 会使此程序集中的类型
|
||||
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
|
||||
//请将此类型的 ComVisible 特性设置为 true。
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
|
||||
[assembly: Guid("530b6426-08e7-461c-91dc-787f876620fc")]
|
||||
|
||||
// 程序集的版本信息由下列四个值组成:
|
||||
//
|
||||
// 主版本
|
||||
// 次版本
|
||||
// 生成号
|
||||
// 修订号
|
||||
//
|
||||
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
|
||||
//通过使用 "*",如下所示:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.1.2" newVersion="4.0.1.2" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Text.Encoding.CodePages" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Security.Cryptography.Xml" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-6.0.0.1" newVersion="6.0.0.1" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.1.4.0" newVersion="4.1.4.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net472" />
|
||||
</packages>
|
||||
@@ -0,0 +1,46 @@
|
||||
using SqlSugar;
|
||||
|
||||
namespace JinYuan.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 电芯进站
|
||||
/// </summary>
|
||||
public class AGearEntity
|
||||
{
|
||||
//[SugarColumn(IsIgnore = false)] //存储到数据库
|
||||
public System.String CNum { get; set; }
|
||||
/// <summary>
|
||||
/// 电芯条码
|
||||
/// </summary>
|
||||
public System.String BarCode { get; set; }
|
||||
/// <summary>
|
||||
/// 通道号
|
||||
/// </summary>
|
||||
public int ID { get; set; }
|
||||
/// <summary>
|
||||
/// 上传状态
|
||||
/// </summary>
|
||||
public string UpState { get; set; }
|
||||
/// <summary>
|
||||
/// 进站电芯反馈结果
|
||||
/// </summary>
|
||||
public string Result { get; set; }
|
||||
/// <summary>
|
||||
/// 时间
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
public System.String TestTime { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
public string Remark { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 标志
|
||||
/// </summary>
|
||||
public int Flag { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
using CsvHelper.Configuration.Attributes;
|
||||
|
||||
namespace JinYuan.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 工位报警数据
|
||||
/// </summary>
|
||||
public class AlarmData
|
||||
{
|
||||
/// <summary>
|
||||
/// 报警唯一标识符
|
||||
/// </summary>
|
||||
public string AlarmGuid { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 报警地址
|
||||
/// </summary>
|
||||
public string PLCAdress { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 报警内容
|
||||
/// </summary>
|
||||
public string AlarmContent { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 报警代码
|
||||
/// </summary>
|
||||
public string AlarmCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 报警类型 停机报警/非停机报警
|
||||
/// </summary>
|
||||
public string AlarmType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 报警开始时间
|
||||
/// </summary>
|
||||
public System.String StartTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 报警消除时间
|
||||
/// </summary>
|
||||
public System.String EndTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 报警描述
|
||||
/// </summary>
|
||||
public string AlarmDesc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 报警状态 传1或0,1是开始报警,0结束报警
|
||||
/// </summary>
|
||||
public string AlarmState { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 更新状态
|
||||
/// </summary>
|
||||
public int Flag { get; set; }
|
||||
}
|
||||
|
||||
public class AlarmCSVData
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 报警开始时间
|
||||
/// </summary>
|
||||
[Name("报警时间")]
|
||||
public string StartTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 报警内容
|
||||
/// </summary>
|
||||
///
|
||||
[Name("报警内容")]
|
||||
public string AlarmContent { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
namespace JinYuan.Models
|
||||
{
|
||||
public class AlarmStatus
|
||||
{
|
||||
/// <summary>
|
||||
/// 报警地址
|
||||
/// </summary>
|
||||
public string PLCAdress { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 报警状态
|
||||
/// </summary>
|
||||
public bool Status { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
|
||||
namespace JinYuan.Models
|
||||
{
|
||||
public class AlarmCountEntry
|
||||
{
|
||||
/// <summary>
|
||||
/// PLC地址
|
||||
/// </summary>
|
||||
public string PLCAdress { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 报警内容
|
||||
/// </summary>
|
||||
public string AlarmContent { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 报警次数
|
||||
/// </summary>
|
||||
public int AlarmCount { get; set; }
|
||||
/// <summary>
|
||||
/// 班次
|
||||
/// </summary>
|
||||
public string Class { get; set; }
|
||||
/// <summary>
|
||||
/// 更新时间
|
||||
/// </summary>
|
||||
public DateTime AlarmTime { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using CsvHelper.Configuration.Attributes;
|
||||
|
||||
namespace JinYuan.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 报警表单数据
|
||||
/// </summary>
|
||||
public class AlarmForm
|
||||
{
|
||||
/// <summary>
|
||||
/// 报警地址
|
||||
/// </summary>
|
||||
[Name("寄存器地址")]
|
||||
public string PLCAdress { get; set; }
|
||||
/// <summary>
|
||||
/// 报警内容
|
||||
/// </summary>
|
||||
[Name("报警信息")]
|
||||
public string AlarmContent { get; set; }
|
||||
/// <summary>
|
||||
/// 报警代码
|
||||
/// </summary>
|
||||
[Name("故障代码")]
|
||||
public string AlarmCode { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,245 @@
|
||||
using SqlSugar;
|
||||
|
||||
namespace JinYuan.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 电芯出站
|
||||
/// </summary>
|
||||
public class BGearEntity
|
||||
{
|
||||
public int[] MyNo = new int[3];//AB序号
|
||||
public short[] listRes = new short[3];//AB反馈结果
|
||||
public string[] ScanTime = new string[3];//AB芯包扫码时间
|
||||
public string[] listBatCode = new string[3];//芯包条码
|
||||
public string[] judgment_result = new string[3];//AB芯包出站判定结果
|
||||
|
||||
public short[,] list_Data1 = new short[3, 28];//芯包信息1
|
||||
public int[,] list_Data2 = new int[3, 19];//芯包信息2(焊机相关次数)
|
||||
public float[,] list_Data3 = new float[3, 54];//芯包信息3(设定值)
|
||||
public float[,] list_Data4 = new float[3, 47];//芯包信息4(实际值)
|
||||
|
||||
public short[,] list_pan = new short[3, 1];//物流线托盘码
|
||||
//
|
||||
public int[,] CCD_Data = new int[3, 27];//芯包CCD信息1,2,3
|
||||
public string[,] CCD_NgNo = new string[3, 27];//芯包不良编码信息1,2,3
|
||||
// public float[,] Thickness_Data = new float[3, 3];//电芯3_厚度数据信息1,2,3
|
||||
// public int[,] Thickness_PLCData = new int[3, 3];//电芯3_厚度数据OKNG1,2,3 与ccd一样 1 OK,0 NG,2 缺图
|
||||
/// <summary>
|
||||
/// 通道
|
||||
/// </summary>
|
||||
public int ChannelNo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A芯包扫码时间
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = false)]
|
||||
public string CSBYHASCANNINGTIME { get; set; }
|
||||
/// <summary>
|
||||
/// 上传状态
|
||||
/// </summary>
|
||||
public string UpState { get; set; }
|
||||
public string RFID { get; set; }
|
||||
public string ScanBarRes { get; set; }
|
||||
/// <summary>
|
||||
/// 反馈结果
|
||||
/// </summary>
|
||||
public int Result { get; set; }
|
||||
/// <summary>
|
||||
/// 区分A和B
|
||||
/// </summary>
|
||||
// public string A_B { get; set; }
|
||||
/// <summary>
|
||||
/// 电芯1_CCD1结果 1 OK,0 NG,2 缺图
|
||||
/// </summary>
|
||||
public int CCD1 { get; set; }
|
||||
public int CCD2 { get; set; }
|
||||
public int CCD3 { get; set; }
|
||||
public int CCD4 { get; set; }
|
||||
public int CCD5 { get; set; }
|
||||
public int CCD6 { get; set; }
|
||||
public int CCD7 { get; set; }
|
||||
public int CCD8 { get; set; }
|
||||
public int CCD9 { get; set; }
|
||||
public int CCD10 { get; set; }
|
||||
public int CCD11 { get; set; }
|
||||
public int CCD12 { get; set; }
|
||||
public int CCD13 { get; set; }
|
||||
public int CCD14 { get; set; }
|
||||
public int CCD15 { get; set; }
|
||||
public int CCD16 { get; set; }
|
||||
public int CCD17 { get; set; }
|
||||
public int CCD18 { get; set; }
|
||||
public int CCD19 { get; set; }
|
||||
public int CCD20 { get; set; }
|
||||
public int CCD21 { get; set; }
|
||||
public int CCD22 { get; set; }
|
||||
public int CCD23 { get; set; }
|
||||
public int CCD24 { get; set; }
|
||||
public int CCD25 { get; set; }
|
||||
public int CCD26 { get; set; }
|
||||
public int CCD27 { get; set; }
|
||||
public string CCD1NgCode { get; set; }
|
||||
public string CCD2NgCode { get; set; }
|
||||
public string CCD3NgCode { get; set; }
|
||||
public string CCD4NgCode { get; set; }
|
||||
public string CCD5NgCode { get; set; }
|
||||
public string CCD6NgCode { get; set; }
|
||||
public string CCD7NgCode { get; set; }
|
||||
public string CCD8NgCode { get; set; }
|
||||
public string CCD9NgCode { get; set; }
|
||||
public string CCD10NgCode { get; set; }
|
||||
public string CCD11NgCode { get; set; }
|
||||
public string CCD12NgCode { get; set; }
|
||||
public string CCD13NgCode { get; set; }
|
||||
public string CCD14NgCode { get; set; }
|
||||
public string CCD15NgCode { get; set; }
|
||||
public string CCD16NgCode { get; set; }
|
||||
public string CCD17NgCode { get; set; }
|
||||
/// <summary>
|
||||
/// 二维码ng 不良编号
|
||||
/// </summary>
|
||||
public string CCD18NgCode { get; set; }
|
||||
public string CCD19NgCode { get; set; }
|
||||
public string CCD20NgCode { get; set; }
|
||||
public string CCD21NgCode { get; set; }
|
||||
public string CCD22NgCode { get; set; }
|
||||
public string CCD23NgCode { get; set; }
|
||||
public string CCD24NgCode { get; set; }
|
||||
public string CCD25NgCode { get; set; }
|
||||
public string CCD26NgCode { get; set; }
|
||||
public string CCD27NgCode { get; set; }
|
||||
/// <summary>
|
||||
/// <summary>
|
||||
/// 电芯1_厚度数据1
|
||||
/// </summary>
|
||||
public float Thickness1 { get; set; }
|
||||
// public float Thickness2 { get; set; }
|
||||
// public float Thickness3 { get; set; }
|
||||
/// <summary>
|
||||
/// 电芯1_厚度 PLC判定 OKNG 1 OK,0 NG
|
||||
/// </summary>
|
||||
// public int ThicknessPLCResult1 { get; set; }
|
||||
// public int ThicknessPLCResult2 { get; set; }
|
||||
// public int ThicknessPLCResult3 { get; set; }
|
||||
/// <summary>
|
||||
/// 电芯1_厚度OKNG 显示OK NG
|
||||
/// </summary>
|
||||
public string ThicknessResult1 { get; set; }
|
||||
// public string ThicknessResult2 { get; set; }
|
||||
// public string ThicknessResult3 { get; set; }
|
||||
/// <summary>
|
||||
/// 平面度设定值
|
||||
/// </summary>
|
||||
public string flatness_setpoint { get; set; }
|
||||
/// <summary>
|
||||
/// 平面度实际值
|
||||
/// </summary>
|
||||
public string flatness_actual { get; set; }
|
||||
/// <summary>
|
||||
/// 电芯_CCD1结果 1 OK,0 NG,2 缺图
|
||||
/// </summary>
|
||||
public string CCDResult1 { get; set; }
|
||||
public string CCDResult2 { get; set; }
|
||||
public string CCDResult3 { get; set; }
|
||||
public string CCDResult4 { get; set; }
|
||||
public string CCDResult5 { get; set; }
|
||||
public string CCDResult6 { get; set; }
|
||||
public string CCDResult7 { get; set; }
|
||||
public string CCDResult8 { get; set; }
|
||||
public string CCDResult9 { get; set; }
|
||||
public string CCDResult10 { get; set; }
|
||||
public string CCDResult11 { get; set; }
|
||||
public string CCDResult12 { get; set; }
|
||||
public string CCDResult13 { get; set; }
|
||||
public string CCDResult14 { get; set; }
|
||||
public string CCDResult15 { get; set; }
|
||||
public string CCDResult16 { get; set; }
|
||||
public string CCDResult17 { get; set; }
|
||||
public string CCDResult18 { get; set; }
|
||||
public string CCDResult19 { get; set; }
|
||||
public string CCDResult20 { get; set; }
|
||||
public string CCDResult21 { get; set; }
|
||||
public string CCDResult22 { get; set; }
|
||||
public string CCDResult23 { get; set; }
|
||||
public string CCDResult24 { get; set; }
|
||||
public string CCDResult25 { get; set; }
|
||||
public string CCDResult26 { get; set; }
|
||||
public string CCDResult27 { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 芯包条码
|
||||
/// </summary>
|
||||
public string BarCode { get; set; }
|
||||
/// <summary>
|
||||
/// 物料编码
|
||||
/// </summary>
|
||||
public string MaterialCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 电芯A/B出站判定结果
|
||||
/// </summary>
|
||||
public string CSBYHOUTSTATIONJUDGMENTRESULT { get; set; }
|
||||
/// <summary>
|
||||
/// 电芯A/B工序名
|
||||
/// </summary>
|
||||
public string CSBYHPROCESSNAME { get; set; }
|
||||
/// <summary>
|
||||
/// 电芯A/B班次
|
||||
/// </summary>
|
||||
public string CSBYHSCHEDULE { get; set; }
|
||||
/// <summary>
|
||||
/// 电芯A/B进站时间
|
||||
/// </summary>
|
||||
public string CSBYHINSTATIONTIME { get; set; }
|
||||
/// <summary>
|
||||
/// 电芯A/B出站时间
|
||||
/// </summary>
|
||||
public string CSBYHOUTSTATIONTIME { get; set; }
|
||||
/// <summary>
|
||||
/// 复投次数
|
||||
/// </summary>
|
||||
public int RethrowNum { get; set; }
|
||||
/// <summary>
|
||||
/// 标志
|
||||
/// </summary>
|
||||
public int Flag { get; set; }
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
public string Remark { get; set; }
|
||||
public int PlcResult { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 进出站电池等级
|
||||
/// </summary>
|
||||
public string in_battery_grade { get; set; }
|
||||
/// <summary>
|
||||
/// 进出站电池等级
|
||||
/// </summary>
|
||||
public string out_battery_grade { get; set; }
|
||||
/// <summary>
|
||||
/// MES返回电池档位
|
||||
/// </summary>
|
||||
public string Mes_battery_Grade { get; set; }
|
||||
// MES返回分选方案
|
||||
public string Mes_sorting_scheme { get; set; }
|
||||
public string appearance_standard { get; set; }
|
||||
//撕膜机
|
||||
public string SM_cleaning_defocus_dist { get; set; }
|
||||
public string SM_cleaning_peak_power { get; set; }
|
||||
public string SM_cleaning_frequency { get; set; }
|
||||
public string SM_cleaning_speed { get; set; }
|
||||
public string SM_cutting_defocus_dist { get; set; }
|
||||
public string SM_cutting_peak_power { get; set; }
|
||||
public string SM_cutting_frequency { get; set; }
|
||||
public string SM_cutting_speed { get; set; }
|
||||
public string SM_dust_removal_wind_speed { get; set; }
|
||||
public string barcode_match_result { get; set; }
|
||||
public string ng_code_summary { get; set; }
|
||||
/// <summary>
|
||||
/// 是否上传结果参数标志
|
||||
/// </summary>
|
||||
public int Flag1 { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
namespace JinYuan.Models
|
||||
{
|
||||
//子组大小:这个与计算内的CPK值又非常打的关系,即是分组的样本个数,数据的分组在此处需要说明的是,必须
|
||||
//是根据实际情况来填写,比如每次抽样为5个,那么子组大小为5个,我们不能随心所欲的任意填写这个值,否则
|
||||
//将没有实际意义。
|
||||
//上规格:用户录入的上规格值
|
||||
//目标值:用户输入的目标值,即期望达到的中心值
|
||||
//下规格:用户输入的下规格值
|
||||
|
||||
|
||||
public class CPKModel
|
||||
{
|
||||
/// <summary>
|
||||
/// 总样本数 。参与分析的数据的个数
|
||||
/// </summary>
|
||||
public int TotalNumber { get; set; }
|
||||
/// <summary>
|
||||
/// 图表类型 .说明进行分析的控制图的类型,此处为XR控制图
|
||||
/// </summary>
|
||||
public string ChartType { get; set; }
|
||||
/// <summary>
|
||||
/// 平均值 所有样本数据的平均值
|
||||
/// </summary>
|
||||
public double MeanVlaue { get; set; }
|
||||
/// <summary>
|
||||
/// 最大值 所有样本的最大值
|
||||
/// </summary>
|
||||
public double MaxValue { get; set; }
|
||||
/// <summary>
|
||||
/// 最小值
|
||||
/// </summary>
|
||||
public double MinValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 正的3倍标准差线
|
||||
/// </summary>
|
||||
public double Pos3Sigma { get; set; }
|
||||
/// <summary>
|
||||
/// 负的3倍标准差线
|
||||
/// </summary>
|
||||
public double Neg3Sigma { get; set; }
|
||||
/// <summary>
|
||||
/// 组内标准差值
|
||||
/// </summary>
|
||||
public double GroupSTDEV { get; set; }
|
||||
/// <summary>
|
||||
/// 整体标准差值
|
||||
/// </summary>
|
||||
public double WholeSTDEV { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 组内CPK值 工序能力指数,与规格值及上述标准差值相关联
|
||||
/// </summary>
|
||||
public double GroupCPK { get; set; }
|
||||
/// <summary>
|
||||
/// 整体CPK值 工序能力指数,与规格值及上述标准差值相关联
|
||||
/// </summary>
|
||||
public double WholeCPK { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 组内CP值 Cp值是衡量过程满足产品品质标准的成都,也叫制程精密度,Cp值越大,表示过程变异越小,过程能力越差
|
||||
/// </summary>
|
||||
public double GroupCP { get; set; }
|
||||
/// <summary>
|
||||
/// 整体CP值 Cp值是衡量过程满足产品品质标准的成都,也叫制程精密度,Cp值越大,表示过程变异越小,过程能力越差
|
||||
/// </summary>
|
||||
public double WholeCP { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 组内CPL值 相对应于下规格的工序能力值;
|
||||
/// </summary>
|
||||
public double GroupCPL { get; set; }
|
||||
/// <summary>
|
||||
/// 整体CPL值 相对应于下规格的工序能力值;
|
||||
/// </summary>
|
||||
public double WholeCPL { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 组内CPU值 相对应于上规格的工序能力值;
|
||||
/// </summary>
|
||||
public double GroupCPU { get; set; }
|
||||
/// <summary>
|
||||
/// 整体CPU值 相对应于上规格的工序能力值;
|
||||
/// </summary>
|
||||
public double WholeCPU { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 组内PPM<LSL值,预测的低于下规格值的不合格品数(PPM -百万分之比)
|
||||
/// </summary>
|
||||
public double GroupPPM_LSL { get; set; }
|
||||
/// <summary>
|
||||
/// 整体PPM<LSL值,预测的低于下规格值的不合格品数(PPM -百万分之比);
|
||||
/// </summary>
|
||||
public double WholePPM_LSL { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 实际检测PPM<LSL值,预测的低于下规格值的不合格品数(PPM -百万分之比);
|
||||
/// </summary>
|
||||
public double MeasuredPPM_LSL { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 组内PPM<USL值,预测的低于上规格值的不合格品数(PPM -百万分之比)
|
||||
/// </summary>
|
||||
public double GroupPPM_USL { get; set; }
|
||||
/// <summary>
|
||||
/// 整体PPM<USL值,预测的低于上规格值的不合格品数(PPM -百万分之比);
|
||||
/// </summary>
|
||||
public double WholePPM_USL { get; set; }
|
||||
/// <summary>
|
||||
/// 实际检测PPM<USL值,预测的低于上规格值的不合格品数(PPM -百万分之比)
|
||||
/// </summary>
|
||||
public double MeasuredPPM_USL { get; set; }
|
||||
/// <summary>
|
||||
/// 组内PPM Total值,预测的总的不合格品数
|
||||
/// </summary>
|
||||
public double GroupPPM_Total { get; set; }
|
||||
/// <summary>
|
||||
/// 整体PPM<USL值,预测的总的不合格品数
|
||||
/// </summary>
|
||||
public double WholePPM_Total { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 实际检测PPM<USL值,预测的总的不合格品数
|
||||
/// </summary>
|
||||
public double MeasuredPPM_Total { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 制程准确度,值越小越好
|
||||
/// </summary>
|
||||
public double CA { get; set; }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,203 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace JinYuan.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// CPQCPT数据
|
||||
/// </summary>
|
||||
public class CPQCPTDate
|
||||
{
|
||||
/// <summary>
|
||||
/// 注液前重量
|
||||
/// </summary>
|
||||
public string CTP_PreWeighing_Value { get; set; }
|
||||
/// <summary>
|
||||
/// 保液量
|
||||
/// </summary>
|
||||
public string CTP_Liquid_Retention_Value { get; set; }
|
||||
/// <summary>
|
||||
/// 注液量
|
||||
/// </summary>
|
||||
public string CTP_Filling_Value { get; set; }
|
||||
/// <summary>
|
||||
/// 失液量
|
||||
/// </summary>
|
||||
public string CTP_Liquid_Loss_Value { get; set; }
|
||||
/// <summary>
|
||||
/// 充氦值
|
||||
/// </summary>
|
||||
public string CTP_Helium_Filling_Value { get; set; }
|
||||
/// <summary>
|
||||
/// 钟罩真空值
|
||||
/// </summary>
|
||||
public string CTP_Belljar_Vacuum_Value { get; set; }
|
||||
/// <summary>
|
||||
/// 钟罩真空时间
|
||||
/// </summary>
|
||||
public string CTP_Belljar_Vacuum_Time { get; set; }
|
||||
/// <summary>
|
||||
/// 钟罩高压值
|
||||
/// </summary>
|
||||
public string CTP_Belljar_HighPressure_Value { get; set; }
|
||||
/// <summary>
|
||||
/// 钟罩高压时间
|
||||
/// </summary>
|
||||
public string CTP_Belljar_HighPressure_Time { get; set; }
|
||||
/// <summary>
|
||||
/// 钟罩循环次数
|
||||
/// </summary>
|
||||
public string CTP_Belljar_Cycles_Number { get; set; }
|
||||
/// <summary>
|
||||
/// 回氦前真空值
|
||||
/// </summary>
|
||||
public string CTP_Pre_Helium_Value { get; set; }
|
||||
/// <summary>
|
||||
/// 回氦后真空值
|
||||
/// </summary>
|
||||
public string CTP_Post_Helium_Value { get; set; }
|
||||
/// <summary>
|
||||
/// 平压压力
|
||||
/// </summary>
|
||||
public string CTP_Flat_Pressure { get; set; }
|
||||
/// <summary>
|
||||
/// 电芯测厚压力
|
||||
/// </summary>
|
||||
public string CTP_Cell_Thickness_Pressure { get; set; }
|
||||
/// <summary>
|
||||
/// 注液后重量
|
||||
/// </summary>
|
||||
public string CTQ_PostWeighing_Value { get; set; }
|
||||
/// <summary>
|
||||
/// 电芯厚度
|
||||
/// </summary>
|
||||
public string CTQ_Cell_Thickness { get; set; }
|
||||
/// <summary>
|
||||
/// 终压胶粒高度
|
||||
/// </summary>
|
||||
public string CTQ_Finalpress_Rubber_Height { get; set; }
|
||||
/// <summary>
|
||||
/// 注液前负压压力
|
||||
/// </summary>
|
||||
public string CTP_PreInjection_Pressure { get; set; }
|
||||
/// <summary>
|
||||
/// 电解液保有量-
|
||||
/// </summary>
|
||||
public string CTQ_Electrolyte_Inventory { get; set; }
|
||||
/// <summary>
|
||||
/// 预钉打钉行程
|
||||
/// </summary>
|
||||
public string CTP_PreNailing_Stroke { get; set; }
|
||||
/// <summary>
|
||||
/// 回氦前抽真空压力
|
||||
/// </summary>
|
||||
public string CTP_PreHelium_Vacuum_Pressure { get; set; }
|
||||
/// <summary>
|
||||
/// 终压打钉行程
|
||||
/// </summary>
|
||||
public string CTP_FinalNailing_Stroke { get; set; }
|
||||
/// <summary>
|
||||
/// 压密封胶粒后电芯厚度
|
||||
/// </summary>
|
||||
public string CTQ_Finalpress_Rubber_Thickness { get; set; }
|
||||
}
|
||||
/// <summary>
|
||||
/// 进出站上传数据
|
||||
/// </summary>
|
||||
public class EnterandExit
|
||||
{
|
||||
/// <summary>
|
||||
/// BU编码
|
||||
/// </summary>
|
||||
public string bu_id;
|
||||
/// <summary>
|
||||
/// 区域简称
|
||||
/// </summary>
|
||||
public string district_id;
|
||||
/// <summary>
|
||||
/// 工厂编码
|
||||
/// </summary>
|
||||
public string factory_id;
|
||||
/// <summary>
|
||||
/// 产线编码
|
||||
/// </summary>
|
||||
public string production_line_id;
|
||||
/// <summary>
|
||||
/// 工序编码
|
||||
/// </summary>
|
||||
public string production_processes_id;
|
||||
/// <summary>
|
||||
/// 工作中心编码
|
||||
/// </summary>
|
||||
public string work_center_id;
|
||||
/// <summary>
|
||||
/// 工站
|
||||
/// </summary>
|
||||
public string station_id;
|
||||
/// <summary>
|
||||
/// 设备编码
|
||||
/// </summary>
|
||||
public string device_name;
|
||||
/// <summary>
|
||||
/// 进出站标识
|
||||
/// </summary>
|
||||
public string action;
|
||||
/// <summary>
|
||||
/// 动作时间(进出站)
|
||||
/// </summary>
|
||||
public string action_time;
|
||||
}
|
||||
|
||||
public class CollectionUpload
|
||||
{
|
||||
/// <summary>
|
||||
/// BU编码
|
||||
/// </summary>
|
||||
public string bu_id;
|
||||
/// <summary>
|
||||
/// 区域简称
|
||||
/// </summary>
|
||||
public string district_id;
|
||||
/// <summary>
|
||||
/// 工厂编码
|
||||
/// </summary>
|
||||
public string factory_id;
|
||||
/// <summary>
|
||||
/// 产线编码
|
||||
/// </summary>
|
||||
public string production_line_id;
|
||||
/// <summary>
|
||||
/// 工序编码
|
||||
/// </summary>
|
||||
public string production_processes_id;
|
||||
/// <summary>
|
||||
/// 工作中心编码
|
||||
/// </summary>
|
||||
public string work_center_id;
|
||||
/// <summary>
|
||||
/// 工站
|
||||
/// </summary>
|
||||
public string station_id;
|
||||
/// <summary>
|
||||
/// 设备编码
|
||||
/// </summary>
|
||||
public string device_name;
|
||||
/// <summary>
|
||||
/// 采集项数据列表
|
||||
/// </summary>
|
||||
public List<Collection> taglist { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public class Collection
|
||||
{
|
||||
/// <summary>
|
||||
/// 时间
|
||||
/// </summary>
|
||||
public string device_time { get; set; }
|
||||
/// <summary>
|
||||
/// 采集项键值对
|
||||
/// </summary>
|
||||
public Dictionary<string, string> collection_items { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
namespace JinYuan.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 24小时统计表数据
|
||||
/// </summary>
|
||||
public class Chart12HourData
|
||||
{
|
||||
/// <summary>
|
||||
/// 优率
|
||||
/// </summary>
|
||||
public string DisplayTime { get; set; }
|
||||
/// <summary>
|
||||
/// 产出数
|
||||
/// </summary>
|
||||
public int ProdIn { set; get; }
|
||||
/// <summary>
|
||||
/// 投入数
|
||||
/// </summary>
|
||||
public int ProdOut { set; get; }
|
||||
/// <summary>
|
||||
/// 不良数量
|
||||
/// </summary>
|
||||
public int ProdNg { set; get; }
|
||||
/// <summary>
|
||||
/// 优率
|
||||
/// </summary>
|
||||
public string OKRatio { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
namespace JinYuan.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 不良統計
|
||||
/// </summary>
|
||||
public class ChartDataType
|
||||
{
|
||||
/// <summary>
|
||||
/// 數據類型
|
||||
/// </summary>
|
||||
public string DataType { get; set; }
|
||||
/// <summary>
|
||||
/// 數量
|
||||
/// </summary>
|
||||
public int DataCount { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using SqlSugar;
|
||||
|
||||
namespace JinYuan.Models
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class DataTurnover
|
||||
{
|
||||
/// <summary>
|
||||
/// 设备编号
|
||||
/// </summary>
|
||||
public System.String equipNum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 托杯码
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
public System.String containerCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 电芯码
|
||||
/// </summary>
|
||||
public System.String identification { get; set; }
|
||||
/// <summary>
|
||||
/// 信息
|
||||
/// </summary>
|
||||
public string message { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 时间
|
||||
/// </summary>
|
||||
public System.DateTime? Time { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace JinYuan.Models
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 设备综合效率
|
||||
/// </summary>
|
||||
public class DeviceOEE
|
||||
{
|
||||
/// <summary>
|
||||
/// 生产总数
|
||||
/// </summary>
|
||||
public int TotalQty { set; get; }
|
||||
/// <summary>
|
||||
/// 良品数
|
||||
/// </summary>
|
||||
public int ProOKQty { set; get; }
|
||||
/// <summary>
|
||||
/// 良率
|
||||
/// </summary>
|
||||
public double YieldRate { set; get; }
|
||||
/// <summary>
|
||||
/// 稼动率
|
||||
/// </summary>
|
||||
public double UtilizationRate { set; get; }
|
||||
/// <summary>
|
||||
/// PPM
|
||||
/// </summary>
|
||||
public int PPM { set; get; }
|
||||
/// <summary>
|
||||
/// 风速仪器
|
||||
/// </summary>
|
||||
public List<double> listWindSpeed { set; get; }
|
||||
/// <summary>
|
||||
/// 报警
|
||||
/// </summary>
|
||||
public List<ChartDataType> ListAlarmData { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 不良统计
|
||||
/// </summary>
|
||||
public List<ChartDataType> ListNGData { set; get; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public class Hour12Data
|
||||
{
|
||||
/// <summary>
|
||||
/// 12小时产能
|
||||
/// </summary>
|
||||
public List<List12HourData> chart12HourDatas { set; get; }
|
||||
}
|
||||
|
||||
public class List12HourData
|
||||
{
|
||||
public List<string> dataTime { set; get; }
|
||||
public List<int> dataTotal { set; get; }
|
||||
public List<int> dataOk { set; get; }
|
||||
public List<double> dataLV { set; get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
namespace JinYuan.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 智能电表
|
||||
/// </summary>
|
||||
public class ElectricEnergy
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 有功电能(累计电能)KWH
|
||||
/// </summary>
|
||||
public System.Decimal? AccumulatedElectricity { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A相电压 V
|
||||
/// </summary>
|
||||
public System.Decimal? PhaseVoltageA { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// B相电压
|
||||
/// </summary>
|
||||
public System.Decimal? PhaseVoltageB { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// C相电压
|
||||
/// </summary>
|
||||
public System.Decimal? PhaseVoltageC { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A相电流
|
||||
/// </summary>
|
||||
public System.Decimal? PhaseCurrentA { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// B相电流
|
||||
/// </summary>
|
||||
public System.Decimal? PhaseCurrentB { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// C相电流
|
||||
/// </summary>
|
||||
public System.Decimal? PhaseCurrentC { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A相功率
|
||||
/// </summary>
|
||||
public System.Decimal? PhasePowerA { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// B相功率
|
||||
/// </summary>
|
||||
public System.Decimal? PhasePowerB { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// C相功率
|
||||
/// </summary>
|
||||
public System.Decimal? PhasePowerC { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 总有功功率
|
||||
/// </summary>
|
||||
public System.Decimal? ActivePower { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 总功率因数
|
||||
/// </summary>
|
||||
public System.Decimal? PowerFactor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 电压变比
|
||||
/// </summary>
|
||||
public System.Decimal? pt { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 电流变比
|
||||
/// </summary>
|
||||
public System.Decimal? ct { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
using SqlSugar;
|
||||
|
||||
namespace JinYuan.Models
|
||||
{
|
||||
public class FDConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// 编号
|
||||
/// </summary>
|
||||
|
||||
public int FdNum { get; set; }
|
||||
/// <summary>
|
||||
/// OK拉带类型1
|
||||
/// </summary>
|
||||
public string OKLD1Type { get; set; }
|
||||
/// <summary>
|
||||
/// OK拉带类型2
|
||||
/// </summary>
|
||||
public string OKLD2Type { get; set; }
|
||||
/// <summary>
|
||||
/// OK拉带类型3
|
||||
/// </summary>
|
||||
public string OKLD3Type { get; set; }
|
||||
/// <summary>
|
||||
/// OK拉带类型4
|
||||
/// </summary>
|
||||
public string OKLD4Type { get; set; }
|
||||
/// <summary>
|
||||
/// NG拉带类型5
|
||||
/// </summary>
|
||||
public string NGLD5Type { get; set; }
|
||||
/// <summary>
|
||||
/// NG拉带类型6
|
||||
/// </summary>
|
||||
public string NGLD6Type { get; set; }
|
||||
/// <summary>
|
||||
/// NG拉带类型7
|
||||
/// </summary>
|
||||
public string NGLD7Type { get; set; }
|
||||
/// <summary>
|
||||
/// 是否开启分档
|
||||
/// </summary>
|
||||
public bool IsFDActive { get; set; }
|
||||
/// <summary>
|
||||
///是否激活NG电池不分类排出
|
||||
/// </summary>
|
||||
|
||||
public bool IsNGActive { get; set; }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
using SqlSugar;
|
||||
|
||||
namespace JinYuan.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 24小时产能
|
||||
/// </summary>
|
||||
public class Hourprod
|
||||
{
|
||||
/// <summary>
|
||||
/// 日期
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
public System.String FDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 小时
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
public System.Int32 FHour { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 投入数
|
||||
/// </summary>
|
||||
public System.Int32 ProdIn { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 产出数
|
||||
/// </summary>
|
||||
public System.Int32 ProdOut { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 时间
|
||||
/// </summary>
|
||||
public System.DateTime? TestTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// PPM
|
||||
/// </summary>
|
||||
public System.Int32 Ppm { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 稼动率
|
||||
/// </summary>
|
||||
public System.Decimal JiaDL { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
<?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>{4C0BCB84-5CD7-4846-8363-C4C10D46E391}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>JinYuan.Models</RootNamespace>
|
||||
<AssemblyName>JinYuan.Models</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<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' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="CsvHelper, Version=30.0.0.0, Culture=neutral, PublicKeyToken=8c4959082be5c823, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\CsvHelper.30.0.1\lib\net47\CsvHelper.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.1.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Bcl.HashCode, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Bcl.HashCode.1.0.0\lib\net461\Microsoft.Bcl.HashCode.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MiniExcel, Version=1.31.2.0, Culture=neutral, PublicKeyToken=e7310002a53eac39, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MiniExcel.1.31.2\lib\net45\MiniExcel.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="PLCCommunication">
|
||||
<HintPath>..\LargeSquareOne\Lib\PLCCommunication.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SqlSugar, Version=5.1.4.94, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\SqlSugar.5.1.4.94\lib\SqlSugar.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Buffers, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.IO.Compression" />
|
||||
<Reference Include="System.Memory, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Memory.4.5.0\lib\netstandard2.0\System.Memory.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Numerics" />
|
||||
<Reference Include="System.Numerics.Vectors, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Numerics.Vectors.4.4.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.2\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll</HintPath>
|
||||
</Reference>
|
||||
<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="NgCodeEntity.cs" />
|
||||
<Compile Include="AlarmCountEntry.cs" />
|
||||
<Compile Include="AlarmForm.cs" />
|
||||
<Compile Include="Alarm\AlarmStatus.cs" />
|
||||
<Compile Include="Alarm\AlarmData.cs" />
|
||||
<Compile Include="FDConfig.cs" />
|
||||
<Compile Include="Chart12HourData.cs" />
|
||||
<Compile Include="ChartDataType.cs" />
|
||||
<Compile Include="AGearEntity.cs" />
|
||||
<Compile Include="CPQCPTDate.cs" />
|
||||
<Compile Include="ElectricEnergy.cs" />
|
||||
<Compile Include="Hourprod.cs" />
|
||||
<Compile Include="BGearEntity.cs" />
|
||||
<Compile Include="SysConfig\ChallengeCode.cs" />
|
||||
<Compile Include="SysConfig\Device.cs" />
|
||||
<Compile Include="CPKModel.cs" />
|
||||
<Compile Include="DeviceOEE.cs" />
|
||||
<Compile Include="SysConfig\Enum.cs" />
|
||||
<Compile Include="SysConfig\Group.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="SysConfig\ParamBase.cs" />
|
||||
<Compile Include="SysConfig\ParamList.cs" />
|
||||
<Compile Include="SysConfig\ProductModel.cs" />
|
||||
<Compile Include="SysConfig\ProductModelParam.cs" />
|
||||
<Compile Include="SysConfig\Variable.cs" />
|
||||
<Compile Include="SysConfig\SysAdmin.cs" />
|
||||
<Compile Include="SysConfig\SysConfig.cs" />
|
||||
<Compile Include="SysConfig\SysLog.cs" />
|
||||
<Compile Include="DataTurnover.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -0,0 +1,21 @@
|
||||
using SqlSugar;
|
||||
|
||||
namespace JinYuan.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// NGCode
|
||||
/// </summary>
|
||||
public class NgCodeEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// 编码
|
||||
/// </summary>
|
||||
public string ngCode { get; set; }
|
||||
/// <summary>
|
||||
/// 不良信息
|
||||
/// </summary>
|
||||
public string ngMessage { get; set; }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// 有关程序集的一般信息由以下
|
||||
// 控制。更改这些特性值可修改
|
||||
// 与程序集关联的信息。
|
||||
[assembly: AssemblyTitle("JinYuan.Models")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("JinYuan.Models")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2023")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// 将 ComVisible 设置为 false 会使此程序集中的类型
|
||||
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
|
||||
//请将此类型的 ComVisible 特性设置为 true。
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
|
||||
[assembly: Guid("4c0bcb84-5cd7-4846-8363-c4c10d46e391")]
|
||||
|
||||
// 程序集的版本信息由下列四个值组成:
|
||||
//
|
||||
// 主版本
|
||||
// 次版本
|
||||
// 生成号
|
||||
// 修订号
|
||||
//
|
||||
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
|
||||
//通过使用 "*",如下所示:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
|
||||
namespace JinYuan.Models
|
||||
{
|
||||
public class Challenge
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 挑战件条码
|
||||
/// </summary>
|
||||
public String ChallengeBarCode { get; set; }
|
||||
/// <summary>
|
||||
/// 电芯信息
|
||||
/// </summary>
|
||||
public String CodeMessage { get; set; }
|
||||
/// <summary>
|
||||
/// 焊前/焊后CCD
|
||||
/// </summary>
|
||||
public String WeldingCCD { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,317 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
|
||||
namespace JinYuan.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 通信设备实体类
|
||||
/// </summary>
|
||||
public class Device
|
||||
{
|
||||
/// <summary>
|
||||
/// IP地址
|
||||
/// </summary>
|
||||
public string IPAddress { get; set; }
|
||||
/// <summary>
|
||||
/// 端口
|
||||
/// </summary>
|
||||
public int Port { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// PLC类型
|
||||
/// </summary>
|
||||
public string PLCType { get; set; }
|
||||
/// <summary>
|
||||
/// 当前设备的连接状态
|
||||
/// </summary>
|
||||
|
||||
public bool IsConnected { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否是首次连接
|
||||
/// </summary>
|
||||
|
||||
public bool IsFirstConnect { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// 重连周期
|
||||
/// </summary>
|
||||
|
||||
public int ReConnectTime { get; set; } = 2000;
|
||||
|
||||
/// <summary>
|
||||
/// 休眠时间
|
||||
/// </summary>
|
||||
|
||||
public int SleepTime { get; set; } = 10;
|
||||
|
||||
/// <summary>
|
||||
/// 大小端
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public int DataFormat { get; set; } = 0;
|
||||
/// <summary>
|
||||
/// 出错次数
|
||||
/// </summary>
|
||||
public int ErrorTimes { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 容错次数
|
||||
/// </summary>
|
||||
public int AllowErrorTimes { get; set; } = 3;
|
||||
|
||||
/// <summary>
|
||||
/// 多线程取消源标志位
|
||||
/// </summary>
|
||||
public CancellationTokenSource Cts { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 计时器
|
||||
/// </summary>
|
||||
|
||||
public Stopwatch Stopwatch { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 所有归档变量的集合
|
||||
/// </summary>
|
||||
|
||||
public List<Variable> StoreVarList { get; set; } = new List<Variable>();
|
||||
|
||||
/// <summary>
|
||||
/// 按工位读取
|
||||
/// </summary>
|
||||
|
||||
public List<Group> WorkVarList { get; set; } = new List<Group>();
|
||||
/// <summary>
|
||||
/// 通信组集合
|
||||
/// </summary>
|
||||
public List<Group> GroupList { get; set; } = new List<Group>();
|
||||
/// <summary>
|
||||
/// 所有变量的集合
|
||||
/// </summary>
|
||||
public List<Variable> VarList { get; set; } = new List<Variable>();
|
||||
|
||||
/// <summary>
|
||||
/// 所有变量名称与值的集合
|
||||
/// </summary>
|
||||
public Dictionary<string, object> CurrentValue { get; set; } = new Dictionary<string, object>();
|
||||
|
||||
/// <summary>
|
||||
/// 定义报警触发和消除事件
|
||||
/// </summary>
|
||||
public event Action<bool, Variable> AlarmTrigEvent;
|
||||
|
||||
/// <summary>
|
||||
/// 变量初始化
|
||||
/// </summary>
|
||||
public void Init()
|
||||
{
|
||||
foreach (var gp in GroupList)
|
||||
{
|
||||
|
||||
if (gp.IsTiggerRead)
|
||||
{
|
||||
WorkVarList.Add(gp);
|
||||
}
|
||||
foreach (var variable in gp.VarList)
|
||||
{
|
||||
if (!gp.IsTiggerRead)
|
||||
{
|
||||
VarList.Add(variable);
|
||||
|
||||
|
||||
if (CurrentValue.ContainsKey(variable.VarName))
|
||||
{
|
||||
CurrentValue[variable.VarName] = "NA";
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentValue.Add(variable.VarName, "NA");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 索引器,通过键名获取到数据
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
[JsonIgnore]
|
||||
public object this[string key]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (CurrentValue.ContainsKey(key))
|
||||
{
|
||||
return CurrentValue[key];
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 实时更新
|
||||
/// </summary>
|
||||
/// <param name="variable"></param>
|
||||
public void Update(Variable variable)
|
||||
{
|
||||
//更新处理
|
||||
if (CurrentValue.ContainsKey(variable.VarName))
|
||||
{
|
||||
CurrentValue[variable.VarName] = variable.VarValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentValue.Add(variable.VarName, variable.VarValue);
|
||||
}
|
||||
|
||||
//报警处理
|
||||
if (variable.HighAlarmEnable || variable.LowAlarmEnable)
|
||||
{
|
||||
float compareValue = 0.0f;
|
||||
|
||||
if (variable.DataType.ToLower() == "bool")
|
||||
{
|
||||
compareValue = Convert.ToBoolean(variable.VarValue) ? 1.0f : 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
compareValue = Convert.ToSingle(variable.VarValue);
|
||||
}
|
||||
|
||||
int compareResult = 0;
|
||||
//高报警时,触发事件
|
||||
if (variable.HighAlarmEnable)
|
||||
{
|
||||
compareResult = Compare(compareValue, variable.HighAlarmValue, variable.HighAlarmCacheValue, true);
|
||||
|
||||
if (compareResult != 0)
|
||||
{
|
||||
//通过事件做通知
|
||||
|
||||
OnAlarmAckEvent(variable, new AlarmEventArgs()
|
||||
{
|
||||
Name = variable.VarName,
|
||||
CurrentValue = variable.VarValue.ToString(),
|
||||
SetValue = variable.HighAlarmValue.ToString(),
|
||||
AlarmNote = variable.HighAlarmNote,
|
||||
IsTrigger = compareResult == 1
|
||||
});
|
||||
}
|
||||
|
||||
variable.HighAlarmCacheValue = compareValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
compareResult = Compare(compareValue, variable.LowAlarmValue, variable.LowAlarmCacheValue, false);
|
||||
|
||||
if (compareResult != 0)
|
||||
{
|
||||
//通过事件做通知
|
||||
|
||||
OnAlarmAckEvent(variable, new AlarmEventArgs()
|
||||
{
|
||||
Name = variable.VarName,
|
||||
CurrentValue = variable.VarValue.ToString(),
|
||||
SetValue = variable.LowAlarmValue.ToString(),
|
||||
AlarmNote = variable.LowAlarmNote,
|
||||
IsTrigger = compareResult == 1
|
||||
});
|
||||
|
||||
}
|
||||
variable.LowAlarmCacheValue = compareValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 报警触发的事件
|
||||
/// </summary>
|
||||
//public event AlarmTriggerEventDelegate AlarmTriggerEvent;
|
||||
|
||||
/// <summary>
|
||||
/// 触发事件
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void OnAlarmAckEvent(object sender, AlarmEventArgs e)
|
||||
{
|
||||
//AlarmTriggerEvent?.Invoke(sender, e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 报警比较
|
||||
/// </summary>
|
||||
/// <param name="current">当前值</param>
|
||||
/// <param name="set">设置值</param>
|
||||
/// <param name="last">缓存值</param>
|
||||
/// <param name="isPositive">上升沿还是下降沿</param>
|
||||
/// <returns>比较结果,1表示触发,-1表示消除,0表示无变化</returns>
|
||||
private int Compare(float current, float set, float last, bool isPositive)
|
||||
{
|
||||
if (isPositive)
|
||||
{
|
||||
if (current >= set && last < set)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if (current < set && last >= set)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (current <= set && last > set)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if (current > set && last <= set)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public class AlarmEventArgs : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// 变量名称
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 当前值
|
||||
/// </summary>
|
||||
public string CurrentValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 报警说明
|
||||
/// </summary>
|
||||
public string AlarmNote { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 报警设定值
|
||||
/// </summary>
|
||||
public string SetValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否为触发
|
||||
/// </summary>
|
||||
public bool IsTrigger { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
namespace JinYuan.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 所有窗体枚举,小于临界窗体的为固定窗体,不执行关闭
|
||||
/// </summary>
|
||||
public enum FormNames
|
||||
{
|
||||
集中监控,
|
||||
数据监控,
|
||||
日志报警,
|
||||
临界窗体,
|
||||
数据分析,
|
||||
数据追溯,
|
||||
参数设置,
|
||||
系统设置,
|
||||
用户管理
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
using MiniExcelLibs.Attributes;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace JinYuan.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 通信组实体类
|
||||
/// </summary>
|
||||
public class Group
|
||||
{
|
||||
/// <summary>
|
||||
///通信组名称
|
||||
/// </summary>
|
||||
public string GroupName { get; set; }
|
||||
/// <summary>
|
||||
/// 起始地址
|
||||
/// </summary>
|
||||
public string Start { get; set; }
|
||||
/// <summary>
|
||||
/// 长度
|
||||
/// </summary>
|
||||
public ushort Length { get; set; }
|
||||
/// <summary>
|
||||
/// 是否为触发读取
|
||||
/// </summary>
|
||||
public bool IsTiggerRead { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否需要反馈结果到PLC
|
||||
/// </summary>
|
||||
public bool IsFeedbackPlc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否启用
|
||||
/// </summary>
|
||||
public bool IsActive { get; set; }
|
||||
/// <summary>
|
||||
/// 备注说明
|
||||
/// </summary>
|
||||
public string Remark { get; set; }
|
||||
/// <summary>
|
||||
/// 变量集合
|
||||
/// </summary>
|
||||
[ExcelIgnore]
|
||||
public List<Variable> VarList { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using SqlSugar;
|
||||
|
||||
namespace JinYuan.Models
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class ParamBase
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public ParamBase()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 序号
|
||||
/// </summary>
|
||||
public System.Int32? fNo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 参数名称
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
public System.String ParaName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
public System.String Remark { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
using SqlSugar;
|
||||
|
||||
namespace JinYuan.Models
|
||||
{
|
||||
public class ParamList
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
public System.String ModelName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
public System.String ParaName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public System.String ParaValueMin { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public System.String ParaValueMax { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public System.String Uint { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public System.String Remark { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public System.DateTime? UpdateTime { get; set; } = System.DateTime.Now;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using SqlSugar;
|
||||
|
||||
namespace JinYuan.Models
|
||||
{
|
||||
public class ProductModel
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
public System.String ModelName { get; set; }
|
||||
/// <summary>
|
||||
/// 物料编码
|
||||
/// </summary>
|
||||
public System.String MaterialCode { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public System.String Remark { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
namespace JinYuan.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 产品型号参数范围
|
||||
/// </summary>
|
||||
public class ProductModelParam
|
||||
{
|
||||
/// <summary>
|
||||
/// 入壳压力1MAX
|
||||
/// </summary>
|
||||
public decimal PrePressure1Max { set; get; }
|
||||
/// <summary>
|
||||
/// 入壳压力2MAX
|
||||
/// </summary>
|
||||
public decimal PrePressure2Max { set; get; }
|
||||
/// <summary>
|
||||
/// 入壳压力3MAX
|
||||
/// </summary>
|
||||
public decimal PrePressure3Max { set; get; }
|
||||
/// <summary>
|
||||
/// 入壳压力下限
|
||||
/// </summary>
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using SqlSugar;
|
||||
|
||||
namespace JinYuan.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 登录实体类型
|
||||
/// </summary>
|
||||
public class SysAdmin
|
||||
{
|
||||
[SugarColumn(IsPrimaryKey = true, IsIgnore = true)]
|
||||
public int LoginId { get; set; }
|
||||
public string LoginName { get; set; }
|
||||
public string LoginPwd { get; set; }
|
||||
public string LoginUid { get; set; }
|
||||
public string LoginLevel { get; set; }
|
||||
public bool SystemLog { get; set; }
|
||||
public bool CpkData { get; set; }
|
||||
public bool HistoryData { get; set; }
|
||||
public bool ParamSet { get; set; }
|
||||
public bool SystemSet { get; set; }
|
||||
public bool UserManage { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
namespace JinYuan.Models
|
||||
{
|
||||
public class SysConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// 开机自动启动
|
||||
/// </summary>
|
||||
public bool AutoStart { get; set; }
|
||||
/// <summary>
|
||||
///启动自动登录
|
||||
/// </summary>
|
||||
public bool AutoLogin { get; set; }
|
||||
/// <summary>
|
||||
///无操作自动锁屏
|
||||
/// </summary>
|
||||
public bool AutoLock { get; set; }
|
||||
/// <summary>
|
||||
///锁屏间隙时间,单位是分钟
|
||||
/// </summary>
|
||||
public int LockPeriod { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///无操作自动锁屏
|
||||
/// </summary>
|
||||
public bool AutoQieHuanM { get; set; }
|
||||
/// <summary>
|
||||
///锁屏间隙时间,单位是分钟
|
||||
/// </summary>
|
||||
public int QieHuanMPeriod { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
///曲线显示数量
|
||||
/// </summary>
|
||||
public int ShowSeriesCount { get; set; }
|
||||
/// <summary>
|
||||
/// 开启刷卡模式
|
||||
/// </summary>
|
||||
public bool SwipeCardMode { get; set; }
|
||||
/// <summary>
|
||||
/// MES/非MES模式切换
|
||||
/// </summary>
|
||||
public bool MesModeSwitching { get; set; }
|
||||
/// <summary>
|
||||
/// 切屏
|
||||
/// </summary>
|
||||
public bool ScreenCutting { get; set; }
|
||||
/// <summary>
|
||||
/// 获取MES参数
|
||||
/// </summary>
|
||||
public bool GetMesParam { get; set; }
|
||||
/// <summary>
|
||||
/// 切换强制OK模式
|
||||
/// </summary>
|
||||
public bool OKSwitching { get; set; }
|
||||
/// <summary>
|
||||
/// 线程耗时日志保存
|
||||
/// </summary>
|
||||
public bool SaveThreadTime { get; set; }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user