Commit 9bd03d45 by zonevg

init

parents
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.sln.docstates
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
build/
bld/
[Bb]in/
[Oo]bj/
# Roslyn cache directories
*.ide/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
#NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile
# Visual Studio profiler
*.psess
*.vsp
*.vspx
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding addin-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
_NCrunch_*
.*crunch*.local.xml
# 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
## TODO: Comment the next line if you want to checkin your
## web deploy settings but do note that will include unencrypted
## passwords
*.pubxml
# NuGet Packages
packages/*
*.nupkg
## TODO: If the tool you use requires repositories.config
## uncomment the next line
#!packages/repositories.config
# Enable "build/" folder in the NuGet Packages folder since
# NuGet packages use it for MSBuild targets.
# This line needs to be after the ignore of the build folder
# (and the packages folder if the line above has been uncommented)
!packages/build/
# Windows Azure Build Output
csx/
*.build.csdef
# Windows Store app package directory
AppPackages/
# Others
sql/
*.Cache
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.pfx
*.publishsettings
node_modules/
# 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
# SQL Server files
*.mdf
*.ldf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
# Microsoft Fakes
FakesAssemblies/
/.vs
/JmpModel/CodeTemplates
/JunmpPoliceStation/appsettings.json
/JunmpPoliceStation/internal-nlog.txt
/JunmpPoliceStation/JunmpPoliceStation.xml
This source diff could not be displayed because it is too large. You can view the blob instead.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace JmpCommon.Camera
{
public class BaseCamera : ICamera
{
public string Address { get; protected set; }
public string UserName { get; protected set; }
public string UserPwd { get; protected set; }
public int Port { get; protected set; }
public int Channel { get; protected set; }
public virtual bool CaptureFile(string fileName)
{
return default;
}
public virtual byte[] CaptureBuffer(string fileName="")
{
return default;
}
public virtual bool Initial(string addr, int port, int channel, string userName, string userPwd)
{
Address = addr;
Port = port;
UserName = userName;
UserPwd = userPwd;
Channel = channel;
return true;
}
public virtual bool Login()
{
return default;
}
public virtual bool Logout()
{
return default;
}
public virtual void Cleanup() { }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace JmpCommon.Camera
{
public static class ConstStr
{
public static string SNAP_PATH = "Snap";
public static string UPLOAD_PATH = $"/SnapPic/Channel/";
}
}
using NetSDKCS;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace JmpCommon.Camera
{
public class DahuaCamera : BaseCamera
{
private NET_DEVICEINFO_Ex deviceInfo;
private DahuaCameraControlSettings settings = new DahuaCameraControlSettings();
private IntPtr Hwnd { get; set; }
public DahuaCamera()
{
settings.fileEvent = new ManualResetEvent(true);
settings.bufferEvent = new ManualResetEvent(true);
DahuaCameraControl.Init();
}
public override bool Login()
{
if (string.IsNullOrEmpty(Address))
{
Log.WorkLog("视频设备地址不正确");
return false;
}
else if (string.IsNullOrEmpty(UserName))
{
Log.WorkLog("视频设备登录用户不正确");
return false;
}
else if (string.IsNullOrEmpty(UserPwd))
{
Log.WorkLog("视频设备登录密码不正确");
return false;
}
else if (Port <= 0)
{
Log.WorkLog("视频设备端口不正确");
return false;
}
else if (Channel < 0)
{
Log.WorkLog("视频设备通道号不正确");
return false;
}
else
{
return test();
}
}
public bool test()
{
Hwnd = DahuaCameraControl.LoginWithHighLevelSecurity(settings, Address, (ushort)Port, UserName, UserPwd, EM_LOGIN_SPAC_CAP_TYPE.TCP, IntPtr.Zero, ref deviceInfo);
if (Hwnd == IntPtr.Zero)
{
Log.WorkLog($"视频设备登录失败,错误代码:{DahuaCameraControl.GetLastError()}");
return false;
}
else
{
return true;
}
}
public override bool Logout()
{
if (Hwnd == IntPtr.Zero)
{
return true;
}
else
{
var res = DahuaCameraControl.Logout((IntPtr)Hwnd);
Hwnd = IntPtr.Zero;
return res;
}
}
public override bool CaptureFile(string fileName)
{
try
{
if (Hwnd == IntPtr.Zero)
{
return false;
}
else
{
settings.fileName = fileName;
settings.fileEvent.Reset();
NET_SNAP_PARAMS options = new NET_SNAP_PARAMS();
options.Channel = (uint)Channel;
options.Quality = 6;
options.ImageSize = 2;
options.mode = 0;
options.InterSnap = 0;
options.CmdSerial = 1;
bool ret = DahuaCameraControl.SnapPictureEx((IntPtr)Hwnd, options, IntPtr.Zero);
if (!ret)
{
return false;
}
else
{
settings.fileEvent.WaitOne(15000);
return fileName == string.Empty;
}
}
}
catch (Exception ex)
{
Log.ErrorLog(ex.ToString());
return false;
}
}
public override byte[] CaptureBuffer(string fileName = "")
{
try
{
if (Hwnd == IntPtr.Zero)
{
return default;
}
else
{
settings.isBuffer = true;
settings.bufferEvent.Reset();
NET_SNAP_PARAMS options = new NET_SNAP_PARAMS();
options.Channel = (uint)Channel;
options.Quality = 6;
options.ImageSize = 2;
options.mode = 0;
options.InterSnap = 0;
options.CmdSerial = 1;
bool ret = DahuaCameraControl.SnapPictureEx((IntPtr)Hwnd, options, IntPtr.Zero);
if (!ret)
{
return default;
}
else
{
settings.bufferEvent.WaitOne(15000);
return settings.fileBuffer;
}
}
}
catch (Exception ex)
{
Log.ErrorLog(ex.ToString());
return default;
}
finally
{
settings.fileBuffer = default;
settings.isBuffer = false;
}
}
public override void Cleanup()
{
Logout();
DahuaCameraControl.Cleanup();
}
}
}
using NetSDKCS;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace JmpCommon.Camera
{
public static class DahuaCameraControl
{
private static fSnapRevCallBack m_SnapRevCallBack;
private static fDisConnectCallBack m_DisConnectCallBack;
private static fHaveReConnectCallBack m_ReConnectCallBack;
private static bool _isInit = false;
private static readonly Dictionary<IntPtr, DahuaCameraControlSettings> Dictionary = new Dictionary<IntPtr, DahuaCameraControlSettings>();
public static void Init()
{
if (!_isInit)
{
_isInit = true;
m_SnapRevCallBack = new fSnapRevCallBack(SnapRevCallBack);
m_DisConnectCallBack = new fDisConnectCallBack(DisConnectCallBack);
m_ReConnectCallBack = new fHaveReConnectCallBack(ReConnectCallBack);
NETClient.Init(m_DisConnectCallBack, IntPtr.Zero, default);
NETClient.SetAutoReconnect(m_ReConnectCallBack, IntPtr.Zero);
NETClient.SetSnapRevCallBack(m_SnapRevCallBack, IntPtr.Zero);
}
}
private static void DisConnectCallBack(IntPtr lLoginID, IntPtr pchDVRIP, int nDVRPort, IntPtr dwUser)
{
}
private static void ReConnectCallBack(IntPtr lLoginID, IntPtr pchDVRIP, int nDVRPort, IntPtr dwUser)
{
}
public static void SnapRevCallBack(IntPtr lLoginID, IntPtr pBuf, uint RevLen, uint EncodeType, uint CmdSerial, IntPtr dwUser)
{
string path = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + ConstStr.SNAP_PATH + "\\" + DateTime.Now.ToString("yyyyMMdd");
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
if (EncodeType == 10) //.jpg
{
if (Dictionary.TryGetValue(lLoginID, out var settings))
{
if (settings.isBuffer)
{
byte[] buffer = new byte[RevLen];
Marshal.Copy(pBuf, buffer, 0, (int)RevLen);
settings.fileBuffer = buffer;
settings.bufferEvent.Set();
}
else
{
string filePath = $"{path}\\{settings.fileName}.jpg";
byte[] buffer = new byte[RevLen];
Marshal.Copy(pBuf, buffer, 0, (int)RevLen);
using (FileStream stream = new FileStream(filePath, FileMode.OpenOrCreate))
{
stream.Write(buffer, 0, (int)RevLen);
stream.Flush();
stream.Dispose();
}
settings.fileEvent.Set();
settings.fileName = string.Empty;
}
}
}
}
public static bool SnapPictureEx(IntPtr lLoginID, NET_SNAP_PARAMS par, IntPtr reserved)
{
return NETClient.SnapPictureEx(lLoginID, par, reserved);
}
public static IntPtr LoginWithHighLevelSecurity(DahuaCameraControlSettings settings, string pchDVRIP, ushort wDVRPort, string pchUserName, string pchPassword, EM_LOGIN_SPAC_CAP_TYPE emSpecCap, IntPtr pCapParam, ref NET_DEVICEINFO_Ex deviceInfo)
{
var res = NETClient.LoginWithHighLevelSecurity(pchDVRIP, wDVRPort, pchUserName, pchPassword, emSpecCap, pCapParam, ref deviceInfo);
if (res != IntPtr.Zero)
{
if (Dictionary.ContainsKey(res))
{
Dictionary.Remove(res);
}
Dictionary.Add(res, settings);
}
return res;
}
public static bool Logout(IntPtr lLoginID)
{
Dictionary.Remove(lLoginID);
return NETClient.Logout(lLoginID);
}
public static string GetLastError()
{
return NETClient.GetLastError();
}
public static void Cleanup()
{
NETClient.Cleanup();
}
}
}
using NetSDKCS;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace JmpCommon.Camera
{
public class DahuaCameraControlSettings
{
public uint Channel { get; set; }
public uint Quality { get; set; }
public uint ImageSize { get; set; }
public uint mode { get; set; }
public uint InterSnap { get; set; }
public uint CmdSerial { get; set; }
public bool isBuffer { get; set; }
public string fileName { get; set; }
public byte[] fileBuffer { get; set; }
public ManualResetEvent fileEvent { get; set; }
public ManualResetEvent bufferEvent { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace JmpCommon.Camera
{
public interface ICamera
{
bool Initial(string addr,int port, int channel, string userName,string userPwd);
bool Login();
bool Logout();
bool CaptureFile(string fileName);
byte[] CaptureBuffer(string fileName="");
void Cleanup();
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace JmpCommon.Camera
{
public class ResponeUpload
{
public int code { get; set; }
public string msg { get; set; }
public int timestamp { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace JmpCommon
{
public class HotKey
{
//如果函数执行成功,返回值不为0。
//如果函数执行失败,返回值为0。要得到扩展错误信息,调用GetLastError。
[DllImport("user32.dll", SetLastError = true)]
public static extern bool RegisterHotKey(
IntPtr hWnd, //要定义热键的窗口的句柄
int id, //定义热键ID(不能与其它ID重复)
KeyModifiers fsModifiers, //标识热键是否在按Alt、Ctrl、Shift、Windows等键时才会生效
int vk //定义热键的内容
);
[DllImport("user32.dll", SetLastError = true)]
public static extern bool UnregisterHotKey(
IntPtr hWnd, //要取消热键的窗口的句柄
int id //要取消热键的ID
);
//定义了辅助键的名称(将数字转变为字符以便于记忆,也可去除此枚举而直接使用数值)
[Flags()]
public enum KeyModifiers
{
None = 0,
Alt = 1,
Ctrl = 2,
Shift = 4,
WindowsKey = 8
}
}
}
<?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>{8662BAF0-5206-4472-84AF-2E44669C3E2C}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>JmpCommon</RootNamespace>
<AssemblyName>JmpCommon</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\Programe\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>8.0</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\Programe\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>8.0</LangVersion>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Reference Include="LiteDB, Version=5.0.8.0, Culture=neutral, PublicKeyToken=4ee40123013c9f27, processorArchitecture=MSIL">
<HintPath>..\packages\LiteDB.5.0.8\lib\net45\LiteDB.dll</HintPath>
</Reference>
<Reference Include="NetSDKCS">
<HintPath>..\Lib\NetSDKCS.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Management" />
<Reference Include="System.Runtime" />
<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="Analyzingepc.cs" />
<Compile Include="Camera\BaseCamera.cs" />
<Compile Include="Camera\ConstStr.cs" />
<Compile Include="Camera\DahuaCamera.cs" />
<Compile Include="Camera\DahuaCameraControlSettings.cs" />
<Compile Include="Camera\DahuaCameraControl.cs" />
<Compile Include="Camera\HikCamera.cs" />
<Compile Include="Camera\ICamera.cs" />
<Compile Include="Camera\ResponeUpload.cs" />
<Compile Include="CHCNetSDK.cs" />
<Compile Include="HotKey.cs" />
<Compile Include="HttpHelper.cs" />
<Compile Include="JmpDes.cs" />
<Compile Include="LiteDBHelper.cs" />
<Compile Include="Log.cs" />
<Compile Include="MachineIdentity.cs" />
<Compile Include="Model\ChannelReadEquType.cs" />
<Compile Include="Model\DoorCardInfo.cs" />
<Compile Include="Model\equ_info.cs" />
<Compile Include="Model\FingerInfo.cs" />
<Compile Include="Model\GpiTrigger.cs" />
<Compile Include="Model\response_BagInvModel.cs" />
<Compile Include="Model\response_Shelf.cs" />
<Compile Include="Model\EquipmentInventory.cs" />
<Compile Include="Model\response_ShelfPrint.cs" />
<Compile Include="Model\response_TransformInfo.cs" />
<Compile Include="Model\response_BoxMarkModel.cs" />
<Compile Include="Model\request_sign.cs" />
<Compile Include="Model\sync_police.cs" />
<Compile Include="Model\respone_update.cs" />
<Compile Include="Model\LocalConfig.cs" />
<Compile Include="Model\RemoteConfig.cs" />
<Compile Include="Model\request_head.cs" />
<Compile Include="Model\respone_head.cs" />
<Compile Include="Model\warehouse_info.cs" />
<Compile Include="MyCache.cs" />
<Compile Include="SessionUtility.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TtsEnum.cs" />
<Compile Include="TtsStruct.cs" />
<Compile Include="Win32API.cs" />
<Compile Include="XfVioceMsc.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
namespace JmpCommon
{
public class JmpDes
{
/// <summary> 加密字符串
/// </summary>
/// <param name="strText">需被加密的字符串</param>
/// <param name="strEncrKey">密钥</param>
/// <returns></returns>
public static string Encrypt(string strText, string strKey = "jMp838668")
{
try
{
byte[] byKey = null;
byte[] IV = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF };
byKey = Encoding.UTF8.GetBytes(strKey.Substring(0, 8));
DESCryptoServiceProvider des = new DESCryptoServiceProvider();
byte[] inputByteArray = Encoding.UTF8.GetBytes(strText);
MemoryStream ms = new MemoryStream();
CryptoStream cs = new CryptoStream(ms, des.CreateEncryptor(byKey, IV), CryptoStreamMode.Write);
cs.Write(inputByteArray, 0, inputByteArray.Length);
cs.FlushFinalBlock();
return Convert.ToBase64String(ms.ToArray());
}
catch
{
return "";
}
}
/// <summary> 解密字符串
/// </summary>
/// <param name="strText">需被解密的字符串</param>
/// <param name="sDecrKey">密钥</param>
/// <returns></returns>
public static string Decrypt(string strText, string strKey = "jMp838668")
{
try
{
byte[] byKey = null;
byte[] IV = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF };
byte[] inputByteArray = new Byte[strText.Length];
byKey = Encoding.UTF8.GetBytes(strKey.Substring(0, 8));
DESCryptoServiceProvider des = new DESCryptoServiceProvider();
inputByteArray = Convert.FromBase64String(strText);
MemoryStream ms = new MemoryStream();
CryptoStream cs = new CryptoStream(ms, des.CreateDecryptor(byKey, IV), CryptoStreamMode.Write);
cs.Write(inputByteArray, 0, inputByteArray.Length);
cs.FlushFinalBlock();
Encoding encoding = new UTF8Encoding();
return encoding.GetString(ms.ToArray());
}
catch
{
return string.Empty;
}
}
}
}
using JmpCommon;
using JmpCommon.Model;
using LiteDB;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace JmpCommon
{
public static class LiteDBHelper
{
public static bool AddOrUpdate(TagCacheInfo entity)
{
try
{
using (var db = new LiteDatabase($"{System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase}epcs.db"))
{
var col = db.GetCollection<TagCacheInfo>(nameof(TagCacheInfo));
if (entity.Id == null || entity.Id == 0)
{
var res = col.Insert(entity).AsInt32 > 0;
if (!res) { Log.WorkLog("EPC缓存写入失败", "写入失败"); }
else { Log.WorkLog("EPC缓存写入成功", "写入成功"); }
return res;
}
else
{
entity.LastDate = DateTime.Now;
var res = col.Update(entity);
if (!res) { Log.WorkLog("EPC缓存更新失败", "更新失败"); }
else { Log.WorkLog("EPC缓存更新成功", "更新成功"); }
return res;
}
}
}
catch (Exception ex)
{
Log.ErrorLog(ex.ToString());
return false;
}
}
public static TagCacheInfo FindByEpc(string epc, string warehouseId, int state = -1)
{
try
{
using (var db = new LiteDatabase($"{System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase}epcs.db"))
{
var col = db.GetCollection<TagCacheInfo>(nameof(TagCacheInfo));
if (state == -1)
{
return col.FindOne(x => x.Epc.Contains(epc) && x.WarehouseId == warehouseId);
}
else
{
return col.FindOne(x => x.Epc.Contains(epc) && x.CurrentState == state && x.WarehouseId == warehouseId);
}
}
}
catch (Exception ex)
{
Log.ErrorLog(ex.ToString());
return default;
}
}
public static TagCacheInfo FindByEpc(string epc, string warehouseId)
{
try
{
using (var db = new LiteDatabase($"{System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase}epcs.db"))
{
var col = db.GetCollection<TagCacheInfo>(nameof(TagCacheInfo));
return col.FindOne(x => x.Epc.Contains(epc) && x.WarehouseId == warehouseId);
}
}
catch (Exception ex)
{
Log.ErrorLog(ex.ToString());
return default;
}
}
public static bool DeleteAll()
{
try
{
using (var db = new LiteDatabase($"{System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase}epcs.db"))
{
var col = db.GetCollection<TagCacheInfo>(nameof(TagCacheInfo));
return col.DeleteAll() >= 0;
}
}
catch (Exception ex)
{
Log.ErrorLog(ex.ToString());
return false;
}
}
public static void RefreshAll()
{
try
{
using (var db = new LiteDatabase($"{System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase}epcs.db"))
{
var col = db.GetCollection<TagCacheInfo>(nameof(TagCacheInfo));
var list = col.FindAll().ToList();
list.ForEach(s =>
{
s.LastDate = DateTime.Now.Date;
col.Update(s);
});
}
}
catch (Exception ex)
{
Log.ErrorLog(ex.ToString());
}
}
public static List<SyncCardInfo> FindAll()
{
try
{
using (var db = new LiteDatabase($"{System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase}epcs.db"))
{
var col = db.GetCollection<SyncCardInfo>(nameof(SyncCardInfo));
return col.FindAll().ToList();
}
}
catch (Exception ex)
{
Log.ErrorLog(ex.ToString());
return default;
}
}
public static bool AddOrUpdate(SyncCardInfo entity)
{
try
{
using (var db = new LiteDatabase($"{System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase}epcs.db"))
{
var col = db.GetCollection<SyncCardInfo>(nameof(SyncCardInfo));
if (entity == null || entity.Id == 0)
{
var res = col.Insert(entity).AsInt32 > 0;
if (!res) { Log.WorkLog("人员数据写入失败", "写入失败"); }
else { Log.WorkLog("人员数据写入成功", "写入成功"); }
return res;
}
else
{
var res = col.Update(entity);
if (!res) { Log.WorkLog("人员数据更新失败", "更新失败"); }
else { Log.WorkLog("人员数据更新成功", "更新成功"); }
return res;
}
}
}
catch (Exception ex)
{
Log.ErrorLog(ex.ToString());
return false;
}
}
public static bool DeleteByCard(string cardNo)
{
try
{
using (var db = new LiteDatabase($"{System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase}epcs.db"))
{
var col = db.GetCollection<SyncCardInfo>(nameof(SyncCardInfo));
return col.DeleteMany(t => t.CardNo == cardNo) >= 0;
}
}
catch (Exception ex)
{
Log.ErrorLog(ex.ToString());
return false;
}
}
public static bool DeleteByCard(Expression<Func<SyncCardInfo, bool>> predicate)
{
try
{
using (var db = new LiteDatabase($"{System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase}epcs.db"))
{
var col = db.GetCollection<SyncCardInfo>(nameof(SyncCardInfo));
var res = col.DeleteMany(predicate) >= 0;
return res;
}
}
catch (Exception ex)
{
Log.ErrorLog(ex.ToString());
return false;
}
}
}
public class TagCacheInfo
{
public string WarehouseId { get; set; }
public int Id { get; set; }
public string Epc { get; set; }
public DateTime LastDate { get; set; }
public int CurrentState { get; set; }
}
public class SyncCardInfo
{
public string orgId { get; set; }
public int Id { get; set; }
public string PoliceId { get; set; }
public string CardNo { get; set; }
public string OrgId { get; set; }
public string FacePic { get; set; }
public DateTime SyncDate { get; set; }
public bool IsSyncCard { get; set; }
public bool IsSyncFace { get; set; }
public bool IsSyncFinger { get; set; }
public bool IsPushedPic { get; set; }
public List<FingerInfo> FingerList { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace JmpCommon
{
public class Log
{
//private static
private static StreamWriter sr;
private static readonly object syncWorkObj = new object();
private static readonly object syncErrorObj = new object();
private static readonly object syncDebugObj = new object();
private static bool bEnableWorkLog = true;
private static bool bEnableErrorLog = true;
private static bool bEnableDebugLog = true;
public Log()
{
}
/// <summary>
/// Log 启用
/// </summary>
/// <param name="enable"></param>
public static void EnableWorkLog(bool enable)
{
bEnableWorkLog = enable;
}
/// <summary>
/// Log 启用
/// </summary>
/// <param name="enable"></param>
public static void EnableErrorLog(bool enable)
{
bEnableErrorLog = enable;
}
/// <summary>
/// Log 启用
/// </summary>
/// <param name="enable"></param>
public static void EnableDebugLog(bool enable)
{
bEnableDebugLog = enable;
}
/// <summary>
/// 工作日志
/// </summary>
/// <param name="logTxt"></param>
/// <param name="ModuleName"></param>
public static void WorkLog(string logTxt, [CallerMemberName] string ModuleName = default)
{
lock (syncWorkObj)
{
if (bEnableWorkLog)
{
WriteLine(logTxt, ModuleName, "WorkLog/");
}
}
}
/// <summary>
/// 异常日志
/// </summary>
/// <param name="logTxt"></param>
/// <param name="ModuleName"></param>
public static void ErrorLog(string logTxt, [CallerMemberName] string ModuleName = default)
{
lock (syncErrorObj)
{
if (bEnableErrorLog)
{
WriteLine(logTxt, ModuleName, "ErrorLog/");
}
}
}
/// <summary>
/// 异常日志
/// </summary>
/// <param name="logTxt"></param>
/// <param name="ModuleName"></param>
public static void DebugLog(string logTxt, [CallerMemberName] string ModuleName = null)
{
lock (syncDebugObj)
{
if (bEnableDebugLog)
{
WriteLine(logTxt, ModuleName, "WorkLog/");
}
}
}
/// <summary>
/// 写日志
/// </summary>
/// <param name="logTxt"></param>
/// <param name="ModuleName"></param>
/// <param name="pathName"></param>
private static void WriteLine(string logTxt, string ModuleName, string pathName)
{
try
{
string logPath = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + pathName
+ DateTime.Now.ToString("yyyyMMdd") + ".log";
ClearFile(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + pathName);
logTxt = string.Format(" {0}|{1}|{2}",
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"),
ModuleName,
logTxt);
sr = new StreamWriter(logPath, true, Encoding.Default);
sr.WriteLine(logTxt);
sr.Close();
}
catch { }
}
/// <summary>
/// 日志清除文件
/// </summary>
/// <param name="FilePath"></param>
private static void ClearFile(string FilePath)
{
if (!Directory.Exists(FilePath))
{
Directory.CreateDirectory(FilePath);
}
String[] Files = Directory.GetFiles(FilePath);
if (Files.Length > 30)
{
for (int i = 0; i < 1; i++)
{
try
{
File.Delete(Files[i]);
}
catch
{
}
}
}
}
}
}
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Management;
using System.Security.Cryptography;
using System.Text;
namespace JmpCommon
{
/// <summary>
/// 根据机器的硬件ID生成唯一标识
/// </summary>
public class MachineIdentity
{
/// <summary>
/// 机器的唯一硬件ID。
/// </summary>
public String UniqueId { get; set; }
/// <summary>
/// 获取此机器的硬件ID。
/// </summary>
/// <returns></returns>
public static string GetCurrentIdentity()
{
return GetSha1Hash(GetVolumeSerialId(GetPrimaryDriveLetter()) + GetCpuId(), Encoding.ASCII);
}
/// <summary>
/// 获取主驱动器号
/// </summary>
/// <returns></returns>
private static string GetPrimaryDriveLetter()
{
string drive = String.Empty;
//发现第一个磁盘驱动器
foreach (var compDrive in DriveInfo.GetDrives())
{
if (compDrive.IsReady && compDrive.DriveType == DriveType.Fixed)
{
drive = compDrive.RootDirectory.ToString();
break;
}
}
if (drive.EndsWith(":\\"))
{
//C:\ -> C
drive = drive.Substring(0, drive.Length - 2);
}
return drive;
}
/// <summary>
/// 获取卷序列号
/// </summary>
/// <param name="drive"></param>
/// <returns></returns>
private static string GetVolumeSerialId(string drive)
{
var disk = new ManagementObject(@"win32_logicaldisk.deviceid=""" + drive + @":""");
disk.Get();
string volumeSerial = disk["VolumeSerialNumber"].ToString();
disk.Dispose();
return volumeSerial;
}
/// <summary>
/// 获取CPU序列号
/// </summary>
/// <returns></returns>
private static string GetCpuId()
{
string cpuInfo = "";
var managClass = new ManagementClass("win32_processor");
var managCollec = managClass.GetInstances();
foreach (ManagementObject managObj in managCollec)
{
if (cpuInfo == "")
{
//只获取第一个CPU的ID
cpuInfo = managObj.Properties["processorID"].Value.ToString();
break;
}
}
return cpuInfo;
}
/// <summary>
/// 计算SHA1哈希
/// </summary>
/// <param name="text">字符串</param>
/// <param name="enc">编码格式</param>
/// <returns>哈希值</returns>
private static string GetSha1Hash(string text, Encoding enc)
{
var buffer = enc.GetBytes(text);
var cryptoTransformSHA1 =
new SHA1CryptoServiceProvider();
string hash = BitConverter.ToString(cryptoTransformSHA1.ComputeHash(buffer)).Replace("-", "");
return hash;
}
/// <summary>
/// 获取通道唯一编码
/// </summary>
/// <returns></returns>
public static string GetFileIdentity()
{
try
{
var appCfg = System.Environment.GetFolderPath(System.Environment.SpecialFolder.CommonApplicationData) + "\\Junmp";
if (!Directory.Exists(appCfg)) { Directory.CreateDirectory(appCfg); }
var cfgFile = appCfg + "\\tdunique.txt";
if (File.Exists(cfgFile))
{
return File.ReadAllText(cfgFile.Replace(" ", ""), Encoding.UTF8);
}
else
{
string unique = GetSha1Hash(Guid.NewGuid().ToString() + DateTime.Now.ToString("yyyyMMddHHmmssfff"), Encoding.ASCII);
File.WriteAllText(cfgFile, unique, Encoding.UTF8);
return unique;
}
}
catch
{
return string.Empty;
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace JmpCommon.Model
{
public class ChannelReadEquType
{
public string equipmentName { get; set; }
public string code { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace JmpCommon.Model
{
public class DoorCardInfo
{
/// <summary>
/// 0普通用户,1管理员
/// </summary>
public int UserType { get; set; }
public string CardNo { get; set; }
public string EmployeeNo { get; set; }
public string Name { get; set; }
public bool IsValid { get; set; }
public string Password { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace JmpCommon.Model
{
public class EquipmentInventory
{
public string Name { get; set; }
public string Count { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace JmpCommon.Model
{
public class FingerInfo
{
public int fingerNum { get; set; }
public string fingerInfo { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace JmpCommon.Model
{
public class GpiTrigger
{
public string StatusStr
{
get
{
return Gpi1Str + Gpi2Str;
}
}
public string Gpi1Str { get; set; }
public string Gpi2Str { get; set; }
public DateTime LastTime { get; set; }
public void SetEmpty()
{
Gpi1Str = string.Empty;
Gpi2Str = string.Empty;
}
}
}
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace JmpCommon
{
public class LocalConfig
{
public const string GetPolices = "/api/ChannelCfg/GetOrgStaff";
public const string UpdateFinger = "/api/ChannelCfg/UpdateFinger";
public const string ApplyUrl = "/api/Inventory/UploadRFIDNew";
public const string GetPoliceUrl = "/api/Common/GetPoliceByCardNo";
public const string GetCurrentCfg = "/api/ChannelCfg/GetCfgByNumV2";
public const string SoftUpdate = "/api/SoftUpdate/GetLastUpdate";
public const string GetServerime = "/api/ChannelCfg/GetServerTime";
public const string UploadFace = "/api/ChannelCfg/UploadFace";
public const string BatchUpdateCardNo = "/api/Policeman/BatchUpdateCardNo";
public const string GetInvListByEpc = "/api/Inventory/GetInvListByEpc";
public const string GetEpcListByBoxMarkEpc = "/api/EquipmentBoxMark/GetEpcListByBoxMarkEpc";
public const string GetEpcListByBagInvEpc = "/api/Mission/GetEpcListByBagInvEpc";
public const string GetOpenOrderInfo = "/api/Inventory/GetOpenOrderInfo";
public const string GetEquInfo = "/api/EquipmentDetail/GetListEquipmentDetail";
public const string GetListOrgWarehouse = "/api/Warehouse/GetListOrgWarehouse";
public const string GetListShelfAndInventory = "/api/Shelf/GetListShelfAndInventory";
public const string ApplyMonitorEpcList = "/api/ChannelCfg/ApplyMonitorEpcList";
public LocalConfig()
{
AppTitle = "通道服务v" + FileVersionInfo.GetVersionInfo(Process.GetCurrentProcess().MainModule.FileName).FileVersion;
AppVersion = FileVersionInfo.GetVersionInfo(Process.GetCurrentProcess().MainModule.FileName).FileVersion;
AppCode = "10001";
UploadPic = "http://41.190.20.132:5000/api/ChannelCfg/UploadPic";
DomainUrl = "http://41.190.20.132:18761/api/service";
UserID = "";
TestModel = false;
SpecialModel = false;
ApiVersion = "1.0";
SyncUserInfo = true;
SyncCfgInfo = false;
AppKey = "q6t0lEKOmMg5Tm+dg3XdZQ==";
SecretKey = "ba4d855b3b83eab441a51ea9bd9d9671";
IsEnabledShelf = false;
ShelfAddress = "http://192.168.3.128:38080/api/BoundDocuments";
IsAutoUpdate = true;
AutoUpdateTime = 0;
IsSyncFaces = true;
IsSyncFinger = true;
IsSyncCard = true;
ChooseWarehouseId = "";
MQTTAddress = "41.190.20.132";
MQTTPort = 17777;
MQTTUserName = "test";
MQTTPassword = "junmp123";
IsPushShelfPrint = false;
PushShelfPrintCom = "";
}
public string UploadPic { get; set; }
public string DomainUrl { get; set; }
public string UserID { get; set; }
public bool TestModel { get; set; }
public bool SpecialModel { get; set; }
[JsonIgnore]
public string AppTitle { get; set; }
[JsonIgnore]
public string AppCode { get; set; }
[JsonIgnore]
public string AppVersion { get; set; }
public string ApiVersion { get; set; }
public bool SyncUserInfo { get; set; }
public bool SyncCfgInfo { get; set; }
public string AppKey { get; set; }
public string SecretKey { get; set; }
public bool IsEnabledShelf { get; set; }
public string ShelfAddress { get; set; }
public bool IsAutoUpdate { get; set; }
public int AutoUpdateTime { get; set; }
public bool IsSyncFaces { get; set; }
public bool IsSyncFinger { get; set; }
public bool IsSyncCard { get; set; }
public bool IsChangeWarehouse { get; set; }
public string ChooseWarehouseId { get; set; }
public string MQTTAddress { get; set; }
public int MQTTPort { get; set; }
public string MQTTUserName { get; set; }
public string MQTTPassword { get; set; }
public bool IsPushShelfPrint { get; set; }
public string PushShelfPrintCom { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace JmpCommon
{
public class RemoteConfig
{
public string orgId { get; set; }
public string warehouseId { get; set; }
public int filterTime { get; set; } = 3;
public List<FaceConfig> faceConfig { get; set; }
public List<ReaderConfig> readerConfig { get; set; }
public string showText { get; set; } = "位置:未获取云端配置";
public string channelReadEquTypeJson { get; set; }
}
public class FaceConfig
{
/// <summary>
/// 人脸识别登录地址
/// </summary>
public string faceAddress { get; set; }
/// <summary>
/// 人脸识别登录端口
/// </summary>
public int facePort { get; set; }
/// <summary>
/// 人脸识别登录用户
/// </summary>
public string faceUser { get; set; }
/// <summary>
/// 读写器端口
/// </summary>
public string facePwd { get; set; }
/// <summary>
/// 启用禁用人脸识别
/// </summary>
public bool faceEnable { get; set; }
}
public class ReaderConfig
{
/// <summary>
/// 读写器类型
/// 英频杰:0
/// 索立得401:1
/// 索立得401X(新版):2
/// </summary>
public int type { get; set; }
/// <summary>
/// 读写器名(不能重复,涉及到配置文件命名)
/// </summary>
public string name { get; set; }
/// <summary>
/// 读写器地址
/// </summary>
public string address { get; set; }
/// <summary>
/// 读写器端口
/// </summary>
public int port { get; set; }
/// <summary>
/// 读写时间(毫秒)
/// </summary>
public int readerTime { get; set; }
/// <summary>
/// gpio地址
/// </summary>
public string gpioAddr { get; set; }
/// <summary>
/// gpio端口
/// </summary>
public int gpioPort { get; set; }
/// <summary>
/// 是否出入库分离
/// </summary>
public bool isCameraSeparate { get; set; }
/// <summary>
/// 是否抓拍(出库)
/// </summary>
public bool useSnapshot { get; set; }
/// <summary>
/// 视频厂商(出库)
/// 大华:0
/// 海康:1
/// </summary>
public int camType { get; set; }
/// <summary>
/// 视频地址(出库)
/// </summary>
public string camAddress { get; set; }
/// <summary>
/// 视频端口(出库)
/// </summary>
public int camPort { get; set; }
/// <summary>
/// 视频用户(出库)
/// </summary>
public string camUser { get; set; }
/// <summary>
/// 视频密码(出库)
/// </summary>
public string camPwd { get; set; }
/// <summary>
/// 视频通道(出库)
/// </summary>
public int camChannel { get; set; }
/// <summary>
/// 是否抓拍(入库)
/// </summary>
public bool useSnapshot2 { get; set; }
/// <summary>
/// 视频厂商(入库)
/// 大华:0
/// 海康:1
/// </summary>
public int camType2 { get; set; }
/// <summary>
/// 视频地址(入库)
/// </summary>
public string camAddress2 { get; set; }
/// <summary>
/// 视频端口(入库)
/// </summary>
public int camPort2 { get; set; }
/// <summary>
/// 视频用户(入库)
/// </summary>
public string camUser2 { get; set; }
/// <summary>
/// 视频密码(入库)
/// </summary>
public string camPwd2 { get; set; }
/// <summary>
/// 视频通道(入库)
/// </summary>
public int camChannel2 { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace JmpCommon.Model
{
public class equ_info
{
public string id { get; set; }
public string code { get; set; }
public string name { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace JmpCommon
{
public class request_head
{
public request_head()
{
RFIDList = new List<EpcInfo>();
BagRFIDList = new List<EpcInfo>();
}
public string orgId { get; set; }
public string warehouseId { get; set; }
public string policeId { get; set; }
public int currentState { get; set; }
public string picUrl { get; set; }
public List<EpcInfo> RFIDList { get; set; }
public List<EpcInfo> BagRFIDList { get; set; }
}
public class EpcInfo
{
public string RFID { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace JmpCommon.Model
{
public class request_sign
{
public string appKey { get; set; } = string.Empty;
public string orgId { get; set; } = string.Empty;
public string version { get; set; } = "1.0";
public string timestamp { get; set; }
public string body { get; set; }
public string sign { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace JmpCommon
{
public class respone_head<T>
{
public int code { get; set; }
public string msg { get; set; }
public T data { get; set; }
}
public class police_info
{
public string policeName { get; set; }
public string policeId { get; set; }
public string orgId { get; set; }
}
public class request_epc
{
public string epc { get; set; }
public string type { get; set; }
public string name { get; set; }
public string Size { get; set; }
public int currentState { get; set; }
public int safeLevel { get; set; }
public string shelfAddress { get; set; }
}
}
namespace JmpCommon.Model
{
public class respone_update
{
public int version { get; set; }
public string version2 { get; set; }
public string name { get; set; }
public string appCode { get; set; }
public string note { get; set; }
public string address { get; set; }
public string updateTime { get; set; }
public string fileMd5 { get; set; }
public bool isAutoUpdate { get; set; }
public string autoUpdateAddress { get; set; }
public string autoUpdateFileMd5 { get; set; }
public string autoUpdateVersion2 { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace JmpCommon.Model
{
public class response_BagInvModel
{
public response_BagInvModel()
{
epcList = new List<string>();
}
public string id { get; set; }
public string createTime { get; set; }
public string epc { get; set; }
public string warehouseId { get; set; }
public string warehouseName { get; set; }
public string orgizationId { get; set; }
public List<string> epcList { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace JmpCommon.Model
{
public class response_BoxMarkModel
{
public string id { get; set; }
public string createTime { get; set; }
public string epc { get; set; }
public int oneBoxNum { get; set; }
public string warehouseId { get; set; }
public string warehouseName { get; set; }
public string orgizationId { get; set; }
public string equipmentInfoId { get; set; }
public string equipmentDetailId { get; set; }
public string equipmentDetailName { get; set; }
public string equipmentDetailCode { get; set; }
public string sizeId { get; set; }
public string sizeName { get; set; }
public string sizeCode { get; set; }
public string sizeEpcType { get; set; }
public string supplierId { get; set; }
public string supplierCode { get; set; }
public string supplierName { get; set; }
public List<string> epcList { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace JmpCommon.Model
{
public class response_Shelf
{
public string Name { get; set; }
public string Url { get; set; }
public string Type { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace JmpCommon.Model
{
public class response_ShelfPrint
{
public string Name { get; set; }
public string Url { get; set; }
public string OrganizationName { get; set; }
public List<response_ShelfPrintInfo> InfoList { get; set; }
}
public class response_ShelfPrintInfo
{
public string Name { get; set; }
public List<response_ShelfPrintDetail> InventoryList { get; set; }
}
public class response_ShelfPrintDetail
{
public string Name { get; set; }
public int Count { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace JmpCommon.Model
{
public class response_TransformInfo
{
public int type { get; set; }
public string orgId { get; set; }
public DateTime? updateTime { get; set; }
public DateTime? expectedReturnTime { get; set; }
public string id { get; set; }
public string applyId { get; set; }
public string applyName { get; set; }
public string note { get; set; }
public DateTime? createTime { get; set; }
public string warehouseName { get; set; }
public string warehouseId { get; set; }
public string order { get; set; }
public string transferName { get; set; }
public string transferId { get; set; }
public string targetName { get; set; }
public string targetId { get; set; }
public List<response_TransformRealityDetail> realityDetailList { get; set; }
}
public class response_TransformRealityDetail
{
public string targetId { get; set; }
public string equipmentSizeId { get; set; }
public string equipmentSizeName { get; set; }
public string equipmentDetailId { get; set; }
public string equipmentDetailCode { get; set; }
public string warehouseId { get; set; }
public string warehouseName { get; set; }
public string equipmentDetailName { get; set; }
public int quantity { get; set; }
public int realCount { get; set; }
public int insideRealCount { get; set; }
public int state { get; set; }
public string supplierId { get; set; }
public string supplierName { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace JmpCommon.Model
{
public class sync_police
{
public string orgId { get; set; }
public string id { get; set; }
public string name { get; set; }
public string policeCode { get; set; }
public string photo { get; set; }
public string cardNo { get; set; }
public DateTime udateTime { get; set; }
public DateTime createTime { get; set; }
public List<FingerInfo> fingerList { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace JmpCommon.Model
{
public class warehouse_info
{
public string id { get; set; }
public string name { get; set; }
public string location { get; set; }
public string locationDetail { get; set; }
public string orgizationId { get; set; }
public bool? isEnableChannelReadEqu { get; set; }
public string channelReadEquTypeJson { get; set; }
}
}
using JmpCommon.Model;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace JmpCommon
{
public static class MyCache
{
public static List<warehouse_info> WarehouseList { get; set; }
public static List<sync_police> PoliceList { get; set; }
public static List<equ_info> EquInfos { get; set; }
public static LocalConfig SysConfig { get; set; }
public static RemoteConfig ChannelCfg { get; set; }
public static LocalConfig LoadSystemStep()
{
try
{
var path = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "config.json";
if (!File.Exists(path))
{
return default;
}
else
{
string json = File.ReadAllText(path, Encoding.Default);
var des_str = JmpDes.Decrypt(json);
if (string.IsNullOrEmpty(des_str))
{
return default;
}
else
{
var cfg = JsonConvert.DeserializeObject<LocalConfig>(des_str);
if (cfg == null)
{
return default;
}
else
{
//预处理替换
if (cfg.DomainUrl == "http://41.204.7.134:18761/api/service")
{
cfg.DomainUrl = "http://41.190.20.132:18761/api/service";
}
if (cfg.UploadPic == "http://41.204.7.134:5000/api/ChannelCfg/UploadPic")
{
cfg.UploadPic = "http://41.190.20.132:5000/api/ChannelCfg/UploadPic";
}
return cfg;
}
}
}
}
catch (Exception ex)
{
Log.ErrorLog(ex.ToString());
return default;
}
}
public static void SetSystemSetp()
{
if (SysConfig != null)
{
var json = JsonConvert.SerializeObject(SysConfig, Formatting.Indented);
if (string.IsNullOrEmpty(json)) { return; }
else
{
File.WriteAllText(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "config.json", JmpDes.Encrypt(json), Encoding.UTF8);
}
}
}
}
}
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("JmpCommon")]
[assembly: AssemblyDescription("钧普公共调用库")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Junmp")]
[assembly: AssemblyProduct("JmpCommon")]
[assembly: AssemblyCopyright("Copyright © Junmp 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("8662baf0-5206-4472-84af-2e44669c3e2c")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.21")]
[assembly: AssemblyFileVersion("1.0.0.21")]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Security.Principal;
using System.Text;
using System.Threading.Tasks;
namespace JmpCommon
{
/// <summary>
/// 解决vista和win7在windows服务中交互桌面权限问题:穿透Session 0 隔离
/// 用于windows服务 启动外部程序 或者截取图片等
/// 默认windows服务的权限是在session0中
/// </summary>
public class SessionUtility
{
#region 如果服务只是简单的向桌面用户Session 发送消息窗口,则可以使用WTSSendMessage 函数实现
public static IntPtr WTS_CURRENT_SERVER_HANDLE = IntPtr.Zero;
public static void ShowMessageBox(string message, string title)
{
int resp = 0;
WTSSendMessage(
WTS_CURRENT_SERVER_HANDLE,
WTSGetActiveConsoleSessionId(),
title, title.Length,
message, message.Length,
0, 0, out resp, false);
}
[DllImport("kernel32.dll", SetLastError = true)]
public static extern int WTSGetActiveConsoleSessionId();
[DllImport("wtsapi32.dll", SetLastError = true)]
public static extern bool WTSSendMessage(
IntPtr hServer,
int SessionId,
String pTitle,
int TitleLength,
String pMessage,
int MessageLength,
int Style,
int Timeout,
out int pResponse,
bool bWait);
//在ShowMessageBox 函数中调用了WTSSendMessage 来发送信息窗口,这样我们就可以在Service 的OnStart 函数中使用,打开Service1.cs 加入下面代码:
//protected override void OnStart(string[] args)
//{
// Interop.ShowMessageBox("This a message from AlertService.",
// "AlertService Message");
//}
#endregion
/*
* 如果想通过服务向桌面用户Session 创建一个复杂UI 程序界面,
* 则需要使用CreateProcessAsUser 函数为用户创建一个新进程用来运行相应的程序。
*/
#region 复杂进程
public static void CreateProcess(string app, string para, int sessionID)
{
if (!string.IsNullOrEmpty(para))
{
para = app + @"\" + para;
app = null;
}
bool result;
IntPtr hToken = WindowsIdentity.GetCurrent().Token;
IntPtr hDupedToken = IntPtr.Zero;
var pi = new PROCESS_INFORMATION();
var sa = new SECURITY_ATTRIBUTES();
sa.Length = Marshal.SizeOf(sa);
var si = new STARTUPINFO();
si.cb = Marshal.SizeOf(si);
int dwSessionID = sessionID;
if (sessionID < 0)
dwSessionID = WTSGetActiveConsoleSessionId();
result = WTSQueryUserToken(dwSessionID, out hToken);
if (!result)
{
ShowMessageBox("WTSQueryUserToken failed", "AlertService Message");
}
result = DuplicateTokenEx(
hToken,
GENERIC_ALL_ACCESS,
ref sa,
(int)SECURITY_IMPERSONATION_LEVEL.SecurityIdentification,
(int)TOKEN_TYPE.TokenPrimary,
ref hDupedToken
);
if (!result)
{
ShowMessageBox("DuplicateTokenEx failed", "AlertService Message");
}
IntPtr lpEnvironment = IntPtr.Zero;
result = CreateEnvironmentBlock(out lpEnvironment, hDupedToken, false);
if (!result)
{
ShowMessageBox("CreateEnvironmentBlock failed", "AlertService Message");
}
result = CreateProcessAsUser(
hDupedToken,
app,
para,
ref sa, ref sa,
false, 0, IntPtr.Zero,
null, ref si, ref pi);
if (!result)
{
int error = Marshal.GetLastWin32Error();
string message = String.Format("CreateProcessAsUser Error: {0}", error);
ShowMessageBox(message, "AlertService Message");
}
if (pi.hProcess != IntPtr.Zero)
CloseHandle(pi.hProcess);
if (pi.hThread != IntPtr.Zero)
CloseHandle(pi.hThread);
if (hDupedToken != IntPtr.Zero)
CloseHandle(hDupedToken);
}
[StructLayout(LayoutKind.Sequential)]
public struct STARTUPINFO
{
public Int32 cb;
public string lpReserved;
public string lpDesktop;
public string lpTitle;
public Int32 dwX;
public Int32 dwY;
public Int32 dwXSize;
public Int32 dwXCountChars;
public Int32 dwYCountChars;
public Int32 dwFillAttribute;
public Int32 dwFlags;
public Int16 wShowWindow;
public Int16 cbReserved2;
public IntPtr lpReserved2;
public IntPtr hStdInput;
public IntPtr hStdOutput;
public IntPtr hStdError;
}
[StructLayout(LayoutKind.Sequential)]
public struct PROCESS_INFORMATION
{
public IntPtr hProcess;
public IntPtr hThread;
public Int32 dwProcessID;
public Int32 dwThreadID;
}
[StructLayout(LayoutKind.Sequential)]
public struct SECURITY_ATTRIBUTES
{
public Int32 Length;
public IntPtr lpSecurityDescriptor;
public bool bInheritHandle;
}
public enum SECURITY_IMPERSONATION_LEVEL
{
SecurityAnonymous,
SecurityIdentification,
SecurityImpersonation,
SecurityDelegation
}
public enum TOKEN_TYPE
{
TokenPrimary = 1,
TokenImpersonation
}
public const int GENERIC_ALL_ACCESS = 0x10000000;
[DllImport("kernel32.dll", SetLastError = true,
CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
public static extern bool CloseHandle(IntPtr handle);
[DllImport("advapi32.dll", SetLastError = true,
CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern bool CreateProcessAsUser(
IntPtr hToken,
string lpApplicationName,
string lpCommandLine,
ref SECURITY_ATTRIBUTES lpProcessAttributes,
ref SECURITY_ATTRIBUTES lpThreadAttributes,
bool bInheritHandle,
Int32 dwCreationFlags,
IntPtr lpEnvrionment,
string lpCurrentDirectory,
ref STARTUPINFO lpStartupInfo,
ref PROCESS_INFORMATION lpProcessInformation);
[DllImport("advapi32.dll", SetLastError = true)]
public static extern bool DuplicateTokenEx(
IntPtr hExistingToken,
Int32 dwDesiredAccess,
ref SECURITY_ATTRIBUTES lpThreadAttributes,
Int32 ImpersonationLevel,
Int32 dwTokenType,
ref IntPtr phNewToken);
[DllImport("wtsapi32.dll", SetLastError = true)]
public static extern bool WTSQueryUserToken(
Int32 sessionId,
out IntPtr Token);
[DllImport("userenv.dll", SetLastError = true)]
private static extern bool CreateEnvironmentBlock(
out IntPtr lpEnvironment,
IntPtr hToken,
bool bInherit);
#endregion
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace JmpCommon
{
/// <summary>
/// WAV语音音频头
/// </summary>
public struct WAVE_Header
{
public int RIFF_ID;
public int File_Size;
public int RIFF_Type;
public int FMT_ID;
public int FMT_Size;
public short FMT_Tag;
public ushort FMT_Channel;
public int FMT_SamplesPerSec;
public int AvgBytesPerSec;
public ushort BlockAlign;
public ushort BitsPerSample;
public int DATA_ID;
public int DATA_Size;
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace JmpCommon
{
public class Win32API
{
[DllImport("Kernel32.dll")]
public static extern bool SetLocalTime(ref SYSTEMTIME Time);
[DllImport("Kernel32.dll")]
public static extern void GetLocalTime(ref SYSTEMTIME Time);
}
/// <summary>
///
/// </summary>
public struct SYSTEMTIME
{
public ushort wYear;
public ushort wMonth;
public ushort wDayOfWeek;
public ushort wDay;
public ushort wHour;
public ushort wMinute;
public ushort wSecond;
public ushort wMilliseconds;
/// <summary>
/// 从System.DateTime转换。
/// </summary>
/// <param name="time">System.DateTime类型的时间。</param>
public void FromDateTime(DateTime time)
{
wYear = (ushort)time.Year;
wMonth = (ushort)time.Month;
wDayOfWeek = (ushort)time.DayOfWeek;
wDay = (ushort)time.Day;
wHour = (ushort)time.Hour;
wMinute = (ushort)time.Minute;
wSecond = (ushort)time.Second;
wMilliseconds = (ushort)time.Millisecond;
}
/// <summary>
/// 转换为System.DateTime类型。
/// </summary>
/// <returns></returns>
public DateTime ToDateTime()
{
return new DateTime(wYear, wMonth, wDay, wHour, wMinute, wSecond, wMilliseconds);
}
/// <summary>
/// 静态方法。转换为System.DateTime类型。
/// </summary>
/// <param name="time">SYSTEMTIME类型的时间。</param>
/// <returns></returns>
public static DateTime ToDateTime(SYSTEMTIME time)
{
return time.ToDateTime();
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="LiteDB" version="5.0.8" targetFramework="net45" />
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net45" />
<package id="System.Management" version="4.7.0" targetFramework="net45" />
</packages>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>
\ No newline at end of file
<?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>{2D595EED-41D5-48DF-8121-600E08F2C273}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>JmpRestart</RootNamespace>
<AssemblyName>JmpRestart</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\Programe\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>..\Programe\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>restart.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<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="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="App.config" />
</ItemGroup>
<ItemGroup>
<Content Include="restart.ico" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
namespace JmpRestart
{
class Program
{
static void Main(string[] args)
{
if (args.Length == 0)
{
Console.WriteLine($"[{DateTime.Now.ToString("yyyy-MM-dd HH:mm")}] 参数为空...");
Console.ReadKey();
return;
}
else
{
var path = HttpUtility.UrlDecode(args[0], Encoding.UTF8);
if (!File.Exists(path))
{
Console.WriteLine($"[{DateTime.Now.ToString("yyyy-MM-dd HH:mm")}] 程序文件不存在...");
Console.ReadKey();
}
else
{
Console.WriteLine($"[{DateTime.Now.ToString("yyyy-MM-dd HH:mm")}] 重启软件中...");
var process = Process.GetProcessesByName("JmpServiceMgr");
if (process.Length > 0)
{
Console.WriteLine($"[{DateTime.Now.ToString("yyyy-MM-dd HH:mm")}] 关闭已有进程...");
foreach (var item in process)
{
item.Kill();
}
}
Console.WriteLine($"[{DateTime.Now.ToString("yyyy-MM-dd HH:mm")}] - 启动通道程序...");
Process.Start(path);
}
}
}
}
}
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("JmpReset")]
[assembly: AssemblyDescription("钧普通道服务启动器")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Junmp")]
[assembly: AssemblyProduct("JmpReset")]
[assembly: AssemblyCopyright("Copyright © Junmp 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("2d595eed-41d5-48df-8121-600e08f2c273")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.1")]
[assembly: AssemblyFileVersion("1.0.0.1")]

namespace JmpServiceMgr
{
partial class AutoClosingMessageBox
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AutoClosingMessageBox));
this.btnClose = new DevComponents.DotNetBar.ButtonX();
this.btnOk = new DevComponents.DotNetBar.ButtonX();
this.lb_msg = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// btnClose
//
this.btnClose.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
this.btnClose.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
this.btnClose.Font = new System.Drawing.Font("宋体", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnClose.Location = new System.Drawing.Point(202, 159);
this.btnClose.Name = "btnClose";
this.btnClose.Size = new System.Drawing.Size(96, 40);
this.btnClose.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
this.btnClose.TabIndex = 8;
this.btnClose.Text = "取消";
this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
//
// btnOk
//
this.btnOk.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
this.btnOk.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
this.btnOk.Font = new System.Drawing.Font("宋体", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.btnOk.Location = new System.Drawing.Point(74, 159);
this.btnOk.Name = "btnOk";
this.btnOk.Size = new System.Drawing.Size(96, 40);
this.btnOk.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
this.btnOk.TabIndex = 7;
this.btnOk.Text = "确定";
this.btnOk.Click += new System.EventHandler(this.btnOk_Click);
//
// lb_msg
//
this.lb_msg.BackColor = System.Drawing.Color.White;
this.lb_msg.Font = new System.Drawing.Font("宋体", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lb_msg.ForeColor = System.Drawing.Color.Black;
this.lb_msg.Location = new System.Drawing.Point(71, 58);
this.lb_msg.Name = "lb_msg";
this.lb_msg.Size = new System.Drawing.Size(242, 49);
this.lb_msg.TabIndex = 11;
this.lb_msg.Text = "msg";
this.lb_msg.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// AutoClosingMessageBox
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(384, 211);
this.Controls.Add(this.lb_msg);
this.Controls.Add(this.btnClose);
this.Controls.Add(this.btnOk);
this.DoubleBuffered = true;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "AutoClosingMessageBox";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Form1";
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.AutoClosingMessageBox_FormClosed);
this.ResumeLayout(false);
}
#endregion
private DevComponents.DotNetBar.ButtonX btnClose;
private DevComponents.DotNetBar.ButtonX btnOk;
private System.Windows.Forms.Label lb_msg;
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevComponents.DotNetBar.Metro;
namespace JmpServiceMgr
{
public partial class AutoClosingMessageBox : MetroForm
{
private int _count = 0;
private System.Threading.Timer _timer;
private Action _callBack;
public AutoClosingMessageBox(Form form, string content, string title, int count, Action callback)
{
InitializeComponent();
Owner = form;
this.Text = title;
lb_msg.Text = content;
_count = count;
_callBack = callback;
_timer = new System.Threading.Timer(TimerFunction, null, 0, 1000);
}
private void TimerFunction(object state)
{
if (this.IsHandleCreated)
this.Invoke(new Action(() => btnOk.Text = $"确定({_count})"));
if (_count < 0)
{
_timer.Dispose();
if (this.IsHandleCreated)
this.Invoke(new Action(() => this.btnOk_Click(null, null)));
}
_count--;
}
private void btnOk_Click(object sender, EventArgs e)
{
//执行
_timer.Dispose();
_callBack.BeginInvoke(null, null);
this.Close();
}
private void btnClose_Click(object sender, EventArgs e)
{
_timer.Dispose();
this.Close();
}
private void AutoClosingMessageBox_FormClosed(object sender, FormClosedEventArgs e)
{
btnClose_Click(null, null);
}
}
}
This source diff could not be displayed because it is too large. You can view the blob instead.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Impinj.OctaneSdk;
using JmpCommon;
using JmpCommon.Camera;
using JmpServiceMgr.Properties;
using JunmpDALib;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace JmpServiceMgr.Helper
{
/// <summary>
/// 摄像头操作
/// </summary>
public class CameraHelper
{
private readonly IRFIDReader _reader;
private readonly FrmMgr _form;
private readonly CancellationTokenSource _cTol;
public string _snap_fileName = string.Empty;
public string _snap_directoy = string.Empty;
public object _snap_lock_obj = new object();
private byte[] _snap_buffer = default;
public Action<string, string> onSnapPic;
public Action onUploadPic;
public bool IsWork;
public CameraHelper(IRFIDReader reader, FrmMgr form, CancellationTokenSource cTol)
{
_reader = reader;
_form = form;
_cTol = cTol;
}
public void Init()
{
//启用抓拍,则开启
if (_reader.RFIDReaderSettings.IsUseSnapshot)
{
switch (_reader.RFIDReaderSettings.CamType)
{
case 0:
_reader.SnapCmaOut = new DahuaCamera();
break;
case 1:
_reader.SnapCmaOut = new HikCamera();
break;
default: break;
}
if (_reader.SnapCmaOut != null)
{
_reader.SnapCmaOut.Initial(_reader.RFIDReaderSettings.CamAddress,
_reader.RFIDReaderSettings.CamPort,
_reader.RFIDReaderSettings.CamChannel,
_reader.RFIDReaderSettings.CamUser,
_reader.RFIDReaderSettings.CamPwd);
if (!_reader.SnapCmaOut.Login())
{
Log.WorkLog("出库视频服务器登录失败");
_form.SetLogs("出库视频登录失败");
XfVioceMsc.Text2Voice("出库视频登录失败");
}
}
else
{
Log.WorkLog("出库视频厂商类型不正确");
_form.SetLogs("出库视频厂商类型不正确");
XfVioceMsc.Text2Voice("出库视频厂商类型不正确");
}
}
if (_reader.RFIDReaderSettings.IsCameraSeparate)
{
//启用抓拍,则开启
if (_reader.RFIDReaderSettings.IsUseSnapshot2)
{
switch (_reader.RFIDReaderSettings.CamType2)
{
case 0:
_reader.SnapCmaIn = new DahuaCamera();
break;
case 1:
_reader.SnapCmaIn = new HikCamera();
break;
default: break;
}
if (_reader.SnapCmaIn != null)
{
_reader.SnapCmaIn.Initial(_reader.RFIDReaderSettings.CamAddress2,
_reader.RFIDReaderSettings.CamPort2,
_reader.RFIDReaderSettings.CamChannel2,
_reader.RFIDReaderSettings.CamUser2,
_reader.RFIDReaderSettings.CamPwd2);
if (!_reader.SnapCmaIn.Login())
{
Log.WorkLog("出库视频服务器登录失败");
_form.SetLogs("出库视频登录失败");
XfVioceMsc.Text2Voice("出库视频登录失败");
}
}
else
{
Log.WorkLog("出库视频厂商类型不正确");
_form.SetLogs("出库视频厂商类型不正确");
XfVioceMsc.Text2Voice("出库视频厂商类型不正确");
}
}
}
else
{
_reader.SnapCmaIn = _reader.SnapCmaOut;
}
//绑定抓拍事件
onSnapPic = SnapPic;
onUploadPic = UploadPic;
}
/// <summary>
/// 抓拍并上传文件
/// </summary>
/// <param name="snap_fileName"></param>
/// <param name="snap_directoy"></param>
public void SnapPic(string snap_fileName, string snap_directoy)
{
var state = "";
if (_reader.GpiTrigger.Gpi1Str == "1")
{
//入库先触发
state = "in";
}
else if (_reader.GpiTrigger.Gpi2Str == "1")
{
//出库先触发
state = "out";
}
if (state == "")
{
SnapClear();
Log.WorkLog("抓拍失败,无效光电触发");
return;
}
lock (_snap_lock_obj)
{
_snap_fileName = snap_fileName;
_snap_directoy = snap_directoy;
if ((!_reader.RFIDReaderSettings.IsUseSnapshot) && state == "out")
{
SnapClear();
return;
}
if ((_reader.RFIDReaderSettings.IsCameraSeparate && !_reader.RFIDReaderSettings.IsUseSnapshot2) && state == "in")
{
SnapClear();
return;
}
if (_reader.SnapCmaOut == null || _reader.SnapCmaIn == null)
{
SnapClear();
Log.WorkLog("抓拍失败,摄像头未初始化");
return;
}
else
{
Log.WorkLog("开始抓拍");
IsWork = true;
if (state == "in")
{
_snap_buffer = _reader.SnapCmaIn.CaptureBuffer();
}
else
{
_snap_buffer = _reader.SnapCmaOut.CaptureBuffer();
}
if (_snap_buffer is { Length: > 0 })
{
Log.WorkLog("抓拍成功,暂存");
}
else
{
SnapClear();
Log.WorkLog("抓拍失败,请检查");
}
IsWork = false;
}
}
}
public void UploadPic()
{
if (_snap_buffer == null || _snap_buffer.Length == 0)
{
}
else
{
if (string.IsNullOrEmpty(_snap_fileName) || string.IsNullOrEmpty(_snap_directoy))
{
}
else
{
var buffer = _snap_buffer.ToArray();
var fileName = _snap_fileName;
var directoy = _snap_directoy;
//上传图片 尝试3次
Task.Run(() =>
{
for (int i = 0; i < 3; i++)
{
if (HttpHelper.UploadPic(buffer, fileName, directoy))
{
break;
}
}
});
}
}
SnapClear();
}
public void SnapClear()
{
_snap_fileName = string.Empty;
_snap_directoy = string.Empty;
_snap_buffer = default;
}
public void Dispose()
{
SnapClear();
_reader?.SnapCmaOut?.Cleanup();
_reader?.SnapCmaIn?.Cleanup();
}
}
}
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Impinj.OctaneSdk;
using JmpCommon;
using JmpServiceMgr.Properties;
using JunmpDALib;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace JmpServiceMgr.Helper
{
/// <summary>
/// GPIO操作
/// </summary>
public class DalHelper
{
private readonly IRFIDReader _reader;
private readonly CameraHelper _camHelper;
private readonly FrmMgr _form;
private readonly CancellationTokenSource _cTol;
public DalHelper(IRFIDReader reader, CameraHelper camHelper, FrmMgr form, CancellationTokenSource cTol)
{
_reader = reader;
_camHelper = camHelper;
_form = form;
_cTol = cTol;
}
private AutoResetEvent ctolEvent = new AutoResetEvent(false);
private bool _ctolStatus = false;
public void InitialGpio()
{
try
{
if (MyCache.ChannelCfg == null || string.IsNullOrEmpty(_reader.RFIDReaderSettings.GpioAddr) || _reader.RFIDReaderSettings.GpioPort <= 0)
{
if (MyCache.ChannelCfg?.orgId== "E05CC28D-C189-4389-8081-DD0D6E483B40")
{
//宁波市局无gpio,通过读写器控制抓拍
_reader.GpiChanged += _reader_GpiChanged;
}
else
{
_form.SetLogs(_reader.RFIDReaderSettings.Name + "GPIO配置不正确");
}
return;
}
else
{
_reader.Dal = new DAL(_reader.RFIDReaderSettings.GpioAddr, _reader.RFIDReaderSettings.GpioPort);
if (_reader.Dal.IsOpen())
{
_form.SetLogs(_reader.RFIDReaderSettings.Name + "GPIO连接成功");
}
else
{
if (_reader.Dal.Open())
{
_form.SetLogs(_reader.RFIDReaderSettings.Name + "GPIO连接成功");
_reader.Dal.OnLinkLost += OnGpioLinkLost;
_reader.Dal.OnGPIChanged += OnGPIChanged;
_reader.Dal.GpioInit();
_ctolStatus = true;
}
else
{
_form.SetLogs(_reader.RFIDReaderSettings.Name + "GPIO连接失败");
XfVioceMsc.Text2Voice("GPIO连接失败");
}
new Task(() => PollingCtol(_cTol.Token)).Start();
}
}
}
catch (Exception ex)
{
Log.ErrorLog(ex.ToString());
_form.SetLogs(_reader.RFIDReaderSettings.Name + "GPIO连接异常");
XfVioceMsc.Text2Voice("GPIO连接异常");
}
}
private void _reader_GpiChanged(IRFIDReader reader, object e)
{
if (e is GpiEvent gpiEvent)
{
if (gpiEvent.State&&!_camHelper.IsWork)
{
//抓拍
var snap_fileName = DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".jpg";
var snap_directoy = DateTime.Now.ToString("yyyyMMdd");
//异步抓拍开始
_camHelper.onSnapPic?.BeginInvoke(snap_fileName, snap_directoy, default, default);
}
}
}
private void PollingCtol(CancellationToken token)
{
while (!token.IsCancellationRequested)
{
try
{
if (!_reader.Dal.IsOpen())
{
if (_reader.Dal.Open())
{
_reader.Dal.GpioInit();
_ctolStatus = true;
}
else
{
Log.WorkLog("GPIO重连失败");
}
}
if (ctolEvent.WaitOne(5000)) { continue; }
}
catch (Exception e)
{
Log.ErrorLog("GPIO重连异常" + e.ToString());
}
}
}
/// <summary>
/// 状态监控
/// </summary>
private void OnGpioLinkLost()
{
//重置状态
_ctolStatus = false;
//立即重连
ctolEvent.Set();
}
/// <summary>
/// GPIO事件
/// </summary>
/// <param name="args"></param>
private void OnGPIChanged(GPIArgs args)
{
try
{
//出入判断
if (args.Value && (string.IsNullOrEmpty(_reader.GpiTrigger.Gpi1Str) || string.IsNullOrEmpty(_reader.GpiTrigger.Gpi2Str)))
{
_reader.GpiTrigger.LastTime = DateTime.Now;
switch (args.Location)
{
case 0:
//光电2已触发
if (!string.IsNullOrEmpty(_reader.GpiTrigger.Gpi2Str))
{
_reader.GpiTrigger.Gpi1Str = "2";
}
else
{
_reader.GpiTrigger.Gpi1Str = "1";
}
break;
case 1:
//光电1已触发
if (!string.IsNullOrEmpty(_reader.GpiTrigger.Gpi1Str))
{
_reader.GpiTrigger.Gpi2Str = "2";
}
else
{
_reader.GpiTrigger.Gpi2Str = "1";
}
break;
default: break;
}
}
//读写器触发读取
switch (args.Location)
{
case 0:
case 1:
if (args.Value && !_reader.IsInventory)
{
if (_reader?.IsConnected ?? false)
{
//开始盘点并开始抓拍
var snap_fileName = DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".jpg";
var snap_directoy = DateTime.Now.ToString("yyyyMMdd");
//异步抓拍开始
_camHelper.onSnapPic?.BeginInvoke(snap_fileName, snap_directoy, default, default);
_reader.IsInventory = true;
_form.SetLogs("光电触发,开始盘点");
//延迟超过5秒爆炸,切换成线程跑
Task.Run(() => _reader.InventoryStart());
}
else
{
_form.SetLogs("读写器未连接,开启盘点失败");
}
}
else
{
//_form.SetLogs("读写器盘点中,无需开启盘点");
}
break;
default:
break;
}
}
catch (Exception ex)
{
Log.ErrorLog(ex.ToString());
}
}
}
}
using JmpCommon;
using MQTTnet;
using MQTTnet.Client;
using MQTTnet.Client.Connecting;
using MQTTnet.Client.Disconnecting;
using MQTTnet.Client.Options;
using MQTTnet.Client.Receiving;
using MQTTnet.Protocol;
using System;
using System.Text;
using System.Threading;
using Newtonsoft.Json.Linq;
namespace JmpServiceMgr.Helper
{
/// <summary>
/// MQTT操作
/// </summary>
public class MQTTHelper
{
private readonly FrmMgr _form;
private readonly CancellationTokenSource _cTol;
private bool ReconnectFlag = false;
public MQTTHelper(FrmMgr form, CancellationTokenSource cTol)
{
_form = form;
_cTol = cTol;
}
public MqttClient MqttClient;
public async void InitialMQTT()
{
try
{
var mqttFactory = new MqttFactory();
var options = new MqttClientOptions
{
ClientId = _form._unique,
ProtocolVersion = MQTTnet.Formatter.MqttProtocolVersion.V311,
ChannelOptions = new MqttClientTcpOptions
{
Server = MyCache.SysConfig.MQTTAddress,
Port = MyCache.SysConfig.MQTTPort
},
WillDelayInterval = 10,
WillMessage = new MqttApplicationMessage()
{
Topic = "Lost",
Payload = Encoding.UTF8.GetBytes("通道程序连接丢失"),
QualityOfServiceLevel = MqttQualityOfServiceLevel.ExactlyOnce
},
Credentials = new MqttClientCredentials
{
Username = MyCache.SysConfig.MQTTUserName,
Password = Encoding.UTF8.GetBytes(MyCache.SysConfig.MQTTPassword)
},
CleanSession = true,
KeepAlivePeriod = TimeSpan.FromSeconds(5),
};
MqttClient = mqttFactory.CreateMqttClient() as MqttClient;
MqttClient.ConnectedHandler = new MqttClientConnectedHandlerDelegate(OnMqttClientConnected);
MqttClient.DisconnectedHandler = new MqttClientDisconnectedHandlerDelegate(OnMqttClientDisConnected);
MqttClient.ApplicationMessageReceivedHandler = new MqttApplicationMessageReceivedHandlerDelegate(OnSubscriberMessageReceived);
var res = await MqttClient.ConnectAsync(options, _cTol.Token);
if (res.ResultCode == MqttClientConnectResultCode.Success)
{
//订阅通道code
await MqttClient.SubscribeAsync(_form._unique);
Console.WriteLine("MQTT启动成功");
Log.WorkLog("MQTT启动成功");
}
else
{
Log.ErrorLog("MQTT启动失败");
}
}
catch (Exception ex)
{
//MqttClient?.Dispose();
Log.ErrorLog("MQTT启动失败:" + ex.ToString());
}
}
public async void PushData(string topic, string message)
{
if (MqttClient.IsConnected)
{
await MqttClient.PublishAsync(new MqttApplicationMessage()
{
Topic = topic,
Payload = Encoding.UTF8.GetBytes(message),
QualityOfServiceLevel = MqttQualityOfServiceLevel.ExactlyOnce,
Retain = false
});
}
}
private void OnSubscriberMessageReceived(MqttApplicationMessageReceivedEventArgs obj)
{
//接收消息处理
var message = Encoding.UTF8.GetString(obj.ApplicationMessage.Payload);
if (message.Length > 2 && message.Substring(0, 2) == "/C") //控制消息
{
var data = message.Split('|');
if (data.Length == 3)
{
switch (data[1])
{
case "RemoteOpen":
{
var jObj = JObject.Parse(data[2]);
var userId = jObj["userId"]?.Value<string>();
var name = jObj["name"]?.Value<string>();
var token = jObj["token"]?.Value<string>();
if (_form.HikFaceHelperList[0].RemoteOpenDoor(userId, name))
{
//发送成功消息
PushData(_form._unique, $"/C|Response|{{\"token\":\"{token}\",\"code\":\"10000\",\"msg\":\"OK\"}}");
}
else
{
PushData(_form._unique, $"/C|Response|{{\"token\":\"{token}\",\"code\":\"19999\",\"msg\":\"开门失败\"}}");
}
break;
}
case "RemoteOpenShelfLight":
{
var jObj = JObject.Parse(data[2]);
var shelfUrl = jObj["shelfUrl"]?.Value<string>();
var token = jObj["token"]?.Value<string>();
_form.SerialPortHelper.PushData(shelfUrl, "30", "", false);
//发送成功消息
PushData(_form._unique, $"/C|Response|{{\"token\":\"{token}\",\"code\":\"10000\",\"msg\":\"OK\"}}");
break;
}
default:
{
//未知类型
break;
}
}
}
}
}
private async void OnMqttClientDisConnected(MqttClientDisconnectedEventArgs obj)
{
//重连
if (ReconnectFlag)
{
return;
}
while (!MqttClient.IsConnected)
{
ReconnectFlag = true;
Thread.Sleep(10000);
try
{
var res = await MqttClient.ReconnectAsync(_cTol.Token);
if (res.ResultCode == MqttClientConnectResultCode.Success)
{
//订阅通道code
await MqttClient.SubscribeAsync(_form._unique);
ReconnectFlag = false;
}
}
catch (Exception e)
{
Log.ErrorLog("MQTT重连失败:" + e.ToString());
}
}
}
private void OnMqttClientConnected(MqttClientConnectedEventArgs obj)
{
Log.WorkLog("MQTT启动成功");
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
namespace JmpServiceMgr.Helper
{
public class RFIDReaderSettings
{
public RFIDReaderSettings()
{
Antennas = new AntennasSettingGroups();
}
/// <summary>
/// 天线设置
/// </summary>
public AntennasSettingGroups Antennas { get; set; }
/// <summary>
/// 读写器类型
/// 英频杰:0
/// 索立得:1
/// </summary>
public int Type { get; set; }
/// <summary>
/// 读写器名(不能重复,涉及到配置文件命名)
/// </summary>
public string Name { get; set; }
/// <summary>
/// 读写器地址
/// </summary>
public string Address { get; set; }
/// <summary>
/// 读写器端口
/// </summary>
public int Port { get; set; }
/// <summary>
/// 读写时间(毫秒)
/// </summary>
public int ReaderTime { get; set; }
/// <summary>
/// gpio地址
/// </summary>
public string GpioAddr { get; set; }
/// <summary>
/// gpio端口
/// </summary>
public int GpioPort { get; set; }
/// <summary>
/// 是否出入库分离
/// </summary>
public bool IsCameraSeparate { get; set; }
/// <summary>
/// 是否抓拍(出库)
/// </summary>
public bool IsUseSnapshot { get; set; }
/// <summary>
/// 视频厂商(出库)
/// 大华:0
/// 海康:1
/// </summary>
public int CamType { get; set; }
/// <summary>
/// 视频地址(出库)
/// </summary>
public string CamAddress { get; set; }
/// <summary>
/// 视频端口(出库)
/// </summary>
public int CamPort { get; set; }
/// <summary>
/// 视频用户(出库)
/// </summary>
public string CamUser { get; set; }
/// <summary>
/// 视频密码(出库)
/// </summary>
public string CamPwd { get; set; }
/// <summary>
/// 视频通道(出库)
/// </summary>
public int CamChannel { get; set; }
/// <summary>
/// 是否抓拍(入库)
/// </summary>
public bool IsUseSnapshot2 { get; set; }
/// <summary>
/// 视频厂商(入库)
/// 大华:0
/// 海康:1
/// </summary>
public int CamType2 { get; set; }
/// <summary>
/// 视频地址(入库)
/// </summary>
public string CamAddress2 { get; set; }
/// <summary>
/// 视频端口(入库)
/// </summary>
public int CamPort2 { get; set; }
/// <summary>
/// 视频用户(入库)
/// </summary>
public string CamUser2 { get; set; }
/// <summary>
/// 视频密码(入库)
/// </summary>
public string CamPwd2 { get; set; }
/// <summary>
/// 视频通道(入库)
/// </summary>
public int CamChannel2 { get; set; }
}
public class AntennasSettingGroups
{
public AntennasSettingGroups(int antennaCount = 4)
{
AntennaConfigs = new AntennaConfig[antennaCount];
}
/// <summary>
/// 天线总数
/// </summary>
public int Length => AntennaConfigs.Length;
/// <summary>
/// 天线设置
/// </summary>
public AntennaConfig[] AntennaConfigs { get; set; }
}
public class AntennaConfig
{
/// <summary>
/// 是否开启
/// </summary>
public bool IsEnabled { get; set; }
/// <summary>
/// 天线功率
/// </summary>
public double TxPower { get; set; }
/// <summary>
/// 是否使用最大天线功率
/// </summary>
public bool IsUseMaxTxPower { get; set; }
/// <summary>
/// 接收灵敏度
/// </summary>
public double RxSensitivity { get; set; }
/// <summary>
/// 是否使用最大接收灵敏度
/// </summary>
public bool IsUseMaxRxSensitivity { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
namespace JmpServiceMgr.Helper
{
public class ShelfMessageStatus
{
public ShelfMessageStatus()
{
}
public bool IsSuccess { get; set; }
public string Message { get; set; }
public string Address { get; set; }
public bool IsNeedPushInventory { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
namespace JmpServiceMgr.Helper
{
public class TagReportData
{
public TagReportData()
{
Tags = new List<TagData>();
}
public List<TagData> Tags { get; set; }
}
public class TagData
{
public string Epc { get; set; }
/// <summary>
/// The reader antenna port number for the antenna that last saw the tag;
/// requires this option to be enabled in the reader settings report configuration.
/// </summary>
public int AntennaPortNumber { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using JmpCommon;
using JmpCommon.Camera;
using JmpCommon.Model;
using JunmpDALib;
using Newtonsoft.Json.Linq;
namespace JmpServiceMgr.Helper
{
public interface IRFIDReader
{
delegate void ConnectionLostHandler(IRFIDReader reader);
delegate void TagsReportedHandler(IRFIDReader reader, TagReportData report);
delegate void ReaderStartedEventHandler(IRFIDReader reader, object e);
delegate void ReaderStoppedEventHandler(IRFIDReader reader, object e);
delegate void GpiChangedHandler(IRFIDReader reader, object e);
abstract event ConnectionLostHandler ConnectionLost;
abstract event TagsReportedHandler TagsReported;
abstract event ReaderStartedEventHandler ReaderStarted;
abstract event ReaderStoppedEventHandler ReaderStopped;
abstract event GpiChangedHandler GpiChanged;
/// <summary>
/// GPIO
/// </summary>
DAL Dal { get; set; }
BaseCamera SnapCmaIn { get; set; }
BaseCamera SnapCmaOut { get; set; }
bool IsConnected { get; }
bool IsLost { get; set; }
bool IsInventory { get; set; }
RFIDReaderSettings RFIDReaderSettings { get; set; }
object syncEpc { get; }
List<string> EpcList { get; set; }
List<string> CacheList { get; set; }
GpiTrigger GpiTrigger { get; }
RFIDReaderSettings LoadSettings(ReaderConfig readerConfig);
bool ApplySettings(RFIDReaderSettings settings);
void Connect(string address);
void Disconnect();
void InventoryStart();
void InventoryStop();
}
}
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using JmpCommon;
using JmpCommon.Camera;
using JmpCommon.Model;
using JunmpDALib;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using SReaderAPI;
namespace JmpServiceMgr.Helper
{
public class Solid401RFIDReader : IRFIDReader
{
public event IRFIDReader.ConnectionLostHandler ConnectionLost;
public event IRFIDReader.TagsReportedHandler TagsReported;
public event IRFIDReader.ReaderStartedEventHandler ReaderStarted;
public event IRFIDReader.ReaderStoppedEventHandler ReaderStopped;
public event IRFIDReader.GpiChangedHandler GpiChanged;
private SReader _reader;
public Solid401RFIDReader()
{
syncEpc = new object();
GpiTrigger = new GpiTrigger();
EpcList = new List<string>();
CacheList = new List<string>();
}
~Solid401RFIDReader()
{
_reader?.Dispose();
}
public DAL Dal { get; set; }
public BaseCamera SnapCmaIn { get; set; }
public BaseCamera SnapCmaOut { get; set; }
public bool IsInventory { get; set; }
public RFIDReaderSettings RFIDReaderSettings { get; set; }
public object syncEpc { get; }
public List<string> EpcList { get; set; }
public List<string> CacheList { get; set; }
public bool IsConnected => _isConnected;
public bool IsLost { get; set; } = false;
private bool _isConnected = false;
private void Reader_GpiChanged(SReader reader, object e)
{
GpiChanged?.Invoke(this, e);
}
//private void Reader_ReaderStopped(Reader reader, object e)
//{
// ReaderStopped?.Invoke(this, e);
//}
//private void Reader_ReaderStarted(Reader reader, object e)
//{
// ReaderStarted?.Invoke(this, e);
//}
private void Reader_TagsReported(object sender, TagReadDataEventArgs report)
{
var tagReportData = new TagReportData();
tagReportData.Tags.Add(new TagData
{
Epc = report.TagData.EpcString,
AntennaPortNumber = report.TagData.Ant
});
TagsReported?.Invoke(this, tagReportData);
}
private void Reader_ConnectionLost(SReader reader)
{
ConnectionLost?.Invoke(this);
}
public GpiTrigger GpiTrigger { get; }
public RFIDReaderSettings LoadSettings(ReaderConfig readerConfig)
{
if (RFIDReaderSettings != null)
{
return RFIDReaderSettings;
}
if (IsConnected)
{
}
else
{
//无法获取配置信息
return null;
}
//401无配置文件
//if (File.Exists(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + readerConfig.name + "_Solid_settings.xml"))
//{
// _reader.LoadConfig(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + readerConfig.name + "_Solid_settings.xml");
//}
var antennaCount = _reader?.GetPortReadPower()?.Length ?? 4;
RFIDReaderSettings = new RFIDReaderSettings
{
Name = readerConfig.name,
Address = readerConfig.address,
Port = readerConfig.port,
ReaderTime = readerConfig.readerTime,
Type = readerConfig.type,
Antennas = new AntennasSettingGroups(antennaCount),
GpioAddr = readerConfig.gpioAddr,
GpioPort = readerConfig.gpioPort,
IsCameraSeparate = readerConfig.isCameraSeparate,
IsUseSnapshot = readerConfig.useSnapshot,
CamType = readerConfig.camType,
CamAddress = readerConfig.camAddress,
CamChannel = readerConfig.camChannel,
CamPort = readerConfig.camPort,
CamPwd = readerConfig.camPwd,
CamUser = readerConfig.camUser,
IsUseSnapshot2 = readerConfig.useSnapshot2,
CamType2 = readerConfig.camType2,
CamAddress2 = readerConfig.camAddress2,
CamChannel2 = readerConfig.camChannel2,
CamPort2 = readerConfig.camPort2,
CamPwd2 = readerConfig.camPwd2,
CamUser2 = readerConfig.camUser2,
};
var antennaPowerList = _reader?.GetPortReadPower();
var config = _reader?.GetReaderInfo();
for (var i = 0; i < antennaCount; i++)
{
RFIDReaderSettings.Antennas.AntennaConfigs[i] = new AntennaConfig
{
IsEnabled = (config?.Ant & Convert.ToInt32(Math.Pow(2, i))) != 0,
IsUseMaxRxSensitivity = false,
IsUseMaxTxPower = false,
RxSensitivity = 0, //索立得无灵敏度设置
TxPower = antennaPowerList?.Length > i ? antennaPowerList[i] : 0
};
}
return RFIDReaderSettings;
}
public bool ApplySettings(RFIDReaderSettings settings)
{
RFIDReaderSettings = settings;
var openAntennaList = new List<int>();
var powerList = new List<int>();
var antennaCount = _reader.GetPortReadPower()?.Length ?? 4;
//更新
for (var i = 0; i < RFIDReaderSettings.Antennas.AntennaConfigs.Length; i++)
{
if (antennaCount < i + 1)
{
break;
}
var config = RFIDReaderSettings.Antennas.AntennaConfigs[i];
if (config.IsEnabled)
{
openAntennaList.Add(i + 1);
}
powerList.Add(Convert.ToInt32(config.TxPower));
}
//天线自动识别,不进行强制设置
_reader.SetCheckAnt(1);
//_reader.SetAntenna(openAntennaList.ToArray());
_reader.SetPortReadPower(powerList.ToArray());
//频段 美国频段
_reader.SetRegion(SReader.Region.US);
//_reader.SetRegion(SReader.Region.Chinese2);
Thread.Sleep(500);
//401无配置文件
//_reader.SaveConfig(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase +
// RFIDReaderSettings.Name + "_Solid_settings.xml");
return true;
}
public void Connect(string address)
{
try
{
if (_reader != null)
{
_reader.ShutDown();
_reader = null;
}
_reader = SReader.Create("tcp://" + address.Remove(address.IndexOf(':')));
_reader.TagRead += Reader_TagsReported;
_reader.Connect();
if (!string.IsNullOrEmpty(_reader.getVersion()))
{
_isConnected = true;
}
}
catch (Exception e)
{
Log.ErrorLog(e.Message + "|" + e.StackTrace);
_isConnected = false;
}
}
public void Disconnect()
{
_reader.TagRead -= Reader_TagsReported;
IsInventory = false;
_reader.ShutDown();
_isConnected = false;
}
public void InventoryStart()
{
try
{
int q = 4;
int session = 1;
int scantime = RFIDReaderSettings.ReaderTime / 100;
System.Diagnostics.Debug.WriteLine("_reader.StartReading()");
ReaderStarted?.Invoke(this, null);
Task.Run(() =>
{
//盘点停止
Thread.Sleep(RFIDReaderSettings.ReaderTime);
InventoryStop();
});
var t = 0;
while (IsInventory)
{
for (var i = 0; i < RFIDReaderSettings.Antennas.AntennaConfigs.Length; i++)
{
var config = RFIDReaderSettings.Antennas.AntennaConfigs[i];
if (config.IsEnabled)
{
_reader.Inventry(new Gen2.InventryValue(true, 0, i + 1, 10, q, session), null);
}
}
t++;
if (t > 100)
{
//防止卡死保险措施
break;
}
}
}
catch (Exception e)
{
IsInventory = false;
Log.ErrorLog(e.Message + "|" + e.StackTrace);
}
}
public void InventoryStop()
{
try
{
_reader.Inventry_stop();
}
catch (Exception e)
{
IsInventory = false;
Log.ErrorLog(e.Message + "|" + e.StackTrace);
}
finally
{
ReaderStopped?.Invoke(this, null);
}
}
}
}
<?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>{442DABC1-9869-4B57-BFCC-287106799248}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>JmpServiceMgr</RootNamespace>
<AssemblyName>JmpServiceMgr</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\Programe\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\Programe\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>door.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup>
<TargetZone>LocalIntranet</TargetZone>
</PropertyGroup>
<PropertyGroup>
<GenerateManifests>false</GenerateManifests>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>Properties\app.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<Reference Include="DevComponents.DotNetBar2, Version=12.1.0.0, Culture=neutral, PublicKeyToken=c39c3242a43eee2b, processorArchitecture=MSIL" />
<Reference Include="Impinj.OctaneSdk, Version=3.4.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\OctaneSDK.3.4.0\lib\net461\Impinj.OctaneSdk.dll</HintPath>
</Reference>
<Reference Include="JunmpDALib">
<HintPath>..\Lib\JunmpDALib.dll</HintPath>
</Reference>
<Reference Include="LLRP, Version=10.40.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\libltknet-sdk.10.40.0\lib\net461\LLRP.dll</HintPath>
</Reference>
<Reference Include="LLRP.Impinj, Version=10.40.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\libltknet-sdk.10.40.0\lib\net461\LLRP.Impinj.dll</HintPath>
</Reference>
<Reference Include="MercuryAPI">
<HintPath>..\Lib\MercuryAPI.dll</HintPath>
</Reference>
<Reference Include="MQTTnet, Version=3.1.2.0, Culture=neutral, PublicKeyToken=b69712f52770c0a7, processorArchitecture=MSIL">
<HintPath>..\packages\MQTTnet.3.1.2\lib\net461\MQTTnet.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="Renci.SshNet, Version=2016.1.0.0, Culture=neutral, PublicKeyToken=1cee9f8bde3db106, processorArchitecture=MSIL">
<HintPath>..\packages\SSH.NET.2016.1.0\lib\net40\Renci.SshNet.dll</HintPath>
</Reference>
<Reference Include="SReaderAPI">
<HintPath>..\Lib\SReaderAPI.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Management" />
<Reference Include="System.ServiceProcess" />
<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.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AutoClosingMessageBox.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="AutoClosingMessageBox.Designer.cs">
<DependentUpon>AutoClosingMessageBox.cs</DependentUpon>
</Compile>
<Compile Include="FrmConfig.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FrmConfig.Designer.cs">
<DependentUpon>FrmConfig.cs</DependentUpon>
</Compile>
<Compile Include="FrmMgr.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FrmMgr.Designer.cs">
<DependentUpon>FrmMgr.cs</DependentUpon>
</Compile>
<Compile Include="Helper\HikFaceHelper.cs" />
<Compile Include="Helper\CameraHelper.cs" />
<Compile Include="Helper\Model\ShelfMessageStatus.cs" />
<Compile Include="Helper\Model\TagReport.cs" />
<Compile Include="Helper\SerialPortHelper.cs" />
<Compile Include="Helper\Reader\Solid401RFIDReader.cs" />
<Compile Include="Helper\MQTTHelper.cs" />
<Compile Include="Helper\RFIDReaderHelper.cs" />
<Compile Include="Helper\DalHelper.cs" />
<Compile Include="Helper\Reader\Solid401XRFIDReader.cs" />
<Compile Include="Helper\Reader\ImpinjRFIDReader.cs" />
<Compile Include="Helper\Model\RFIDReaderSettings.cs" />
<Compile Include="Helper\Reader\IRFIDReader.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RfidConfig.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="RfidConfig.Designer.cs">
<DependentUpon>RfidConfig.cs</DependentUpon>
</Compile>
<EmbeddedResource Include="AutoClosingMessageBox.resx">
<DependentUpon>AutoClosingMessageBox.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="FrmConfig.resx">
<DependentUpon>FrmConfig.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="FrmMgr.resx">
<DependentUpon>FrmMgr.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<EmbeddedResource Include="app.config" />
<EmbeddedResource Include="RfidConfig.resx">
<DependentUpon>RfidConfig.cs</DependentUpon>
</EmbeddedResource>
<None Include="config.json" />
<None Include="packages.config" />
<None Include="Properties\app.manifest" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\JmpCommon\JmpCommon.csproj">
<Project>{8662BAF0-5206-4472-84AF-2E44669C3E2C}</Project>
<Name>JmpCommon</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Content Include="door.ico" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.6.1">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.6.1 %28x86 和 x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file
using DevComponents.DotNetBar;
using Impinj.OctaneSdk;
using JmpCommon;
using JmpCommon.Camera;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Threading;
using System.Windows.Forms;
namespace JmpServiceMgr
{
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
//Thread.Sleep(10000);
MessageBoxEx.EnableGlass = false;
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
System.Threading.Mutex _mutex;
_mutex = new System.Threading.Mutex(true, Process.GetCurrentProcess().ProcessName, out var ret);
if (!ret)
{
MessageBox.Show("已有另一个程序在运行!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);//弹出提示信息
Environment.Exit(0);
}
else
{
MyCache.SysConfig = MyCache.LoadSystemStep();
if (MyCache.SysConfig == null)
{
MessageBox.Show("配置文件加载失败,创建默认配置文件");
MyCache.SysConfig = new LocalConfig();
MyCache.SetSystemSetp();
}
else
{
var _update = HttpHelper.GetUpdate(MyCache.SysConfig?.AppCode ?? "");
if (_update == null)
{
}
else
{
if (Version.TryParse(_update.version2, out var version) && version > new Version(MyCache.SysConfig.AppVersion))
{
if (MessageBox.Show("检测到新版本,是否更新?", "更新提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
System.Diagnostics.Process.Start("explorer.exe", MyCache.SysConfig.DomainUrl.TrimEnd('/') + "/" + _update.address.TrimStart('/'));
Process.GetCurrentProcess().Kill();
}
else { }
}
}
}
HttpHelper.SetLocalTime();
Application.Run(new FrmMgr());
}
}
}
}
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("JmpServiceMgr")]
[assembly: AssemblyDescription("钧普通道程序")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Junmp")]
[assembly: AssemblyProduct("JmpServiceMgr")]
[assembly: AssemblyCopyright("Copyright © Junmp 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("442dabc1-9869-4b57-bfcc-287106799248")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.2.14.09150")]
[assembly: AssemblyFileVersion("1.2.14.09150")]
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace JmpServiceMgr.Properties {
using System;
/// <summary>
/// 一个强类型的资源类,用于查找本地化的字符串等。
/// </summary>
// 此类是由 StronglyTypedResourceBuilder
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// 返回此类使用的缓存的 ResourceManager 实例。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("JmpServiceMgr.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// 重写当前线程的 CurrentUICulture 属性,对
/// 使用此强类型资源类的所有资源查找执行重写。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
\ No newline at end of file
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace JmpServiceMgr.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.6.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app" />
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!-- UAC 清单选项
如果想要更改 Windows 用户帐户控制级别,请使用
以下节点之一替换 requestedExecutionLevel 节点。n
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
指定 requestedExecutionLevel 元素将禁用文件和注册表虚拟化。
如果你的应用程序需要此虚拟化来实现向后兼容性,则删除此
元素。
-->
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
</requestedPrivileges>
<applicationRequestMinimum>
<defaultAssemblyRequest permissionSetReference="Custom" />
<PermissionSet class="System.Security.PermissionSet" version="1" Unrestricted="true" ID="Custom" SameSite="site" />
</applicationRequestMinimum>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- 设计此应用程序与其一起工作且已针对此应用程序进行测试的
Windows 版本的列表。取消评论适当的元素,
Windows 将自动选择最兼容的环境。 -->
<!-- Windows Vista -->
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->
<!-- Windows 7 -->
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />-->
<!-- Windows 8 -->
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />-->
<!-- Windows 8.1 -->
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />-->
<!-- Windows 10 -->
<!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />-->
</application>
</compatibility>
<!-- 指示该应用程序可以感知 DPI 且 Windows 在 DPI 较高时将不会对其进行
自动缩放。Windows Presentation Foundation (WPF)应用程序自动感知 DPI,无需
选择加入。选择加入此设置的 Windows 窗体应用程序(目标设定为 .NET Framework 4.6 )还应
在其 app.config 中将 "EnableWindowsFormsHighDpiAutoResizing" 设置设置为 "true"。-->
<!--
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
</windowsSettings>
</application>
-->
<!-- 启用 Windows 公共控件和对话框的主题(Windows XP 和更高版本) -->
<!--
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
-->
</assembly>
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论