This commit is contained in:
hehaoyang 2023-10-18 23:43:19 +08:00
commit f541d26955
39 changed files with 4132 additions and 0 deletions

271
.gitignore vendored Normal file
View File

@ -0,0 +1,271 @@
其他资料/gcm.zip
其他资料/Lubuntu_1404_For_OrangePiPC_v0_8_0_.img.zip
其他资料/protocol.proto
其他资料/prototobuf/build.bat
其他资料/prototobuf/protobuf-net.dll
其他资料/prototobuf/protobuf-net.Reflection.dll
其他资料/prototobuf/protoc.exe
其他资料/prototobuf/protocol.cs
其他资料/prototobuf/protocol.proto
其他资料/prototobuf/protogen.exe
其他资料/win32_disk_imager/Changelog.txt
其他资料/win32_disk_imager/D3Dcompiler_47.dll
其他资料/win32_disk_imager/GPL-2
其他资料/win32_disk_imager/LGPL-2.1
其他资料/win32_disk_imager/libEGL.dll
其他资料/win32_disk_imager/libgcc_s_dw2-1.dll
其他资料/win32_disk_imager/libGLESV2.dll
其他资料/win32_disk_imager/libstdc++-6.dll
其他资料/win32_disk_imager/libwinpthread-1.dll
其他资料/win32_disk_imager/opengl32sw.dll
其他资料/win32_disk_imager/Qt5Core.dll
其他资料/win32_disk_imager/Qt5Gui.dll
其他资料/win32_disk_imager/Qt5Svg.dll
其他资料/win32_disk_imager/Qt5Widgets.dll
其他资料/win32_disk_imager/README.txt
其他资料/win32_disk_imager/Win32DiskImager.exe
其他资料/win32_disk_imager/platforms/qwindows.dll
其他资料/win32_disk_imager/translations/diskimager_de.qm
其他资料/win32_disk_imager/translations/diskimager_es.qm
其他资料/win32_disk_imager/translations/diskimager_fr.qm
其他资料/win32_disk_imager/translations/diskimager_it.qm
其他资料/win32_disk_imager/translations/diskimager_nl.qm
其他资料/win32_disk_imager/translations/diskimager_pl.qm
其他资料/win32_disk_imager/translations/diskimager_ta_IN.qm
其他资料/win32_disk_imager/translations/diskimager_zh_CN.qm
其他资料/win32_disk_imager/translations/diskimager_zh_TW.qm
其他资料/win32_disk_imager/translations/qt_ca.qm
其他资料/win32_disk_imager/translations/qt_cs.qm
其他资料/win32_disk_imager/translations/qt_de.qm
其他资料/win32_disk_imager/translations/qt_en.qm
其他资料/win32_disk_imager/translations/qt_fi.qm
其他资料/win32_disk_imager/translations/qt_fr.qm
其他资料/win32_disk_imager/translations/qt_he.qm
其他资料/win32_disk_imager/translations/qt_hu.qm
其他资料/win32_disk_imager/translations/qt_it.qm
其他资料/win32_disk_imager/translations/qt_ja.qm
其他资料/win32_disk_imager/translations/qt_ko.qm
其他资料/win32_disk_imager/translations/qt_lv.qm
其他资料/win32_disk_imager/translations/qt_pl.qm
其他资料/win32_disk_imager/translations/qt_ru.qm
其他资料/win32_disk_imager/translations/qt_sk.qm
其他资料/win32_disk_imager/translations/qt_uk.qm
TestView/.vs/TestView/FileContentIndex/5c1e8809-58e8-4f8d-9995-548a206fd26c.vsidx
TestView/.vs/TestView/FileContentIndex/read.lock
TestView/.vs/TestView/v17/.suo
PrinterClient/.vs/PrinterClient/DesignTimeBuild/.dtbcache.v2
PrinterClient/.vs/PrinterClient/FileContentIndex/b9d10d80-0d83-471f-a7e3-ffbdd3b3b617.vsidx
PrinterClient/.vs/PrinterClient/v17/.futdcache.v1
PrinterClient/.vs/PrinterClient/v17/.futdcache.v2
PrinterClient/.vs/PrinterClient/v17/.suo
PrinterClient/.vs/PrinterClient/xs/UserPrefs.xml
PrinterClient/.vs/PrinterClient/xs/project-cache/AutoUpgrade-Debug.json
PrinterClient/.vs/PrinterClient/xs/project-cache/PrinterClient-Debug.json
PrinterClient/.vs/ProjectEvaluation/printerclient.metadata.v7.bin
PrinterClient/.vs/ProjectEvaluation/printerclient.projects.v7.bin
PrinterClient/.vscode/settings.json
PrinterClient/AutoUpgrade/bin/Debug/netcoreapp3.1/AutoUpgrade
PrinterClient/AutoUpgrade/bin/Debug/netcoreapp3.1/AutoUpgrade.deps.json
PrinterClient/AutoUpgrade/bin/Debug/netcoreapp3.1/AutoUpgrade.dll
PrinterClient/AutoUpgrade/bin/Debug/netcoreapp3.1/AutoUpgrade.exe
PrinterClient/AutoUpgrade/bin/Debug/netcoreapp3.1/AutoUpgrade.pdb
PrinterClient/AutoUpgrade/bin/Debug/netcoreapp3.1/AutoUpgrade.runtimeconfig.dev.json
PrinterClient/AutoUpgrade/bin/Debug/netcoreapp3.1/AutoUpgrade.runtimeconfig.json
PrinterClient/AutoUpgrade/obj/AutoUpgrade.csproj.nuget.dgspec.json
PrinterClient/AutoUpgrade/obj/AutoUpgrade.csproj.nuget.g.props
PrinterClient/AutoUpgrade/obj/AutoUpgrade.csproj.nuget.g.targets
PrinterClient/AutoUpgrade/obj/project.assets.json
PrinterClient/AutoUpgrade/obj/project.nuget.cache
PrinterClient/AutoUpgrade/obj/Debug/netcoreapp3.1/.NETCoreApp,Version=v3.1.AssemblyAttributes.cs
PrinterClient/AutoUpgrade/obj/Debug/netcoreapp3.1/apphost
PrinterClient/AutoUpgrade/obj/Debug/netcoreapp3.1/apphost.exe
PrinterClient/AutoUpgrade/obj/Debug/netcoreapp3.1/AutoUpgrade.AssemblyInfo.cs
PrinterClient/AutoUpgrade/obj/Debug/netcoreapp3.1/AutoUpgrade.AssemblyInfoInputs.cache
PrinterClient/AutoUpgrade/obj/Debug/netcoreapp3.1/AutoUpgrade.assets.cache
PrinterClient/AutoUpgrade/obj/Debug/netcoreapp3.1/AutoUpgrade.csproj.AssemblyReference.cache
PrinterClient/AutoUpgrade/obj/Debug/netcoreapp3.1/AutoUpgrade.csproj.CoreCompileInputs.cache
PrinterClient/AutoUpgrade/obj/Debug/netcoreapp3.1/AutoUpgrade.csproj.FileListAbsolute.txt
PrinterClient/AutoUpgrade/obj/Debug/netcoreapp3.1/AutoUpgrade.dll
PrinterClient/AutoUpgrade/obj/Debug/netcoreapp3.1/AutoUpgrade.GeneratedMSBuildEditorConfig.editorconfig
PrinterClient/AutoUpgrade/obj/Debug/netcoreapp3.1/AutoUpgrade.genruntimeconfig.cache
PrinterClient/AutoUpgrade/obj/Debug/netcoreapp3.1/AutoUpgrade.pdb
PrinterClient/PrinterClient/.vscode/launch.json
PrinterClient/PrinterClient/obj/PrinterClient.csproj.nuget.dgspec.json
PrinterClient/PrinterClient/obj/PrinterClient.csproj.nuget.g.props
PrinterClient/PrinterClient/obj/PrinterClient.csproj.nuget.g.targets
PrinterClient/PrinterClient/obj/project.assets.json
PrinterClient/PrinterClient/obj/project.nuget.cache
PrinterClient/PrinterClient/obj/Debug/netcoreapp3.1/.NETCoreApp,Version=v3.1.AssemblyAttributes.cs
PrinterClient/PrinterClient/obj/Debug/netcoreapp3.1/apphost
PrinterClient/PrinterClient/obj/Debug/netcoreapp3.1/apphost.exe
PrinterClient/PrinterClient/obj/Debug/netcoreapp3.1/PrinterClient.AssemblyInfo.cs
PrinterClient/PrinterClient/obj/Debug/netcoreapp3.1/PrinterClient.AssemblyInfoInputs.cache
PrinterClient/PrinterClient/obj/Debug/netcoreapp3.1/PrinterClient.assets.cache
PrinterClient/PrinterClient/obj/Debug/netcoreapp3.1/PrinterClient.csproj.AssemblyReference.cache
PrinterClient/PrinterClient/obj/Debug/netcoreapp3.1/PrinterClient.csproj.BuildWithSkipAnalyzers
PrinterClient/PrinterClient/obj/Debug/netcoreapp3.1/PrinterClient.csproj.CopyComplete
PrinterClient/PrinterClient/obj/Debug/netcoreapp3.1/PrinterClient.csproj.CoreCompileInputs.cache
PrinterClient/PrinterClient/obj/Debug/netcoreapp3.1/PrinterClient.csproj.FileListAbsolute.txt
PrinterClient/PrinterClient/obj/Debug/netcoreapp3.1/PrinterClient.dll
PrinterClient/PrinterClient/obj/Debug/netcoreapp3.1/PrinterClient.GeneratedMSBuildEditorConfig.editorconfig
PrinterClient/PrinterClient/obj/Debug/netcoreapp3.1/PrinterClient.genruntimeconfig.cache
PrinterClient/PrinterClient/obj/Debug/netcoreapp3.1/PrinterClient.pdb
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/CyStat.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/CyStat64.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/DotNetty.Buffers.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/DotNetty.Codecs.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/DotNetty.Codecs.Protobuf.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/DotNetty.Common.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/DotNetty.Handlers.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/DotNetty.Transport.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/DotNetty.Transport.Libuv.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/Google.Protobuf.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/Microsoft.Extensions.DependencyInjection.Abstractions.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/Microsoft.Extensions.DependencyInjection.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/Microsoft.Extensions.Logging.Abstractions.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/Microsoft.Extensions.Logging.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/Microsoft.Extensions.Options.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/Microsoft.Extensions.Primitives.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/Microsoft.Win32.SystemEvents.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/Newtonsoft.Json.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/printer.uuid.txt
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/PrinterClient
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/PrinterClient.deps.json
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/PrinterClient.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/PrinterClient.dll.config
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/PrinterClient.exe
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/PrinterClient.pdb
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/PrinterClient.runtimeconfig.dev.json
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/PrinterClient.runtimeconfig.json
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/protobuf-net.Core.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/protobuf-net.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/System.Configuration.ConfigurationManager.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/System.Diagnostics.DiagnosticSource.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/System.Drawing.Common.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/System.Runtime.CompilerServices.Unsafe.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/System.Security.AccessControl.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/System.Security.Cryptography.ProtectedData.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/System.Security.Permissions.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/System.Security.Principal.Windows.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/System.Windows.Extensions.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/runtimes/linux-arm/native/libuv.so
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/runtimes/linux-arm64/native/libuv.so
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/runtimes/linux-armel/native/libuv.so
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/runtimes/linux-x64/native/libuv.so
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/runtimes/osx/native/libuv.dylib
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/runtimes/unix/lib/netcoreapp2.1/System.Security.Principal.Windows.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/runtimes/unix/lib/netcoreapp3.1/System.Drawing.Common.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/runtimes/win/lib/netcoreapp2.1/System.Security.Principal.Windows.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/runtimes/win/lib/netcoreapp3.1/Microsoft.Win32.SystemEvents.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/runtimes/win/lib/netcoreapp3.1/System.Drawing.Common.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/runtimes/win/lib/netcoreapp3.1/System.Windows.Extensions.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/runtimes/win/lib/netstandard2.0/System.Security.AccessControl.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/runtimes/win/lib/netstandard2.0/System.Security.Cryptography.ProtectedData.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/runtimes/win-arm/native/libuv.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/runtimes/win-x64/native/libuv.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/runtimes/win-x86/native/libuv.dll
TestView/TestView/obj/Debug/.NETFramework,Version=v4.5.2.AssemblyAttributes.cs
TestView/TestView/obj/Debug/.NETFramework,Version=v4.7.2.AssemblyAttributes.cs
TestView/TestView/obj/Debug/.NETFramework,Version=v4.8.AssemblyAttributes.cs
TestView/TestView/obj/Debug/App.g.cs
TestView/TestView/obj/Debug/App.g.i.cs
TestView/TestView/obj/Debug/DesignTimeResolveAssemblyReferences.cache
TestView/TestView/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
TestView/TestView/obj/Debug/GeneratedInternalTypeHelper.g.cs
TestView/TestView/obj/Debug/GeneratedInternalTypeHelper.g.i.cs
TestView/TestView/obj/Debug/Loading.baml
TestView/TestView/obj/Debug/Loading.g.cs
TestView/TestView/obj/Debug/Loading.g.i.cs
TestView/TestView/obj/Debug/MainWindow.baml
TestView/TestView/obj/Debug/MainWindow.g.cs
TestView/TestView/obj/Debug/MainWindow.g.i.cs
TestView/TestView/obj/Debug/TaskControl.g.i.cs
TestView/TestView/obj/Debug/TaskInfoWindow.baml
TestView/TestView/obj/Debug/TaskInfoWindow.g.cs
TestView/TestView/obj/Debug/TaskInfoWindow.g.i.cs
TestView/TestView/obj/Debug/TestView_MarkupCompile.cache
TestView/TestView/obj/Debug/TestView_MarkupCompile.i.cache
TestView/TestView/obj/Debug/TestView_MarkupCompile.lref
TestView/TestView/obj/Debug/TestView.csproj.AssemblyReference.cache
TestView/TestView/obj/Debug/TestView.csproj.CopyComplete
TestView/TestView/obj/Debug/TestView.csproj.CoreCompileInputs.cache
TestView/TestView/obj/Debug/TestView.csproj.FileListAbsolute.txt
TestView/TestView/obj/Debug/TestView.csproj.GenerateResource.cache
TestView/TestView/obj/Debug/TestView.csproj.SuggestedBindingRedirects.cache
TestView/TestView/obj/Debug/TestView.exe
TestView/TestView/obj/Debug/TestView.g.resources
TestView/TestView/obj/Debug/TestView.pdb
TestView/TestView/obj/Debug/TestView.Properties.Resources.resources
TestView/TestView/obj/Debug/TempPE/Properties.Resources.Designer.cs.dll
TestView/TestView/bin/Debug/Newtonsoft.Json.dll
TestView/TestView/bin/Debug/Newtonsoft.Json.xml
TestView/TestView/bin/Debug/TestView.exe
TestView/TestView/bin/Debug/TestView.exe.config
TestView/TestView/bin/Debug/TestView.pdb
TestView/TestView/obj/Debug/build.force
TestView/TestView/obj/Debug/TestView_MarkupCompile.i.lref
TestView/packages/Newtonsoft.Json.13.0.3/.signature.p7s
TestView/packages/Newtonsoft.Json.13.0.3/LICENSE.md
TestView/packages/Newtonsoft.Json.13.0.3/Newtonsoft.Json.13.0.3.nupkg
TestView/packages/Newtonsoft.Json.13.0.3/packageIcon.png
TestView/packages/Newtonsoft.Json.13.0.3/README.md
TestView/packages/Newtonsoft.Json.13.0.3/lib/net20/Newtonsoft.Json.dll
TestView/packages/Newtonsoft.Json.13.0.3/lib/net20/Newtonsoft.Json.xml
TestView/packages/Newtonsoft.Json.13.0.3/lib/net35/Newtonsoft.Json.dll
TestView/packages/Newtonsoft.Json.13.0.3/lib/net35/Newtonsoft.Json.xml
TestView/packages/Newtonsoft.Json.13.0.3/lib/net40/Newtonsoft.Json.dll
TestView/packages/Newtonsoft.Json.13.0.3/lib/net40/Newtonsoft.Json.xml
TestView/packages/Newtonsoft.Json.13.0.3/lib/net45/Newtonsoft.Json.dll
TestView/packages/Newtonsoft.Json.13.0.3/lib/net45/Newtonsoft.Json.xml
TestView/packages/Newtonsoft.Json.13.0.3/lib/net6.0/Newtonsoft.Json.dll
TestView/packages/Newtonsoft.Json.13.0.3/lib/net6.0/Newtonsoft.Json.xml
TestView/packages/Newtonsoft.Json.13.0.3/lib/netstandard1.0/Newtonsoft.Json.dll
TestView/packages/Newtonsoft.Json.13.0.3/lib/netstandard1.0/Newtonsoft.Json.xml
TestView/packages/Newtonsoft.Json.13.0.3/lib/netstandard1.3/Newtonsoft.Json.dll
TestView/packages/Newtonsoft.Json.13.0.3/lib/netstandard1.3/Newtonsoft.Json.xml
TestView/packages/Newtonsoft.Json.13.0.3/lib/netstandard2.0/Newtonsoft.Json.dll
TestView/packages/Newtonsoft.Json.13.0.3/lib/netstandard2.0/Newtonsoft.Json.xml
TestView/.vs/TestView/FileContentIndex/64c275c3-c896-471e-9b80-378ddd44f3c4.vsidx
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/._DotNetty.Buffers.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/._DotNetty.Codecs.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/._DotNetty.Codecs.Protobuf.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/._DotNetty.Common.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/._DotNetty.Handlers.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/._DotNetty.Transport.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/._DotNetty.Transport.Libuv.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/._Google.Protobuf.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/._Microsoft.Extensions.DependencyInjection.Abstractions.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/._Microsoft.Extensions.DependencyInjection.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/._Microsoft.Extensions.Logging.Abstractions.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/._Microsoft.Extensions.Logging.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/._Microsoft.Extensions.Options.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/._Microsoft.Extensions.Primitives.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/._Microsoft.Win32.SystemEvents.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/._Newtonsoft.Json.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/._protobuf-net.Core.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/._protobuf-net.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/._System.Configuration.ConfigurationManager.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/._System.Diagnostics.DiagnosticSource.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/._System.Drawing.Common.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/._System.Runtime.CompilerServices.Unsafe.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/._System.Security.AccessControl.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/._System.Security.Cryptography.ProtectedData.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/._System.Security.Permissions.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/._System.Security.Principal.Windows.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/._System.Windows.Extensions.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/runtimes/linux-arm/native/._libuv.so
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/runtimes/linux-arm64/native/._libuv.so
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/runtimes/linux-armel/native/._libuv.so
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/runtimes/linux-x64/native/._libuv.so
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/runtimes/osx/native/._libuv.dylib
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/runtimes/unix/lib/netcoreapp2.1/._System.Security.Principal.Windows.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/runtimes/unix/lib/netcoreapp3.1/._System.Drawing.Common.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/runtimes/win/lib/netcoreapp2.1/._System.Security.Principal.Windows.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/runtimes/win/lib/netcoreapp3.1/._Microsoft.Win32.SystemEvents.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/runtimes/win/lib/netcoreapp3.1/._System.Drawing.Common.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/runtimes/win/lib/netcoreapp3.1/._System.Windows.Extensions.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/runtimes/win/lib/netstandard2.0/._System.Security.AccessControl.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/runtimes/win/lib/netstandard2.0/._System.Security.Cryptography.ProtectedData.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/runtimes/win-arm/native/._libuv.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/runtimes/win-x64/native/._libuv.dll
PrinterClient/PrinterClient/bin/Debug/netcoreapp3.1/runtimes/win-x86/native/._libuv.dll

View File

@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Remove="._Program.cs" />
</ItemGroup>
<ItemGroup>
<None Remove="._bin" />
<None Remove="._obj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,93 @@
using System;
using System.Diagnostics;
using System.IO;
namespace AutoUpgrade
{
class Program
{
static bool ExecuteCommand(string fileName, string arguments)
{
/* 创建一个ProcessStartInfo对象 使用系统shell 指定命令和参数 设置标准输出 */
var startInfo = new ProcessStartInfo(fileName, arguments)
{
RedirectStandardOutput = true
};
/* 启动 */
var process = Process.Start(startInfo);
if (process != null)
{
/* 开始读取 */
using (var streamReader = process.StandardOutput)
{
while (!streamReader.EndOfStream)
Console.WriteLine(streamReader.ReadLine());
if (!process.HasExited)
{
process.Kill();
}
}
return true;
}
return false;
}
static void DebugWriteLine(string output, ConsoleColor color)
{
Console.ForegroundColor = color;
Console.WriteLine($"{DateTime.Now:yyyy-MM-dd HH:mm:ss}, upgrade application: {output}");
Console.ResetColor();
}
static void Main(string[] args)
{
/* 程序目录 */
var filepath = "/root/netcoreapp3.1/";
/* 下载名称 */
var upgrade_file = Path.Combine(filepath, "AutoUpgrade", $"{Guid.NewGuid()}.zip");
try
{
DebugWriteLine("downloading", ConsoleColor.Green);
DebugWriteLine(args[0], ConsoleColor.Green);
Console.ForegroundColor = ConsoleColor.DarkCyan;
if (ExecuteCommand("wget", $"-O {upgrade_file} {args[0]}"))
{
DebugWriteLine("download complete", ConsoleColor.Green);
DebugWriteLine("start upgrade", ConsoleColor.Green);
//DebugWriteLine("stop printerclient.service", ConsoleColor.Green);
//ExecuteCommand("systemctl", "stop printerclient.service");
DebugWriteLine($"unzip file, {upgrade_file} => {filepath}", ConsoleColor.Green);
ExecuteCommand("unzip", $"-o {upgrade_file} -d {filepath}");
DebugWriteLine("start printerclient.service", ConsoleColor.Green);
ExecuteCommand("systemctl", "restart printerclient.service");
DebugWriteLine("upgrade complete", ConsoleColor.Green);
}
else
{
DebugWriteLine("download error", ConsoleColor.Red);
}
}
catch (Exception ex)
{
DebugWriteLine($"error={ex.Message}", ConsoleColor.Red);
}
finally { ExecuteCommand("rm", upgrade_file); }
}
}
}

View File

@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.33424.131
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PrinterClient", "PrinterClient\PrinterClient.csproj", "{3C8E7DD6-A14C-4613-AE71-D445742EE112}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoUpgrade", "AutoUpgrade\AutoUpgrade.csproj", "{EC3F20F1-ABB8-432A-9546-289C37B6A1AF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3C8E7DD6-A14C-4613-AE71-D445742EE112}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3C8E7DD6-A14C-4613-AE71-D445742EE112}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3C8E7DD6-A14C-4613-AE71-D445742EE112}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3C8E7DD6-A14C-4613-AE71-D445742EE112}.Release|Any CPU.Build.0 = Release|Any CPU
{EC3F20F1-ABB8-432A-9546-289C37B6A1AF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EC3F20F1-ABB8-432A-9546-289C37B6A1AF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EC3F20F1-ABB8-432A-9546-289C37B6A1AF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EC3F20F1-ABB8-432A-9546-289C37B6A1AF}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {DE4EAAEE-7F2C-42EF-95FF-CECF8FF0608F}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,620 @@
using System;
using System.IO;
using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using DotNetty.Buffers;
using DotNetty.Handlers.Timeout;
using DotNetty.Transport.Bootstrapping;
using DotNetty.Transport.Channels;
using DotNetty.Transport.Channels.Sockets;
using Google.Protobuf.WellKnownTypes;
namespace PrinterClient;
public class BoxServer
{
long serialNo = 0;
string equipNo = "TWS-TR-01";
Bootstrap bootstrap = new();
MultithreadEventLoopGroup group = new();
static IChannel clientChannel;
///* 是否有打印任务正在进行 */
//bool isPrinter = false;
///* 当前正在打印的订单号 */
//string TerminalPrintTaskState_PrintOrderCode = "";
///* 当前订单执行状态 */
//int TerminalPrintTaskState_Status = 0;
public static int Total = 0;
public static bool Status = false;
public BoxServer(string equipNo)
{
this.equipNo = equipNo;
}
public void Connect(string address, int port)
{
bootstrap
.Group(group)
.Channel<TcpSocketChannel>()
.Option(ChannelOption.TcpNodelay, true)
.Option(ChannelOption.ConnectTimeout, TimeSpan.FromSeconds(3))
.Option(ChannelOption.RcvbufAllocator, new FixedRecvByteBufAllocator(1024))
.Handler(new ActionChannelInitializer<ISocketChannel>(channel =>
{
var pipeline = channel.Pipeline;
pipeline.AddLast(new IdleStateHandler(60, 60, 60));
pipeline.AddLast(new ClientHandler(ReceiveHandler, Connect));
}));
bootstrap.RemoteAddress(new IPEndPoint(IPAddress.Parse(address), port));
Connect();
new Task(WorkThread, TaskCreationOptions.LongRunning).Start();
}
private async void Connect()
{
try
{
Interlocked.Increment(ref Total);
if (Total == 1)
{
if (clientChannel == null)
{
Program.DebugWriteLine("try conneting");
clientChannel = await bootstrap.ConnectAsync();
}
}
}
catch (Exception ex)
{
Total = 0;
LogUtils.AppendError(ex);
Thread.Sleep(10000);
Connect();
}
}
private async void SendHandler(PrintMessage printMessage)
{
await Task.Run(() =>
{
try
{
if (clientChannel == null)
return;
var message = Unpooled.Buffer();
message.WriteBytes(printMessage.Serialize());
clientChannel.WriteAndFlushAsync(message);
Program.DebugWriteLine($"common send: serialNo={printMessage.serialNo}");
}
catch (Exception ex) { LogUtils.AppendError(ex); }
});
}
private async void ReceiveHandler(PrintMessage printMessage)
{
await Task.Run(() =>
{
switch (printMessage.ecsType)
{
/* 通用回复指令 */
case TaskType.CommonResponse:
Program.DebugWriteLine($"common response: serialNo={printMessage.serialNo}, status={printMessage.commandResponse.Status}, remark={printMessage.commandResponse.Remark}");
break;
/* 下发打印任务 */
case TaskType.TerminalPrinttask:
TerminalPrintTaskHandle(printMessage.serialNo, printMessage.terminalPrintTask);
break;
/* 程序版本回复 */
case TaskType.TerminalCheckversionResult:
TerminalCheckVersionResultHandle(printMessage.terminalCheckVersionResult);
break;
/* 终端控制指令 */
case TaskType.TerminalControl:
TerminalControlHandle(printMessage.terminalControl);
break;
}
});
}
private void WorkThread()
{
while (true)
{
if (TimerUtils.IsInterval("TerminalStateUpdateHandle", 1000 * 10))
TerminalStateUpdateHandle();
if (TimerUtils.IsInterval("TerminalCheckVersionHandle", 1000 * 60 * 10))
TerminalCheckVersionHandle();
///* 打印盒子在获取打印任务后开始执行打印任务打印盒子定时上传打印状态定时2秒上传一次 */
//if (isPrinter)
//{
// if (TimerUtils.IsInterval("TerminalPrintTaskStateHandle", 1000 * 2))
// TerminalPrintTaskStateHandle();
//}
Thread.Sleep(100);
}
}
/// <summary>
/// 通用回复指令
/// </summary>
/// <param name="serialNo">消息序列号</param>
/// <param name="status">状态, 0=成功1=异常</param>
/// <param name="remark">描述情况</param>
private async void CommonResponseHandle(string serialNo, int status, string remark)
{
await Task.Run(() =>
{
PrintMessage printMessage = new()
{
serialNo = serialNo,
ecsType = TaskType.CommonResponse,
commandResponse = new()
{
equipNo = equipNo,
equipCode = Program.Uuid,
Status = status.ToString(),
Remark = remark,
}
};
SendHandler(printMessage);
});
}
/// <summary>
/// 上传终端状态数据
/// </summary>
private async void TerminalStateUpdateHandle()
{
await Task.Run(() =>
{
PrintMessage printMessage = new()
{
serialNo = (serialNo++).ToString(),
ecsType = TaskType.TerminalStateUpdate,
terminalStateUpdate = new()
{
equipNo = equipNo,
equipType = "3",
equipCode = Program.Uuid,
Longitude = "",
Latitude = "",
equipVer = ReadMe.Version,
equipTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"),
Ip = "",
equipStatus = Printer.BoxStatus.ToString(),
printerStatus = Printer.Status.ToString(),
peripheralFeatureIds = "110001",
printerCode = Printer.Serial
}
};
SendHandler(printMessage);
});
}
/*
54802
*/
/// <summary>
/// 下发打印任务
/// </summary>
/// <param name="serialNo"></param>
/// <param name="result"></param>
private async void TerminalPrintTaskHandle(string serialNo, TerminalPrintTask result)
{
await Task.Run(() =>
{
if (result.equipCode.Equals(Program.Uuid))
{
var printerStatus = Printer.Status;
/* 生成唯一ID */
var uuid = Guid.NewGuid().ToString();
/* 盒子收到指令 */
TerminalPrintTaskStateHandle(result.printOrderCode, 12, printerStatus);
Program.DebugWriteLine($"{result.printOrderCode}, checking Printer status = {printerStatus}");
DebugTool.UploadTaskStatus(uuid, result.printOrderCode, "收到指令");
if (printerStatus == (int)PrinterStatus.DriveFailed ||
printerStatus == (int)PrinterStatus.NotDriven ||
printerStatus == (int)PrinterStatus.Maintenance ||
printerStatus == (int)PrinterStatus.NoPaper ||
printerStatus == (int)PrinterStatus.Sleep)
{
DebugTool.UploadTaskStatus(uuid, result.printOrderCode, "打印失败(打印机异常)");
Program.DebugWriteLine("打印机异常");
/* 异常 */
TerminalPrintTaskStateHandle(result.printOrderCode, 15, printerStatus);
return;
}
else if (printerStatus == (int)PrinterStatus.Printing)
{
DebugTool.UploadTaskStatus(uuid, result.printOrderCode, "打印失败(正在打印中)");
Program.DebugWriteLine("打印机正在打印中");
/* 盒子当前有任务执行 */
TerminalPrintTaskStateHandle(result.printOrderCode, 16, printerStatus);
return;
}
/* 开始执行打印任务 */
Program.DebugWriteLine("开始执行打印任务");
DebugTool.UploadTaskStatus(uuid, result.printOrderCode, "开始执行打印任务");
Directory.CreateDirectory(Program.ImagePath);
string error = "";
string filename = $"{Program.ImagePath}{result.printOrderCode}.jpg";
try
{
Program.DebugWriteLine($"Current task order number: {result.printOrderCode}");
Printer.BoxStatus = (int)BoxStatus.Download;
/* 盒子开始处理 */
TerminalPrintTaskStateHandle(result.printOrderCode, 13, Printer.Status);
Thread.Sleep(2000);
/* 开始下载文件 */
DebugTool.UploadTaskStatus(uuid, result.printOrderCode, "开始下载文件");
Program.DebugWriteLine($"开始下载文件 {result.printFileUrl} {filename}");
TaskDispatcher.ExecuteCommand("wget", $" --read-timeout=5 --tries=5 {result.printFileUrl} -O {filename}", out string output);
Program.DebugWriteLine($"下载完成, {output}");
DebugTool.UploadTaskStatus(uuid, result.printOrderCode, "下载完成");
DebugTool.UploadTaskImage(uuid, filename);
/* 下载完成 */
Printer.BoxStatus = (int)BoxStatus.Normal;
/* 盒子开始打印 */
TerminalPrintTaskStateHandle(result.printOrderCode, 14, Printer.Status);
Printer.Printing = true;
Program.DebugWriteLine("开始打印");
DebugTool.UploadTaskStatus(uuid, result.printOrderCode, "开始打印");
while (!Printer.Print(result.fileFormatId, result.printModeId, result.printSizeId, filename, out string job))
{
Program.DebugWriteLine("打印失败5s后重试");
DebugTool.UploadTaskStatus(uuid, result.printOrderCode, "打印失败5s后重试");
Thread.Sleep(5000);
}
/* 等待盒子打印完成 */
DateTime current = DateTime.Now;
while (true)
{
TerminalPrintTaskStateHandle(result.printOrderCode, 14, Printer.Status);
/* 最大等待时长1分钟 */
if (DateTime.Now - current >= TimeSpan.FromMinutes(1))
{
error = "打印超时";
DebugTool.UploadTaskStatus(uuid, result.printOrderCode, "打印超时");
while (Printer.QueryEntries() != null)
{
Program.DebugWriteLine($"删除所有的打印任务");
Printer.Clear();
Thread.Sleep(1000);
}
break;
}
if (Printer.Status != (int)PrinterStatus.Printing)
break;
Thread.Sleep(2000);
}
Thread.Sleep(2000);
/* 打印超时 */
if (error == "打印超时")
TerminalPrintTaskStateHandle(result.printOrderCode, 23, Printer.Status);
else /* 打印成功 */
{
Thread.Sleep(5000);
TerminalPrintTaskStateHandle(result.printOrderCode, 21, Printer.Status);
}
}
catch (Exception ex)
{
LogUtils.AppendError(ex);
/* 异常 */
TerminalPrintTaskStateHandle(result.printOrderCode, 15, Printer.Status);
}
finally
{
/* 打印完成 */
Program.DebugWriteLine($"打印任务结束 {error}");
DebugTool.UploadTaskStatus(uuid, result.printOrderCode, "打印任务结束");
Printer.Printing = false;
if (!Program.ImageSave)
{
if (File.Exists(filename))
File.Delete(filename);
}
}
}
});
}
///// <summary>
///// 上传打印任务情况
///// </summary>
//private async void TerminalPrintTaskStateHandle()
//{
// await Task.Run(() =>
// {
// PrintMessage printMessage = new()
// {
// serialNo = (serialNo++).ToString(),
// ecsType = TaskType.TerminalPrinttaskState,
// terminalPrintTaskState = new()
// {
// equipNo = equipNo,
// equipCode = Program.Uuid,
// printOrderCode = TerminalPrintTaskState_PrintOrderCode,
// Status = TerminalPrintTaskState_Status.ToString(),
// printerStatus = Printer.Status.ToString()
// }
// };
// SendHandler(printMessage);
// });
//}
/// <summary>
/// 上传打印任务情况
/// </summary>
private async void TerminalPrintTaskStateHandle(string printOrderCode, int status, int printerStatus)
{
await Task.Run(() =>
{
PrintMessage printMessage = new()
{
serialNo = (serialNo++).ToString(),
ecsType = TaskType.TerminalPrinttaskState,
terminalPrintTaskState = new()
{
equipNo = equipNo,
equipCode = Program.Uuid,
printOrderCode = printOrderCode,
Status = status.ToString(),
printerStatus = printerStatus.ToString()
}
};
SendHandler(printMessage);
});
}
///// <summary>
///// 终端接收任务回复
///// <paramref name="printOrderCode">订单号</paramref>
///// <paramref name="status">状态</paramref>
///// </summary>
//private async void TerminalPrintTaskResultHandle(string printOrderCode, int status, string remark = "")
//{
// await Task.Run(() =>
// {
// PrintMessage printMessage = new()
// {
// serialNo = (serialNo++).ToString(),
// ecsType = TaskType.TERMINAL_PRINTTASK_RESULT,
// terminalPrintTaskResult = new()
// {
// equipNo = equipNo,
// equipCode = uuid,
// printOrderCode = printOrderCode,
// status = status.ToString(),
// remark = remark,
// }
// };
// SendHandler(printMessage);
// });
//}
/// <summary>
/// 终端查询版本
/// </summary>
private async void TerminalCheckVersionHandle()
{
await Task.Run(() =>
{
PrintMessage printMessage = new()
{
serialNo = (serialNo++).ToString(),
ecsType = TaskType.TerminalCheckversion,
terminalCheckVersion = new()
{
equipCode = Program.Uuid,
Type = "1",
versionCode = ReadMe.Version,
}
};
SendHandler(printMessage);
});
}
/// <summary>
/// 程序版本回复
/// </summary>
/// <param name="result"></param>
private async void TerminalCheckVersionResultHandle(TerminalCheckVersionResult result)
{
await Task.Run(() =>
{
if (string.IsNullOrEmpty(result.versionCode))
return;
Program.DebugWriteLine($"remote version {result.versionCode}, url {result.verUrl}");
if (!string.IsNullOrEmpty(result.versionCode) && result.versionCode != ReadMe.Version)
{
TaskDispatcher.ExecuteCommand("dotnet", $"AutoUpgrade/AutoUpgrade.dll {result.verUrl}", out string _);
}
});
}
/// <summary>
/// 终端控制
/// </summary>
/// <param name="result"></param>
private async void TerminalControlHandle(TerminalControl control)
{
await Task.Run(() =>
{
int status = 21; /* 失败 */
switch (control.Type)
{
/* 重启应用 */
case "1101":
Program.DebugWriteLine("接收到 重启应用 指令");
TerminalControlUpdateHandle(control.orderCode, control.Type, status);
Thread.Sleep(5000);
TaskDispatcher.AsyncExecuteCommand("systemctl", "restart printerclient.service");
break;
/* 重启系统 */
case "1201":
Program.DebugWriteLine("接收到 重启系统 指令");
TerminalControlUpdateHandle(control.orderCode, control.Type, status);
Thread.Sleep(5000);
TaskDispatcher.AsyncExecuteCommand("reboot", "");
break;
}
});
}
/// <summary>
/// 终端控制回复
/// </summary>
/// <param name="result"></param>
private async void TerminalControlUpdateHandle(string orderCode, string type, int status)
{
await Task.Run(() =>
{
PrintMessage printMessage = new()
{
serialNo = (serialNo++).ToString(),
ecsType = TaskType.TerminalControlUpdate,
terminalControlUpdate = new()
{
equipNo = equipNo,
equipCode = Program.Uuid,
orderCode = orderCode,
Type = type,
Status = status.ToString()
}
};
SendHandler(printMessage);
});
}
public class ClientHandler : ChannelHandlerAdapter
{
private readonly IByteBuffer initialMessage = null;
private readonly Action DroplineAction = null;
private readonly Action<PrintMessage> Receiveaction = null;
public ClientHandler(Action<PrintMessage> receiveaction, Action droplineAction)
{
this.Receiveaction = receiveaction;
this.DroplineAction = droplineAction;
}
public override void ChannelActive(IChannelHandlerContext context)
{
BoxServer.Status = true;
Program.DebugWriteLine("connect success");
context.WriteAndFlushAsync(initialMessage);
}
public override void ChannelRead(IChannelHandlerContext context, object message)
{
if (message is IByteBuffer byteBuffer)
{
Receiveaction.Invoke(byteBuffer.Array.Deserialize<PrintMessage>(byteBuffer.ArrayOffset + byteBuffer.ReaderIndex, byteBuffer.ReadableBytes));
}
}
public override void ChannelReadComplete(IChannelHandlerContext context) => context.Flush();
public override void ExceptionCaught(IChannelHandlerContext context, Exception exception)
{
Program.DebugWriteLine("Exception: " + exception);
context.CloseAsync();
}
public override void HandlerAdded(IChannelHandlerContext context)
{
base.HandlerAdded(context);
}
public override void HandlerRemoved(IChannelHandlerContext context)
{
BoxServer.Status = false;
Program.DebugWriteLine($"receive {context.Channel.LocalAddress} disconnect notification. current connect {clientChannel.LocalAddress}");
if (context.Channel.LocalAddress.ToString().Equals(clientChannel.LocalAddress.ToString()))
{
Total = 0;
clientChannel = null;
DroplineAction();
}
base.HandlerRemoved(context);
}
}
}

View File

@ -0,0 +1,135 @@
using System;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Net;
using System.Net.Sockets;
using System.IO;
namespace PrinterClient
{
public class TcpBuffer
{
public TcpClient Client;
public byte[] Buffer = new byte[1024 * 1024];
}
public class DebugTool
{
class Model
{
public int Type { get; set; }
public object MsgInfo { get; set; }
public override string ToString() => Newtonsoft.Json.JsonConvert.SerializeObject(this);
public Model(int Type, object MsgInfo = null) { this.Type = Type; this.MsgInfo = MsgInfo; }
}
private static TcpClient tcpClient = null;
private static TcpListener tcpListener = null;
public static void Start()
{
tcpListener = new TcpListener(IPAddress.Any, 8566);
tcpListener.Start();
tcpListener.BeginAcceptTcpClient(AcceptTcpClientCallback, null);
/* 每2秒上传一次状态信息 */
Task.Run(() =>
{
while (true)
{
Write(new Model(0, new
{
UUID = Program.Uuid,
Serial = Printer.Serial,
ServiceStatus = BoxServer.Status,
PrinterStatus = Printer.Status,
}));
Thread.Sleep(2000);
}
});
}
public static void Write(object message)
{
try
{
if (tcpClient?.Connected == true)
{
var buffer = Encoding.UTF8.GetBytes(message.ToString() + "\n");
tcpClient.GetStream().Write(buffer, 0, buffer.Length);
}
}
catch { }
}
public static void UploadTaskStatus(string uuid, string id, string status)
{
Write(new Model(1, new
{
Uuid = uuid,
ID = id,
Status = status,
}));
}
public static void UploadTaskImage(string uuid, string filename)
{
Write(new Model(2, new
{
Uuid = uuid,
Base64String = Convert.ToBase64String(File.ReadAllBytes(filename))
}));
}
private static void BeginRead(TcpClient client)
{
tcpClient = client;
var tb = new TcpBuffer() { Client = tcpClient };
tcpClient.GetStream().BeginRead(tb.Buffer, 0, tb.Buffer.Length, ReadCallback, tb);
}
private static void AcceptTcpClientCallback(IAsyncResult ar)
{
try
{
if (tcpClient != null)
{
tcpClient.Close();
tcpClient = null;
}
BeginRead(tcpListener.EndAcceptTcpClient(ar));
}
catch { }
tcpListener.BeginAcceptTcpClient(AcceptTcpClientCallback, null);
}
private static void ReadCallback(IAsyncResult ar)
{
try
{
var tb = ar.AsyncState as TcpBuffer;
var length = tb.Client.GetStream().EndRead(ar);
Console.WriteLine(Encoding.ASCII.GetString(tb.Buffer, 0, length));
BeginRead(tcpListener.EndAcceptTcpClient(ar));
}
catch { }
}
}
}

View File

@ -0,0 +1,56 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<LangVersion>latest</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<None Remove="protobuf-net" />
<None Remove="DotNetty.Codecs.Protobuf" />
<None Remove="DotNetty.Handlers" />
<None Remove="DotNetty.Transport.Libuv" />
<None Remove="Utils\" />
<None Remove="Newtonsoft.Json" />
<None Remove="System.Configuration.ConfigurationManager" />
<None Remove="Costura.Fody" />
<None Remove="RX1\" />
<None Remove="RX1\Win32\" />
<None Remove="._RX1" />
<None Remove="RX1\._Win32" />
<None Remove="._app.config" />
<None Remove="._bin" />
<None Remove="._obj" />
<None Remove="._Utils" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="protobuf-net" Version="3.0.101" />
<PackageReference Include="DotNetty.Codecs.Protobuf" Version="0.7.2" />
<PackageReference Include="DotNetty.Handlers" Version="0.7.2" />
<PackageReference Include="DotNetty.Transport.Libuv" Version="0.7.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="6.0.0" />
<PackageReference Include="Microsoft.VisualBasic" Version="10.3.0" />
</ItemGroup>
<ItemGroup>
<Compile Remove="._TaskDispatcher.cs" />
<Compile Remove="._Program.cs" />
<Compile Remove="._protocol.cs" />
<Compile Remove="._BoxServer.cs" />
<Compile Remove="._ReadMe.cs" />
<Compile Remove="Utils\._TimerUtils.cs" />
<Compile Remove="._CyStatus.cs" />
<Compile Remove="RX1\._CyStatus.cs" />
<Compile Remove="._DebugTool.cs" />
<Compile Remove="Utils\._ByteUtils.cs" />
<Compile Remove="Utils\._DeviceUtils.cs" />
<Compile Remove="Utils\._FileUtils.cs" />
<Compile Remove="Utils\._LogUtils.cs" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,72 @@
using System;
using System.Configuration;
using System.IO;
using System.Runtime.InteropServices;
using System.Threading;
namespace PrinterClient;
class Program
{
readonly static string UuidPath = "printer.uuid.txt";
static BoxServer boxServer;
static bool debugging = false;
public static string ImagePath = "Image/";
public static bool ImageSave = false;
public static string Platform = "";
public static string Uuid = Guid.NewGuid().ToString();
static void Main(string[] args)
{
DebugTool.Start();
/* 获取运行平台类型 */
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
Platform = "Linux";
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
Platform = "OSX";
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
Platform = "Windows";
/* 生成唯一编码 */
if (File.Exists(UuidPath))
{
Uuid = File.ReadAllText(UuidPath);
}
else
{
File.WriteAllText(UuidPath, Uuid);
}
var address = ConfigurationManager.AppSettings["address"].ToString();
var port = Convert.ToInt32(ConfigurationManager.AppSettings["port"]);
debugging = Convert.ToBoolean(ConfigurationManager.AppSettings["debugging"]);
ImageSave = Convert.ToBoolean(ConfigurationManager.AppSettings["image_save"]);
DebugWriteLine($"uuid: {Uuid}, version: {ReadMe.Version}");
DebugWriteLine($"remote address: {address}, port: {port}, debugging: {debugging}, image_save: {ImageSave}");
boxServer = new BoxServer("TWS-TR-01");
boxServer.Connect(address, port);
while (true) { Thread.Sleep(1000); }
}
public static void DebugWriteLine(string value)
{
var str = $"{DateTime.Now:yyyy-MM-dd HH:mm:ss}: {value}";
if (debugging)
LogUtils.AppendLog(str);
else
Console.WriteLine(str);
}
}

View File

@ -0,0 +1,317 @@
using System;
using System.Drawing.Printing;
using System.IO;
using System.Runtime.InteropServices;
namespace PrinterClient
{
public class CyStatus
{
public const int GROUP_USUALLY = 0x10000;
public const int GROUP_SETTING = 0x20000;
public const int GROUP_HARDWARE = 0x40000;
public const int GROUP_SYSTEM = 0x80000;
public const int GROUP_FLSHPROG = 0x100000;
public const int STATUS_ERROR = int.MinValue;
public const int STATUS_USUALLY_IDLE = 0x10001;
public const int STATUS_USUALLY_PRINTING = 0x10002;
public const int STATUS_USUALLY_STANDSTILL = 0x10004;
public const int STATUS_USUALLY_PAPER_END = 0x10008;
public const int STATUS_USUALLY_RIBBON_END = 0x10010;
public const int STATUS_USUALLY_COOLING = 0x10020;
public const int STATUS_USUALLY_MOTCOOLING = 0x10020;
public const int STATUS_SETTING_COVER_OPEN = 0x20001;
public const int STATUS_SETTING_PAPER_JAM = 0x20002;
public const int STATUS_SETTING_RIBBON_ERR = 0x20004;
public const int STATUS_SETTING_PAPER_ERR = 0x20008;
public const int STATUS_SETTING_DATA_ERR = 0x20010;
public const int STATUS_SETTING_SCRAPBOX_ERR = 0x20020;
public const int STATUS_HARDWARE_ERR01 = 0x40001;
public const int STATUS_HARDWARE_ERR02 = 0x40002;
public const int STATUS_HARDWARE_ERR03 = 0x40004;
public const int STATUS_HARDWARE_ERR04 = 0x40008;
public const int STATUS_HARDWARE_ERR05 = 0x40010;
public const int STATUS_HARDWARE_ERR06 = 0x40020;
public const int STATUS_HARDWARE_ERR07 = 0x40040;
public const int STATUS_HARDWARE_ERR08 = 0x40080;
public const int STATUS_HARDWARE_ERR09 = 0x40100;
public const int STATUS_HARDWARE_ERR10 = 0x40200;
public const int STATUS_SYSTEM_ERR01 = 0x80001;
public const int STATUS_FLSHPROG_IDLE = 0x100001;
public const int STATUS_FLSHPROG_WRITING = 0x100002;
public const int STATUS_FLSHPROG_FINISHED = 0x100004;
public const int STATUS_FLSHPROG_DATA_ERR1 = 0x100008;
public const int STATUS_FLSHPROG_DEVICE_ERR1 = 0x100010;
public const int STATUS_FLSHPROG_OTHERS_ERR1 = 0x100020;
public const int CVG_USUALLY = 0x10000;
public const int CVG_SETTING = 0x20000;
public const int CVG_HARDWARE = 0x40000;
public const int CVG_SYSTEM = 0x80000;
public const int CVG_FLSHPROG = 0x100000;
public const int CVSTATUS_ERROR = int.MinValue;
public const int CVS_USUALLY_IDLE = 0x10001;
public const int CVS_USUALLY_PRINTING = 0x10002;
public const int CVS_USUALLY_STANDSTILL = 0x10004;
public const int CVS_USUALLY_PAPER_END = 0x10008;
public const int CVS_USUALLY_RIBBON_END = 0x10010;
public const int CVS_USUALLY_COOLING = 0x10020;
public const int CVS_USUALLY_MOTCOOLING = 0x10040;
public const int CVS_SETTING_COVER_OPEN = 0x20001;
public const int CVS_SETTING_PAPER_JAM = 0x20002;
public const int CVS_SETTING_RIBBON_ERR = 0x20004;
public const int CVS_SETTING_PAPER_ERR = 0x20008;
public const int CVS_SETTING_DATA_ERR = 0x20010;
public const int CVS_SETTING_SCRAP_ERR = 0x20020;
public const int CVS_HARDWARE_ERR01 = 0x40001;
public const int CVS_HARDWARE_ERR02 = 0x40002;
public const int CVS_HARDWARE_ERR03 = 0x40004;
public const int CVS_HARDWARE_ERR04 = 0x40008;
public const int CVS_HARDWARE_ERR05 = 0x40010;
public const int CVS_HARDWARE_ERR06 = 0x40020;
public const int CVS_HARDWARE_ERR07 = 0x40040;
public const int CVS_HARDWARE_ERR08 = 0x40080;
public const int CVS_HARDWARE_ERR09 = 0x40100;
public const int CVS_HARDWARE_ERR10 = 0x40200;
public const int CVS_SYSTEM_ERR01 = 0x80001;
public const int CVS_FLSHPROG_IDLE = 0x100001;
public const int CVS_FLSHPROG_WRITING = 0x100002;
public const int CVS_FLSHPROG_FINISHED = 0x100004;
public const int CVS_FLSHPROG_DATA_ERR1 = 0x100008;
public const int CVS_FLSHPROG_DEVICE_ERR1 = 0x100010;
public const int CVS_FLSHPROG_OTHERS_ERR1 = 0x100020;
public const short CUTTER_MODE_STANDARD = 0;
public const short CUTTER_MODE_NONSCRAP = 1;
public const short CUTTER_MODE_2INCHCUT = 120;
public const string path = "CyStat64.dll";
#pragma warning disable CS0618 // 类型或成员已过时
[DllImport(path, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public static extern int CvInitialize([MarshalAs(UnmanagedType.LPWStr)] string pszPortName);
[DllImport(path, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public static extern int CvGetVersion(int lPortNum, [MarshalAs(UnmanagedType.VBByRefStr)] ref string s);
[DllImport(path, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public static extern int CvGetSensorInfo(int lPortNum, [MarshalAs(UnmanagedType.VBByRefStr)] ref string s);
[DllImport(path, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public static extern int CvGetMedia(int lPortNum, [MarshalAs(UnmanagedType.VBByRefStr)] ref string s);
[DllImport(path, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public static extern int CvGetStatus(int lPortNum);
[DllImport(path, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public static extern int CvGetPQTY(int lPortNum);
[DllImport(path, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public static extern int CvGetCounterL(int lPortNum);
[DllImport(path, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public static extern int CvGetCounterA(int lPortNum);
[DllImport(path, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public static extern int CvGetCounterB(int lPortNum);
[DllImport(path, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public static extern int CvGetMediaCounter(int lPortNum);
[DllImport(path, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public static extern int CvGetMediaColorOffset(int lPortNum);
[DllImport(path, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public static extern int CvGetMediaLotNo(int lPortNum, [MarshalAs(UnmanagedType.VBByRefStr)] ref string s);
[DllImport(path, CharSet = CharSet.Ansi, EntryPoint = "CvSetColorDataVersion", ExactSpelling = true, SetLastError = true)]
public static extern int CvSetColorDataVersion_(int lPortNum, long lpBuff, int bLen);
[DllImport(path, CharSet = CharSet.Ansi, EntryPoint = "SetColorDataWrite", ExactSpelling = true, SetLastError = true)]
public static extern int CvSetColorDataWrite_(int lPortNum, long lpBuff, int bLen);
[DllImport(path, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public static extern int CvGetColorDataVersion(int lPortNum, [MarshalAs(UnmanagedType.VBByRefStr)] ref string s);
[DllImport(path, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public static extern int CvSetColorDataClear(int lPortNum);
[DllImport(path, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public static extern int CvGetColorDataChecksum(int lPortNum, [MarshalAs(UnmanagedType.VBByRefStr)] ref string s);
[DllImport(path, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public static extern int CvGetSerialNo(int lPortNum, [MarshalAs(UnmanagedType.VBByRefStr)] ref string s);
[DllImport(path, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public static extern int CvGetResolutionH(int lPortNum);
[DllImport(path, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public static extern int CvGetResolutionV(int lPortNum);
[DllImport(path, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public static extern int CvGetFreeBuffer(int lPortNum);
[DllImport(path, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public static extern int CvSetClearCounterA(int lPortNum);
[DllImport(path, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public static extern int CvSetClearCounterB(int lPortNum);
[DllImport(path, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public static extern int CvSetFirmwUpdateMode(int lPortNum);
[DllImport(path, CharSet = CharSet.Ansi, EntryPoint = "SetFirmwDataWrite", ExactSpelling = true, SetLastError = true)]
public static extern int CvSetFirmwDataWrite_(int lPortNum, long lpBuff, int bLen);
[DllImport(path, CharSet = CharSet.Ansi, EntryPoint = "CvSetCommand", ExactSpelling = true, SetLastError = true)]
public static extern int CvSetCommand_(int lPortNum, long lpCmd, int dwCmdLen);
[DllImport(path, CharSet = CharSet.Ansi, EntryPoint = "CvGetCommand", ExactSpelling = true, SetLastError = true)]
public static extern int CvGetCommand_(int lPortNum, long lpCmd, int dwCmdLen, [MarshalAs(UnmanagedType.VBByRefStr)] ref string lpRetBuff, int dwRetBuffSize, ref long lpdwRetLen);
[DllImport(path, CharSet = CharSet.Ansi, EntryPoint = "CvGetCommandEX", ExactSpelling = true, SetLastError = true)]
public static extern int CvGetCommandEX_(int lPortNum, long lpCmd, int dwCmdLen, [MarshalAs(UnmanagedType.VBByRefStr)] ref string lpRetBuff, int dwRetBuffSize);
[DllImport(path, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public static extern int PortInitialize([MarshalAs(UnmanagedType.LPWStr)] string pszPortName);
[DllImport(path, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public static extern int GetFirmwVersion(int lPortNum, [MarshalAs(UnmanagedType.VBByRefStr)] ref string s);
[DllImport(path, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public static extern int GetSensorInfo(int lPortNum, [MarshalAs(UnmanagedType.VBByRefStr)] ref string s);
[DllImport(path, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public static extern int GetMedia(int lPortNum, [MarshalAs(UnmanagedType.VBByRefStr)] ref string s);
[DllImport(path, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public static extern int GetStatus(int lPortNum);
[DllImport(path, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public static extern int GetPQTY(int lPortNum);
[DllImport(path, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public static extern int GetCounterL(int lPortNum);
[DllImport(path, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public static extern int GetCounterA(int lPortNum);
[DllImport(path, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public static extern int GetCounterB(int lPortNum);
[DllImport(path, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public static extern int GetCounterP(int lPortNum);
[DllImport(path, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public static extern int GetCounterMatte(int lPortNum);
[DllImport(path, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public static extern int GetCounterM(int lPortNum);
[DllImport(path, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public static extern int GetMediaCounter(int lPortNum);
[DllImport(path, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public static extern int GetMediaCounter_R(int lPortNum);
[DllImport(path, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public static extern int GetMediaColorOffset(int lPortNum);
[DllImport(path, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public static extern int GetMediaLotNo(int lPortNum, [MarshalAs(UnmanagedType.VBByRefStr)] ref string s);
[DllImport(path, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public static extern int GetMediaIdSetInfo(int lPortNum);
[DllImport(path, CharSet = CharSet.Ansi, EntryPoint = "SetColorDataVersion", ExactSpelling = true, SetLastError = true)]
public static extern int SetColorDataVersion_(int lPortNum, long lpBuff, int bLen);
[DllImport(path, CharSet = CharSet.Ansi, EntryPoint = "SetColorDataWrite", ExactSpelling = true, SetLastError = true)]
public static extern int SetColorDataWrite_(int lPortNum, long lpBuff, int bLen);
[DllImport(path, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public static extern int GetColorDataVersion(int lPortNum, [MarshalAs(UnmanagedType.VBByRefStr)] ref string s);
[DllImport(path, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public static extern int SetColorDataClear(int lPortNum);
[DllImport(path, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public static extern int GetColorDataChecksum(int lPortNum, [MarshalAs(UnmanagedType.VBByRefStr)] ref string s);
[DllImport(path, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public static extern int GetSerialNo(int lPortNum, [MarshalAs(UnmanagedType.VBByRefStr)] ref string s);
[DllImport(path, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public static extern int GetResolutionH(int lPortNum);
[DllImport(path, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public static extern int GetResolutionV(int lPortNum);
[DllImport(path, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public static extern int GetFreeBuffer(int lPortNum);
[DllImport(path, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public static extern int SetClearCounterA(int lPortNum);
[DllImport(path, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public static extern int SetClearCounterB(int lPortNum);
[DllImport(path, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public static extern int SetClearCounterM(int lPortNum);
[DllImport(path, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public static extern int SetCounterP(int lPortNum, int Counter);
[DllImport(path, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public static extern int SetFirmwUpdateMode(int lPortNum);
[DllImport(path, CharSet = CharSet.Ansi, EntryPoint = "SetFirmwDataWrite", ExactSpelling = true, SetLastError = true)]
public static extern int SetFirmwDataWrite_(int lPortNum, long lpBuff, int bLen);
[DllImport(path, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public static extern int SetCutterMode(int lPortNum, int d);
[DllImport(path, CharSet = CharSet.Ansi, EntryPoint = "SetCommand", ExactSpelling = true, SetLastError = true)]
public static extern int SetCommand_(int lPortNum, long lpCmd, int dwCmdLen);
[DllImport(path, CharSet = CharSet.Ansi, EntryPoint = "GetCommand", ExactSpelling = true, SetLastError = true)]
public static extern int GetCommand_(int lPortNum, long lpCmd, int dwCmdLen, [MarshalAs(UnmanagedType.VBByRefStr)] ref string lpRetBuff, int dwRetBuffSize, ref long lpdwRetLen);
[DllImport(path, CharSet = CharSet.Ansi, EntryPoint = "GetCommandEX", ExactSpelling = true, SetLastError = true)]
public static extern int GetCommandEX_(int lPortNum, long lpCmd, int dwCmdLen, [MarshalAs(UnmanagedType.VBByRefStr)] ref string lpRetBuff, int dwRetBuffSize);
[DllImport(path, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public static extern int GetRfidMediaClass(int lPortNum, [MarshalAs(UnmanagedType.VBByRefStr)] ref string s);
[DllImport(path, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public static extern int GetRfidReserveData(int lPortNum, [MarshalAs(UnmanagedType.VBByRefStr)] ref string s, int dwPage);
[DllImport(path, CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public static extern int GetInitialMediaCount(int lPortNum);
#pragma warning restore CS0618 // 类型或成员已过时
public static void SendFileToPrinter(string printname, string szFileName)
{
PrintDocument pd = new PrintDocument();
pd.DocumentName = szFileName;
pd.PrintPage += PicturePrintDocument_PrintPage; //注册打印事件
pd.Print();
}
private static void PicturePrintDocument_PrintPage(object sender, PrintPageEventArgs e)
{
var pd = (PrintDocument)sender;
//打开文件
FileStream fs = File.OpenRead(pd.DocumentName);
//转换为BYTE
int filelength = (int)fs.Length;
byte[] imageByte = new byte[filelength]; //建立一个字节数组
fs.Read(imageByte, 0, filelength); //按字节流读取
//转换为 IMAGE
System.Drawing.Image image = System.Drawing.Image.FromStream(fs);
fs.Close();
e.Graphics.DrawImage(image, 0, 0); //img大小
//e.Graphics.DrawString(TicCode, DrawFont, brush, 600, 600); //绘制字符串
e.HasMorePages = false;
}
}
}

View File

@ -0,0 +1,96 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace PrinterClient;
/// <summary>
/// 版本信息
/// </summary>
static class ReadMe
{
public static string AppName { get => "PrinterClient"; }
public static string Version => Versions.First().Key;
static readonly Dictionary<string, List<string>> Versions = new()
{
["1.1.0 Alpha Bulid 20231018"] = new List<string>()
{
"删除: 检测打印机更换功能",
"删除: 打印机驱动加载功能",
"删除: 打印机参数设置功能",
"修改: 发送给调试软件日志时延时1s变为不延时",
"修改: 打印成功后, 延时5s上传状态",
"添加: 驱动加载、打印、参数设置由脚本完成",
},
["1.0.9 Alpha Bulid 20230913"] = new List<string>()
{
"修改若干BUG",
},
["1.0.8 Alpha Bulid 20230829"] = new List<string>()
{
"修改若干BUG",
},
["1.0.7 Alpha Bulid 20230207"] = new List<string>()
{
"添加重启系统及应用指令",
},
["1.0.6 Alpha Bulid 20230109"] = new List<string>()
{
"添加打印机序列号获取及上传",
"启动时主动添加一次打印机驱动",
},
["1.0.5 Alpha Bulid 20221220"] = new List<string>()
{
"添加打印超时的状态上传"
},
["1.0.4 Alpha Bulid 20221027"] = new List<string>()
{
"打印任务超时后, 进行任务清空的操作",
"检测不到默认打印机时,重新设置默认打印机",
"添加打印失败后重新尝试打印的操作",
"打印超时问题未解决"
},
["1.0.3 Alpha Bulid 20220307"] = new List<string>()
{
"添加: 设置打印机打印格式、类型、尺寸",
},
["1.0.2 Alpha Bulid 20211208"] = new List<string>()
{
"修复: 没有正确识别打印机休眠状态",
"修复: 重连导致服务器过多连接",
"添加: 打印机禁用状态下, 发送激活命令启用打印机",
},
["1.0.1 Alpha Bulid 20211105"] = new List<string>()
{
"实现升级功能",
"添加设置信息",
},
["1.0.0 Alpha Bulid 20211103"] = new List<string>()
{
"实现基本功能",
},
};
public static void Bulid()
{
var path = Path.GetDirectoryName(typeof(Program).Module.FullyQualifiedName);
using FileStream fr = new(Path.Combine(path, "ReadMe.md"), FileMode.OpenOrCreate, FileAccess.Write, FileShare.ReadWrite);
using StreamWriter sw = new(fr, Encoding.UTF8);
StringBuilder sb = new();
sb.AppendLine($"# {AppName} 版本历史介绍").AppendLine();
foreach (var item in Versions)
{
sb.AppendLine($"## {item.Key}");
foreach (var value in item.Value)
sb.AppendLine($"* {value}");
sb.AppendLine();
}
sb.Remove(sb.Length - 2, 2);
sw.Write(sb);
}
}

View File

@ -0,0 +1,485 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading;
namespace PrinterClient
{
public enum BoxStatus : int
{
/// <summary>
/// 正常
/// </summary>
Normal = 0,
/// <summary>
/// 异常
/// </summary>
Failed = 201,
/// <summary>
/// 下载中
/// </summary>
Download = 104,
/// <summary>
/// 升级中
/// </summary>
Upgrade = 301,
}
public enum PrinterStatus : int
{
/// <summary>
/// 正常
/// </summary>
Normal = 101,
/// <summary>
/// 打印中
/// </summary>
Printing = 102,
/// <summary>
/// 等待文件下载
/// </summary>
Waiting_For_File_Download = 104,
/// <summary>
/// 检测中
/// </summary>
Testing = 109,
/// <summary>
/// 无纸
/// </summary>
NoPaper = 201,
/// <summary>
/// 休眠
/// </summary>
Sleep = 302,
/// <summary>
/// 未驱动
/// </summary>
NotDriven = 306,
/// <summary>
/// 驱动失败
/// </summary>
DriveFailed = 310,
/// <summary>
/// 维护
/// </summary>
Maintenance = 209,
}
public class TaskDispatcher
{
public static bool ExecuteCommand(string fileName, string arguments, out string output)
{
output = string.Empty;
/* 创建一个ProcessStartInfo对象 使用系统shell 指定命令和参数 设置标准输出 */
var startInfo = new ProcessStartInfo(fileName, arguments)
{
RedirectStandardOutput = true
};
/* 启动 */
var process = Process.Start(startInfo);
if (process != null)
{
/* 开始读取 */
using (var streamReader = process.StandardOutput)
{
while (!streamReader.EndOfStream)
{
output += streamReader.ReadLine() + "\r\n";
}
if (!process.HasExited)
{
process.Kill();
}
}
return true;
}
return false;
}
public static void AsyncExecuteCommand(string fileName, string arguments)
{
LogUtils.AppendLog(fileName + " " + arguments);
/* 创建一个ProcessStartInfo对象 使用系统shell 指定命令和参数 设置标准输出 */
var startInfo = new ProcessStartInfo(fileName, arguments)
{
RedirectStandardOutput = true
};
Process.Start(startInfo);
}
}
public class Printer
{
/// <summary>
/// 当前是否正在打印
/// </summary>
public static bool Printing = false;
private static int rx1_handle = -1;
public static int BoxStatus { get; set; } = (int)PrinterClient.BoxStatus.Normal;
public static int Status
{
get
{
var value = GetStatus();
switch (value)
{
case PrinterStatus.Normal:
if (BoxStatus == (int)PrinterClient.BoxStatus.Download)
return (int)PrinterStatus.Waiting_For_File_Download;
else
return (int)PrinterStatus.Normal;
default:
return (int)value;
}
}
}
/* 序列号 */
public static string Serial = "";
private static void FindSerial()
{
/* 获取打印机信息 */
if (TaskDispatcher.ExecuteCommand("lpinfo", "-v", out string result))
{
if (result.IndexOf("gutenprint52+usb://Dai+Nippon+Printing/Photo+Printer?serial=") == -1)
{
return;
}
var arrays = result.Split(new char[] { '\r', '\n' });
var directs = arrays.ToList().FindAll(ar => ar.IndexOf("gutenprint52+usb://Dai+Nippon+Printing/Photo+Printer?serial=") != -1);
string code = "";
foreach (var direct in directs)
{
int a = direct.LastIndexOf("serial="), b = direct.LastIndexOf("&backend");
if (a == -1 || b == -1)
continue;
code = direct.Substring(a + 7, b - a - 7);
if (code.IndexOf("NONE_UNKNOWN") != -1)
continue;
break;
}
if (code.Equals("NONE_UNKNOWN"))
Serial = "";
else
Serial = code;
}
}
private static PrinterStatus GetStatus()
{
PrinterStatus status = PrinterStatus.Normal;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
if (rx1_handle == -1)
rx1_handle = CyStatus.PortInitialize("USB001");
var res = CyStatus.GetStatus(rx1_handle);
if (res == int.MinValue)
return PrinterStatus.DriveFailed;
else
{
switch (res)
{
case CyStatus.STATUS_USUALLY_IDLE:
return PrinterStatus.Normal;
case CyStatus.STATUS_USUALLY_PRINTING:
return PrinterStatus.Printing;
case CyStatus.STATUS_USUALLY_PAPER_END:
return PrinterStatus.NoPaper;
}
}
}
else
{
string result;
/* 通过查找打印机序列号来判断打印机是否连接 */
for (int i = 0; i < 6; i++)
{
FindSerial();
if (!string.IsNullOrEmpty(Serial))
break;
}
if (string.IsNullOrEmpty(Serial))
return PrinterStatus.NotDriven;
/* 检查默认打印机 */
for (int i = 0; i < 3; i++)
{
if (TaskDispatcher.ExecuteCommand("lpstat", "-d", out result))
{
if (result.IndexOf("system default destination: DS-RX1HS") == -1)
{
/* 如果此时正在打印, 那么出现这种状况是有可能的, 先认为正常 */
if(Printing)
return PrinterStatus.Normal;
else
Program.DebugWriteLine($"未找到默认打印机");
}
else
{
status = PrinterStatus.Normal;
break;
}
}
Thread.Sleep(10000);
}
if (status == PrinterStatus.DriveFailed)
return status;
/* 检查是否处于打印中的状态 */
if (TaskDispatcher.ExecuteCommand("lpq", "", out result))
{
//Console.WriteLine($"打印机当前状态:{status}");
if (!result.Contains("no entries"))
return PrinterStatus.Printing;
}
/* 检查打印机空闲状态 */
if (TaskDispatcher.ExecuteCommand("lpstat", "-p", out result))
{
if (result.IndexOf("printer DS-RX1HS is idle.") == -1)
{
/* 激活打印机 */
TaskDispatcher.ExecuteCommand("cupsenable", "DS-RX1HS", out _);
/* 设置为接受作业 */
TaskDispatcher.ExecuteCommand("cupsaccept", "DS-RX1HS", out _);
return PrinterStatus.Sleep;
}
}
}
return status;
}
/// <summary>
/// 删除任务
/// </summary>
/// <param name="job">工作序号</param>
public static void Delete(string job)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
TaskDispatcher.ExecuteCommand("lprm", job, out _);
}
}
/// <summary>
/// 清空任务
/// </summary>
public static void Clear() => Delete("");
/// <summary>
/// 获取打印队列
/// </summary>
/// <returns></returns>
public static List<LprEntries> QueryEntries()
{
List<LprEntries> lprEntries = new();
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
if (TaskDispatcher.ExecuteCommand("lpq", "", out string result))
{
lprEntries.Clear();
Console.WriteLine(result);
if (result.Contains("no entries"))
return null;
/* 根据文件查找job */
var array = result.Split("\r\n");
for (int a = 2; a < array.Length; a++)
{
string temporary_data = "";
List<string> temporary_datas = new();
for (int b = 0; b < array[a].Length; b++)
{
if (array[a][b] == ' ')
{
if (temporary_data != "")
{
temporary_datas.Add(temporary_data);
temporary_data = "";
}
}
else
{
temporary_data += array[a][b];
if (b == array[a].Length - 1)
temporary_datas.Add(temporary_data);
}
}
if (temporary_datas.Count == 6)
{
lprEntries.Add(new LprEntries() { Rank = temporary_datas[0], Owner = temporary_datas[1], Job = temporary_datas[2], File = temporary_datas[3], TotalSize = temporary_datas[4] + " " + temporary_datas[5] });
}
}
}
}
return lprEntries;
}
/// <summary>
/// 打印
/// </summary>
/// <param name="file">文件</param>
/// <returns></returns>
public static bool Print(string file_format_id, string print_mode_id, string print_size_id, string file, out string job)
{
job = string.Empty;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
CyStatus.SendFileToPrinter("DS-RX1", file);
return true;
}
else
{
//TaskDispatcher.AsyncExecuteCommand("lpr", file);
//TaskDispatcher.ExecuteCommand("PrintPhoto", $"DS-RX1HS {file}", out string result);
string file_format = "TextGraphics", print_mode = "RGB", print_size = "B7";
switch (file_format_id)
{
case "29": file_format = "Text"; break;
case "30": file_format = "Graphics"; break;
case "31": file_format = "TextGraphics"; break;
case "32": file_format = "Photo"; break;
case "33": file_format = "LineArt"; break;
}
switch (print_mode_id)
{
case "1": print_mode = "RGB"; break;
case "2": print_mode = "Gray"; break;
case "3": print_mode = "Black"; break;
case "4": print_mode = "CMY"; break;
case "5": print_mode = "CMYK"; break;
case "6": print_mode = "KCMY"; break;
}
switch (print_size_id)
{
case "5": print_size = "B7"; break;
case "6": print_size = "w288h432"; break;
case "7": print_size = "w360h504"; break;
case "8": print_size = "A5"; break;
}
TaskDispatcher.ExecuteCommand("./printer.sh", $"{file_format} {print_mode} {print_size} {file}", out string result);
Console.WriteLine(result);
if (file == "")
file = "(stdin)";
var lprEntries = QueryEntries();
int count = 3;
while (count-- > 0)
{
if (lprEntries.Count > 0) break;
Thread.Sleep(10000);
lprEntries = QueryEntries();
}
var enteries = lprEntries?.Find(ar => ar.File.Replace(".jpg", "").Equals(file.Replace(Program.ImagePath, "").Replace(".jpg", "")));
if (enteries != null)
{
job = enteries.Job;
Console.WriteLine($"Rank = {enteries.Rank}, Job = {enteries.Job}, File = {enteries.File}, TotalSize = {enteries.TotalSize}");
return true;
}
}
return false;
}
public static void SetProperty(string name, string value) => TaskDispatcher.AsyncExecuteCommand("lpoptions", $"-o {name}={value}");
public static bool GetProperty(string name, out string value)
{
value = string.Empty;
try
{
if (TaskDispatcher.ExecuteCommand("lpoptions", $"-l", out string result))
{
result = result.Split(new char[] { '\n', '\r' }).ToList().Find(s => s.IndexOf(name) != -1);
value = result.Split(' ').ToList().Find(s => s[0] == '*').Remove(0, 1);
return true;
}
}
catch { }
return false;
}
}
public class LprEntries
{
public string Rank { get; set; }
public string Owner { get; set; }
public string Job { get; set; }
public string File { get; set; }
public string TotalSize { get; set; }
}
}

View File

@ -0,0 +1,30 @@
using System;
using System.IO;
using System.Text;
using ProtoBuf;
namespace PrinterClient
{
public static class ByteUtils
{
public static byte[] Serialize<T>(this T t)
{
using MemoryStream ms = new();
Serializer.Serialize<T>(ms, t);
return ms.ToArray();
}
public static T Deserialize<T>(this byte[] content, int index, int count)
{
using MemoryStream ms = new(content, index, count);
return Serializer.Deserialize<T>(ms);
}
public static T Deserialize<T>(this string content)
{
using MemoryStream ms = new(Encoding.UTF8.GetBytes(content));
return Serializer.Deserialize<T>(ms);
}
}
}

View File

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Net.Sockets;
using System.Net;
using System.Text;
namespace PrinterClient.Utils
{
public class DeviceUtils
{
public static string GetLocalIP()
{
string address = string.Empty;
using (Socket socket = new(AddressFamily.InterNetwork, SocketType.Dgram, 0))
{
socket.Connect("8.8.8.8", 65530);
address = (socket.LocalEndPoint as IPEndPoint).Address.ToString();
}
return address;
}
}
}

View File

@ -0,0 +1,74 @@
using System;
using System.IO;
using System.Text;
namespace PrinterClient;
public class FileUtils
{
public static long Size(string fullpath) { try { return new FileInfo(fullpath).Length; } catch { return 0; } }
public static string GetName(string fullpath) { try { return new FileInfo(fullpath).Name; } catch { return ""; } }
public static string ReadString(string fullpath) { try { return File.ReadAllText(fullpath); } catch { return null; } }
public static byte[] ReadBytes(string fullpath) { try { return File.ReadAllBytes(fullpath); } catch { return new byte[] { }; } }
public static void Append(string fullpath, string contents)
{
try
{
Directory.CreateDirectory(fullpath.Substring(0, fullpath.LastIndexOf("/")));
using FileStream fr = new FileStream(fullpath, FileMode.Append, FileAccess.Write, FileShare.ReadWrite);
using StreamWriter sw = new StreamWriter(fr, Encoding.UTF8);
sw.WriteLine(contents);
}
catch { }
}
public static void Append(string fullpath, byte[] contents)
{
try
{
Directory.CreateDirectory(fullpath.Substring(0, fullpath.LastIndexOf("/")));
using FileStream fr = new FileStream(fullpath, FileMode.Append, FileAccess.Write, FileShare.ReadWrite);
fr.Write(contents, 0, contents.Length);
}
catch { }
}
public static void Append(string fullpath, byte[] contents, int offset, int count)
{
try
{
Directory.CreateDirectory(fullpath.Substring(0, fullpath.LastIndexOf("/")));
using FileStream fr = new FileStream(fullpath, FileMode.Append, FileAccess.Write, FileShare.ReadWrite);
fr.Write(contents, offset, count);
}
catch { }
}
public static void WriteFile(string fullpath, string contents)
{
try
{
Directory.CreateDirectory(fullpath.Substring(0, fullpath.LastIndexOf("/")));
using FileStream fr = new FileStream(fullpath, FileMode.Create, FileAccess.Write, FileShare.ReadWrite);
using StreamWriter sw = new StreamWriter(fr, Encoding.UTF8);
sw.WriteLine(contents);
}
catch { }
}
public static void WriteFile(string fullpath, byte[] contents)
{
try
{
Directory.CreateDirectory(fullpath.Substring(0, fullpath.LastIndexOf("/")));
using FileStream fr = new FileStream(fullpath, FileMode.Create, FileAccess.Write, FileShare.ReadWrite);
fr.Write(contents, 0, contents.Length);
}
catch { }
}
}

View File

@ -0,0 +1,44 @@
using System;
using System.IO;
namespace PrinterClient;
public class LogUtils
{
public static string filepath { get; set; } = "Log";
public static void AppendLog(string message)
{
Console.WriteLine(message);
FileUtils.Append(Path.Combine(filepath, DateTime.Now.ToString("yyyyMMdd"), "Log.log"), $"{DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")} {message}");
}
public static void AppendLog(string filename, string message)
{
Console.WriteLine(message);
FileUtils.Append(Path.Combine(filepath, DateTime.Now.ToString("yyyyMMdd"), filename), $"{DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")} {message}");
}
public static void AppendError(string message)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(message);
Console.ForegroundColor = ConsoleColor.White;
FileUtils.Append(Path.Combine(filepath, DateTime.Now.ToString("yyyyMMdd"), "Error.log"), $"{DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")} {message}");
}
public static void AppendError(string filename, string message)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(message);
Console.ForegroundColor = ConsoleColor.White;
FileUtils.Append(Path.Combine(filepath, DateTime.Now.ToString("yyyyMMdd"), filename), $"{DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")} {message}");
}
public static void AppendError(Exception ex) => AppendError($"exception Message:{ex.Message}, StackTrace:{ex.StackTrace}");
public static void AppendError(string filename, Exception ex) => AppendError(filename, $"exception Message:{ex.Message}, StackTrace:{ex.StackTrace}");
}

View File

@ -0,0 +1,38 @@
using System;
using System.Collections.Concurrent;
namespace PrinterClient
{
public class TimerUtils
{
private static ConcurrentDictionary<string, DateTime> Records = new ConcurrentDictionary<string, DateTime>();
public static bool IsInterval(string name, double millsecond)
{
DateTime record = DateTime.MinValue;
if (!Records.ContainsKey(name)) Records.TryAdd(name, DateTime.Now.AddMilliseconds(millsecond * -1));
if(Records.TryGetValue(name, out record))
{
/* 时间发生异常改变时 */
if (Math.Abs((DateTime.Now - record).TotalDays) > 1 || Math.Abs(DateTime.Now.Day - record.Day) >= 1)
{
Records.TryUpdate(name, DateTime.Now, record);
return false;
}
if ((DateTime.Now - record).TotalMilliseconds > millsecond)
{
Records.TryUpdate(name, DateTime.Now, record);
return true;
}
else
return false;
}
else return false;
}
}
}

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="address" value="121.33.72.228"/>
<add key="port" value="8007"/>
<add key="debugging" value="true"/>
<add key="image_save" value="false"/>
</appSettings>
</configuration>

View File

@ -0,0 +1,351 @@
// This file was generated by a tool; you should avoid making direct changes.
// Consider using 'partial classes' to extend these types
// Input: protocol.proto
#pragma warning disable CS1591, CS0612, CS3021
namespace Google.Protobuf.WellKnownTypes
{
[global::ProtoBuf.ProtoContract()]
public partial class CommonResponse
{
[global::ProtoBuf.ProtoMember(1)]
[global::System.ComponentModel.DefaultValue("")]
public string equipNo { get; set; } = "";
[global::ProtoBuf.ProtoMember(2)]
[global::System.ComponentModel.DefaultValue("")]
public string equipCode { get; set; } = "";
[global::ProtoBuf.ProtoMember(3, Name = @"status")]
[global::System.ComponentModel.DefaultValue("")]
public string Status { get; set; } = "";
[global::ProtoBuf.ProtoMember(4, Name = @"remark")]
[global::System.ComponentModel.DefaultValue("")]
public string Remark { get; set; } = "";
}
[global::ProtoBuf.ProtoContract()]
public partial class TerminalStateUpdate
{
[global::ProtoBuf.ProtoMember(1)]
[global::System.ComponentModel.DefaultValue("")]
public string equipNo { get; set; } = "";
[global::ProtoBuf.ProtoMember(2)]
[global::System.ComponentModel.DefaultValue("")]
public string equipType { get; set; } = "";
[global::ProtoBuf.ProtoMember(3)]
[global::System.ComponentModel.DefaultValue("")]
public string equipCode { get; set; } = "";
[global::ProtoBuf.ProtoMember(4, Name = @"longitude")]
[global::System.ComponentModel.DefaultValue("")]
public string Longitude { get; set; } = "";
[global::ProtoBuf.ProtoMember(5, Name = @"latitude")]
[global::System.ComponentModel.DefaultValue("")]
public string Latitude { get; set; } = "";
[global::ProtoBuf.ProtoMember(6)]
[global::System.ComponentModel.DefaultValue("")]
public string equipVer { get; set; } = "";
[global::ProtoBuf.ProtoMember(7)]
[global::System.ComponentModel.DefaultValue("")]
public string equipTime { get; set; } = "";
[global::ProtoBuf.ProtoMember(8, Name = @"ip")]
[global::System.ComponentModel.DefaultValue("")]
public string Ip { get; set; } = "";
[global::ProtoBuf.ProtoMember(9)]
[global::System.ComponentModel.DefaultValue("")]
public string equipStatus { get; set; } = "";
[global::ProtoBuf.ProtoMember(10)]
[global::System.ComponentModel.DefaultValue("")]
public string printerStatus { get; set; } = "";
[global::ProtoBuf.ProtoMember(11)]
[global::System.ComponentModel.DefaultValue("")]
public string peripheralFeatureIds { get; set; } = "";
[global::ProtoBuf.ProtoMember(12)]
[global::System.ComponentModel.DefaultValue("")]
public string printerCode { get; set; } = "";
}
[global::ProtoBuf.ProtoContract()]
public partial class TerminalPrintTaskState
{
[global::ProtoBuf.ProtoMember(1)]
[global::System.ComponentModel.DefaultValue("")]
public string equipNo { get; set; } = "";
[global::ProtoBuf.ProtoMember(2)]
[global::System.ComponentModel.DefaultValue("")]
public string equipCode { get; set; } = "";
[global::ProtoBuf.ProtoMember(3)]
[global::System.ComponentModel.DefaultValue("")]
public string printOrderCode { get; set; } = "";
[global::ProtoBuf.ProtoMember(4, Name = @"status")]
[global::System.ComponentModel.DefaultValue("")]
public string Status { get; set; } = "";
[global::ProtoBuf.ProtoMember(5)]
[global::System.ComponentModel.DefaultValue("")]
public string printerStatus { get; set; } = "";
}
[global::ProtoBuf.ProtoContract()]
public partial class TerminalPrintTask
{
[global::ProtoBuf.ProtoMember(1)]
[global::System.ComponentModel.DefaultValue("")]
public string printOrderCode { get; set; } = "";
[global::ProtoBuf.ProtoMember(2)]
[global::System.ComponentModel.DefaultValue("")]
public string equipNo { get; set; } = "";
[global::ProtoBuf.ProtoMember(3)]
[global::System.ComponentModel.DefaultValue("")]
public string equipCode { get; set; } = "";
[global::ProtoBuf.ProtoMember(4)]
[global::System.ComponentModel.DefaultValue("")]
public string fileFormatId { get; set; } = "";
[global::ProtoBuf.ProtoMember(5)]
[global::System.ComponentModel.DefaultValue("")]
public string printModeId { get; set; } = "";
[global::ProtoBuf.ProtoMember(6)]
[global::System.ComponentModel.DefaultValue("")]
public string mediaTypeId { get; set; } = "";
[global::ProtoBuf.ProtoMember(7)]
[global::System.ComponentModel.DefaultValue("")]
public string printTypeId { get; set; } = "";
[global::ProtoBuf.ProtoMember(8)]
[global::System.ComponentModel.DefaultValue("")]
public string copyCount { get; set; } = "";
[global::ProtoBuf.ProtoMember(9)]
[global::System.ComponentModel.DefaultValue("")]
public string borderlessTypeId { get; set; } = "";
[global::ProtoBuf.ProtoMember(10)]
[global::System.ComponentModel.DefaultValue("")]
public string printFileUrl { get; set; } = "";
[global::ProtoBuf.ProtoMember(11)]
[global::System.ComponentModel.DefaultValue("")]
public string printSizeId { get; set; } = "";
[global::ProtoBuf.ProtoMember(12)]
[global::System.ComponentModel.DefaultValue("")]
public string printPageNumber { get; set; } = "";
}
[global::ProtoBuf.ProtoContract()]
public partial class TerminalPrintTaskResult
{
[global::ProtoBuf.ProtoMember(1)]
[global::System.ComponentModel.DefaultValue("")]
public string equipNo { get; set; } = "";
[global::ProtoBuf.ProtoMember(2)]
[global::System.ComponentModel.DefaultValue("")]
public string equipCode { get; set; } = "";
[global::ProtoBuf.ProtoMember(3)]
[global::System.ComponentModel.DefaultValue("")]
public string printOrderCode { get; set; } = "";
[global::ProtoBuf.ProtoMember(4, Name = @"status")]
[global::System.ComponentModel.DefaultValue("")]
public string Status { get; set; } = "";
[global::ProtoBuf.ProtoMember(5, Name = @"remark")]
[global::System.ComponentModel.DefaultValue("")]
public string Remark { get; set; } = "";
}
[global::ProtoBuf.ProtoContract()]
public partial class TerminalCheckVersion
{
[global::ProtoBuf.ProtoMember(1)]
[global::System.ComponentModel.DefaultValue("")]
public string equipNo { get; set; } = "";
[global::ProtoBuf.ProtoMember(2)]
[global::System.ComponentModel.DefaultValue("")]
public string equipCode { get; set; } = "";
[global::ProtoBuf.ProtoMember(3, Name = @"type")]
[global::System.ComponentModel.DefaultValue("")]
public string Type { get; set; } = "";
[global::ProtoBuf.ProtoMember(4)]
[global::System.ComponentModel.DefaultValue("")]
public string versionCode { get; set; } = "";
}
[global::ProtoBuf.ProtoContract()]
public partial class TerminalCheckVersionResult
{
[global::ProtoBuf.ProtoMember(1)]
[global::System.ComponentModel.DefaultValue("")]
public string equipNo { get; set; } = "";
[global::ProtoBuf.ProtoMember(2)]
[global::System.ComponentModel.DefaultValue("")]
public string equipCode { get; set; } = "";
[global::ProtoBuf.ProtoMember(3)]
[global::System.ComponentModel.DefaultValue("")]
public string versionCode { get; set; } = "";
[global::ProtoBuf.ProtoMember(4)]
[global::System.ComponentModel.DefaultValue("")]
public string versionName { get; set; } = "";
[global::ProtoBuf.ProtoMember(5, Name = @"type")]
[global::System.ComponentModel.DefaultValue("")]
public string Type { get; set; } = "";
[global::ProtoBuf.ProtoMember(6)]
[global::System.ComponentModel.DefaultValue("")]
public string verUrl { get; set; } = "";
}
[global::ProtoBuf.ProtoContract()]
public partial class TerminalControl
{
[global::ProtoBuf.ProtoMember(1)]
[global::System.ComponentModel.DefaultValue("")]
public string equipNo { get; set; } = "";
[global::ProtoBuf.ProtoMember(2)]
[global::System.ComponentModel.DefaultValue("")]
public string equipCode { get; set; } = "";
[global::ProtoBuf.ProtoMember(3)]
[global::System.ComponentModel.DefaultValue("")]
public string orderCode { get; set; } = "";
[global::ProtoBuf.ProtoMember(4, Name = @"type")]
[global::System.ComponentModel.DefaultValue("")]
public string Type { get; set; } = "";
}
[global::ProtoBuf.ProtoContract()]
public partial class TerminalControlUpdate
{
[global::ProtoBuf.ProtoMember(1)]
[global::System.ComponentModel.DefaultValue("")]
public string equipNo { get; set; } = "";
[global::ProtoBuf.ProtoMember(2)]
[global::System.ComponentModel.DefaultValue("")]
public string equipCode { get; set; } = "";
[global::ProtoBuf.ProtoMember(3)]
[global::System.ComponentModel.DefaultValue("")]
public string orderCode { get; set; } = "";
[global::ProtoBuf.ProtoMember(4, Name = @"type")]
[global::System.ComponentModel.DefaultValue("")]
public string Type { get; set; } = "";
[global::ProtoBuf.ProtoMember(5, Name = @"status")]
[global::System.ComponentModel.DefaultValue("")]
public string Status { get; set; } = "";
}
[global::ProtoBuf.ProtoContract()]
public partial class PrintMessage
{
[global::ProtoBuf.ProtoMember(1)]
[global::System.ComponentModel.DefaultValue("")]
public string serialNo { get; set; } = "";
[global::ProtoBuf.ProtoMember(2, Name = @"source")]
[global::System.ComponentModel.DefaultValue("")]
public string Source { get; set; } = "";
[global::ProtoBuf.ProtoMember(3)]
public TaskType ecsType { get; set; }
[global::ProtoBuf.ProtoMember(4)]
public CommonResponse commandResponse { get; set; }
[global::ProtoBuf.ProtoMember(5)]
public TerminalStateUpdate terminalStateUpdate { get; set; }
[global::ProtoBuf.ProtoMember(6)]
public TerminalPrintTaskState terminalPrintTaskState { get; set; }
[global::ProtoBuf.ProtoMember(7)]
public TerminalPrintTask terminalPrintTask { get; set; }
[global::ProtoBuf.ProtoMember(8)]
public TerminalPrintTaskResult terminalPrintTaskResult { get; set; }
[global::ProtoBuf.ProtoMember(9)]
public TerminalCheckVersion terminalCheckVersion { get; set; }
[global::ProtoBuf.ProtoMember(10)]
public TerminalCheckVersionResult terminalCheckVersionResult { get; set; }
[global::ProtoBuf.ProtoMember(11)]
public TerminalControl terminalControl { get; set; }
[global::ProtoBuf.ProtoMember(12)]
public TerminalControlUpdate terminalControlUpdate { get; set; }
}
[global::ProtoBuf.ProtoContract()]
public enum TaskType
{
[global::ProtoBuf.ProtoEnum(Name = @"COMMON_RESPONSE")]
CommonResponse = 0,
[global::ProtoBuf.ProtoEnum(Name = @"TERMINAL_STATE_UPDATE")]
TerminalStateUpdate = 1,
[global::ProtoBuf.ProtoEnum(Name = @"TERMINAL_PRINTTASK_STATE")]
TerminalPrinttaskState = 2,
[global::ProtoBuf.ProtoEnum(Name = @"TERMINAL_PRINTTASK")]
TerminalPrinttask = 3,
[global::ProtoBuf.ProtoEnum(Name = @"TERMINAL_PRINTTASK_RESULT")]
TerminalPrinttaskResult = 4,
[global::ProtoBuf.ProtoEnum(Name = @"TERMINAL_CHECKVERSION")]
TerminalCheckversion = 5,
[global::ProtoBuf.ProtoEnum(Name = @"TERMINAL_CHECKVERSION_RESULT")]
TerminalCheckversionResult = 6,
[global::ProtoBuf.ProtoEnum(Name = @"TERMINAL_CONTROL")]
TerminalControl = 7,
[global::ProtoBuf.ProtoEnum(Name = @"TERMINAL_CONTROL_UPDATE")]
TerminalControlUpdate = 8,
}
}
#pragma warning restore CS1591, CS0612, CS3021

25
TestView/TestView.sln Normal file
View File

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.4.33403.182
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestView", "TestView\TestView.csproj", "{9BAA18D0-A437-4EB1-BB28-BA85A5F45B32}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9BAA18D0-A437-4EB1-BB28-BA85A5F45B32}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9BAA18D0-A437-4EB1-BB28-BA85A5F45B32}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9BAA18D0-A437-4EB1-BB28-BA85A5F45B32}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9BAA18D0-A437-4EB1-BB28-BA85A5F45B32}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {478FBF3F-6E9C-48EB-BA8F-82E28B0C2417}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
</startup>
</configuration>

View File

@ -0,0 +1,9 @@
<Application x:Class="TestView.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:TestView"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace TestView
{
/// <summary>
/// App.xaml 的交互逻辑
/// </summary>
public partial class App : Application
{
}
}

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd"></Weavers>

View File

@ -0,0 +1,141 @@
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. -->
<xs:element name="Weavers">
<xs:complexType>
<xs:all>
<xs:element name="Costura" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:all>
<xs:element minOccurs="0" maxOccurs="1" name="ExcludeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="IncludeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="ExcludeRuntimeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of runtime assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="IncludeRuntimeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of runtime assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="Unmanaged32Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of unmanaged 32 bit assembly names to include, delimited with line breaks.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="Unmanaged64Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of unmanaged 64 bit assembly names to include, delimited with line breaks.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="PreloadOrder" type="xs:string">
<xs:annotation>
<xs:documentation>The order of preloaded assemblies, delimited with line breaks.</xs:documentation>
</xs:annotation>
</xs:element>
</xs:all>
<xs:attribute name="CreateTemporaryAssemblies" type="xs:boolean">
<xs:annotation>
<xs:documentation>This will copy embedded files to disk before loading them into memory. This is helpful for some scenarios that expected an assembly to be loaded from a physical file.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="IncludeDebugSymbols" type="xs:boolean">
<xs:annotation>
<xs:documentation>Controls if .pdbs for reference assemblies are also embedded.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="IncludeRuntimeReferences" type="xs:boolean">
<xs:annotation>
<xs:documentation>Controls if runtime assemblies are also embedded.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="UseRuntimeReferencePaths" type="xs:boolean">
<xs:annotation>
<xs:documentation>Controls whether the runtime assemblies are embedded with their full path or only with their assembly name.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="DisableCompression" type="xs:boolean">
<xs:annotation>
<xs:documentation>Embedded assemblies are compressed by default, and uncompressed when they are loaded. You can turn compression off with this option.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="DisableCleanup" type="xs:boolean">
<xs:annotation>
<xs:documentation>As part of Costura, embedded assemblies are no longer included as part of the build. This cleanup can be turned off.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="LoadAtModuleInit" type="xs:boolean">
<xs:annotation>
<xs:documentation>Costura by default will load as part of the module initialization. This flag disables that behavior. Make sure you call CosturaUtility.Initialize() somewhere in your code.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="IgnoreSatelliteAssemblies" type="xs:boolean">
<xs:annotation>
<xs:documentation>Costura will by default use assemblies with a name like 'resources.dll' as a satellite resource and prepend the output path. This flag disables that behavior.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="ExcludeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with |</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="IncludeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of assembly names to include from the default action of "embed all Copy Local references", delimited with |.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="ExcludeRuntimeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of runtime assembly names to exclude from the default action of "embed all Copy Local references", delimited with |</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="IncludeRuntimeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of runtime assembly names to include from the default action of "embed all Copy Local references", delimited with |.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="Unmanaged32Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of unmanaged 32 bit assembly names to include, delimited with |.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="Unmanaged64Assemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of unmanaged 64 bit assembly names to include, delimited with |.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="PreloadOrder" type="xs:string">
<xs:annotation>
<xs:documentation>The order of preloaded assemblies, delimited with |.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:all>
<xs:attribute name="VerifyAssembly" type="xs:boolean">
<xs:annotation>
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="VerifyIgnoreCodes" type="xs:string">
<xs:annotation>
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="GenerateXsd" type="xs:boolean">
<xs:annotation>
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:schema>

View File

@ -0,0 +1,99 @@
<UserControl x:Class="TestView.Loading"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid Width="24" Height="24">
<Grid.Resources>
<DrawingBrush x:Key="brush" Stretch="None" AlignmentX="Center" AlignmentY="Top">
<DrawingBrush.Drawing>
<GeometryDrawing Brush="DarkCyan">
<GeometryDrawing.Geometry>
<EllipseGeometry RadiusX="1.5" RadiusY="4"/>
</GeometryDrawing.Geometry>
</GeometryDrawing>
</DrawingBrush.Drawing>
</DrawingBrush>
</Grid.Resources>
<Rectangle x:Name="r01" Fill="{StaticResource brush}" Opacity="1" RenderTransformOrigin="0.5,0.5">
<Rectangle.RenderTransform>
<RotateTransform Angle="0"/>
</Rectangle.RenderTransform>
</Rectangle>
<Rectangle x:Name="r02" Fill="{StaticResource brush}" Opacity="1" RenderTransformOrigin="0.5,0.5">
<Rectangle.RenderTransform>
<RotateTransform Angle="30"/>
</Rectangle.RenderTransform>
</Rectangle>
<Rectangle x:Name="r03" Fill="{StaticResource brush}" Opacity="1" RenderTransformOrigin="0.5,0.5">
<Rectangle.RenderTransform>
<RotateTransform Angle="60"/>
</Rectangle.RenderTransform>
</Rectangle>
<Rectangle x:Name="r04" Fill="{StaticResource brush}" Opacity="1" RenderTransformOrigin="0.5,0.5">
<Rectangle.RenderTransform>
<RotateTransform Angle="90"/>
</Rectangle.RenderTransform>
</Rectangle>
<Rectangle x:Name="r05" Fill="{StaticResource brush}" Opacity="1" RenderTransformOrigin="0.5,0.5">
<Rectangle.RenderTransform>
<RotateTransform Angle="120"/>
</Rectangle.RenderTransform>
</Rectangle>
<Rectangle x:Name="r06" Fill="{StaticResource brush}" Opacity="1" RenderTransformOrigin="0.5,0.5">
<Rectangle.RenderTransform>
<RotateTransform Angle="150"/>
</Rectangle.RenderTransform>
</Rectangle>
<Rectangle x:Name="r07" Fill="{StaticResource brush}" Opacity="1" RenderTransformOrigin="0.5,0.5">
<Rectangle.RenderTransform>
<RotateTransform Angle="180"/>
</Rectangle.RenderTransform>
</Rectangle>
<Rectangle x:Name="r08" Fill="{StaticResource brush}" Opacity="1" RenderTransformOrigin="0.5,0.5">
<Rectangle.RenderTransform>
<RotateTransform Angle="210"/>
</Rectangle.RenderTransform>
</Rectangle>
<Rectangle x:Name="r09" Fill="{StaticResource brush}" Opacity="1" RenderTransformOrigin="0.5,0.5">
<Rectangle.RenderTransform>
<RotateTransform Angle="240"/>
</Rectangle.RenderTransform>
</Rectangle>
<Rectangle x:Name="r10" Fill="{StaticResource brush}" Opacity="1" RenderTransformOrigin="0.5,0.5">
<Rectangle.RenderTransform>
<RotateTransform Angle="270"/>
</Rectangle.RenderTransform>
</Rectangle>
<Rectangle x:Name="r11" Fill="{StaticResource brush}" Opacity="1" RenderTransformOrigin="0.5,0.5">
<Rectangle.RenderTransform>
<RotateTransform Angle="300"/>
</Rectangle.RenderTransform>
</Rectangle>
<Rectangle x:Name="r12" Fill="{StaticResource brush}" Opacity="1" RenderTransformOrigin="0.5,0.5">
<Rectangle.RenderTransform>
<RotateTransform Angle="330"/>
</Rectangle.RenderTransform>
</Rectangle>
<Grid.Triggers>
<EventTrigger RoutedEvent="Grid.Loaded">
<BeginStoryboard>
<Storyboard RepeatBehavior="Forever">
<DoubleAnimation Storyboard.TargetName="r01" Storyboard.TargetProperty="Opacity" AutoReverse="True" Duration="0:0:0.08333" BeginTime="0:0:0.00000" To="0"/>
<DoubleAnimation Storyboard.TargetName="r02" Storyboard.TargetProperty="Opacity" AutoReverse="True" Duration="0:0:0.08333" BeginTime="0:0:0.08333" To="0"/>
<DoubleAnimation Storyboard.TargetName="r03" Storyboard.TargetProperty="Opacity" AutoReverse="True" Duration="0:0:0.08333" BeginTime="0:0:0.16666" To="0"/>
<DoubleAnimation Storyboard.TargetName="r04" Storyboard.TargetProperty="Opacity" AutoReverse="True" Duration="0:0:0.08333" BeginTime="0:0:0.24999" To="0"/>
<DoubleAnimation Storyboard.TargetName="r05" Storyboard.TargetProperty="Opacity" AutoReverse="True" Duration="0:0:0.08333" BeginTime="0:0:0.33332" To="0"/>
<DoubleAnimation Storyboard.TargetName="r06" Storyboard.TargetProperty="Opacity" AutoReverse="True" Duration="0:0:0.08333" BeginTime="0:0:0.41665" To="0"/>
<DoubleAnimation Storyboard.TargetName="r07" Storyboard.TargetProperty="Opacity" AutoReverse="True" Duration="0:0:0.08333" BeginTime="0:0:0.49998" To="0"/>
<DoubleAnimation Storyboard.TargetName="r08" Storyboard.TargetProperty="Opacity" AutoReverse="True" Duration="0:0:0.08333" BeginTime="0:0:0.58331" To="0"/>
<DoubleAnimation Storyboard.TargetName="r09" Storyboard.TargetProperty="Opacity" AutoReverse="True" Duration="0:0:0.08333" BeginTime="0:0:0.66664" To="0"/>
<DoubleAnimation Storyboard.TargetName="r10" Storyboard.TargetProperty="Opacity" AutoReverse="True" Duration="0:0:0.08333" BeginTime="0:0:0.74997" To="0"/>
<DoubleAnimation Storyboard.TargetName="r11" Storyboard.TargetProperty="Opacity" AutoReverse="True" Duration="0:0:0.08333" BeginTime="0:0:0.83330" To="0"/>
<DoubleAnimation Storyboard.TargetName="r12" Storyboard.TargetProperty="Opacity" AutoReverse="True" Duration="0:0:0.08333" BeginTime="0:0:0.91663" To="0"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Grid.Triggers>
</Grid>
</UserControl>

View File

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace TestView
{
/// <summary>
/// Loading.xaml 的交互逻辑
/// </summary>
public partial class Loading : UserControl
{
public Loading()
{
InitializeComponent();
}
}
}

View File

@ -0,0 +1,90 @@
<Window x:Class="TestView.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:TestView"
mc:Ignorable="d" Loaded="Window_Loaded"
Title="调试Demo" Height="660" Width="500">
<Window.Resources>
<Style TargetType="Label">
<Setter Property="Margin" Value="1"/>
<Setter Property="Width" Value="84"/>
<Setter Property="Height" Value="25"/>
</Style>
<Style TargetType="Button">
<Setter Property="Margin" Value="1"/>
<Setter Property="Width" Value="72"/>
<Setter Property="Height" Value="25"/>
</Style>
<Style TargetType="TextBox">
<Setter Property="Margin" Value="1"/>
<Setter Property="Height" Value="25"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
</Style>
</Window.Resources>
<StackPanel>
<DockPanel>
<Label DockPanel.Dock="Left">设备地址</Label>
<Button DockPanel.Dock="Right" Content="连接" Click="Connect_Click"/>
<TextBox Name="m_address" Text="teweishi.oicp.net"/>
</DockPanel>
<Label Content="设备状态" Width="Auto" FontWeight="Bold" HorizontalContentAlignment="Left"/>
<DockPanel>
<Label DockPanel.Dock="Left"/>
<Label DockPanel.Dock="Left" Content="更新时间"/>
<Label Width="Auto">
<TextBlock Text="{Binding DeviceStatus.DateTime, StringFormat=yyyy-MM-dd HH:mm:ss}"/>
</Label>
</DockPanel>
<DockPanel>
<Label DockPanel.Dock="Left"/>
<Label DockPanel.Dock="Left" Content="设备编号"/>
<Label Width="Auto" Content="{Binding DeviceStatus.Uuid}"/>
</DockPanel>
<DockPanel>
<Label DockPanel.Dock="Left"/>
<Label DockPanel.Dock="Left" Content="打印机序列号"/>
<Label Width="Auto" Content="{Binding DeviceStatus.Serial}"/>
</DockPanel>
<DockPanel>
<Label DockPanel.Dock="Left"/>
<Label DockPanel.Dock="Left" Content="服务器"/>
<Label Width="Auto">
<TextBlock Text="{Binding DeviceStatus.ServiceStatusString}" FontWeight="Bold" Foreground="{Binding DeviceStatus.ServiceStatusColor}"/>
</Label>
</DockPanel>
<DockPanel>
<Label DockPanel.Dock="Left"/>
<Label DockPanel.Dock="Left" Content="打印机"/>
<Label Width="Auto">
<TextBlock Text="{Binding DeviceStatus.PrinterStatusString}" FontWeight="Bold" Foreground="{Binding DeviceStatus.PrinterStatusColor}"/>
</Label>
</DockPanel>
<Label Content="任务状态" Width="Auto" FontWeight="Bold" HorizontalContentAlignment="Left"/>
<ListBox Name="m_taks_infos" ItemsSource="{Binding TaskInfos}" Height="400">
<ListBox.Resources>
<Style TargetType="ListBoxItem">
<EventSetter Event="MouseDoubleClick" Handler="TaskInfo_MouseDoubleClick"/>
</Style>
</ListBox.Resources>
<ListBox.ItemTemplate>
<DataTemplate>
<DockPanel>
<local:Loading DockPanel.Dock="Right" Visibility="{Binding Loading}" Margin="0 0 0 0"/>
<Label DockPanel.Dock="Top" FontWeight="Bold" Width="Auto" Content="{Binding ID}"/>
<Label DockPanel.Dock="Left" Width="Auto">
<TextBlock Text="{Binding DateTime, StringFormat=yyyy-MM-dd HH:mm:ss}"/>
</Label>
<Label DockPanel.Dock="Left" Content="{Binding Status}" Width="{Binding ActualWidth, ElementName=m_address, Mode=OneWay}" Margin="0 0 -30 0"/>
<Grid/>
</DockPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</StackPanel>
</Window>

View File

@ -0,0 +1,68 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace TestView
{
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
DataContext = TaskDispatcher.DataTemplate;
}
private void Connect_Click(object sender, RoutedEventArgs e)
{
var btn = (Button)sender;
if (btn.Content.ToString() == "连接")
{
if (TaskDispatcher.Connect(m_address.Text))
{
MessageBox.Show("连接成功", "消息", MessageBoxButton.OK, MessageBoxImage.Information);
}
//TaskDispatcher.DataTemplate.ImageSource = new BitmapImage(new Uri(@"C:\Users\hehaoyang\Pictures\Feedback\{9C69F6DD-7324-4AEA-8ABA-BB20372A38BF}\Capture001.png ", UriKind.Absolute));
btn.Content = "断开";
}
else
{
TaskDispatcher.Close();
btn.Content = "连接";
}
}
private void TaskInfo_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
var taskinfo = m_taks_infos.SelectedItem as TaskInfo;
if (taskinfo != null)
{
new TaskInfoWindow(taskinfo) { Left = this.Left + this.Width, Top = this.Top}.Show();
}
}
}
}

View File

@ -0,0 +1,55 @@
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("TestView")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("TestView")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
//若要开始生成可本地化的应用程序,请设置
//.csproj 文件中的 <UICulture>CultureYouAreCodingWith</UICulture>
//例如,如果您在源文件中使用的是美国英语,
//使用的是美国英语,请将 <UICulture> 设置为 en-US。 然后取消
//对以下 NeutralResourceLanguage 特性的注释。 更新
//以下行中的“en-US”以匹配项目文件中的 UICulture 设置。
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //主题特定资源词典所处位置
//(未在页面中找到资源时使用,
//或应用程序资源字典中找到时使用)
ResourceDictionaryLocation.SourceAssembly //常规资源词典所处位置
//(未在页面中找到资源时使用,
//、应用程序或任何主题专用资源字典中找到时使用)
)]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace TestView.Properties {
using System;
/// <summary>
/// 一个强类型的资源类,用于查找本地化的字符串等。
/// </summary>
// 此类是由 StronglyTypedResourceBuilder
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// 返回此类使用的缓存的 ResourceManager 实例。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TestView.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;
}
}
}
}

View File

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

View File

@ -0,0 +1,26 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace TestView.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.4.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;
}
}
}
}

View File

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

View File

@ -0,0 +1,383 @@
using Newtonsoft.Json;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Net.Sockets;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.ComponentModel;
using System.Windows.Media;
using System.IO;
using System.Windows.Media.Imaging;
using System.Collections.ObjectModel;
using System.Windows.Data;
using System.Windows;
namespace TestView
{
public class Model
{
public int type { get; set; }
public object msgInfo { get; set; }
public static Model Build(int type, object msgInfo) => new Model() { type = type, msgInfo = msgInfo };
public override string ToString()
{
return JsonConvert.SerializeObject(this);
}
public static Model Convert(string json)
{
var result = JsonConvert.DeserializeObject<Model>(json);
if (result == null)
return new Model();
return result;
}
private const string pattern = "{.+?}\n";
public static bool TryConvert(ref string json, out List<Model> models)
{
models = new List<Model>();
if (json.Length == 0)
return false;
/* 循环提取,直到剩下的消息是不完整的数据(或刚好全部提取完)*/
while (Regex.IsMatch(json, pattern))
{
var match = Regex.Match(json, pattern).Groups[0].Value;
json = json.Remove(0, json.IndexOf("\n") + 1);
try { models.Add(JsonConvert.DeserializeObject<Model>(match)); }
catch (Exception ex) { }
}
return models.Count > 0;
}
}
public class DeviceStatus : INotifyPropertyChanged
{
private DateTime dateTime;
private string uuid, serial;
private bool server_status;
private int printer_status;
public DateTime DateTime { get => dateTime; set { dateTime = value; PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("DateTime")); } }
public string Uuid { get => uuid; set { uuid = value; PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Uuid")); } }
public string Serial { get => serial; set { serial = value; PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Serial")); } }
public bool ServiceStatus { get => server_status; set { server_status = value; PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("ServiceStatusString")); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("ServiceStatusColor")); } }
public string ServiceStatusString => ServiceStatus ? "在线" : "离线";
public SolidColorBrush ServiceStatusColor => ServiceStatus ? Brushes.Green : Brushes.Red;
public int PrinterStatus { get => printer_status; set { printer_status = value; PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("PrinterStatusString")); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("PrinterStatusColor")); } }
public string PrinterStatusString
{
get
{
switch (PrinterStatus)
{
case 101: return "正常";
case 102: return "打印中";
case 104: return "等待文件下载中";
case 109: return "检测中";
case 201: return "无纸";
case 302: return "休眠";
case 306: return "未驱动";
case 310: return "驱动失败";
case 209: return "维护";
}
return "...";
}
}
public SolidColorBrush PrinterStatusColor
{
get
{
switch (PrinterStatus)
{
case 101: return Brushes.Green;
case 102: return Brushes.Blue;
case 104: return Brushes.Blue;
case 109: return Brushes.Blue;
case 201: return Brushes.Red;
case 302: return Brushes.Blue;
case 306: return Brushes.Red;
case 310: return Brushes.Red;
case 209: return Brushes.Blue;
}
return Brushes.Red;
}
}
public event PropertyChangedEventHandler PropertyChanged;
public void Update(string json)
{
var ds = JsonConvert.DeserializeObject<DeviceStatus>(json);
if(ds != null)
{
DateTime = DateTime.Now;
Uuid = ds.Uuid;
Serial = ds.Serial;
ServiceStatus = ds.ServiceStatus;
PrinterStatus = ds.PrinterStatus;
}
}
public void Clear()
{
DateTime = DateTime.MinValue;
Uuid = string.Empty;
Serial = string.Empty;
ServiceStatus = false;
PrinterStatus = int.MaxValue;
}
}
public class TaskInfo : INotifyPropertyChanged
{
private DateTime dateTime;
public string id, status, base64String;
public string Uuid { get; set; }
public DateTime DateTime { get => dateTime; set { dateTime = value; PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("DateTime")); } }
public string ID { get => id; set { id = value; PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("ID")); } }
public string Status { get => status; set { status = value; PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Status")); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Loading")); } }
public string Base64String { get => base64String; set { base64String = value; PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Base64String")); } }
public Visibility Loading => status.Equals("打印任务结束") ? Visibility.Hidden : Visibility.Visible;
public event PropertyChangedEventHandler PropertyChanged;
}
public class DataTemplate : INotifyPropertyChanged
{
private DeviceStatus deviceStatus = new DeviceStatus();
public DeviceStatus DeviceStatus { get => deviceStatus; set { deviceStatus = value; PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("DeviceStatus")); } }
public ObservableCollection<TaskInfo> TaskInfos { get; set; } = new ObservableCollection<TaskInfo>();
public event PropertyChangedEventHandler PropertyChanged;
public DataTemplate()
{
BindingOperations.EnableCollectionSynchronization(TaskInfos, new object());
}
public void UpdataTaskStatus(string json)
{
if (json == null)
return;
var taskinfo = JsonConvert.DeserializeObject<TaskInfo>(json);
var info = TaskInfos.FirstOrDefault(ar => ar.Uuid == taskinfo.Uuid);
if(info == null)
{
info = new TaskInfo() { DateTime = DateTime.Now, Uuid = taskinfo.Uuid, ID = taskinfo.ID, Status = taskinfo.Status, };
TaskInfos.Insert(0, info);
}
else
{
info.DateTime = DateTime.Now;
info.Status = taskinfo.Status;
}
}
public void UpdataTaskImage(string json)
{
if (json == null)
return;
var data = JsonConvert.DeserializeObject<Dictionary<string, string>>(json);
var info = TaskInfos.FirstOrDefault(ar => ar.Uuid == data["Uuid"]);
if (info != null)
{
info.DateTime = DateTime.Now;
info.Base64String = data["Base64String"];
}
}
public void Clear()
{
DeviceStatus.Clear();
}
}
public class TaskDispatcher
{
public static DataTemplate DataTemplate = new DataTemplate();
private static TcpClient Client;
private static CancellationTokenSource cancellationTokenSource;
private static string jsonString = string.Empty;
private static ConcurrentQueue<string> Jsons = new ConcurrentQueue<string>();
public static bool Connect(string ipString, int port = 8566)
{
try
{
if (!IPAddress.TryParse(ipString, out IPAddress address))
try { address = Dns.GetHostEntry(ipString).AddressList[0]; } catch (Exception) { }
Client = new TcpClient();
Client.Connect(new IPEndPoint(address, port));
cancellationTokenSource = new CancellationTokenSource();
new Task(ReceiveThread, TaskCreationOptions.LongRunning).Start();
new Task(WorkThread, TaskCreationOptions.LongRunning).Start();
return true;
}
catch { }
return false;
}
public static void Close()
{
cancellationTokenSource.Cancel();
Client?.Close();
Client = null;
}
/// <summary>
/// 等待数据
/// </summary>
/// <param name="action">需要执行的方法</param>
/// <param name="milliseconds">超时时间, 单位:毫秒</param>
/// <returns>true 收到数据; false 未收到数据;</returns>
private static bool WaitReceive(Func<bool> action, double milliseconds = 3000)
{
DateTime now = DateTime.Now;
while (DateTime.Now - now < TimeSpan.FromMilliseconds(milliseconds))
{
if (action())
return true;
Thread.Sleep(10);
}
return false;
}
private static void ReceiveThread()
{
while (!cancellationTokenSource.IsCancellationRequested)
{
try
{
NetworkStream networkStream = Client.GetStream();
if (networkStream.DataAvailable)
{
var buffer = new byte[102400];
var length = networkStream.Read(buffer, 0, buffer.Length);
Jsons.Enqueue(Encoding.UTF8.GetString(buffer, 0, length));
}
}
catch { }
Thread.Sleep(1);
}
}
private static void WorkThread()
{
while (!cancellationTokenSource.IsCancellationRequested)
{
try
{
if (Jsons.TryDequeue(out string data))
{
if (data == null)
continue;
jsonString += data;
if (Model.TryConvert(ref jsonString, out List<Model> models))
{
foreach (var model in models)
Task.Factory.StartNew(() => TryToHandleModel(model));
}
}
}
catch { }
Thread.Sleep(1);
}
}
private static void Write(object data)
{
try
{
if (data == null)
return;
var buffer = Encoding.UTF8.GetBytes(data.ToString());
Client?.GetStream().Write(buffer, 0, buffer.Length);
}
catch { }
}
private static void TryToHandleModel(Model model)
{
switch (model.type)
{
/* 设备状态 */
case 0:
DataTemplate.DeviceStatus.Update(model.msgInfo.ToString());
break;
/* 任务状态 */
case 1:
DataTemplate.UpdataTaskStatus(model.msgInfo.ToString());
break;
/* 任务图片 */
case 2:
DataTemplate.UpdataTaskImage(model.msgInfo.ToString());
break;
}
}
}
}

View File

@ -0,0 +1,52 @@
<Window x:Class="TestView.TaskInfoWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:TestView"
mc:Ignorable="d"
Title="{Binding ID}" Height="475" Width="500" Loaded="Window_Loaded">
<Window.Resources>
<local:Base64ToImage x:Key="Base64ToImage"/>
<Style TargetType="Label">
<Setter Property="Margin" Value="1"/>
<Setter Property="Width" Value="84"/>
<Setter Property="Height" Value="25"/>
</Style>
<Style TargetType="Button">
<Setter Property="Margin" Value="1"/>
<Setter Property="Width" Value="72"/>
<Setter Property="Height" Value="25"/>
</Style>
<Style TargetType="TextBox">
<Setter Property="Margin" Value="1"/>
<Setter Property="Height" Value="25"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
</Style>
</Window.Resources>
<StackPanel>
<Label Content="任务信息" Width="Auto" FontWeight="Bold" HorizontalContentAlignment="Left"/>
<DockPanel>
<Label DockPanel.Dock="Left"/>
<Label DockPanel.Dock="Left" Content="更新时间"/>
<Label Width="Auto">
<TextBlock Text="{Binding DateTime, StringFormat=yyyy-MM-dd HH:mm:ss}"/>
</Label>
</DockPanel>
<DockPanel>
<Label DockPanel.Dock="Left"/>
<Label DockPanel.Dock="Left" Content="任务ID"/>
<Label Width="Auto" Content="{Binding ID}"/>
</DockPanel>
<DockPanel>
<Label DockPanel.Dock="Left"/>
<Label DockPanel.Dock="Left" Content="任务状态"/>
<Label Width="Auto" Content="{Binding Status}"/>
</DockPanel>
<Label Content="任务图片" Width="Auto" FontWeight="Bold" HorizontalContentAlignment="Left"/>
<Image Source="{Binding Base64String, Converter={StaticResource Base64ToImage}}" Height="320"/>
</StackPanel>
</Window>

View File

@ -0,0 +1,58 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace TestView
{
/// <summary>
/// TaskInfoWindow.xaml 的交互逻辑
/// </summary>
public partial class TaskInfoWindow : Window
{
private TaskInfo TaskInfo { get; set; }
public TaskInfoWindow(TaskInfo taskInfo)
{
InitializeComponent();
TaskInfo = taskInfo;
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
DataContext = TaskInfo;
}
}
public class Base64ToImage : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var base64String = (string)value;
if (string.IsNullOrEmpty(base64String))
return null;
byte[] bytes = System.Convert.FromBase64String(base64String);
System.IO.MemoryStream ms = new System.IO.MemoryStream(bytes);
ImageSourceConverter imageSourceConverter = new ImageSourceConverter();
ImageSource source = (ImageSource)imageSourceConverter.ConvertFrom(ms);
return source;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

View File

@ -0,0 +1,122 @@
<?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>{9BAA18D0-A437-4EB1-BB28-BA85A5F45B32}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>TestView</RootNamespace>
<AssemblyName>TestView</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.Data" />
<Reference Include="System.IO.Compression.FileSystem" />
<Reference Include="System.Numerics" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="TaskInfoWindow.xaml.cs">
<DependentUpon>TaskInfoWindow.xaml</DependentUpon>
</Compile>
<Page Include="Loading.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="Loading.xaml.cs">
<DependentUpon>Loading.xaml</DependentUpon>
</Compile>
<Compile Include="TaskDispatcher.cs" />
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Page Include="TaskInfoWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net48" />
</packages>