添加项目文件。

master
wenjy 1 year ago
commit 6b01b182fb

63
.gitattributes vendored

@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp
###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary
###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary
###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain

363
.gitignore vendored

@ -0,0 +1,363 @@
## 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/
[Oo]ut/
[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

Binary file not shown.

@ -0,0 +1,100 @@
using AsyncSocket;
using SLH.SSDMS.Common;
using SLH.SSDMS.Services;
using SLH.SSDMS.Services.serviceImpl;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SLH.SSDMS.Collect
{
public class AsyncSocket
{
private static AsyncSocketServer server = new AsyncSocketServer();
private static IBufferParse bufferParse = new BufferParse();
public static void init()
{
server.Completed += new Action<string, EnSocketAction>((key, enAction) =>
{
switch (enAction)
{
case EnSocketAction.Connect:
LogHelper.Info(String.Format("接收到来自{0}的连接", key));
break;
case EnSocketAction.SendMsg:
LogHelper.Info(String.Format("向客户端{0}发送了一条消息", key));
break;
case EnSocketAction.Close:
LogHelper.Info(String.Format("{0}关闭了连接", key));
break;
default:
break;
}
});
server.Received += new Action<string, byte[]>((key, msg) =>
{
string bufferStr = StringChange.bytesToHexStr(msg, msg.Length);
LogHelper.Info(String.Format("收到客户端:{0}的数据:{1}", key, StringChange.bytesToHexStr(msg, msg.Length)));
if(bufferStr.Contains("A55A") && bufferStr.Contains("0D0A"))
{
byte[] bufferLength = msg.Skip(2).Take(2).ToArray();
int dataLen = Convert.ToInt32(StringChange.bytesToHexStr(bufferLength, bufferLength.Length), 16) + 1;
try
{
byte[] calByte = new byte[dataLen];
Array.Copy(msg, 2, calByte, 0, dataLen);
var info = checkUtil.BCC(calByte);
var test = msg[msg.Length - 2];
//判断校验
if (msg[msg.Length - 3] == info)
{
if (calByte[2] == 132)
{
sendMessage(bufferParse.ReadAnalysis(calByte).Result);
}
if (calByte[2] == 98)
{
sendMessage(bufferParse.HeartAnalysis(calByte).Result);
}
if (calByte[2] == 164)
{
//终端IO返回
}
}
}
catch (Exception ex)
{
LogHelper.Error("接收数据异常", ex);
throw;
}
}
else
{
LogHelper.Info("异常指令:" + StringChange.bytesToHexStr(msg, msg.Length));
}
});
server.StartAsync(7788);
}
private static void sendMessage(byte[] buffer)
{
server.SendAsync(buffer);
}
}
}

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("SLH.SSDMS.Collect")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SLH.SSDMS.Collect")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("c3937ff9-b218-48e4-a602-c59106b67c7b")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

@ -0,0 +1,64 @@
<?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>{C3937FF9-B218-48E4-A602-C59106B67C7B}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SLH.SSDMS.Collect</RootNamespace>
<AssemblyName>SLH.SSDMS.Collect</AssemblyName>
<TargetFrameworkVersion>v4.5.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="AsyncSocket">
<HintPath>..\Dll\AsyncSocket.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="AsyncSocket.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SLH.SSDMS.Common\SLH.SSDMS.Common.csproj">
<Project>{9DB66868-C6F0-4522-A551-09452B927C52}</Project>
<Name>SLH.SSDMS.Common</Name>
</ProjectReference>
<ProjectReference Include="..\SLH.SSDMS.Services\SLH.SSDMS.Services.csproj">
<Project>{3EFE1A92-DF3D-4B98-8A6B-DDA264385E52}</Project>
<Name>SLH.SSDMS.Services</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

@ -0,0 +1,11 @@
<?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>
</assemblyBinding>
</runtime>
</configuration>

@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SLH.SSDMS.Common
{
public class ConfigHelper
{
/// <summary>
/// 获取配置
/// </summary>
/// <param name="sections">节点配置</param>
/// <returns></returns>
public static string GetConfig(string sections)
{
try
{
return ConfigurationManager.AppSettings[sections].ToString();
}
catch (Exception) { }
return "";
}
/// <summary>
/// 更新Config文件若Key已存在替换当前Val值不存在则添加新的键值对
/// </summary>
/// <param name="str_newKey"></param>
/// <param name="str_newVal"></param>
public static void UpdateAppConfig(string key, string value)
{
//增加的内容写在appSettings段下 <add key="RegCode" value="0"/>
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
if (config.AppSettings.Settings[key] == null)
{
config.AppSettings.Settings.Add(key, value);
}
else
{
config.AppSettings.Settings[key].Value = value;
}
config.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection("appSettings");//重新加载新的配置文件
}
}
}

@ -0,0 +1,152 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
namespace SLH.SSDMS.Common
{
/// <summary>
/// 谓词表达式构建器
/// </summary>
public static class ExpressionExtensions
{
/// <summary>
/// 创建一个值恒为 <c>true</c> 的表达式。
/// </summary>
/// <typeparam name="T">表达式方法类型</typeparam>
/// <returns>一个值恒为 <c>true</c> 的表达式。</returns>
public static Expression<Func<T, bool>> True<T>() { return p => true; }
/// <summary>
/// 创建一个值恒为 <c>false</c> 的表达式。
/// </summary>
/// <typeparam name="T">表达式方法类型</typeparam>
/// <returns>一个值恒为 <c>false</c> 的表达式。</returns>
public static Expression<Func<T, bool>> False<T>() { return f => false; }
/// <summary>
/// 使用 Expression.OrElse 的方式拼接两个 System.Linq.Expression。
/// </summary>
/// <typeparam name="T">表达式方法类型</typeparam>
/// <param name="left">左边的 System.Linq.Expression 。</param>
/// <param name="right">右边的 System.Linq.Expression。</param>
/// <returns>拼接完成的 System.Linq.Expression。</returns>
public static Expression<T> Or<T>(this Expression<T> left, Expression<T> right)
{
return MakeBinary(left, right, Expression.OrElse);
}
/// <summary>
/// 使用 Expression.AndAlso 的方式拼接两个 System.Linq.Expression。
/// </summary>
/// <typeparam name="T">表达式方法类型</typeparam>
/// <param name="left">左边的 System.Linq.Expression 。</param>
/// <param name="right">右边的 System.Linq.Expression。</param>
/// <returns>拼接完成的 System.Linq.Expression。</returns>
public static Expression<T> And<T>(this Expression<T> left, Expression<T> right)
{
return MakeBinary(left, right, Expression.AndAlso);
}
/// <summary>
/// 使用自定义的方式拼接两个 System.Linq.Expression。
/// </summary>
/// <typeparam name="T">表达式方法类型</typeparam>
/// <param name="left">左边的 System.Linq.Expression 。</param>
/// <param name="right">右边的 System.Linq.Expression。</param>
/// <param name="func"> </param>
/// <returns>拼接完成的 System.Linq.Expression。</returns>
private static Expression<T> MakeBinary<T>(this Expression<T> left, Expression<T> right, Func<Expression, Expression, Expression> func)
{
return MakeBinary((LambdaExpression)left, right, func) as Expression<T>;
}
/// <summary>
/// 拼接两个 <paramref>
/// <name>System.Linq.Expression</name>
/// </paramref> ,两个 <paramref>
/// <name>System.Linq.Expression</name>
/// </paramref> 的参数必须完全相同。
/// </summary>
/// <param name="left">左边的 <paramref>
/// <name>System.Linq.Expression</name>
/// </paramref> </param>
/// <param name="right">右边的 <paramref>
/// <name>System.Linq.Expression</name>
/// </paramref> </param>
/// <param name="func">表达式拼接的具体逻辑</param>
/// <returns>拼接完成的 <paramref>
/// <name>System.Linq.Expression</name>
/// </paramref> </returns>
private static LambdaExpression MakeBinary(this LambdaExpression left, LambdaExpression right, Func<Expression, Expression, Expression> func)
{
var data = Combinate(right.Parameters, left.Parameters).ToArray();
right = ParameterReplace.Replace(right, data) as LambdaExpression;
return Expression.Lambda(func(left.Body, right.Body), left.Parameters.ToArray());
}
/// <summary>
/// 合并参数
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="left"></param>
/// <param name="right"></param>
/// <returns></returns>
private static IEnumerable<KeyValuePair<T, T>> Combinate<T>(IEnumerable<T> left, IEnumerable<T> right)
{
var a = left.GetEnumerator();
var b = right.GetEnumerator();
while (a.MoveNext() && b.MoveNext())
yield return new KeyValuePair<T, T>(a.Current, b.Current);
}
}
internal sealed class ParameterReplace : ExpressionVisitor
{
public static Expression Replace(Expression e, IEnumerable<KeyValuePair<ParameterExpression, ParameterExpression>> paramList)
{
var item = new ParameterReplace(paramList);
return item.Visit(e);
}
private readonly Dictionary<ParameterExpression, ParameterExpression> _parameters;
public ParameterReplace(IEnumerable<KeyValuePair<ParameterExpression, ParameterExpression>> paramList)
{
_parameters = paramList.ToDictionary(p => p.Key, p => p.Value, new ParameterEquality());
}
protected override Expression VisitParameter(ParameterExpression p)
{
ParameterExpression result;
if (_parameters.TryGetValue(p, out result))
return result;
return base.VisitParameter(p);
}
#region class: ParameterEquality
private class ParameterEquality : IEqualityComparer<ParameterExpression>
{
public bool Equals(ParameterExpression x, ParameterExpression y)
{
if (x == null || y == null)
return false;
return x.Type == y.Type;
}
public int GetHashCode(ParameterExpression obj)
{
if (obj == null)
return 0;
return obj.Type.GetHashCode();
}
}
#endregion
}
}

@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Script.Serialization;
namespace SLH.SSDMS.Common
{
/// <summary>
/// Json格式转换
/// </summary>
public class JsonChange
{
/// <summary>
/// Model 实体转json
/// </summary>
/// <param name="Model">可以是单个实体也可是实体集ToList()</param>
/// <returns></returns>
public static string ModeToJson(object Model)
{
JavaScriptSerializer serializer = new JavaScriptSerializer();
string str = serializer.Serialize(Model);
//HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json") };
//return result;
return str;
}
}
}

@ -0,0 +1,64 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SLH.SSDMS.Common
{
public class LogHelper
{
//GetLogger表示log4net配置文件中logger标签中name属性此处要一致 不然无log输出
public static readonly log4net.ILog loginfo = log4net.LogManager.GetLogger("loginfo");
public static readonly log4net.ILog logerror = log4net.LogManager.GetLogger("logerror");
/// <summary>
/// 记录Info日志
/// </summary>
/// <param name="msg"></param>
/// <param name="ex"></param>
public static void Info(string msg)
{
Console.WriteLine(msg);
if (loginfo.IsInfoEnabled)
{
loginfo.Info(msg);
}
}
/// <summary>
/// 记录Error日志
/// </summary>
/// <param name="errorMsg"></param>
/// <param name="ex"></param>
public static void Error(string info, Exception ex = null)
{
if (!string.IsNullOrEmpty(info) && ex == null)
{
logerror.ErrorFormat("【附加信息】 : {0}<br>", new object[] { info });
}
else if (!string.IsNullOrEmpty(info) && ex != null)
{
string errorMsg = BeautyErrorMsg(ex);
logerror.ErrorFormat("【附加信息】 : {0}<br>{1}", new object[] { info, errorMsg });
}
else if (string.IsNullOrEmpty(info) && ex != null)
{
string errorMsg = BeautyErrorMsg(ex);
logerror.Error(errorMsg);
}
}
/// <summary>
/// 美化错误信息
/// </summary>
/// <param name="ex">异常</param>
/// <returns>错误信息</returns>
private static string BeautyErrorMsg(Exception ex)
{
string errorMsg = string.Format("【异常类型】:{0} <br>【异常信息】:{1} <br>【堆栈调用】:{2}", new object[] { ex.GetType().Name, ex.Message, ex.StackTrace });
errorMsg = errorMsg.Replace("\r\n", "<br>");
errorMsg = errorMsg.Replace("位置", "<strong style=\"color:red\">位置</strong>");
return errorMsg;
}
}
}

@ -0,0 +1,37 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("SLH.SSDMS.Common")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SLH.SSDMS.Common")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net.config", ConfigFileExtension = "config", Watch = true)]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("9db66868-c6f0-4522-a551-09452b927c52")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

@ -0,0 +1,67 @@
<?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>{9DB66868-C6F0-4522-A551-09452B927C52}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SLH.SSDMS.Common</RootNamespace>
<AssemblyName>SLH.SSDMS.Common</AssemblyName>
<TargetFrameworkVersion>v4.5.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="log4net, Version=2.0.12.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.12\lib\net45\log4net.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Web" />
<Reference Include="System.Web.Extensions" />
<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="checkUtil.cs" />
<Compile Include="ConfigHelper.cs" />
<Compile Include="ExpressionExtensions.cs" />
<Compile Include="JsonChange.cs" />
<Compile Include="LogHelper.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="StringChange.cs" />
<Compile Include="StringExtension.cs" />
<Compile Include="UtilConvert.cs" />
</ItemGroup>
<ItemGroup>
<None Include="log4net.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

@ -0,0 +1,119 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SLH.SSDMS.Common
{
/// <summary>
/// 数据类型转换
/// </summary>
public static class StringChange
{
#region 数据类型转换函数
public static byte[] Swap16Bytes(byte[] OldU16)
{
byte[] ReturnBytes = new byte[2];
ReturnBytes[1] = OldU16[0];
ReturnBytes[0] = OldU16[1];
return ReturnBytes;
}
public static bool CompareBytes(byte[] byteA, byte[] byteB, int iLen)
{
for (int i = 0; i < iLen; i++)
{
if (byteA[i] != byteB[i])
{
return false;
}
}
return true;
}
public static string bytesToHexStr(byte[] bytes, int iLen)//e.g. { 0x01, 0x01} ---> " 01 01"
{
string returnStr = "";
if (bytes != null)
{
for (int i = 0; i < iLen; i++)
{
returnStr += bytes[i].ToString("X2");
}
}
return returnStr;
}
public static byte[] HexStrTorbytes(string strHex)//e.g. " 01 01" ---> { 0x01, 0x01}
{
strHex = strHex.Replace(" ", "");
if ((strHex.Length % 2) != 0)
strHex += " ";
byte[] returnBytes = new byte[strHex.Length / 2];
for (int i = 0; i < returnBytes.Length; i++)
returnBytes[i] = Convert.ToByte(strHex.Substring(i * 2, 2), 16);
return returnBytes;
}
public static string StringToHexString(string s, Encoding encode)
{
byte[] b = encode.GetBytes(s); //按照指定编码将string编程字节数组
string result = string.Empty;
for (int i = 0; i < b.Length; i++) //逐字节变为16进制字符以%隔开
{
result += "%" + Convert.ToString(b[i], 16);
}
return result;
}
public static string HexStringToString(string hs, Encoding encode)
{
//以%分割字符串,并去掉空字符
string[] chars = hs.Split(new char[] { '%' }, StringSplitOptions.RemoveEmptyEntries);
byte[] b = new byte[chars.Length];
//逐个字符变为16进制字节数据
for (int i = 0; i < chars.Length; i++)
{
b[i] = Convert.ToByte(chars[i], 16);
}
//按照指定编码将字节数组变为字符串
return encode.GetString(b);
}
public static short SwapInt16(this short n)
{
return (short)(((n & 0xff) << 8) | ((n >> 8) & 0xff));
}
public static ushort SwapUInt16(this ushort n)
{
return (ushort)(((n & 0xff) << 8) | ((n >> 8) & 0xff));
}
public static int SwapInt32(this int n)
{
return (int)(((SwapInt16((short)n) & 0xffff) << 0x10) |
(SwapInt16((short)(n >> 0x10)) & 0xffff));
}
public static uint SwapUInt32(this uint n)
{
return (uint)(((SwapUInt16((ushort)n) & 0xffff) << 0x10) |
(SwapUInt16((ushort)(n >> 0x10)) & 0xffff));
}
public static long SwapInt64(this long n)
{
return (long)(((SwapInt32((int)n) & 0xffffffffL) << 0x20) |
(SwapInt32((int)(n >> 0x20)) & 0xffffffffL));
}
public static ulong SwapUInt64(this ulong n)
{
return (ulong)(((SwapUInt32((uint)n) & 0xffffffffL) << 0x20) |
(SwapUInt32((uint)(n >> 0x20)) & 0xffffffffL));
}
#endregion
}
}

@ -0,0 +1,339 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Serialization;
namespace SLH.SSDMS.Common
{
/// <summary>
/// 字符串通用类
/// </summary>
public static class StringExtension
{
/// <summary>
/// 用于判断是否为空字符
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public static bool IsBlank(this string s)
{
return s == null || (s.Trim().Length == 0);
}
/// <summary>
/// 用于判断是否不为空字符
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public static bool IsNotBlank(this string s)
{
return !s.IsBlank();
}
/// <summary>
/// 判断是否为有效的Email地址
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public static bool IsValidEmail(this string s)
{
if (!s.IsBlank())
{
const string pattern = @"^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$";
return Regex.IsMatch(s, pattern);
}
return false;
}
/// <summary>
/// 验证是否是合法的电话号码
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public static bool IsValidPhone(this string s)
{
if (!s.IsBlank())
{
return Regex.IsMatch(s, @"^\+?((\d{2,4}(-)?)|(\(\d{2,4}\)))*(\d{0,16})*$");
}
return true;
}
/// <summary>
/// 验证是否是合法的手机号码
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public static bool IsValidMobile(this string s)
{
if (!s.IsBlank())
{
return Regex.IsMatch(s, @"^\+?\d{0,4}?[1][3-8]\d{9}$");
}
return false;
}
/// <summary>
/// 验证是否是合法的邮编
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public static bool IsValidZipCode(this string s)
{
if (!s.IsBlank())
{
return Regex.IsMatch(s, @"[1-9]\d{5}(?!\d)");
}
return true;
}
/// <summary>
/// 验证是否是合法的传真
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public static bool IsValidFax(this string s)
{
if (!s.IsBlank())
{
return Regex.IsMatch(s, @"(^[0-9]{3,4}\-[0-9]{7,8}$)|(^[0-9]{7,8}$)|(^\([0-9]{3,4}\)[0-9]{3,8}$)|(^0{0,1}13[0-9]{9}$)");
}
return true;
}
/// <summary>
/// 检查字符串是否为有效的INT32数字
/// </summary>
/// <param name="val"></param>
/// <returns></returns>
public static bool IsInt32(this string val)
{
if (IsBlank(val))
return false;
Int32 k;
return Int32.TryParse(val, out k);
}
/// <summary>
/// 检查字符串是否为有效的INT64数字
/// </summary>
/// <param name="val"></param>
/// <returns></returns>
public static bool IsInt64(this string val)
{
if (IsBlank(val))
return false;
Int64 k;
return Int64.TryParse(val, out k);
}
/// <summary>
/// 检查字符串是否为有效的Decimal
/// </summary>
/// <param name="val"></param>
/// <returns></returns>
public static bool IsDecimal(this string val)
{
if (IsBlank(val))
return false;
decimal d;
return Decimal.TryParse(val, out d);
}
/// <summary>
/// 将字符串转换成MD5加密字符串
/// </summary>
/// <param name="orgStr"></param>
/// <returns></returns>
public static string ToMD5(this string orgStr)
{
MD5 md5Hasher = MD5.Create();
// Convert the input string to a byte array and compute the hash.
byte[] data = md5Hasher.ComputeHash(Encoding.Default.GetBytes(orgStr));
// Create a new Stringbuilder to collect the bytes
// and create a string.
StringBuilder sBuilder = new StringBuilder();
// Loop through each byte of the hashed data
// and format each one as a hexadecimal string.
for (int i = 0; i < data.Length; i++)
{
sBuilder.Append(data[i].ToString("x2"));
}
// Return the hexadecimal string.
return sBuilder.ToString();
}
/// <summary>
/// 将对象序列化成XML
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="obj"></param>
/// <returns></returns>
public static string ToXML<T>(this T obj) where T : class
{
return ToXML(obj, Encoding.Default.BodyName);
}
public static string ToXML<T>(this T obj, string encodeName) where T : class
{
if (obj == null) throw new ArgumentNullException("obj", "obj is null.");
if (obj is string) throw new ApplicationException("obj can't be string object.");
Encoding en = Encoding.GetEncoding(encodeName);
XmlSerializer serial = new XmlSerializer(typeof(T));
XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
ns.Add("", "");
MemoryStream ms = new MemoryStream();
XmlTextWriter xt = new XmlTextWriter(ms, en);
serial.Serialize(xt, obj, ns);
xt.Close();
ms.Close();
return en.GetString(ms.ToArray());
}
/// <summary>
/// 将XML字符串反序列化成对象实体
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="s"></param>
/// <returns></returns>
public static T Deserial<T>(this string s) where T : class
{
return Deserial<T>(s, Encoding.Default.BodyName);
}
public static T Deserial<T>(this string s, string encodeName) where T : class
{
if (s.IsBlank())
{
throw new ApplicationException("xml string is null or empty.");
}
XmlSerializer serial = new XmlSerializer(typeof(T));
XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
ns.Add("", "");
return (T)serial.Deserialize(new StringReader(s));
}
/// <summary>
/// 获取扩展名
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public static string GetExt(this string s)
{
string ret = string.Empty;
if (s.Contains('.'))
{
string[] temp = s.Split('.');
ret = temp[temp.Length - 1];
}
return ret;
}
/// <summary>
/// 验证QQ格式
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public static bool IsValidQQ(this string s)
{
if (!s.IsBlank())
{
return Regex.IsMatch(s, @"^[1-9]\d{4,15}$");
}
return false;
}
/// <summary>
/// 字符串转成Int
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public static int ToInt(this string s)
{
int res;
int.TryParse(s, out res);
return res;
}
/// <summary>
/// 生成单号
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public static string GenerateBillsNo(this string s)
{
return string.Concat(s, DateTime.Now.ToString("yyyyMMddHHmmss"));
}
/// <summary>
/// 生成初次入库单单号,出库单单号,盘点单单号
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public static string GenerateInBillsNo(this string s)
{
return string.Concat(s, DateTime.Now.ToString("yyMMdd") + "001");
}
/// <summary>
/// 生成初次出库单单号
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public static string GenerateOutBillsNo(this string s)
{
return string.Concat(s, DateTime.Now.ToString("yyyyMMdd") + "0001");
}
/// <summary>
/// 生成打印单号
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public static string GenerateNumber(this string s)
{
Random rd = new Random(GetRandomSeed());
string rdNext = rd.Next(000, 999).ToString();
var str = string.Format("{0:000}", int.Parse(s));
return DateTime.Now.Date.ToString("MMdd") + rdNext + str;
}
/// <summary>
/// 生成打印单号,出库单流水号
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public static string GeneratePrintNo(this string s)
{
var str = string.Format("{0:000}", int.Parse(s));
return str;
}
/// <summary>
/// 生成出库单流水号
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public static string GenerateOutBillsFlowNo(this string s)
{
var str = string.Format("{0:0000}", int.Parse(s));
return str;
}
static int GetRandomSeed()
{
byte[] bytes = new byte[4];
RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
rng.GetBytes(bytes);
return BitConverter.ToInt32(bytes, 0);
}
}
}

@ -0,0 +1,218 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SLH.SSDMS.Common
{
/// <summary>
///
/// </summary>
public static class UtilConvert
{
/// <summary>
///
/// </summary>
/// <param name="thisValue"></param>
/// <returns></returns>
public static int ObjToInt2(this object thisValue)
{
int reval = 0;
if (thisValue == null) return 0;
if (thisValue != null && thisValue != DBNull.Value && int.TryParse(thisValue.ToString(), out reval))
{
return reval;
}
return reval;
}
/// <summary>
///
/// </summary>
/// <param name="thisValue"></param>
/// <param name="errorValue"></param>
/// <returns></returns>
public static int ObjToInt2(this object thisValue, int errorValue)
{
int reval = 0;
if (thisValue != null && thisValue != DBNull.Value && int.TryParse(thisValue.ToString(), out reval))
{
return reval;
}
return errorValue;
}
/// <summary>
///
/// </summary>
/// <param name="thisValue"></param>
/// <returns></returns>
public static double ObjToMoney2(this object thisValue)
{
double reval = 0;
if (thisValue != null && thisValue != DBNull.Value && double.TryParse(thisValue.ToString(), out reval))
{
return reval;
}
return 0;
}
/// <summary>
///
/// </summary>
/// <param name="thisValue"></param>
/// <param name="errorValue"></param>
/// <returns></returns>
public static double ObjToMoney2(this object thisValue, double errorValue)
{
double reval = 0;
if (thisValue != null && thisValue != DBNull.Value && double.TryParse(thisValue.ToString(), out reval))
{
return reval;
}
return errorValue;
}
/// <summary>
///
/// </summary>
/// <param name="thisValue"></param>
/// <returns></returns>
public static string ObjToString2(this object thisValue)
{
if (thisValue != null) return thisValue.ToString().Trim();
return "";
}
/// <summary>
///
/// </summary>
/// <param name="thisValue"></param>
/// <param name="errorValue"></param>
/// <returns></returns>
public static string ObjToString2(this object thisValue, string errorValue)
{
if (thisValue != null) return thisValue.ToString().Trim();
return errorValue;
}
/// <summary>
///
/// </summary>
/// <param name="thisValue"></param>
/// <returns></returns>
public static Decimal ObjToDecimal2(this object thisValue)
{
Decimal reval = 0;
if (thisValue != null && thisValue != DBNull.Value && decimal.TryParse(thisValue.ToString(), out reval))
{
return reval;
}
return 0;
}
/// <summary>
///
/// </summary>
/// <param name="thisValue"></param>
/// <param name="errorValue"></param>
/// <returns></returns>
public static Decimal ObjToDecimal2(this object thisValue, decimal errorValue)
{
Decimal reval = 0;
if (thisValue != null && thisValue != DBNull.Value && decimal.TryParse(thisValue.ToString(), out reval))
{
return reval;
}
return errorValue;
}
/// <summary>
///
/// </summary>
/// <param name="thisValue"></param>
/// <returns></returns>
public static DateTime ObjToDate2(this object thisValue)
{
DateTime reval = DateTime.MinValue;
if (thisValue != null && thisValue != DBNull.Value && DateTime.TryParse(thisValue.ToString(), out reval))
{
reval = Convert.ToDateTime(thisValue);
}
return reval;
}
/// <summary>
///
/// </summary>
/// <param name="thisValue"></param>
/// <param name="errorValue"></param>
/// <returns></returns>
public static DateTime ObjToDate2(this object thisValue, DateTime errorValue)
{
DateTime reval = DateTime.MinValue;
if (thisValue != null && thisValue != DBNull.Value && DateTime.TryParse(thisValue.ToString(), out reval))
{
return reval;
}
return errorValue;
}
/// <summary>
///
/// </summary>
/// <param name="thisValue"></param>
/// <returns></returns>
public static bool ObjToBool2(this object thisValue)
{
bool reval = false;
if (thisValue != null && thisValue != DBNull.Value && bool.TryParse(thisValue.ToString(), out reval))
{
return reval;
}
return reval;
}
/// <summary>
/// List<T>转DataSet
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="list"></param>
/// <returns></returns>
public static DataSet ConvertToDataSet<T>(List<T> list)
{
if (list == null || list.Count <= 0)
{
return null;
}
DataSet ds = new DataSet();
DataTable dt = new DataTable(typeof(T).Name);
DataColumn column;
DataRow row;
System.Reflection.PropertyInfo[] myPropertyInfo = typeof(T).GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance);
foreach (T t in list)
{
if (t == null)
{
continue;
}
row = dt.NewRow();
for (int i = 0, j = myPropertyInfo.Length; i < j; i++)
{
System.Reflection.PropertyInfo pi = myPropertyInfo[i];
string name = pi.Name;
if (dt.Columns[name] == null)
{
column = new DataColumn(name, pi.PropertyType);
dt.Columns.Add(column);
}
row[name] = pi.GetValue(t, null);
}
dt.Rows.Add(row);
}
ds.Tables.Add(dt);
return ds;
}
}
}

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SLH.SSDMS.Common
{
public class checkUtil
{
/// <summary>
/// 异或校验
/// </summary>
/// <param name="data"></param>
/// <returns></returns>
public static int BCC(byte[] data)
{
int temp = 0;
for (int index = 0; index < data.Length; index++)
{
temp = temp ^ data[index];
}
return temp;
}
}
}

@ -0,0 +1,59 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="log4net" type="System.Configuration.IgnoreSectionHandler"/>
</configSections>
<appSettings>
</appSettings>
<log4net>
<!--错误日志类-->
<logger name="logerror">
<!--日志类的名字-->
<level value="ALL" />
<!--定义记录的日志级别-->
<appender-ref ref="ErrorAppender" />
<!--记录到哪个介质中去-->
</logger>
<!--信息日志类-->
<logger name="loginfo">
<level value="ALL" />
<appender-ref ref="InfoAppender" />
</logger>
<!--错误日志附加介质-->
<appender name="ErrorAppender" type="log4net.Appender.RollingFileAppender">
<!-- name属性指定其名称,type则是log4net.Appender命名空间的一个类的名称,意思是,指定使用哪种介质-->
<param name="File" value="Log\\LogError\\" />
<!--日志输出到exe程序这个相对目录下-->
<param name="AppendToFile" value="true" />
<!--输出的日志不会覆盖以前的信息-->
<param name="MaxSizeRollBackups" value="100" />
<!--备份文件的个数-->
<param name="MaxFileSize" value="10240" />
<!--当个日志文件的最大大小-->
<param name="StaticLogFileName" value="false" />
<!--是否使用静态文件名-->
<param name="DatePattern" value="yyyyMMdd&quot;.htm&quot;" />
<!--日志文件名-->
<param name="RollingStyle" value="Date" />
<!--文件创建的方式这里是以Date方式创建-->
<!--错误日志布局-->
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="&lt;HR COLOR=red&gt;%n异常时间%d [%t] &lt;BR&gt;%n异常级别%-5p &lt;BR&gt;%n异 常 类:%c [%x] &lt;BR&gt;%n%m &lt;BR&gt;%n &lt;HR Size=1&gt;" />
</layout>
</appender>
<!--信息日志附加介质-->
<appender name="InfoAppender" type="log4net.Appender.RollingFileAppender">
<param name="File" value="Log\\LogInfo\\" />
<param name="AppendToFile" value="true" />
<param name="MaxFileSize" value="10240" />
<param name="MaxSizeRollBackups" value="100" />
<param name="StaticLogFileName" value="false" />
<param name="DatePattern" value="yyyyMMdd&quot;.htm&quot;" />
<param name="RollingStyle" value="Date" />
<!--信息日志布局-->
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="&lt;HR COLOR=blue&gt;%n日志时间%d [%t] &lt;BR&gt;%n日志级别%-5p &lt;BR&gt;%n日 志 类:%c [%x] &lt;BR&gt;%n%m &lt;BR&gt;%n &lt;HR Size=1&gt;" />
</layout>
</appender>
</log4net>
</configuration>

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="log4net" version="2.0.12" targetFramework="net452" />
</packages>

@ -0,0 +1,158 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SLH.SSDMS.Model.DO
{
///<summary>
///
///</summary>
[SugarTable("base_BeltInfo")]
public partial class Base_BeltInfo
{
public Base_BeltInfo()
{
}
public Base_BeltInfo(string lotNum, string proYear, string proMonth, string proMachine, DateTime boardTime)
{
this.lotNum = lotNum;
this.proYear = proYear;
this.proMonth = proMonth;
this.proMachine = proMachine;
this.boardTime = boardTime;
}
/// <summary>
/// Desc:主键
/// Default:
/// Nullable:False
/// </summary>
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public int objId { get; set; }
/// <summary>
/// Desc:卷号
/// Default:
/// Nullable:True
/// </summary>
public string lotNum { get; set; }
/// <summary>
/// Desc:生产年
/// Default:
/// Nullable:True
/// </summary>
public string proYear { get; set; }
/// <summary>
/// Desc:生产月
/// Default:
/// Nullable:True
/// </summary>
public string proMonth { get; set; }
/// <summary>
/// Desc:生产机台
/// Default:
/// Nullable:True
/// </summary>
public string proMachine { get; set; }
/// <summary>
/// Desc:上机时间
/// Default:
/// Nullable:True
/// </summary>
public DateTime boardTime { get; set; }
/// <summary>
/// 安装长度
/// </summary>
public int beltLength { get; set; }
/// <summary>
/// 更换标识
/// </summary>
public int updateFlag { get; set; }
/// <summary>
/// 运行时长
/// </summary>
public decimal runTime { get; set; }
/// <summary>
/// Desc:带强
/// Default:
/// Nullable:True
/// </summary>
public string beltStrength { get; set; }
/// <summary>
/// Desc:带宽
/// Default:
/// Nullable:True
/// </summary>
public string beltWidth { get; set; }
/// <summary>
/// Desc:上胶厚度
/// Default:
/// Nullable:True
/// </summary>
public string upGlueThick { get; set; }
/// <summary>
/// Desc:连接符
/// Default:
/// Nullable:True
/// </summary>
public string unionSymbol { get; set; }
/// <summary>
/// Desc:下胶厚度
/// Default:
/// Nullable:True
/// </summary>
public string downGlueThick { get; set; }
/// <summary>
/// Desc:盖胶级别
/// Default:
/// Nullable:True
/// </summary>
public string coverGlueLevel { get; set; }
/// <summary>
/// 首次上机时间
/// </summary>
public string firstTime { get; set; }
public string uuid { get; set; }
/// <summary>
/// 正转时长
/// </summary>
public int clockwiseTime { get; set; }
/// <summary>
/// 正转里程
/// </summary>
public int clockwiseDistance { get; set; }
/// <summary>
/// 反转时长
/// </summary>
public int antiClockwiseTime { get; set; }
/// <summary>
/// 反转里程
/// </summary>
public int antiClockwiseDistance { get; set; }
}
}

@ -0,0 +1,100 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SLH.SSDMS.Model.DO
{
///<summary>
///
///</summary>
[SugarTable("base_Calculate")]
public partial class Base_Calculate
{
public Base_Calculate()
{
}
/// <summary>
/// Desc:
/// Default:
/// Nullable:False
/// </summary>
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public int objId { get; set; }
/// <summary>
/// Desc:标签序号
/// Default:
/// Nullable:True
/// </summary>
public string rfidOrder { get; set; }
/// <summary>
/// Desc:rfid标签
/// Default:
/// Nullable:True
/// </summary>
public string rfidNum { get; set; }
/// <summary>
/// Desc:第一次记录时间
/// Default:
/// Nullable:True
/// </summary>
public DateTime? firstRecordTime { get; set; }
/// <summary>
/// Desc:最新读取时间
/// Default:
/// Nullable:True
/// </summary>
public DateTime? readTime { get; set; }
/// <summary>
/// Desc:前距
/// Default:
/// Nullable:True
/// </summary>
public string preDistance { get; set; }
/// <summary>
/// Desc:后距
/// Default:
/// Nullable:True
/// </summary>
public string aftDistance { get; set; }
/// <summary>
/// Desc:删除标志
/// Default:
/// Nullable:True
/// </summary>
public string deleteFlag { get; set; }
/// <summary>
/// Desc:预留
/// Default:
/// Nullable:True
/// </summary>
public string reserved1 { get; set; }
/// <summary>
/// Desc:
/// Default:
/// Nullable:True
/// </summary>
public string reserved2 { get; set; }
/// <summary>
/// Desc:
/// Default:
/// Nullable:True
/// </summary>
public string reserved3 { get; set; }
}
}

@ -0,0 +1,143 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SLH.SSDMS.Model.DO
{
///<summary>
///更换记录表
///</summary>
[SugarTable("base_ChangeRecord")]
public partial class Base_ChangeRecord
{
public Base_ChangeRecord()
{
}
public Base_ChangeRecord(string lotNum, string proYear, string proMonth, string proMachine,
string beltStrength, string beltWidth, string upGlueThick,
string unionSymbol, string downGlueThick, string coverGlueLevel, string oldUUID)
{
this.lotNum = lotNum;
this.proYear = proYear;
this.proMonth = proMonth;
this.proMachine = proMachine;
this.beltStrength = beltStrength;
this.beltWidth = beltWidth;
this.upGlueThick = upGlueThick;
this.unionSymbol = unionSymbol;
this.downGlueThick = downGlueThick;
this.coverGlueLevel = coverGlueLevel;
this.oldUUID = oldUUID;
}
/// <summary>
/// Desc:主键
/// Default:
/// Nullable:True
/// </summary>
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public int objId { get; set; }
/// <summary>
/// 历史卷号
/// </summary>
public string oldNum { get; set; }
/// <summary>
/// Desc:卷号
/// Default:
/// Nullable:True
/// </summary>
public string lotNum { get; set; }
/// <summary>
/// Desc:生产年
/// Default:
/// Nullable:True
/// </summary>
public string proYear { get; set; }
/// <summary>
/// Desc:生产月
/// Default:
/// Nullable:True
/// </summary>
public string proMonth { get; set; }
/// <summary>
/// Desc:生产机台
/// Default:
/// Nullable:True
/// </summary>
public string proMachine { get; set; }
/// <summary>
/// Desc:带强
/// Default:
/// Nullable:True
/// </summary>
public string beltStrength { get; set; }
/// <summary>
/// Desc:带宽
/// Default:
/// Nullable:True
/// </summary>
public string beltWidth { get; set; }
/// <summary>
/// Desc:上胶厚度
/// Default:
/// Nullable:True
/// </summary>
public string upGlueThick { get; set; }
/// <summary>
/// Desc:连接符
/// Default:
/// Nullable:True
/// </summary>
public string unionSymbol { get; set; }
/// <summary>
/// Desc:下胶厚度
/// Default:
/// Nullable:True
/// </summary>
public string downGlueThick { get; set; }
/// <summary>
/// Desc:盖胶级别
/// Default:
/// Nullable:True
/// </summary>
public string coverGlueLevel { get; set; }
/// <summary>
/// 更换时间
/// </summary>
public DateTime changeTime { get; set; }
/// <summary>
/// 运行里程
/// </summary>
public int runDistance { get; set; }
/// <summary>
/// 运行时长
/// </summary>
public decimal runTime { get; set; }
/// <summary>
/// 旧胶带UUID
/// </summary>
public string oldUUID { get; set; }
}
}

@ -0,0 +1,63 @@
using SLH.SSDMS.Model.Enums;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SLH.SSDMS.Model.DO
{
///<summary>
///日志记录
///</summary>
[SugarTable("base_LogRecord")]
public partial class Base_LogRecord
{
public Base_LogRecord() { }
public Base_LogRecord(LogType logType, string logInfo, string logError, DateTime recordTime)
{
this.logType = logType;
this.logInfo = logInfo;
this.logError = logError;
this.recordTime = recordTime;
}
/// <summary>
/// Desc:自增标识
/// Default:
/// Nullable:False
/// </summary>
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public int objId { get; set; }
/// <summary>
/// Desc:日志类型1-查询、2-添加、3-修改、4-删除
/// Default:
/// Nullable:True
/// </summary>
public LogType logType { get; set; }
/// <summary>
/// Desc:日志信息
/// Default:
/// Nullable:True
/// </summary>
public string logInfo { get; set; }
/// <summary>
/// Desc:异常日志
/// Default:
/// Nullable:True
/// </summary>
public string logError { get; set; }
/// <summary>
/// Desc:记录时间
/// Default:
/// Nullable:True
/// </summary>
public DateTime recordTime { get; set; }
}
}

@ -0,0 +1,84 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SLH.SSDMS.Model.DO
{
[SugarTable("base_RFIDInfo")]
public class Base_RFIDInfo
{
public Base_RFIDInfo()
{
}
public Base_RFIDInfo(string rfidCode, string lotNum, int orderFlag, int updateFlag, string firstTime, string uuid, int preDistance)
{
this.rfidCode = rfidCode;
this.lotNum = lotNum;
this.orderFlag = orderFlag;
this.updateFlag = updateFlag;
this.firstTime = firstTime;
this.uuid = uuid;
this.preDistance = preDistance;
}
/// <summary>
/// Desc:主键
/// Default:
/// Nullable:False
/// </summary>
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public int objId { get; set; }
/// <summary>
/// Desc:RFID
/// Default:
/// Nullable:True
/// </summary>
public string rfidCode { get; set; }
/// <summary>
/// Desc:卷号
/// Default:
/// Nullable:True
/// </summary>
public string lotNum { get; set; }
/// <summary>
/// Desc:正反转标识 0-正转、1-反转
/// Default:
/// Nullable:True
/// </summary>
public int orderFlag { get; set; }
/// /// <summary>
/// Desc:更换标识 0-否、1-是
/// Default:
/// Nullable:True
/// </summary>
public int updateFlag { get; set; }
/// <summary>
/// Desc:首次读取时间
/// Default:
/// Nullable:True
/// </summary>
public string firstTime { get; set; }
/// <summary>
/// UUID
/// </summary>
public string uuid { get; set; }
/// <summary>
/// 前距
/// </summary>
public int preDistance { get; set; }
}
}

@ -0,0 +1,155 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SLH.SSDMS.Model.DO
{
///<summary>
///
///</summary>
[SugarTable("base_ReadRecord")]
public partial class Base_ReadRecord
{
public Base_ReadRecord()
{
}
/// <summary>
/// Desc:标识
/// Default:
/// Nullable:False
/// </summary>
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public int objId { get; set; }
/// <summary>
/// Desc:rfid标签号
/// Default:
/// Nullable:True
/// </summary>
public string rfidCode { get; set; }
/// <summary>
/// Desc:生产年
/// Default:
/// Nullable:True
/// </summary>
public string proYear { get; set; }
/// <summary>
/// Desc:生产月
/// Default:
/// Nullable:True
/// </summary>
public string proMonth { get; set; }
/// <summary>
/// Desc:生产机台
/// Default:
/// Nullable:True
/// </summary>
public string proMachine { get; set; }
/// <summary>
/// Desc:带强
/// Default:
/// Nullable:True
/// </summary>
public string beltStrength { get; set; }
/// <summary>
/// Desc:带宽
/// Default:
/// Nullable:True
/// </summary>
public string beltWidth { get; set; }
/// <summary>
/// Desc:上胶厚度
/// Default:
/// Nullable:True
/// </summary>
public string upGlueThick { get; set; }
/// <summary>
/// Desc:连接符
/// Default:
/// Nullable:True
/// </summary>
public string unionSymbol { get; set; }
/// <summary>
/// Desc:下胶厚度
/// Default:
/// Nullable:True
/// </summary>
public string downGlueThick { get; set; }
/// <summary>
/// Desc:盖胶级别
/// Default:
/// Nullable:True
/// </summary>
public string coverGlueLevel { get; set; }
/// <summary>
/// Desc:卷号
/// Default:
/// Nullable:True
/// </summary>
public string lotNum { get; set; }
/// <summary>
/// Desc:RFID序号
/// Default:
/// Nullable:True
/// </summary>
public string rfidOrder { get; set; }
/// <summary>
/// Desc:RFID前间隔
/// Default:
/// Nullable:True
/// </summary>
public int preDistance { get; set; }
/// <summary>
/// Desc:RFID后间隔
/// Default:
/// Nullable:True
/// </summary>
public int aftDistance { get; set; }
/// <summary>
/// Desc:记录时间
/// Default:
/// Nullable:True
/// </summary>
public DateTime readTime { get; set; }
/// <summary>
///
/// </summary>
public decimal timeNumber { get; set; }
/// <summary>
/// 终端地址
/// </summary>
public string terminal { get; set; }
/// <summary>
/// UUID
/// </summary>
public string uuid { get; set; }
/// <summary>
/// 正反转标识:0-正转、1-反转
/// </summary>
public int orderFlag { get; set; }
}
}

@ -0,0 +1,83 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SLH.SSDMS.Model.DO
{
///<summary>
///
///</summary>
[SugarTable("base_RunRecord")]
public partial class Base_RunRecord
{
public Base_RunRecord()
{
}
public Base_RunRecord(string lotNum, int runTime, int runDistance, DateTime recordTime)
{
this.lotNum = lotNum;
this.runTime = runTime;
this.runDistance = runDistance;
this.recordTime = recordTime;
}
/// <summary>
/// Desc:主键
/// Default:
/// Nullable:False
/// </summary>
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public int objId { get; set; }
/// <summary>
/// Desc:卷号
/// Default:
/// Nullable:True
/// </summary>
public string lotNum { get; set; }
/// <summary>
/// 开机时间
/// </summary>
public DateTime startTime { get; set; }
/// <summary>
/// 关机时间
/// </summary>
public DateTime endTime { get; set; }
/// <summary>
/// Desc:运行时长
/// Default:
/// Nullable:True
/// </summary>
public int runTime { get; set; }
/// <summary>
/// Desc:运行距离
/// Default:
/// Nullable:True
/// </summary>
public int runDistance { get; set; }
/// <summary>
/// Desc:日期
/// Default:
/// Nullable:True
/// </summary>
public DateTime recordTime { get; set; }
/// <summary>
/// Desc:是否启用
/// Default:
/// Nullable:True
/// </summary>
public int delete_flag { get; set; }
}
}

@ -0,0 +1,52 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SLH.SSDMS.Model.DO
{
/// <summary>
/// RFID顺序
/// </summary>
[SugarTable("base_rfidOrder")]
public class Base_rfidOrder
{
/// <summary>
/// Desc:主键
/// Default:
/// Nullable:False
/// </summary>
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public int objId { get; set; }
/// <summary>
/// Desc:RFID
/// Default:
/// Nullable:False
/// </summary>
public string RFIDCode { get; set; }
/// <summary>
/// Desc:卷号
/// Default:
/// Nullable:False
/// </summary>
public string lotNum { get; set; }
/// <summary>
/// Desc:RFID序号
/// Default:
/// Nullable:False
/// </summary>
public int rfidOrder { get; set; }
/// <summary>
/// Desc:修改时间
/// Default:
/// Nullable:False
/// </summary>
public DateTime updateTime { get; set; }
}
}

@ -0,0 +1,99 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SLH.SSDMS.Model.DO
{
[SugarTable("day_RunInfo")]
public class Day_RunInfo
{
public Day_RunInfo()
{
}
public Day_RunInfo(string lotNum, string beginTime, string endTime, string recordTime)
{
this.lotNum = lotNum;
this.beginTime = beginTime;
this.endTime = endTime;
this.recordTime = recordTime;
}
/// <summary>
/// Desc:主键
/// Default:
/// Nullable:False
/// </summary>
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public int objId { get; set; }
/// <summary>
/// Desc:卷号
/// Default:
/// Nullable:False
/// </summary>
public string lotNum { get; set; }
/// <summary>
/// Desc:开始时间
/// Default:
/// Nullable:False
/// </summary>
public string beginTime { get; set; }
/// <summary>
/// Desc:结束时间
/// Default:
/// Nullable:False
/// </summary>
public string endTime { get; set; }
/// <summary>
/// Desc:运行时长
/// Default:
/// Nullable:False
/// </summary>
public decimal runTime { get; set; }
/// <summary>
/// Desc:运行里程
/// Default:
/// Nullable:False
/// </summary>
public decimal runDistance { get; set; }
/// <summary>
/// Desc:记录时间
/// Default:
/// Nullable:False
/// </summary>
public string recordTime { get; set; }
/// <summary>
/// 正转时长
/// </summary>
public int clockwiseTime { get; set; }
/// <summary>
/// 正转里程
/// </summary>
public int clockwiseDistance { get; set; }
/// <summary>
/// 反转时长
/// </summary>
public int antiClockwiseTime { get; set; }
/// <summary>
/// 反转里程
/// </summary>
public int antiClockwiseDistance { get; set; }
public string uuid { get; set; }
}
}

@ -0,0 +1,25 @@
using Microsoft.SqlServer.Server;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SLH.SSDMS.Model.DO
{
[SugarTable("sys_config")]
public class Sys_Config
{
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public int config_id { get; set; }
public string config_name { get; set; }
public string config_key { get; set; }
public string config_value { get; set; }
public string remark { get; set; }
}
}

@ -0,0 +1,118 @@
using SLH.SSDMS.Model.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SLH.SSDMS.Model.DTO
{
/// <summary>
/// 输送带里程DTO
/// </summary>
public class BeltInfoDTO
{ /// <summary>
/// Desc:主键
/// Default:
/// Nullable:False
/// </summary>
public int objId { get; set; }
/// <summary>
/// Desc:卷号
/// Default:
/// Nullable:True
/// </summary>
public string lotNum { get; set; }
/// <summary>
/// Desc:生产年
/// Default:
/// Nullable:True
/// </summary>
public string proYear { get; set; }
/// <summary>
/// Desc:生产月
/// Default:
/// Nullable:True
/// </summary>
public string proMonth { get; set; }
/// <summary>
/// Desc:生产机台
/// Default:
/// Nullable:True
/// </summary>
public string proMachine { get; set; }
/// <summary>
/// Desc:上机时间
/// Default:
/// Nullable:True
/// </summary>
public DateTime boardTime { get; set; }
/// <summary>
/// 更换标识
/// </summary>
public IfBeltChanged updateFlag { get; set; }
/// <summary>
/// 运行时长
/// </summary>
public decimal runTime { get; set; }
/// <summary>
/// 运行里程
/// </summary>
public decimal distance { get; set; }
/// <summary>
/// Desc:带强
/// Default:
/// Nullable:True
/// </summary>
public string beltStrength { get; set; }
/// <summary>
/// Desc:带宽
/// Default:
/// Nullable:True
/// </summary>
public string beltWidth { get; set; }
/// <summary>
/// Desc:上胶厚度
/// Default:
/// Nullable:True
/// </summary>
public string upGlueThick { get; set; }
/// <summary>
/// Desc:连接符
/// Default:
/// Nullable:True
/// </summary>
public string unionSymbol { get; set; }
/// <summary>
/// Desc:下胶厚度
/// Default:
/// Nullable:True
/// </summary>
public string downGlueThick { get; set; }
/// <summary>
/// Desc:盖胶级别
/// Default:
/// Nullable:True
/// </summary>
public string coverGlueLevel { get; set; }
/// <summary>
///
/// </summary>
public DateTime firstTime { get; set; }
}
}

@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SLH.SSDMS.Model.DTO
{
/// <summary>
/// 通用分页信息类
/// </summary>
public class PageModel<T>
{
/// <summary>
/// 当前页标
/// </summary>
public int page { get; set; } = 1;
/// <summary>
/// 总页数
/// </summary>
public int pageCount { get; set; } = 6;
/// <summary>
/// 数据总数
/// </summary>
public int dataCount { get; set; } = 0;
/// <summary>
/// 每页大小
/// </summary>
public int PageSize { set; get; }
/// <summary>
/// 返回数据
/// </summary>
public List<T> data { get; set; }
}
}

@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SLH.SSDMS.Model.DTO
{
/// <summary>
/// 无人巡检数据上传DTO
/// </summary>
public class UploadModelDTO
{
public int objId { get; set; }
/// <summary>
/// 运行方向
/// </summary>
public int orderFlag { get; set; }
/// <summary>
/// 运行速度
/// </summary>
public decimal speed { get; set; }
/// <summary>
/// 运载流量
/// </summary>
public decimal carryFlow { get; set; }
/// <summary>
/// 总作业量
/// </summary>
public decimal titalWorkLoad { get; set; }
/// <summary>
/// 记录时间
/// </summary>
public string readTime { get; set; }
}
}

@ -0,0 +1,181 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SLH.SSDMS.Model.DTO
{
/// <summary>
/// 视图层数据封装
/// </summary>
public class ViewModelDTO
{
/// <summary>
/// Desc:标识
/// Default:
/// Nullable:False
/// </summary>
public int objId { get; set; }
/// <summary>
/// Desc:rfid标签号
/// Default:
/// Nullable:True
/// </summary>
public string rfidCode { get; set; }
/// <summary>
/// Desc:生产年
/// Default:
/// Nullable:True
/// </summary>
public string proYear { get; set; }
/// <summary>
/// Desc:生产月
/// Default:
/// Nullable:True
/// </summary>
public string proMonth { get; set; }
/// <summary>
/// Desc:生产机台
/// Default:
/// Nullable:True
/// </summary>
public string proMachine { get; set; }
/// <summary>
/// Desc:带强
/// Default:
/// Nullable:True
/// </summary>
public string beltStrength { get; set; }
/// <summary>
/// Desc:带宽
/// Default:
/// Nullable:True
/// </summary>
public string beltWidth { get; set; }
/// <summary>
/// Desc:上胶厚度
/// Default:
/// Nullable:True
/// </summary>
public string upGlueThick { get; set; }
/// <summary>
/// Desc:连接符
/// Default:
/// Nullable:True
/// </summary>
public string unionSymbol { get; set; }
/// <summary>
/// Desc:下胶厚度
/// Default:
/// Nullable:True
/// </summary>
public string downGlueThick { get; set; }
/// <summary>
/// Desc:盖胶级别
/// Default:
/// Nullable:True
/// </summary>
public string coverGlueLevel { get; set; }
/// <summary>
/// Desc:卷号
/// Default:
/// Nullable:True
/// </summary>
public string lotNum { get; set; }
/// <summary>
/// Desc:RFID序号
/// Default:
/// Nullable:True
/// </summary>
public string rfidOrder { get; set; }
/// <summary>
/// Desc:RFID前间隔
/// Default:
/// Nullable:True
/// </summary>
public int preDistance { get; set; }
/// <summary>
/// Desc:RFID后间隔
/// Default:
/// Nullable:True
/// </summary>
public int aftDistance { get; set; }
/// <summary>
/// Desc:记录时间
/// Default:
/// Nullable:True
/// </summary>
public DateTime readTime { get; set; }
/// <summary>
/// 速度
/// </summary>
public decimal speed { get; set; }
/// <summary>
/// 距离
/// </summary>
public decimal distance { get; set; }
/// <summary>
/// 上机时间
/// </summary>
public DateTime boardTime { get; set; }
/// <summary>
/// 更换标识
/// </summary>
public int updateFlag { get; set; }
/// <summary>
/// 累计运行时长
/// </summary>
public decimal runTime { get; set; }
/// <summary>
/// 终端地址
/// </summary>
public string terminal { get; set; }
/// <summary>
/// 胶带数量
/// </summary>
public int beltSum { get; set; }
/// <summary>
/// 运转方向 0-正转1-反转
/// </summary>
public int orderFlag { get; set; }
/// <summary>
/// 首次读取时间
/// </summary>
public string firstTime { get; set; }
/// <summary>
/// 运载流量
/// </summary>
public decimal carryFlow { get; set; }
/// <summary>
/// 总作业量
/// </summary>
public decimal titalWorkLoad { get; set; }
}
}

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SLH.SSDMS.Model.Enums
{
public enum IfBeltChanged
{
/// <summary>
/// 是
/// </summary>
YES,
/// <summary>
/// 否
/// </summary>
NO,
}
}

@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SLH.SSDMS.Model.Enums
{
public enum LogType
{
/// <summary>
/// 查詢
/// </summary>
,
/// <summary>
/// 添加
/// </summary>
,
/// <summary>
/// 修改
/// </summary>
,
/// <summary>
/// 刪除
/// </summary>
,
/// <summary>
/// 接收
/// </summary>
,
/// <summary>
/// 解析
/// </summary>
,
/// <summary>
/// 运行日志
/// </summary>
,
}
}

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("SLH.SSDMS.Model")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SLH.SSDMS.Model")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("1c8b2e03-fc2d-4385-b87a-51a8dd92fe01")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

@ -0,0 +1,70 @@
<?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>{1C8B2E03-FC2D-4385-B87A-51A8DD92FE01}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SLH.SSDMS.Model</RootNamespace>
<AssemblyName>SLH.SSDMS.Model</AssemblyName>
<TargetFrameworkVersion>v4.5.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="SqlSugar, Version=5.0.2.6, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\SqlSugar.5.0.2.6\lib\SqlSugar.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="DO\Base_BeltInfo.cs" />
<Compile Include="DO\Base_Calculate.cs" />
<Compile Include="DO\Base_ChangeRecord.cs" />
<Compile Include="DO\Base_LogRecord.cs" />
<Compile Include="DO\Base_ReadRecord.cs" />
<Compile Include="DO\Base_RFIDInfo.cs" />
<Compile Include="DO\Base_rfidOrder.cs" />
<Compile Include="DO\Base_RunRecord.cs" />
<Compile Include="DO\Day_RunInfo.cs" />
<Compile Include="DO\Sys_Config.cs" />
<Compile Include="DTO\BeltInfoDTO.cs" />
<Compile Include="DTO\PageModel.cs" />
<Compile Include="DTO\UploadModelDTO.cs" />
<Compile Include="DTO\ViewModelDTO.cs" />
<Compile Include="Enums\IfBeltChanged.cs" />
<Compile Include="Enums\LogType.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="SqlSugar" version="5.0.2.6" targetFramework="net452" />
</packages>

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("SLH.SSDMS.RestSharp")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SLH.SSDMS.RestSharp")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("bd42a6ec-6a27-4e28-938f-9e7906d049e0")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

@ -0,0 +1,69 @@
<?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>{BD42A6EC-6A27-4E28-938F-9E7906D049E0}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SLH.SSDMS.RestSharp</RootNamespace>
<AssemblyName>SLH.SSDMS.RestSharp</AssemblyName>
<TargetFrameworkVersion>v4.5.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.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="RestSharp, Version=106.11.7.0, Culture=neutral, PublicKeyToken=598062e77f915f75, processorArchitecture=MSIL">
<HintPath>..\packages\RestSharp.106.11.7\lib\net452\RestSharp.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Web" />
<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="Upload.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SLH.SSDMS.Common\SLH.SSDMS.Common.csproj">
<Project>{9DB66868-C6F0-4522-A551-09452B927C52}</Project>
<Name>SLH.SSDMS.Common</Name>
</ProjectReference>
<ProjectReference Include="..\SLH.SSDMS.Model\SLH.SSDMS.Model.csproj">
<Project>{1C8B2E03-FC2D-4385-B87A-51A8DD92FE01}</Project>
<Name>SLH.SSDMS.Model</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

@ -0,0 +1,45 @@
using Newtonsoft.Json;
using RestSharp;
using SLH.SSDMS.Common;
using SLH.SSDMS.Model.DTO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SLH.SSDMS.RestSharp
{
public class Upload
{
public static void sendMessage(ViewModelDTO viewModelDTO)
{
try
{
var client = new RestClient(ConfigHelper.GetConfig("uploadUrl"));
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
UploadModelDTO uploadModelDTO = new UploadModelDTO
{
objId = 10,
orderFlag = viewModelDTO.orderFlag,
speed = viewModelDTO.speed,
carryFlow = viewModelDTO.carryFlow,
titalWorkLoad = viewModelDTO.titalWorkLoad,
readTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
};
string info = JsonConvert.SerializeObject(uploadModelDTO);
LogHelper.Info("上传数据至无人巡检系统:" + info);
request.AddJsonBody(info);
IRestResponse response = client.Execute<dynamic>(request);
string result = response.Content;
LogHelper.Info("无人巡检数据上传成功,返回:" + result);
}catch(Exception ex)
{
LogHelper.Error("数据上传至无人巡检系统出现异常", ex);
}
}
}
}

@ -0,0 +1,11 @@
<?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>
</assemblyBinding>
</runtime>
</configuration>

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net452" />
<package id="RestSharp" version="106.11.7" targetFramework="net452" />
</packages>

@ -0,0 +1,206 @@
using SLH.SSDMS.Model.DTO;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
namespace SLH.SSDMS.Services
{
/// <summary>
/// IBaseRepository
/// </summary>
public interface IBaseServices<TEntity> where TEntity : class
{
Task<TEntity> QuerySingle(Expression<Func<TEntity, bool>> whereExpression);
Task<TEntity> QueryById(object objId);
Task<TEntity> QueryById(object objId, bool blnUseCache = false);
Task<List<TEntity>> QueryByIDs(object[] lstIds);
Task<int> Add(TEntity model);
Task<int> AddLog(TEntity model);
Task<int> Add(List<TEntity> listEntity);
Task<bool> DeleteById(object id);
Task<bool> Delete(TEntity model);
Task<bool> Delete(Expression<Func<TEntity, bool>> whereExpression);
Task<bool> DeleteByIds(object[] ids);
Task<bool> Update(TEntity model);
Task<bool> Update(TEntity entity, string strWhere);
Task<bool> Update(object operateAnonymousObjects);
Task<bool> Update(TEntity entity, List<string> lstColumns = null, List<string> lstIgnoreColumns = null, string strWhere = "");
Task<List<TEntity>> Query();
Task<List<TEntity>> Query(string strWhere);
Task<List<TEntity>> Query(Expression<Func<TEntity, bool>> whereExpression);
Task<List<TEntity>> Query(Expression<Func<TEntity, bool>> whereExpression, string strOrderByFileds);
Task<List<TEntity>> Query(Expression<Func<TEntity, bool>> whereExpression, Expression<Func<TEntity, object>> orderByExpression, bool isAsc = true);
Task<List<TEntity>> Query(string strWhere, string strOrderByFileds);
Task<TEntity> QueryFirst(Expression<Func<TEntity, bool>> whereExpression, Expression<Func<TEntity, object>> orderByExpression, bool isAsc = true);
Task<List<TEntity>> Query(Expression<Func<TEntity, bool>> whereExpression, int intTop, string strOrderByFileds);
Task<List<TEntity>> Query(string strWhere, int intTop, string strOrderByFileds);
Task<List<TEntity>> Query(
Expression<Func<TEntity, bool>> whereExpression, int intPageIndex, int intPageSize, string strOrderByFileds);
Task<List<TEntity>> Query(string strWhere, int intPageIndex, int intPageSize, string strOrderByFileds);
Task<PageModel<TEntity>> QueryPage(Expression<Func<TEntity, bool>> whereExpression, int intPageIndex = 1, int intPageSize = 20, string strOrderByFileds = null);
Task<List<TResult>> QueryMuch<T, T2, T3, T4, T5, TResult>(
Expression<Func<T, T2, T3, T4, T5, object[]>> joinExpression,
Expression<Func<T, T2, T3, T4, T5, TResult>> selectExpression,
Expression<Func<TResult, bool>> whereLambda = null) where T : class, new();
Task<List<TResult>> QueryMuch<T, T2, T3, T4, TResult>(
Expression<Func<T, T2, T3, T4, object[]>> joinExpression,
Expression<Func<T, T2, T3, T4, TResult>> selectExpression,
Expression<Func<TResult, bool>> whereLambda = null) where T : class, new();
Task<List<TResult>> QueryMuch<T, T2, T3, TResult>(
Expression<Func<T, T2, T3, object[]>> joinExpression,
Expression<Func<T, T2, T3, TResult>> selectExpression,
Expression<Func<TResult, bool>> whereLambda = null) where T : class, new();
Task<List<TResult>> QueryMuch<T, T2, TResult>(
Expression<Func<T, T2, object[]>> joinExpression,
Expression<Func<T, T2, TResult>> selectExpression,
Expression<Func<TResult, bool>> whereLambda = null) where T : class, new();
#region 多表分页
/// <summary>
///查询-多表查询
/// </summary>
/// <typeparam name="T">实体1</typeparam>
/// <typeparam name="T2">实体2</typeparam>
/// <typeparam name="T3">实体3</typeparam>
/// <typeparam name="T4">实体4</typeparam>
/// <typeparam name="T5">实体5</typeparam>
/// <typeparam name="TResult">返回对象</typeparam>
/// <param name="joinExpression">关联表达式 (join1,join2) => new object[] {JoinType.Left,join1.UserNo==join2.UserNo}</param>
/// <param name="selectExpression">返回表达式 (s1, s2) => new { Id =s1.UserNo, Id1 = s2.UserNo}</param>
/// <param name="whereLambda">查询表达式 (w1, w2) =>w1.UserNo == "")</param>
/// <returns>值</returns>
Task<PageModel<TResult>> QueryMuchPage<T, T2, T3, T4, T5, TResult>(
Expression<Func<T, T2, T3, T4, T5, object[]>> joinExpression,
Expression<Func<T, T2, T3, T4, T5, TResult>> selectExpression,
Expression<Func<TResult, bool>> whereLambda = null, int intPageIndex = 1, int intPageSize = 20,
string strOrderByFileds = null) where T : class, new();
/// <summary>
///查询-多表查询
/// </summary>
/// <typeparam name="T">实体1</typeparam>
/// <typeparam name="T2">实体2</typeparam>
/// <typeparam name="T3">实体3</typeparam>
/// <typeparam name="T4">实体4</typeparam>
/// <typeparam name="TResult">返回对象</typeparam>
/// <param name="joinExpression">关联表达式 (join1,join2) => new object[] {JoinType.Left,join1.UserNo==join2.UserNo}</param>
/// <param name="selectExpression">返回表达式 (s1, s2) => new { Id =s1.UserNo, Id1 = s2.UserNo}</param>
/// <param name="whereLambda">查询表达式 (w1, w2) =>w1.UserNo == "")</param>
/// <returns>值</returns>
Task<PageModel<TResult>> QueryMuchPage<T, T2, T3, T4, TResult>(
Expression<Func<T, T2, T3, T4, object[]>> joinExpression,
Expression<Func<T, T2, T3, T4, TResult>> selectExpression,
Expression<Func<TResult, bool>> whereLambda = null, int intPageIndex = 1, int intPageSize = 20,
string strOrderByFileds = null) where T : class, new();
/// <summary>
///查询-多表查询
/// </summary>
/// <typeparam name="T">实体1</typeparam>
/// <typeparam name="T2">实体2</typeparam>
/// <typeparam name="T3">实体3</typeparam>
/// <typeparam name="TResult">返回对象</typeparam>
/// <param name="joinExpression">关联表达式 (join1,join2) => new object[] {JoinType.Left,join1.UserNo==join2.UserNo}</param>
/// <param name="selectExpression">返回表达式 (s1, s2) => new { Id =s1.UserNo, Id1 = s2.UserNo}</param>
/// <param name="whereLambda">查询表达式 (w1, w2) =>w1.UserNo == "")</param>
/// <returns>值</returns>
Task<PageModel<TResult>> QueryMuchPage<T, T2, T3, TResult>(
Expression<Func<T, T2, T3, object[]>> joinExpression,
Expression<Func<T, T2, T3, TResult>> selectExpression,
Expression<Func<TResult, bool>> whereLambda = null, int intPageIndex = 1, int intPageSize = 20,
string strOrderByFileds = null) where T : class, new();
/// <summary>
///查询-多表查询
/// </summary>
/// <typeparam name="T">实体1</typeparam>
/// <typeparam name="T2">实体2</typeparam>
/// <typeparam name="TResult">返回对象</typeparam>
/// <param name="joinExpression">关联表达式 (join1,join2) => new object[] {JoinType.Left,join1.UserNo==join2.UserNo}</param>
/// <param name="selectExpression">返回表达式 (s1, s2) => new { Id =s1.UserNo, Id1 = s2.UserNo}</param>
/// <param name="whereLambda">查询表达式 (w1, w2) =>w1.UserNo == "")</param>
/// <returns>值</returns>
Task<PageModel<TResult>> QueryMuchPage<T, T2, TResult>(
Expression<Func<T, T2, object[]>> joinExpression,
Expression<Func<T, T2, TResult>> selectExpression,
Expression<Func<TResult, bool>> whereLambda = null, int intPageIndex = 1, int intPageSize = 20,
string strOrderByFileds = null) where T : class, new();
/// <summary>
///查询-多表查询 (测试)
/// </summary>
/// <typeparam name="T">实体1</typeparam>
/// <typeparam name="T2">实体2</typeparam>
/// <typeparam name="TResult">返回对象</typeparam>
/// <param name="joinExpression">关联表达式 (join1,join2) => new object[] {JoinType.Left,join1.UserNo==join2.UserNo}</param>
/// <param name="selectExpression">返回表达式 (s1, s2) => new { Id =s1.UserNo, Id1 = s2.UserNo}</param>
/// <param name="whereLambda">查询表达式 (w1, w2) =>w1.UserNo == "")</param>
/// <returns>值</returns>
Task<PageModel<TResult>> QueryMuchPage<T, T2, TResult>(
Expression<Func<T, T2, object[]>> joinExpression,
Expression<Func<T, T2, TResult>> selectExpression,
Expression<Func<TResult, object>> sortExpression,
Expression<Func<T, T2, bool>> whereLambda = null,
int intPageIndex = 1, int intPageSize = 20, string strOrderByFileds = null) where T : class, new();
#endregion
/// <summary>
/// 存储过程
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="parameters"></param>
/// <returns></returns>
Task<List<T>> QueryByProc<T>(string proc, List<SugarParameter> parameters) where T : class, new();
Task<Tuple<List<T>, List<T2>>> QueryByProc<T, T2>(string proc, List<SugarParameter> parameters)
where T : class, new();
/// <summary>
/// sql语句
/// </summary>
Task<List<T>> QueryBySql<T>(string sql, List<SugarParameter> parameters) where T : class, new();
#region 自定义
/// <summary>
/// 添加上机记录
/// </summary>
/// <param name="boardEntity"></param>
/// <param name="whereExpression"></param>
/// <returns></returns>
Task<int> BoardAdd(TEntity boardEntity, Expression<Func<TEntity, bool>> whereExpression);
#endregion
}
}

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SLH.SSDMS.Services
{
public interface IBufferParse
{
/// <summary>
/// 心跳解析
/// </summary>
/// <param name="buffer"></param>
/// <returns></returns>
Task<byte[]> HeartAnalysis(byte[] buffer);
/// <summary>
/// 读取解析
/// </summary>
/// <param name="buffer"></param>
/// <returns></returns>
Task<byte[]> ReadAnalysis(byte[] buffer);
}
}

@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SLH.SSDMS.Services
{
public interface IReturnBuffer
{
/// <summary>
/// 心跳解析成功结果
/// </summary>
/// <returns></returns>
byte[] HeartAnalysisResult(int status, byte terminal);
/// <summary>
/// 读取解析结果
/// </summary>
/// <returns></returns>
byte[] ReadAnalysisResult(int status, byte terminal);
/// <summary>
/// 定点停机、打开终端IO指令
/// </summary>
/// <returns></returns>
byte[] HaltBuffer();
}
}

@ -0,0 +1,47 @@
using SLH.SSDMS.Model.DO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SLH.SSDMS.Services
{
public interface IRfidJudge
{
/// <summary>
/// 判断当前运行方向
/// </summary>
/// <param name="rfidCode"></param>
/// <returns></returns>
Task<int> JudgeDirection(string rfidCode);
/// <summary>
/// 判断当前运行速度
/// </summary>
/// <param name="readRecord"></param>
/// <returns></returns>
Task<decimal> JudgeRunSpeed(Base_ReadRecord readRecord);
/// <summary>
/// 判断当前运行里程
/// </summary>
/// <param name="readRecord"></param>
/// <returns></returns>
Task<decimal> JudgeRunDistance(Base_ReadRecord readRecord);
/// <summary>
/// 判断当前运行时长
/// </summary>
/// <param name="readRecord"></param>
/// <returns></returns>
Task<decimal> JudgeRunTime(Base_ReadRecord readRecord);
/// <summary>
/// 判断当前胶带上机时间
/// </summary>
/// <param name="lotCode"></param>
/// <returns></returns>
Task<string> JudgeFirstTime(string lotCode);
}
}

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("SLH.SSDMS.Services")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SLH.SSDMS.Services")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("3efe1a92-df3d-4b98-8a6b-dda264385e52")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

@ -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>{3EFE1A92-DF3D-4B98-8A6B-DDA264385E52}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SLH.SSDMS.Services</RootNamespace>
<AssemblyName>SLH.SSDMS.Services</AssemblyName>
<TargetFrameworkVersion>v4.5.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="AutoMapper, Version=5.0.2.0, Culture=neutral, PublicKeyToken=be96cd2c38ef1005, processorArchitecture=MSIL">
<HintPath>..\packages\AutoMapper.5.0.2\lib\net45\AutoMapper.dll</HintPath>
</Reference>
<Reference Include="SqlSugar, Version=5.0.2.6, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\SqlSugar.5.0.2.6\lib\SqlSugar.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="IBaseServices.cs" />
<Compile Include="IBufferParse.cs" />
<Compile Include="IReturnBuffer.cs" />
<Compile Include="IRfidJudge.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="serviceImpl\BaseServices.cs" />
<Compile Include="serviceImpl\BufferParse.cs" />
<Compile Include="serviceImpl\ReturnBuffer.cs" />
<Compile Include="serviceImpl\RfidJudge.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SLH.SSDMS.Common\SLH.SSDMS.Common.csproj">
<Project>{9DB66868-C6F0-4522-A551-09452B927C52}</Project>
<Name>SLH.SSDMS.Common</Name>
</ProjectReference>
<ProjectReference Include="..\SLH.SSDMS.Model\SLH.SSDMS.Model.csproj">
<Project>{1C8B2E03-FC2D-4385-B87A-51A8DD92FE01}</Project>
<Name>SLH.SSDMS.Model</Name>
</ProjectReference>
<ProjectReference Include="..\SLH.SSDMS.RestSharp\SLH.SSDMS.RestSharp.csproj">
<Project>{BD42A6EC-6A27-4E28-938F-9E7906D049E0}</Project>
<Name>SLH.SSDMS.RestSharp</Name>
</ProjectReference>
<ProjectReference Include="..\SLH.SSDMS.WebSocket\SLH.SSDMS.WebSocket.csproj">
<Project>{634C0CFF-E2D5-462C-9395-1540BA1282FD}</Project>
<Name>SLH.SSDMS.WebSocket</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

@ -0,0 +1,11 @@
<?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>
</assemblyBinding>
</runtime>
</configuration>

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="AutoMapper" version="5.0.2" targetFramework="net452" />
<package id="SqlSugar" version="5.0.2.6" targetFramework="net452" />
</packages>

@ -0,0 +1,757 @@
using SLH.SSDMS.Common;
using SLH.SSDMS.Model.DTO;
using SqlSugar;
using SqlSugar.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
namespace SLH.SSDMS.Services.serviceImpl
{
public class BaseServices<TEntity> : IBaseServices<TEntity> where TEntity : class, new()
{
private SqlSugarClient _dbBase;
private SqlSugarClient _db
{
get
{
try
{
_dbBase = new SqlSugarClient(new ConnectionConfig()
{
ConnectionString = "Server=" + ConfigHelper.GetConfig("DataBaseServer") + ";Database="
+ ConfigHelper.GetConfig("DataBaseName") + ";User ID=" + ConfigHelper.GetConfig("DataBaseUser")
+ ";Password=" + ConfigHelper.GetConfig("DataBasePassword"),
DbType = DbType.SqlServer,
IsAutoCloseConnection = true,//开启自动释放模式和EF原理一样我就不多解释了
//InitKey默认SystemTable
});
//可注释
_dbBase.Aop.OnLogExecuting = (sql, pars) => //SQL执行中事件
{
Parallel.For(0, 1, e =>
{
string SqlLog = "";
foreach (string item in new string[] { GetParas(pars), "【SQL语句】" + sql })
{
SqlLog = SqlLog + item;
}
LogHelper.Info("SqlLog:" + SqlLog);
});
};
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
return null;
}
return _dbBase;
}
}
private string GetParas(SugarParameter[] pars)
{
string key = "【SQL参数】";
foreach (var param in pars)
{
key += $"{param.ParameterName}:{param.Value}\n";
}
return key;
}
internal SqlSugarClient Db
{
get { return _db; }
}
public async Task<TEntity> QuerySingle(Expression<Func<TEntity, bool>> whereExpression)
{
try
{
return await _db.Queryable<TEntity>().WhereIF(whereExpression != null, whereExpression).SingleAsync();
}
catch (Exception ex)
{
return null;
}
}
public async Task<TEntity> QueryById(object objId)
{
return await _db.Queryable<TEntity>().In(objId).SingleAsync();
}
/// <summary>
/// 功能描述:根据ID查询一条数据
///
/// </summary>
/// <param name="objId">id必须指定主键特性 [SugarColumn(IsPrimaryKey=true)]如果是联合主键请使用Where条件</param>
/// <param name="blnUseCache">是否使用缓存</param>
/// <returns>数据实体</returns>
public async Task<TEntity> QueryById(object objId, bool blnUseCache = false)
{
return await _db.Queryable<TEntity>().WithCacheIF(blnUseCache).In(objId).SingleAsync();
}
/// <summary>
/// 功能描述:根据ID查询数据
///
/// </summary>
/// <param name="lstIds">id列表必须指定主键特性 [SugarColumn(IsPrimaryKey=true)]如果是联合主键请使用Where条件</param>
/// <returns>数据实体列表</returns>
public async Task<List<TEntity>> QueryByIDs(object[] lstIds)
{
return await _db.Queryable<TEntity>().In(lstIds).ToListAsync();
}
/// <summary>
/// 写入实体数据
/// </summary>
/// <param name="entity">博文实体类</param>
/// <returns></returns>
public async Task<int> Add(TEntity entity)
{
try
{
var insert = _db.Insertable(entity);
var info = await insert.ExecuteReturnIdentityAsync();
return info;
}
catch (Exception ex)
{
return 0;
}
}
public async Task<int> AddLog(TEntity entity)
{
try
{
var insert = _db.Insertable(entity);
return await insert.ExecuteReturnIdentityAsync();
}
catch (Exception ex)
{
LogHelper.Error("插入出錯:" + ex.Message);
return 0;
}
}
/// <summary>
/// 批量插入实体(速度快)
/// </summary>
/// <param name="listEntity">实体集合</param>
/// <returns>影响行数</returns>
public async Task<int> Add(List<TEntity> listEntity)
{
return await _db.Insertable(listEntity.ToArray()).ExecuteCommandAsync();
}
/// <summary>
/// 更新实体数据
/// </summary>
/// <param name="entity">博文实体类</param>
/// <returns></returns>
public async Task<bool> Update(TEntity entity)
{
////这种方式会以主键为条件
//var i = await Task.Run(() => _db.Updateable(entity).ExecuteCommand());
//return i > 0;
//这种方式会以主键为条件
return await _db.Updateable(entity).ExecuteCommandHasChangeAsync();
}
public async Task<bool> Update(TEntity entity, string strWhere)
{
//return await Task.Run(() => _db.Updateable(entity).Where(strWhere).ExecuteCommand() > 0);
return await _db.Updateable(entity).Where(strWhere).ExecuteCommandHasChangeAsync();
}
public async Task<bool> Update(string strSql, SugarParameter[] parameters = null)
{
//return await Task.Run(() => _db.Ado.ExecuteCommand(strSql, parameters) > 0);
return await _db.Ado.ExecuteCommandAsync(strSql, parameters) > 0;
}
public async Task<bool> Update(object operateAnonymousObjects)
{
return await _db.Updateable<TEntity>(operateAnonymousObjects).ExecuteCommandAsync() > 0;
}
public async Task<bool> Update(
TEntity entity,
List<string> lstColumns = null,
List<string> lstIgnoreColumns = null,
string strWhere = ""
)
{
IUpdateable<TEntity> up = _db.Updateable(entity);
if (lstIgnoreColumns != null && lstIgnoreColumns.Count > 0)
{
up = up.IgnoreColumns(lstIgnoreColumns.ToArray());
}
if (lstColumns != null && lstColumns.Count > 0)
{
up = up.UpdateColumns(lstColumns.ToArray());
}
if (!string.IsNullOrEmpty(strWhere))
{
up = up.Where(strWhere);
}
return await up.ExecuteCommandHasChangeAsync();
}
/// <summary>
/// 根据实体删除一条数据
/// </summary>
/// <param name="entity">实体类</param>
/// <returns></returns>
public async Task<bool> Delete(TEntity entity)
{
//var i = await Task.Run(() => _db.Deleteable(entity).ExecuteCommand());
//return i > 0;
return await _db.Deleteable(entity).ExecuteCommandHasChangeAsync();
}
/// <summary>
/// 根据表达式删除
/// </summary>
/// <param name="whereExpression"></param>
/// <returns></returns>
public async Task<bool> Delete(Expression<Func<TEntity, bool>> whereExpression)
{
return await _db.Deleteable<TEntity>().Where(whereExpression).ExecuteCommandHasChangeAsync();
}
/// <summary>
/// 删除指定ID的数据
/// </summary>
/// <param name="id">主键ID</param>
/// <returns></returns>
public async Task<bool> DeleteById(object id)
{
//var i = await Task.Run(() => _db.Deleteable<TEntity>(id).ExecuteCommand());
//return i > 0;
return await _db.Deleteable<TEntity>(id).ExecuteCommandHasChangeAsync();
}
/// <summary>
/// 删除指定ID集合的数据(批量删除)
/// </summary>
/// <param name="ids">主键ID集合</param>
/// <returns></returns>
public async Task<bool> DeleteByIds(object[] ids)
{
//var i = await Task.Run(() => _db.Deleteable<TEntity>().In(ids).ExecuteCommand());
//return i > 0;
return await _db.Deleteable<TEntity>().In(ids).ExecuteCommandHasChangeAsync();
}
/// <summary>
/// 功能描述:查询所有数据
///
/// </summary>
/// <returns>数据列表</returns>
public async Task<List<TEntity>> Query()
{
return await _db.Queryable<TEntity>().ToListAsync();
}
/// <summary>
/// 功能描述:查询数据列表
///
/// </summary>
/// <param name="strWhere">条件</param>
/// <returns>数据列表</returns>
public async Task<List<TEntity>> Query(string strWhere)
{
//return await Task.Run(() => _db.Queryable<TEntity>().WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).ToList());
return await _db.Queryable<TEntity>().WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).ToListAsync();
}
/// <summary>
/// 功能描述:查询数据列表
///
/// </summary>
/// <param name="whereExpression">whereExpression</param>
/// <returns>数据列表</returns>
public async Task<List<TEntity>> Query(Expression<Func<TEntity, bool>> whereExpression)
{
try
{
return await _db.Queryable<TEntity>().WhereIF(whereExpression != null, whereExpression).ToListAsync();
}
catch (Exception ex)
{
return null;
}
}
/// <summary>
/// 功能描述:查询一个列表
///
/// </summary>
/// <param name="whereExpression">条件表达式</param>
/// <param name="strOrderByFileds">排序字段如name asc,age desc</param>
/// <returns>数据列表</returns>
public async Task<List<TEntity>> Query(Expression<Func<TEntity, bool>> whereExpression, string strOrderByFileds)
{
//return await Task.Run(() => _db.Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(whereExpression != null, whereExpression).ToList());
return await _db.Queryable<TEntity>().WhereIF(whereExpression != null, whereExpression).OrderByIF(strOrderByFileds != null, strOrderByFileds).ToListAsync();
}
/// <summary>
/// 功能描述:查询一个列表
/// </summary>
/// <param name="whereExpression"></param>
/// <param name="orderByExpression"></param>
/// <param name="isAsc"></param>
/// <returns></returns>
public async Task<List<TEntity>> Query(Expression<Func<TEntity, bool>> whereExpression, Expression<Func<TEntity, object>> orderByExpression, bool isAsc = true)
{
//return await Task.Run(() => _db.Queryable<TEntity>().OrderByIF(orderByExpression != null, orderByExpression, isAsc ? OrderByType.Asc : OrderByType.Desc).WhereIF(whereExpression != null, whereExpression).ToList());
try
{
return await _db.Queryable<TEntity>().OrderByIF(orderByExpression != null, orderByExpression, isAsc ? OrderByType.Asc : OrderByType.Desc).WhereIF(whereExpression != null, whereExpression).ToListAsync();
}
catch (Exception ex)
{
LogHelper.Error(ex.Message);
return null;
}
}
/// <summary>
/// 排序取第一条
/// </summary>
/// <param name="whereExpression"></param>
/// <param name="orderByExpression"></param>
/// <param name="isAsc"></param>
/// <returns></returns>
public async Task<TEntity> QueryFirst(Expression<Func<TEntity, bool>> whereExpression, Expression<Func<TEntity, object>> orderByExpression, bool isAsc = true)
{
try
{
TEntity info = await _db.Queryable<TEntity>().OrderByIF(orderByExpression != null, orderByExpression, isAsc ? OrderByType.Asc : OrderByType.Desc).WhereIF(whereExpression != null, whereExpression).FirstAsync();
return info;
}
catch (Exception ex)
{
return null;
}
}
/// <summary>
/// 功能描述:查询一个列表
///
/// </summary>
/// <param name="strWhere">条件</param>
/// <param name="strOrderByFileds">排序字段如name asc,age desc</param>
/// <returns>数据列表</returns>
public async Task<List<TEntity>> Query(string strWhere, string strOrderByFileds)
{
//return await Task.Run(() => _db.Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).ToList());
return await _db.Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).ToListAsync();
}
/// <summary>
/// 功能描述:查询前N条数据
///
/// </summary>
/// <param name="whereExpression">条件表达式</param>
/// <param name="intTop">前N条</param>
/// <param name="strOrderByFileds">排序字段如name asc,age desc</param>
/// <returns>数据列表</returns>
public async Task<List<TEntity>> Query(
Expression<Func<TEntity, bool>> whereExpression,
int intTop,
string strOrderByFileds)
{
//return await Task.Run(() => _db.Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(whereExpression != null, whereExpression).Take(intTop).ToList());
return await _db.Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(whereExpression != null, whereExpression).Take(intTop).ToListAsync();
}
/// <summary>
/// 功能描述:查询前N条数据
///
/// </summary>
/// <param name="strWhere">条件</param>
/// <param name="intTop">前N条</param>
/// <param name="strOrderByFileds">排序字段如name asc,age desc</param>
/// <returns>数据列表</returns>
public async Task<List<TEntity>> Query(
string strWhere,
int intTop,
string strOrderByFileds)
{
//return await Task.Run(() => _db.Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).Take(intTop).ToList());
return await _db.Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).Take(intTop).ToListAsync();
}
/// <summary>
/// 功能描述:分页查询
///
/// </summary>
/// <param name="whereExpression">条件表达式</param>
/// <param name="intPageIndex">页码下标0</param>
/// <param name="intPageSize">页大小</param>
/// <param name="intTotalCount">数据总量</param>
/// <param name="strOrderByFileds">排序字段如name asc,age desc</param>
/// <returns>数据列表</returns>
public async Task<List<TEntity>> Query(
Expression<Func<TEntity, bool>> whereExpression,
int intPageIndex,
int intPageSize,
string strOrderByFileds)
{
//return await Task.Run(() => _db.Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(whereExpression != null, whereExpression).ToPageList(intPageIndex, intPageSize));
return await _db.Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(whereExpression != null, whereExpression).ToPageListAsync(intPageIndex, intPageSize);
}
/// <summary>
/// 功能描述:分页查询
///
/// </summary>
/// <param name="strWhere">条件</param>
/// <param name="intPageIndex">页码下标0</param>
/// <param name="intPageSize">页大小</param>
/// <param name="intTotalCount">数据总量</param>
/// <param name="strOrderByFileds">排序字段如name asc,age desc</param>
/// <returns>数据列表</returns>
public async Task<List<TEntity>> Query(
string strWhere,
int intPageIndex,
int intPageSize,
string strOrderByFileds)
{
//return await Task.Run(() => _db.Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).ToPageList(intPageIndex, intPageSize));
return await _db.Queryable<TEntity>().OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds).WhereIF(!string.IsNullOrEmpty(strWhere), strWhere).ToPageListAsync(intPageIndex, intPageSize);
}
/// <summary>
/// 分页查询[使用版本,其他分页未测试]
/// </summary>
/// <param name="whereExpression">条件表达式</param>
/// <param name="intPageIndex">页码下标0</param>
/// <param name="intPageSize">页大小</param>
/// <param name="strOrderByFileds">排序字段如name asc,age desc</param>
/// <returns></returns>
public async Task<PageModel<TEntity>> QueryPage(Expression<Func<TEntity, bool>> whereExpression, int intPageIndex = 1, int intPageSize = 20, string strOrderByFileds = null)
{
RefAsync<int> totalCount = 0;
var list = await _db.Queryable<TEntity>()
.OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds)
.WhereIF(whereExpression != null, whereExpression)
.ToPageListAsync(intPageIndex, intPageSize, totalCount);
int pageCount = (Math.Ceiling(totalCount.ObjToDecimal2() / intPageSize.ObjToDecimal2())).ObjToInt();
return new PageModel<TEntity>() { dataCount = totalCount, pageCount = pageCount, page = intPageIndex, PageSize = intPageSize, data = list };
}
/// <summary>
///查询-多表查询
/// </summary>
/// <typeparam name="T">实体1</typeparam>
/// <typeparam name="T2">实体2</typeparam>
/// <typeparam name="T3">实体3</typeparam>
/// <typeparam name="T4">实体4</typeparam>
/// <typeparam name="T5">实体5</typeparam>
/// <typeparam name="TResult">返回对象</typeparam>
/// <param name="joinExpression">关联表达式 (join1,join2) => new object[] {JoinType.Left,join1.UserNo==join2.UserNo}</param>
/// <param name="selectExpression">返回表达式 (s1, s2) => new { Id =s1.UserNo, Id1 = s2.UserNo}</param>
/// <param name="whereLambda">查询表达式 (w1, w2) =>w1.UserNo == "")</param>
/// <returns>值</returns>
public async Task<List<TResult>> QueryMuch<T, T2, T3, T4, T5, TResult>(
Expression<Func<T, T2, T3, T4, T5, object[]>> joinExpression,
Expression<Func<T, T2, T3, T4, T5, TResult>> selectExpression,
Expression<Func<TResult, bool>> whereLambda = null) where T : class, new()
{
if (whereLambda == null)
{
return await _db.Queryable(joinExpression).Select(selectExpression).ToListAsync();
}
return await _db.Queryable(joinExpression).Select(selectExpression).MergeTable().Where(whereLambda).ToListAsync();
}
/// <summary>
///查询-多表查询
/// </summary>
/// <typeparam name="T">实体1</typeparam>
/// <typeparam name="T2">实体2</typeparam>
/// <typeparam name="T3">实体3</typeparam>
/// <typeparam name="T4">实体4</typeparam>
/// <typeparam name="TResult">返回对象</typeparam>
/// <param name="joinExpression">关联表达式 (join1,join2) => new object[] {JoinType.Left,join1.UserNo==join2.UserNo}</param>
/// <param name="selectExpression">返回表达式 (s1, s2) => new { Id =s1.UserNo, Id1 = s2.UserNo}</param>
/// <param name="whereLambda">查询表达式 (w1, w2) =>w1.UserNo == "")</param>
/// <returns>值</returns>
public async Task<List<TResult>> QueryMuch<T, T2, T3, T4, TResult>(
Expression<Func<T, T2, T3, T4, object[]>> joinExpression,
Expression<Func<T, T2, T3, T4, TResult>> selectExpression,
Expression<Func<TResult, bool>> whereLambda = null) where T : class, new()
{
if (whereLambda == null)
{
return await _db.Queryable(joinExpression).Select(selectExpression).ToListAsync();
}
return await _db.Queryable(joinExpression).Select(selectExpression).MergeTable().Where(whereLambda).ToListAsync();
}
/// <summary>
///查询-多表查询
/// </summary>
/// <typeparam name="T">实体1</typeparam>
/// <typeparam name="T2">实体2</typeparam>
/// <typeparam name="T3">实体3</typeparam>
/// <typeparam name="TResult">返回对象</typeparam>
/// <param name="joinExpression">关联表达式 (join1,join2) => new object[] {JoinType.Left,join1.UserNo==join2.UserNo}</param>
/// <param name="selectExpression">返回表达式 (s1, s2) => new { Id =s1.UserNo, Id1 = s2.UserNo}</param>
/// <param name="whereLambda">查询表达式 (w1, w2) =>w1.UserNo == "")</param>
/// <returns>值</returns>
public async Task<List<TResult>> QueryMuch<T, T2, T3, TResult>(
Expression<Func<T, T2, T3, object[]>> joinExpression,
Expression<Func<T, T2, T3, TResult>> selectExpression,
Expression<Func<TResult, bool>> whereLambda = null) where T : class, new()
{
if (whereLambda == null)
{
return await _db.Queryable(joinExpression).Select(selectExpression).ToListAsync();
}
return await _db.Queryable(joinExpression).Select(selectExpression).MergeTable().Where(whereLambda).ToListAsync();
}
/// <summary>
///查询-多表查询
/// </summary>
/// <typeparam name="T">实体1</typeparam>
/// <typeparam name="T2">实体2</typeparam>
/// <typeparam name="TResult">返回对象</typeparam>
/// <param name="joinExpression">关联表达式 (join1,join2) => new object[] {JoinType.Left,join1.UserNo==join2.UserNo}</param>
/// <param name="selectExpression">返回表达式 (s1, s2) => new { Id =s1.UserNo, Id1 = s2.UserNo}</param>
/// <param name="whereLambda">查询表达式 (w1, w2) =>w1.UserNo == "")</param>
/// <returns>值</returns>
public async Task<List<TResult>> QueryMuch<T, T2, TResult>(
Expression<Func<T, T2, object[]>> joinExpression,
Expression<Func<T, T2, TResult>> selectExpression,
Expression<Func<TResult, bool>> whereLambda = null) where T : class, new()
{
if (whereLambda == null)
{
return await _db.Queryable(joinExpression).Select(selectExpression).ToListAsync();
}
return await _db.Queryable(joinExpression).Select(selectExpression).MergeTable().Where(whereLambda).ToListAsync();
}
#region 多表分页
/// <summary>
///查询-多表查询
/// </summary>
/// <typeparam name="T">实体1</typeparam>
/// <typeparam name="T2">实体2</typeparam>
/// <typeparam name="T3">实体3</typeparam>
/// <typeparam name="T4">实体4</typeparam>
/// <typeparam name="T5">实体5</typeparam>
/// <typeparam name="TResult">返回对象</typeparam>
/// <param name="joinExpression">关联表达式 (join1,join2) => new object[] {JoinType.Left,join1.UserNo==join2.UserNo}</param>
/// <param name="selectExpression">返回表达式 (s1, s2) => new { Id =s1.UserNo, Id1 = s2.UserNo}</param>
/// <param name="whereLambda">查询表达式 (w1, w2) =>w1.UserNo == "")</param>
/// <returns>值</returns>
public async Task<PageModel<TResult>> QueryMuchPage<T, T2, T3, T4, T5, TResult>(
Expression<Func<T, T2, T3, T4, T5, object[]>> joinExpression,
Expression<Func<T, T2, T3, T4, T5, TResult>> selectExpression,
Expression<Func<TResult, bool>> whereLambda = null, int intPageIndex = 1, int intPageSize = 20, string strOrderByFileds = null) where T : class, new()
{
RefAsync<int> totalCount = 0;
var list = await _db.Queryable(joinExpression)
.Select(selectExpression)
.MergeTable()
.WhereIF(whereLambda != null, whereLambda)
.OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds)
.ToPageListAsync(intPageIndex, intPageSize, totalCount);
int pageCount = (Math.Ceiling(totalCount.ObjToDecimal2() / intPageSize.ObjToDecimal2())).ObjToInt();
return new PageModel<TResult>() { dataCount = totalCount, pageCount = pageCount, page = intPageIndex, PageSize = intPageSize, data = list };
}
/// <summary>
///查询-多表查询
/// </summary>
/// <typeparam name="T">实体1</typeparam>
/// <typeparam name="T2">实体2</typeparam>
/// <typeparam name="T3">实体3</typeparam>
/// <typeparam name="T4">实体4</typeparam>
/// <typeparam name="TResult">返回对象</typeparam>
/// <param name="joinExpression">关联表达式 (join1,join2) => new object[] {JoinType.Left,join1.UserNo==join2.UserNo}</param>
/// <param name="selectExpression">返回表达式 (s1, s2) => new { Id =s1.UserNo, Id1 = s2.UserNo}</param>
/// <param name="whereLambda">查询表达式 (w1, w2) =>w1.UserNo == "")</param>
/// <returns>值</returns>
public async Task<PageModel<TResult>> QueryMuchPage<T, T2, T3, T4, TResult>(
Expression<Func<T, T2, T3, T4, object[]>> joinExpression,
Expression<Func<T, T2, T3, T4, TResult>> selectExpression,
Expression<Func<TResult, bool>> whereLambda = null, int intPageIndex = 1, int intPageSize = 20, string strOrderByFileds = null) where T : class, new()
{
RefAsync<int> totalCount = 0;
var list = await _db.Queryable(joinExpression)
.Select(selectExpression)
.MergeTable()
.WhereIF(whereLambda != null, whereLambda)
.OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds)
.ToPageListAsync(intPageIndex, intPageSize, totalCount);
int pageCount = (Math.Ceiling(totalCount.ObjToDecimal2() / intPageSize.ObjToDecimal2())).ObjToInt();
return new PageModel<TResult>() { dataCount = totalCount, pageCount = pageCount, page = intPageIndex, PageSize = intPageSize, data = list };
}
/// <summary>
///查询-多表查询
/// </summary>
/// <typeparam name="T">实体1</typeparam>
/// <typeparam name="T2">实体2</typeparam>
/// <typeparam name="T3">实体3</typeparam>
/// <typeparam name="TResult">返回对象</typeparam>
/// <param name="joinExpression">关联表达式 (join1,join2) => new object[] {JoinType.Left,join1.UserNo==join2.UserNo}</param>
/// <param name="selectExpression">返回表达式 (s1, s2) => new { Id =s1.UserNo, Id1 = s2.UserNo}</param>
/// <param name="whereLambda">查询表达式 (w1, w2) =>w1.UserNo == "")</param>
/// <returns>值</returns>
public async Task<PageModel<TResult>> QueryMuchPage<T, T2, T3, TResult>(
Expression<Func<T, T2, T3, object[]>> joinExpression,
Expression<Func<T, T2, T3, TResult>> selectExpression,
Expression<Func<TResult, bool>> whereLambda = null, int intPageIndex = 1, int intPageSize = 20, string strOrderByFileds = null) where T : class, new()
{
RefAsync<int> totalCount = 0;
var list = await _db.Queryable(joinExpression)
.Select(selectExpression)
.MergeTable()
.WhereIF(whereLambda != null, whereLambda)
.OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds)
.ToPageListAsync(intPageIndex, intPageSize, totalCount);
int pageCount = (Math.Ceiling(totalCount.ObjToDecimal2() / intPageSize.ObjToDecimal2())).ObjToInt();
return new PageModel<TResult>() { dataCount = totalCount, pageCount = pageCount, page = intPageIndex, PageSize = intPageSize, data = list };
}
/// <summary>
///查询-多表查询
/// </summary>
/// <typeparam name="T">实体1</typeparam>
/// <typeparam name="T2">实体2</typeparam>
/// <typeparam name="TResult">返回对象</typeparam>
/// <param name="joinExpression">关联表达式 (join1,join2) => new object[] {JoinType.Left,join1.UserNo==join2.UserNo}</param>
/// <param name="selectExpression">返回表达式 (s1, s2) => new { Id =s1.UserNo, Id1 = s2.UserNo}</param>
/// <param name="whereLambda">查询表达式 (w1, w2) =>w1.UserNo == "")</param>
/// <returns>值</returns>
public async Task<PageModel<TResult>> QueryMuchPage<T, T2, TResult>(
Expression<Func<T, T2, object[]>> joinExpression,
Expression<Func<T, T2, TResult>> selectExpression,
Expression<Func<TResult, bool>> whereLambda = null, int intPageIndex = 1, int intPageSize = 20, string strOrderByFileds = null) where T : class, new()
{
RefAsync<int> totalCount = 0;
var list = await _db.Queryable(joinExpression)
.Select(selectExpression)
.MergeTable()
.WhereIF(whereLambda != null, whereLambda)
.OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds)
.ToPageListAsync(intPageIndex, intPageSize, totalCount);
int pageCount = (Math.Ceiling(totalCount.ObjToDecimal2() / intPageSize.ObjToDecimal2())).ObjToInt();
return new PageModel<TResult>() { dataCount = totalCount, pageCount = pageCount, page = intPageIndex, PageSize = intPageSize, data = list };
}
/// <summary>
///查询-多表查询(测试)
/// </summary>
/// <typeparam name="T">实体1</typeparam>
/// <typeparam name="T2">实体2</typeparam>
/// <typeparam name="TResult">返回对象</typeparam>
/// <param name="joinExpression">关联表达式 (join1,join2) => new object[] {JoinType.Left,join1.UserNo==join2.UserNo}</param>
/// <param name="selectExpression">返回表达式 (s1, s2) => new { Id =s1.UserNo, Id1 = s2.UserNo}</param>
/// <param name="whereLambda">查询表达式 (w1, w2) =>w1.UserNo == "")</param>
/// <returns>值</returns>
public async Task<PageModel<TResult>> QueryMuchPage<T, T2, TResult>(
Expression<Func<T, T2, object[]>> joinExpression,
Expression<Func<T, T2, TResult>> selectExpression,
Expression<Func<TResult, object>> sortExpression,
Expression<Func<T, T2, bool>> whereLambda = null,
int intPageIndex = 1, int intPageSize = 20, string strOrderByFileds = null) where T : class, new()
{
RefAsync<int> totalCount = 0;
var list = await _db.Queryable(joinExpression)
.WhereIF(whereLambda != null, whereLambda)
.Select(selectExpression)
.OrderByIF(!string.IsNullOrEmpty(strOrderByFileds), strOrderByFileds)
.ToPageListAsync(intPageIndex, intPageSize, totalCount);
int pageCount = (Math.Ceiling(totalCount.ObjToDecimal2() / intPageSize.ObjToDecimal2())).ObjToInt();
return new PageModel<TResult>() { dataCount = totalCount, pageCount = pageCount, page = intPageIndex, PageSize = intPageSize, data = list };
}
#endregion
/// <summary>
/// 存储过程
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="parameters"></param>
/// <returns></returns>
public async Task<List<T>> QueryByProc<T>(string proc, List<SugarParameter> parameters) where T : class, new()
{
//var nameP = new SugarParameter("@name", "张三");
//var ageP = new SugarParameter("@age", null, true);//isOutput=true
//var ddd = new List<SugarParameter>();
return await _db.Ado.UseStoredProcedure().SqlQueryAsync<T>(proc, parameters);
}
public async Task<Tuple<List<T>, List<T2>>> QueryByProc<T, T2>(string proc, List<SugarParameter> parameters) where T : class, new()
{
return await _db.Ado.UseStoredProcedure().SqlQueryAsync<T, T2>(proc, parameters);
}
/// <summary>
/// sql语句
/// </summary>
public async Task<List<T>> QueryBySql<T>(string sql, List<SugarParameter> parameters) where T : class, new()
{
return await _db.Ado.SqlQueryAsync<T>(sql, parameters);
}
#region 自定义
/// <summary>
/// 添加上机记录,先判断是否存在该卷信息
/// </summary>
/// <param name="boardEntity"></param>
/// <param name="whereExpression"></param>
/// <returns></returns>
public async Task<int> BoardAdd(TEntity boardEntity, Expression<Func<TEntity, bool>> whereExpression)
{
try
{
TEntity entity = await _db.Queryable<TEntity>().WhereIF(whereExpression != null, whereExpression).SingleAsync();
if (entity != null)
{
return new int();
}
return await Add(boardEntity);
}
catch (Exception ex)
{
return new int();
}
}
#endregion
}
}

@ -0,0 +1,272 @@
using AutoMapper;
using SLH.SSDMS.Common;
using SLH.SSDMS.Model.DO;
using SLH.SSDMS.Model.DTO;
using SLH.SSDMS.RestSharp;
using SLH.SSDMS.WebSocket;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SLH.SSDMS.Services.serviceImpl
{
public class BufferParse : IBufferParse
{
private static IReturnBuffer returnBuffer = new ReturnBuffer();
private static IRfidJudge rfidJudge = new RfidJudge();
private static IBaseServices<Base_ReadRecord> baseServices = new BaseServices<Base_ReadRecord>();
private static IBaseServices<Sys_Config> configServices = new BaseServices<Sys_Config>();
/// <summary>
/// 心跳解析
/// </summary>
/// <param name="buffer"></param>
/// <returns></returns>
public async Task<byte[]> HeartAnalysis(byte[] buffer)
{
try
{
WebSocketServer.sendMessage("01");
return returnBuffer.HeartAnalysisResult(1, buffer[3]);
}catch(Exception ex)
{
LogHelper.Error("心跳解析异常", ex);
return returnBuffer.HeartAnalysisResult(0, buffer[3]);
}
}
/// <summary>
/// 指令解析
/// </summary>
/// <param name="buffer"></param>
/// <returns></returns>
public async Task<byte[]> ReadAnalysis(byte[] buffer)
{
try
{
Mapper.Initialize(cret => cret.CreateMap<Base_ReadRecord, ViewModelDTO>());
Base_ReadRecord readRecord = new Base_ReadRecord();
//RFID标签号
string RFIDCode = "";
//终端地址
readRecord.terminal = Convert.ToString(buffer[3], 16);
//生产年
readRecord.proYear = Convert.ToString(buffer[4], 16) + Convert.ToString(buffer[5], 16);
//生产月
readRecord.proMonth = Convert.ToString(buffer[6]);
//生产机台
readRecord.proMachine = Convert.ToString(buffer[7], 16) + Convert.ToString(buffer[8], 16);
//带强
readRecord.beltStrength = Convert.ToString(buffer[9], 16) + Convert.ToString(buffer[10], 16);
switch (readRecord.beltStrength)
{
case "05":
readRecord.beltStrength = "ST1400";
break;
case "06":
readRecord.beltStrength = "ST1600";
break;
case "07":
readRecord.beltStrength = "ST1800";
break;
case "08":
readRecord.beltStrength = "ST2000";
break;
case "09":
readRecord.beltStrength = "ST2250";
break;
default:
readRecord.beltStrength = "ST1800";
break;
}
//带宽
readRecord.beltWidth = Convert.ToString(buffer[11], 16);
switch (readRecord.beltWidth)
{
case "5":
readRecord.beltWidth = "1200mm";
break;
case "6":
readRecord.beltWidth = "1400mm";
break;
case "7":
readRecord.beltWidth = "1600mm";
break;
case "8":
readRecord.beltWidth = "1800mm";
break;
case "9":
readRecord.beltWidth = "2000mm";
break;
default:
readRecord.beltWidth = "1600mm";
break;
}
//上胶厚度
readRecord.upGlueThick = Convert.ToString(buffer[12], 16) + Convert.ToString(buffer[13], 16);
switch (readRecord.upGlueThick)
{
case "10":
readRecord.upGlueThick = "6mm";
break;
case "11":
readRecord.upGlueThick = "6.5mm";
break;
case "12":
readRecord.upGlueThick = "7mm";
break;
case "13":
readRecord.upGlueThick = "7.5mm";
break;
case "14":
readRecord.upGlueThick = "8mm";
break;
default:
readRecord.upGlueThick = "7mm";
break;
}
//连接符 ==>转为ASCII
readRecord.unionSymbol = ((char)Convert.ToInt16(Convert.ToString(buffer[14], 16) + Convert.ToString(buffer[15], 16))).ToString();
//下胶厚度
readRecord.downGlueThick = Convert.ToString(buffer[16], 16) + Convert.ToString(buffer[17], 16);
switch (readRecord.downGlueThick)
{
case "08":
readRecord.downGlueThick = "5mm";
break;
case "09":
readRecord.downGlueThick = "5.5mm";
break;
case "10":
readRecord.downGlueThick = "6mm";
break;
case "11":
readRecord.downGlueThick = "6.5mm";
break;
case "12":
readRecord.downGlueThick = "7mm";
break;
default:
readRecord.downGlueThick = "6mm";
break;
}
//盖胶级别
readRecord.coverGlueLevel = Convert.ToString(buffer[18], 16) + Convert.ToString(buffer[19], 16);
switch (readRecord.coverGlueLevel)
{
case "01":
readRecord.coverGlueLevel = "L";
break;
case "02":
readRecord.coverGlueLevel = "D";
break;
case "03":
readRecord.coverGlueLevel = "H";
break;
case "04":
readRecord.coverGlueLevel = "T1";
break;
case "05":
readRecord.coverGlueLevel = "T2";
break;
default:
readRecord.coverGlueLevel = "T3";
break;
}
//卷号
readRecord.lotNum = Convert.ToString(buffer[20], 16) + Convert.ToString(buffer[21], 16);
//RFID卡序号
readRecord.rfidOrder = Convert.ToString(buffer[22], 16) + Convert.ToString(buffer[23], 16);
//当前RFID前间距
readRecord.preDistance = (Convert.ToString(buffer[24], 16) + Convert.ToString(buffer[25], 16)).ToInt();
//当前RFID后间距
readRecord.aftDistance = (Convert.ToString(buffer[26], 16) + Convert.ToString(buffer[27], 16)).ToInt();
//读取时间
readRecord.readTime = DateTime.Now;
//时间戳
byte[] timeByte = new byte[8];
Array.Copy(buffer, 28, timeByte, 0, 8);
foreach (var item in timeByte)
{
readRecord.timeNumber = readRecord.timeNumber + item;
}
//RFID标签
byte[] rfidByte = new byte[24];
Array.Copy(buffer, 4, rfidByte, 0, 24);
foreach (var item in rfidByte)
{
RFIDCode = RFIDCode + item;
}
readRecord.rfidCode = RFIDCode;
//判断运行顺序
readRecord.orderFlag = await rfidJudge.JudgeDirection(RFIDCode);
LogHelper.Info("标签数据解析完成:" + JsonChange.ModeToJson(readRecord));
LogHelper.Info("运行方向:" + readRecord.orderFlag);
if (readRecord.orderFlag < 2)
{
await baseServices.Add(readRecord);
try
{
ViewModelDTO viewModelDTO = Mapper.Map<ViewModelDTO>(readRecord);
viewModelDTO.runTime = await rfidJudge.JudgeRunTime(readRecord);
viewModelDTO.speed = await rfidJudge.JudgeRunSpeed(readRecord);
viewModelDTO.distance = await rfidJudge.JudgeRunDistance(readRecord);
string firstTime = await rfidJudge.JudgeFirstTime(readRecord.lotNum);
viewModelDTO.firstTime = firstTime.Substring(0, 10);
viewModelDTO.beltSum = 11;
//获取BC9F流量
Sys_Config sys_Config = await GetBC9FWorkFlow();
if(sys_Config != null)
{
viewModelDTO.carryFlow = Convert.ToDecimal(sys_Config.config_value);
viewModelDTO.titalWorkLoad = Convert.ToDecimal(sys_Config.remark);
}
//websocket上传数据
WebSocketServer.sendMessage("01");
WebSocketServer.sendMessage(JsonChange.ModeToJson(viewModelDTO));
//上传无人巡检系统
Upload.sendMessage(viewModelDTO);
}
catch(Exception ex)
{
LogHelper.Info("数据上传异常:" + ex);
}
}
}
catch(Exception ex)
{
LogHelper.Error("指令解析异常", ex);
}
return returnBuffer.ReadAnalysisResult(1, buffer[3]);
}
/// <summary>
/// 获取BC9F作业流量
/// </summary>
private async Task<Sys_Config> GetBC9FWorkFlow()
{
Sys_Config sys_Config = await configServices.QueryById(4);
LogHelper.Info($"获取BC9F数据{JsonChange.ModeToJson(sys_Config)}");
return sys_Config;
}
}
}

@ -0,0 +1,85 @@
using SLH.SSDMS.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SLH.SSDMS.Services.serviceImpl
{
public class ReturnBuffer : IReturnBuffer
{
public byte[] HeartAnalysisResult(int status, byte terminal)
{
byte[] buffer = new byte[10];
buffer[0] = 0xA5;
buffer[1] = 0x5A;
buffer[2] = 0x00;
buffer[3] = 0x04;
buffer[4] = 0x62;
buffer[5] = terminal;
buffer[6] = Convert.ToByte(status); //状态
//取数据长度
byte[] dataLength = new byte[2];
dataLength[0] = buffer[2];
dataLength[1] = buffer[3];
int dataLen = StringChange.bytesToHexStr(dataLength, dataLength.Length).ToInt() + 1;
//取长度、类型、数据计算校验
byte[] calByte = new byte[dataLen];
Array.Copy(buffer, 2, calByte, 0, dataLen);
buffer[7] = Convert.ToByte(checkUtil.BCC(calByte));//校验
buffer[8] = 0x0D;
buffer[9] = 0x0A;
return buffer;
}
public byte[] ReadAnalysisResult(int status, byte terminal)
{
byte[] buffer = new byte[10];
buffer[0] = 0xA5;
buffer[1] = 0x5A;
buffer[2] = 0x00;
buffer[3] = 0x04;
buffer[4] = 0x84;
buffer[5] = terminal;
buffer[6] = Convert.ToByte(status); //状态
//取数据长度
byte[] dataLength = new byte[2];
dataLength[0] = buffer[2];
dataLength[1] = buffer[3];
int dataLen = StringChange.bytesToHexStr(dataLength, dataLength.Length).ToInt() + 1;
//取长度、类型、数据计算校验
byte[] calByte = new byte[dataLen];
Array.Copy(buffer, 2, calByte, 0, dataLen);
buffer[7] = Convert.ToByte(checkUtil.BCC(calByte));//校验
buffer[8] = 0x0D;
buffer[9] = 0x0A;
return buffer;
}
public byte[] HaltBuffer()
{
byte[] buffer = new byte[14];
buffer[0] = 0xA5;
buffer[1] = 0x5A;
buffer[2] = 0x00;
buffer[3] = 0x08;
buffer[4] = 0xA4;
buffer[5] = 0xFF;
buffer[6] = 0x01;
buffer[7] = 0x01;
buffer[8] = 0x00;
buffer[9] = 0x00;
buffer[10] = 0x00;
buffer[11] = 0x53;
buffer[12] = 0x0D;
buffer[13] = 0x0A;
return buffer;
}
}
}

@ -0,0 +1,182 @@
using SLH.SSDMS.Common;
using SLH.SSDMS.Model.DO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
namespace SLH.SSDMS.Services.serviceImpl
{
public class RfidJudge : IRfidJudge
{
private static string lastRfidCode = "";
private static Base_ReadRecord lastReadRecord = new Base_ReadRecord();
private static IBaseServices<Base_RFIDInfo> baseServices = new BaseServices<Base_RFIDInfo>();
private static IBaseServices<Day_RunInfo> runInfoServices = new BaseServices<Day_RunInfo>();
private static IBaseServices<Base_ReadRecord> readRecordServices = new BaseServices<Base_ReadRecord>();
private static IBaseServices<Base_BeltInfo> beltInfoServices = new BaseServices<Base_BeltInfo>();
public async Task<int> JudgeDirection(string rfidCode)
{
Expression<Func<Base_RFIDInfo, bool>> exp = s1 => true;
exp = exp.And(x => x.updateFlag == 0);
Expression<Func<Base_RFIDInfo, object>> order = (x) => x.rfidCode;
List<Base_RFIDInfo> rfidInfos = await baseServices.Query(exp, order,true);
List<string> rfidList = new List<string>();
rfidInfos.ForEach(x => rfidList.Add(x.rfidCode));
if (StringExtension.IsNotBlank(lastRfidCode))
{
int presentIndex = rfidList.IndexOf(rfidCode);
int lastIndex = rfidList.IndexOf(lastRfidCode);
if (lastIndex == 0 && presentIndex > lastIndex && presentIndex == 1)
{
lastRfidCode = rfidCode;
return 1;
}
if (lastIndex == 0 && presentIndex > lastIndex && presentIndex == rfidList.Count - 1)
{
lastRfidCode = rfidCode;
return 0;
}
if (lastIndex > 0 && presentIndex > 0 && lastIndex < presentIndex)
{
lastRfidCode = rfidCode;
return 1;
}
if (lastIndex > 0 && presentIndex > 0 && lastIndex > presentIndex)
{
lastRfidCode = rfidCode;
return 0;
}
if (presentIndex == 0 && lastIndex > presentIndex && lastIndex == rfidList.Count - 1)
{
lastRfidCode = rfidCode;
return 1;
}
if (presentIndex == 0 && lastIndex > presentIndex && lastIndex == 1)
{
lastRfidCode = rfidCode;
return 0;
}
}
lastRfidCode = rfidCode;
return 3;
}
public async Task<decimal> JudgeRunSpeed(Base_ReadRecord readRecord)
{
//计算时间差
try
{
TimeSpan readTime = new TimeSpan(readRecord.readTime.Ticks);
if (lastReadRecord == null)
{
Console.WriteLine("lastReadRecord为空");
return new decimal();
}
TimeSpan lastTime = new TimeSpan(lastReadRecord.readTime.Ticks);
decimal interval = (decimal)readTime.Subtract(lastTime).Duration().TotalSeconds;
Console.WriteLine("时差:" + interval);
//计算速度m/s
decimal result = readRecord.preDistance / interval;
var speed = Math.Round(result, 3);
lastReadRecord = readRecord;
return speed;
}
catch(Exception ex)
{
LogHelper.Error("速度计算异常", ex);
return 0;
}
}
public async Task<decimal> JudgeRunDistance(Base_ReadRecord readRecord)
{
try
{
//查询已经生成好的里程数据
Expression<Func<Day_RunInfo, bool>> exp = s1 => true;
exp = exp.And(x => x.lotNum == readRecord.lotNum);
List<Day_RunInfo> runInfos = await runInfoServices.Query(exp);
var distance = runInfos.Sum(x=>x.runDistance);
//查询当天的里程数据
Expression<Func<Base_ReadRecord, bool>> readExp = s1 => true;
readExp = readExp.And(x => x.readTime.ToString("yyyy-MM-dd") == DateTime.Now.ToString("yyyy-MM-dd"));
List<Base_ReadRecord> readRecords = await readRecordServices.Query(readExp);
var info = readRecords.Sum(x => x.preDistance);
return Math.Round((info + distance) / 1000,3);
}
catch (Exception ex)
{
LogHelper.Error("里程计算异常", ex);
return 0;
}
}
public async Task<decimal> JudgeRunTime(Base_ReadRecord readRecord)
{
try
{
//查询已经生成好的里程数据
Expression<Func<Day_RunInfo, bool>> exp = s1 => true;
exp = exp.And(x => x.lotNum == readRecord.lotNum);
List<Day_RunInfo> runInfos = await runInfoServices.Query(exp);
var runTime = runInfos.Sum(x=>x.runTime);
//查询当天的里程数据
Expression<Func<Base_ReadRecord, bool>> readExp = s1 => true;
readExp = readExp.And(x => x.readTime.ToString("yyyy-MM-dd") == DateTime.Now.ToString("yyyy-MM-dd"));
List<Base_ReadRecord> readRecords = await readRecordServices.Query(readExp);
Base_ReadRecord todayReadRecord = readRecords.OrderBy(x => x.readTime).First();
TimeSpan readTime = new TimeSpan(DateTime.Now.Ticks);
TimeSpan lastTime = new TimeSpan(todayReadRecord.readTime.Ticks);
decimal interval = (decimal)readTime.Subtract(lastTime).Duration().TotalSeconds;
return Math.Round((interval + runTime) / 60 / 60,2);
}
catch (Exception ex)
{
LogHelper.Error("时长计算异常", ex);
return 0;
}
}
public async Task<string> JudgeFirstTime(string lotCode)
{
try
{
Expression<Func<Base_BeltInfo, bool>> exp = s1 => true;
exp = exp.And(x => x.lotNum == lotCode);
var info = await beltInfoServices.Query(exp);
return info.FirstOrDefault().firstTime;
}catch(Exception ex)
{
LogHelper.Error("首次上机时间查询异常"+ lotCode, ex);
return DateTime.Now.ToString("yyyy-MM-dd");
}
}
}
}

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="sqlserver" value="Server=121.36.58.109;Database=SLHSSDMS;User ID=sa;Password=haiwei@123" />
</appSettings>
<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>
</assemblyBinding>
</runtime>
</configuration>

@ -0,0 +1,20 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("SLH.SSDMS.Test")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SLH.SSDMS.Test")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: Guid("883fe05c-20ac-4edb-8720-6e33efa693c7")]
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

@ -0,0 +1,83 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.props" Condition="Exists('..\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.props')" />
<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>{883FE05C-20AC-4EDB-8720-6E33EFA693C7}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SLH.SSDMS.Test</RootNamespace>
<AssemblyName>SLH.SSDMS.Test</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">15.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
<IsCodedUITest>False</IsCodedUITest>
<TestProjectType>UnitTest</TestProjectType>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</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="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\MSTest.TestFramework.2.1.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\MSTest.TestFramework.2.1.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
</ItemGroup>
<ItemGroup>
<Compile Include="UnitTest1.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SLH.SSDMS.Common\SLH.SSDMS.Common.csproj">
<Project>{9DB66868-C6F0-4522-A551-09452B927C52}</Project>
<Name>SLH.SSDMS.Common</Name>
</ProjectReference>
<ProjectReference Include="..\SLH.SSDMS.Model\SLH.SSDMS.Model.csproj">
<Project>{1C8B2E03-FC2D-4385-B87A-51A8DD92FE01}</Project>
<Name>SLH.SSDMS.Model</Name>
</ProjectReference>
<ProjectReference Include="..\SLH.SSDMS.Services\SLH.SSDMS.Services.csproj">
<Project>{3EFE1A92-DF3D-4B98-8A6B-DDA264385E52}</Project>
<Name>SLH.SSDMS.Services</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.props'))" />
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.targets'))" />
</Target>
<Import Project="..\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.targets" Condition="Exists('..\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.targets')" />
</Project>

@ -0,0 +1,61 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SLH.SSDMS.Common;
using SLH.SSDMS.Model.DO;
using SLH.SSDMS.Services;
using SLH.SSDMS.Services.serviceImpl;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
namespace SLH.SSDMS.Test
{
[TestClass]
public class UnitTest1
{
private static IBaseServices<Base_BeltInfo> baseServices = new BaseServices<Base_BeltInfo>();
private static string last;
[TestMethod]
public void TestMethod1()
{
var code = Console.ReadLine();
test(code);
}
public string test(string code)
{
List<string> list = new List<string>();
list.Add("abc");
list.Add("123");
list.Add("456");
list.Add("789");
if (StringExtension.IsNotBlank(last))
{
int presentIndex = list.IndexOf(code);
int lastIndex = list.IndexOf(last);
if (lastIndex > 0 && presentIndex > 0 && lastIndex < presentIndex)
{
return "0";
}
if (lastIndex > 0 && presentIndex > 0 && lastIndex > presentIndex)
{
return "1";
}
if (presentIndex == 0 && lastIndex > presentIndex)
{
return "0";
}
if (presentIndex == 0 && presentIndex > lastIndex)
{
return "1";
}
}
return "";
}
}
}

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="MSTest.TestAdapter" version="2.1.2" targetFramework="net452" />
<package id="MSTest.TestFramework" version="2.1.2" targetFramework="net452" />
</packages>

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("SLH.SSDMS.WebSocket")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SLH.SSDMS.WebSocket")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("634c0cff-e2d5-462c-9395-1540ba1282fd")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

@ -0,0 +1,60 @@
<?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>{634C0CFF-E2D5-462C-9395-1540BA1282FD}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SLH.SSDMS.WebSocket</RootNamespace>
<AssemblyName>SLH.SSDMS.WebSocket</AssemblyName>
<TargetFrameworkVersion>v4.5.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="Fleck, Version=1.2.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Fleck.1.2.0\lib\net45\Fleck.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="WebSocketServer.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SLH.SSDMS.Common\SLH.SSDMS.Common.csproj">
<Project>{9DB66868-C6F0-4522-A551-09452B927C52}</Project>
<Name>SLH.SSDMS.Common</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

@ -0,0 +1,57 @@
using Fleck;
using SLH.SSDMS.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SLH.SSDMS.WebSocket
{
public class WebSocketServer
{
private static List<IWebSocketConnection> allSockets = new List<IWebSocketConnection>();
public static void Init()
{
FleckLog.Level = LogLevel.Debug;
var server = new Fleck.WebSocketServer("ws://0.0.0.0:7181");
server.Start(socket =>
{
socket.OnOpen = () =>
{
var data = socket.ConnectionInfo;
Console.WriteLine("Open!");
allSockets.Add(socket);
};
socket.OnClose = () =>
{
Console.WriteLine("Close!");
allSockets.Remove(socket);
};
socket.OnMessage = message =>
{
Console.WriteLine(message);
socket.Send("Echo:" + message);
};
});
}
public static void sendMessage(string message)
{
try
{
foreach (var socket in allSockets.ToList())
{
socket.Send(message);
LogHelper.Info("WebSocket接口上传数据:" + message);
}
}catch(Exception ex)
{
LogHelper.Error("WebSocket上传数据异常", ex);
}
}
}
}

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Fleck" version="1.2.0" targetFramework="net452" />
</packages>

@ -0,0 +1,67 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31205.134
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SLH.SSDMS", "SLH.SSDMS\SLH.SSDMS.csproj", "{9FB908E1-CD3F-4C24-AEC9-BCE0F1277932}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SLH.SSDMS.Collect", "SLH.SSDMS.Collect\SLH.SSDMS.Collect.csproj", "{C3937FF9-B218-48E4-A602-C59106B67C7B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SLH.SSDMS.Common", "SLH.SSDMS.Common\SLH.SSDMS.Common.csproj", "{9DB66868-C6F0-4522-A551-09452B927C52}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SLH.SSDMS.Model", "SLH.SSDMS.Model\SLH.SSDMS.Model.csproj", "{1C8B2E03-FC2D-4385-B87A-51A8DD92FE01}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SLH.SSDMS.Services", "SLH.SSDMS.Services\SLH.SSDMS.Services.csproj", "{3EFE1A92-DF3D-4B98-8A6B-DDA264385E52}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SLH.SSDMS.Test", "SLH.SSDMS.Test\SLH.SSDMS.Test.csproj", "{883FE05C-20AC-4EDB-8720-6E33EFA693C7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SLH.SSDMS.WebSocket", "SLH.SSDMS.WebSocket\SLH.SSDMS.WebSocket.csproj", "{634C0CFF-E2D5-462C-9395-1540BA1282FD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SLH.SSDMS.RestSharp", "SLH.SSDMS.RestSharp\SLH.SSDMS.RestSharp.csproj", "{BD42A6EC-6A27-4E28-938F-9E7906D049E0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9FB908E1-CD3F-4C24-AEC9-BCE0F1277932}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9FB908E1-CD3F-4C24-AEC9-BCE0F1277932}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9FB908E1-CD3F-4C24-AEC9-BCE0F1277932}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9FB908E1-CD3F-4C24-AEC9-BCE0F1277932}.Release|Any CPU.Build.0 = Release|Any CPU
{C3937FF9-B218-48E4-A602-C59106B67C7B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C3937FF9-B218-48E4-A602-C59106B67C7B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C3937FF9-B218-48E4-A602-C59106B67C7B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C3937FF9-B218-48E4-A602-C59106B67C7B}.Release|Any CPU.Build.0 = Release|Any CPU
{9DB66868-C6F0-4522-A551-09452B927C52}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9DB66868-C6F0-4522-A551-09452B927C52}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9DB66868-C6F0-4522-A551-09452B927C52}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9DB66868-C6F0-4522-A551-09452B927C52}.Release|Any CPU.Build.0 = Release|Any CPU
{1C8B2E03-FC2D-4385-B87A-51A8DD92FE01}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1C8B2E03-FC2D-4385-B87A-51A8DD92FE01}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1C8B2E03-FC2D-4385-B87A-51A8DD92FE01}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1C8B2E03-FC2D-4385-B87A-51A8DD92FE01}.Release|Any CPU.Build.0 = Release|Any CPU
{3EFE1A92-DF3D-4B98-8A6B-DDA264385E52}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3EFE1A92-DF3D-4B98-8A6B-DDA264385E52}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3EFE1A92-DF3D-4B98-8A6B-DDA264385E52}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3EFE1A92-DF3D-4B98-8A6B-DDA264385E52}.Release|Any CPU.Build.0 = Release|Any CPU
{883FE05C-20AC-4EDB-8720-6E33EFA693C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{883FE05C-20AC-4EDB-8720-6E33EFA693C7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{883FE05C-20AC-4EDB-8720-6E33EFA693C7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{883FE05C-20AC-4EDB-8720-6E33EFA693C7}.Release|Any CPU.Build.0 = Release|Any CPU
{634C0CFF-E2D5-462C-9395-1540BA1282FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{634C0CFF-E2D5-462C-9395-1540BA1282FD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{634C0CFF-E2D5-462C-9395-1540BA1282FD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{634C0CFF-E2D5-462C-9395-1540BA1282FD}.Release|Any CPU.Build.0 = Release|Any CPU
{BD42A6EC-6A27-4E28-938F-9E7906D049E0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BD42A6EC-6A27-4E28-938F-9E7906D049E0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BD42A6EC-6A27-4E28-938F-9E7906D049E0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BD42A6EC-6A27-4E28-938F-9E7906D049E0}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D6670BC7-6C9E-4C2B-B151-53A74EE757E8}
EndGlobalSection
EndGlobal

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
<appSettings>
<add key="DataBaseServer" value="127.0.0.1" />
<add key="DataBaseName" value="SSDMS" />
<add key="DataBaseUser" value="sa" />
<add key="DataBasePassword" value="123456" />
<add key="uploadUrl" value="http://10.169.161.174:8000/api/sld/run.status" />
</appSettings>
<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>
</assemblyBinding>
</runtime>
</configuration>

@ -0,0 +1,63 @@
using SLH.SSDMS.Collect;
using SLH.SSDMS.Common;
using SLH.SSDMS.Model.DO;
using SLH.SSDMS.Model.DTO;
using SLH.SSDMS.RestSharp;
using SLH.SSDMS.Services;
using SLH.SSDMS.Services.serviceImpl;
using SLH.SSDMS.WebSocket;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.ServiceProcess;
using System.Text;
using System.Threading.Tasks;
namespace SLH.SSDMS
{
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
static void Main()
{
try
{
ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[]
{
new Service1()
};
ServiceBase.Run(ServicesToRun);
}
catch(Exception ex)
{
LogHelper.Error("异常捕获", ex);
}
}
public static void test()
{
try
{
ViewModelDTO viewModelDTO = new ViewModelDTO();
viewModelDTO.orderFlag = 0;
viewModelDTO.runTime = 123.3M;
viewModelDTO.speed = 4.2M;
viewModelDTO.distance = 123;
string firstTime = "2021-10-11";
viewModelDTO.firstTime = firstTime.Substring(0, 10);
viewModelDTO.beltSum = 11;
//上传无人巡检系统
Upload.sendMessage(viewModelDTO);
}catch(Exception ex)
{
Console.WriteLine("上传异常:" + ex.Message);
}
}
}
}

@ -0,0 +1,59 @@

namespace SLH.SSDMS
{
partial class ProjectInstaller
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region 组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.serviceProcessInstaller1 = new System.ServiceProcess.ServiceProcessInstaller();
this.serviceInstaller1 = new System.ServiceProcess.ServiceInstaller();
//
// serviceProcessInstaller1
//
this.serviceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalService;
this.serviceProcessInstaller1.Password = null;
this.serviceProcessInstaller1.Username = null;
//
// serviceInstaller1
//
this.serviceInstaller1.DisplayName = "RFID采集服务";
this.serviceInstaller1.ServiceName = "Service1";
//
// ProjectInstaller
//
this.Installers.AddRange(new System.Configuration.Install.Installer[] {
this.serviceProcessInstaller1,
this.serviceInstaller1});
}
#endregion
private System.ServiceProcess.ServiceProcessInstaller serviceProcessInstaller1;
private System.ServiceProcess.ServiceInstaller serviceInstaller1;
}
}

@ -0,0 +1,19 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration.Install;
using System.Linq;
using System.Threading.Tasks;
namespace SLH.SSDMS
{
[RunInstaller(true)]
public partial class ProjectInstaller : System.Configuration.Install.Installer
{
public ProjectInstaller()
{
InitializeComponent();
}
}
}

@ -0,0 +1,129 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="serviceProcessInstaller1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="serviceInstaller1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>351, 17</value>
</metadata>
<metadata name="$this.TrayLargeIcon" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
</root>

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("SLH.SSDMS")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SLH.SSDMS")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("9fb908e1-cd3f-4c24-aec9-bce0f1277932")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

@ -0,0 +1,102 @@
<?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>{9FB908E1-CD3F-4C24-AEC9-BCE0F1277932}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>SLH.SSDMS</RootNamespace>
<AssemblyName>SLH.SSDMS</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Configuration.Install" />
<Reference Include="System.Core" />
<Reference Include="System.Management" />
<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.ServiceProcess" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ProjectInstaller.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="ProjectInstaller.Designer.cs">
<DependentUpon>ProjectInstaller.cs</DependentUpon>
</Compile>
<Compile Include="Service1.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Service1.Designer.cs">
<DependentUpon>Service1.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SLH.SSDMS.Collect\SLH.SSDMS.Collect.csproj">
<Project>{C3937FF9-B218-48E4-A602-C59106B67C7B}</Project>
<Name>SLH.SSDMS.Collect</Name>
</ProjectReference>
<ProjectReference Include="..\SLH.SSDMS.Common\SLH.SSDMS.Common.csproj">
<Project>{9DB66868-C6F0-4522-A551-09452B927C52}</Project>
<Name>SLH.SSDMS.Common</Name>
</ProjectReference>
<ProjectReference Include="..\SLH.SSDMS.Model\SLH.SSDMS.Model.csproj">
<Project>{1C8B2E03-FC2D-4385-B87A-51A8DD92FE01}</Project>
<Name>SLH.SSDMS.Model</Name>
</ProjectReference>
<ProjectReference Include="..\SLH.SSDMS.RestSharp\SLH.SSDMS.RestSharp.csproj">
<Project>{BD42A6EC-6A27-4E28-938F-9E7906D049E0}</Project>
<Name>SLH.SSDMS.RestSharp</Name>
</ProjectReference>
<ProjectReference Include="..\SLH.SSDMS.Services\SLH.SSDMS.Services.csproj">
<Project>{3EFE1A92-DF3D-4B98-8A6B-DDA264385E52}</Project>
<Name>SLH.SSDMS.Services</Name>
</ProjectReference>
<ProjectReference Include="..\SLH.SSDMS.WebSocket\SLH.SSDMS.WebSocket.csproj">
<Project>{634C0CFF-E2D5-462C-9395-1540BA1282FD}</Project>
<Name>SLH.SSDMS.WebSocket</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="ProjectInstaller.resx">
<DependentUpon>ProjectInstaller.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

@ -0,0 +1,38 @@

namespace SLH.SSDMS
{
partial class Service1
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region 组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
this.ServiceName = "Service1";
}
#endregion
}
}

@ -0,0 +1,32 @@
using SLH.SSDMS.Collect;
using SLH.SSDMS.WebSocket;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Threading.Tasks;
namespace SLH.SSDMS
{
public partial class Service1 : ServiceBase
{
public Service1()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
AsyncSocket.init();
WebSocketServer.Init();
}
protected override void OnStop()
{
}
}
}
Loading…
Cancel
Save