commit f541d26955098bb625eddfbf7243fbaa46bf32c0 Author: hehaoyang Date: Wed Oct 18 23:43:19 2023 +0800 V1.1.0 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..74b8f27 --- /dev/null +++ b/.gitignore @@ -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 diff --git a/PrinterClient/AutoUpgrade/AutoUpgrade.csproj b/PrinterClient/AutoUpgrade/AutoUpgrade.csproj new file mode 100644 index 0000000..c2946bd --- /dev/null +++ b/PrinterClient/AutoUpgrade/AutoUpgrade.csproj @@ -0,0 +1,15 @@ + + + + Exe + netcoreapp3.1 + + + + + + + + + + diff --git a/PrinterClient/AutoUpgrade/Program.cs b/PrinterClient/AutoUpgrade/Program.cs new file mode 100644 index 0000000..1dc8e8e --- /dev/null +++ b/PrinterClient/AutoUpgrade/Program.cs @@ -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); } + } + } +} + diff --git a/PrinterClient/PrinterClient.sln b/PrinterClient/PrinterClient.sln new file mode 100644 index 0000000..9050f98 --- /dev/null +++ b/PrinterClient/PrinterClient.sln @@ -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 diff --git a/PrinterClient/PrinterClient/BoxServer.cs b/PrinterClient/PrinterClient/BoxServer.cs new file mode 100644 index 0000000..5c91bae --- /dev/null +++ b/PrinterClient/PrinterClient/BoxServer.cs @@ -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() + .Option(ChannelOption.TcpNodelay, true) + .Option(ChannelOption.ConnectTimeout, TimeSpan.FromSeconds(3)) + .Option(ChannelOption.RcvbufAllocator, new FixedRecvByteBufAllocator(1024)) + .Handler(new ActionChannelInitializer(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); + } + } + + /// + /// 通用回复指令 + /// + /// 消息序列号 + /// 状态, 0=成功,1=异常 + /// 描述情况 + 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); + }); + } + + /// + /// 上传终端状态数据 + /// + 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); + }); + } + + /* + 5,打印4张时,百分之80几率只能打印成功2张后平台状态一直停留在打印中或盒子开始处理等状态。 + */ + + /// + /// 下发打印任务 + /// + /// + /// + 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); + } + } + } + }); + } + + ///// + ///// 上传打印任务情况 + ///// + //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); + // }); + //} + + /// + /// 上传打印任务情况 + /// + 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); + }); + } + + ///// + ///// 终端接收任务回复 + ///// 订单号 + ///// 状态 + ///// + //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); + // }); + //} + + /// + /// 终端查询版本 + /// + 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); + }); + } + + /// + /// 程序版本回复 + /// + /// + 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 _); + } + }); + } + + /// + /// 终端控制 + /// + /// + 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; + } + }); + } + + /// + /// 终端控制回复 + /// + /// + 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 Receiveaction = null; + + public ClientHandler(Action 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(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); + } + } +} + diff --git a/PrinterClient/PrinterClient/DebugTool.cs b/PrinterClient/PrinterClient/DebugTool.cs new file mode 100644 index 0000000..24a59a0 --- /dev/null +++ b/PrinterClient/PrinterClient/DebugTool.cs @@ -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 { } + } + } +} + diff --git a/PrinterClient/PrinterClient/PrinterClient.csproj b/PrinterClient/PrinterClient/PrinterClient.csproj new file mode 100644 index 0000000..a2fefe0 --- /dev/null +++ b/PrinterClient/PrinterClient/PrinterClient.csproj @@ -0,0 +1,56 @@ + + + + Exe + netcoreapp3.1 + + + + latest + + + latest + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/PrinterClient/PrinterClient/Program.cs b/PrinterClient/PrinterClient/Program.cs new file mode 100644 index 0000000..6d56203 --- /dev/null +++ b/PrinterClient/PrinterClient/Program.cs @@ -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); + } +} \ No newline at end of file diff --git a/PrinterClient/PrinterClient/RX1/CyStatus.cs b/PrinterClient/PrinterClient/RX1/CyStatus.cs new file mode 100644 index 0000000..72a2894 --- /dev/null +++ b/PrinterClient/PrinterClient/RX1/CyStatus.cs @@ -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; + } + } +} \ No newline at end of file diff --git a/PrinterClient/PrinterClient/ReadMe.cs b/PrinterClient/PrinterClient/ReadMe.cs new file mode 100644 index 0000000..34c983c --- /dev/null +++ b/PrinterClient/PrinterClient/ReadMe.cs @@ -0,0 +1,96 @@ +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; + +namespace PrinterClient; + +/// +/// 版本信息 +/// +static class ReadMe +{ + public static string AppName { get => "PrinterClient"; } + + public static string Version => Versions.First().Key; + + static readonly Dictionary> Versions = new() + { + ["1.1.0 Alpha Bulid 20231018"] = new List() + { + "删除: 检测打印机更换功能", + "删除: 打印机驱动加载功能", + "删除: 打印机参数设置功能", + "修改: 发送给调试软件日志时延时1s变为不延时", + "修改: 打印成功后, 延时5s上传状态", + "添加: 驱动加载、打印、参数设置由脚本完成", + }, + ["1.0.9 Alpha Bulid 20230913"] = new List() + { + "修改若干BUG", + }, + ["1.0.8 Alpha Bulid 20230829"] = new List() + { + "修改若干BUG", + }, + ["1.0.7 Alpha Bulid 20230207"] = new List() + { + "添加重启系统及应用指令", + }, + ["1.0.6 Alpha Bulid 20230109"] = new List() + { + "添加打印机序列号获取及上传", + "启动时主动添加一次打印机驱动", + }, + ["1.0.5 Alpha Bulid 20221220"] = new List() + { + "添加打印超时的状态上传" + }, + ["1.0.4 Alpha Bulid 20221027"] = new List() + { + "打印任务超时后, 进行任务清空的操作", + "检测不到默认打印机时,重新设置默认打印机", + "添加打印失败后重新尝试打印的操作", + "打印超时问题未解决" + }, + ["1.0.3 Alpha Bulid 20220307"] = new List() + { + "添加: 设置打印机打印格式、类型、尺寸", + }, + ["1.0.2 Alpha Bulid 20211208"] = new List() + { + "修复: 没有正确识别打印机休眠状态", + "修复: 重连导致服务器过多连接", + "添加: 打印机禁用状态下, 发送激活命令启用打印机", + }, + ["1.0.1 Alpha Bulid 20211105"] = new List() + { + "实现升级功能", + "添加设置信息", + }, + ["1.0.0 Alpha Bulid 20211103"] = new List() + { + "实现基本功能", + }, + }; + + 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); + } + +} + diff --git a/PrinterClient/PrinterClient/TaskDispatcher.cs b/PrinterClient/PrinterClient/TaskDispatcher.cs new file mode 100644 index 0000000..7fd34c6 --- /dev/null +++ b/PrinterClient/PrinterClient/TaskDispatcher.cs @@ -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 + { + /// + /// 正常 + /// + Normal = 0, + + /// + /// 异常 + /// + Failed = 201, + + /// + /// 下载中 + /// + Download = 104, + + /// + /// 升级中 + /// + Upgrade = 301, + } + + public enum PrinterStatus : int + { + /// + /// 正常 + /// + Normal = 101, + + /// + /// 打印中 + /// + Printing = 102, + + /// + /// 等待文件下载 + /// + Waiting_For_File_Download = 104, + + /// + /// 检测中 + /// + Testing = 109, + + /// + /// 无纸 + /// + NoPaper = 201, + + /// + /// 休眠 + /// + Sleep = 302, + + /// + /// 未驱动 + /// + NotDriven = 306, + + /// + /// 驱动失败 + /// + DriveFailed = 310, + + /// + /// 维护 + /// + 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 + { + /// + /// 当前是否正在打印 + /// + 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; + } + + /// + /// 删除任务 + /// + /// 工作序号 + public static void Delete(string job) + { + if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + { + TaskDispatcher.ExecuteCommand("lprm", job, out _); + } + } + + /// + /// 清空任务 + /// + public static void Clear() => Delete(""); + + /// + /// 获取打印队列 + /// + /// + public static List QueryEntries() + { + List 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 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; + } + + /// + /// 打印 + /// + /// 文件 + /// + 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; } + } +} diff --git a/PrinterClient/PrinterClient/Utils/ByteUtils.cs b/PrinterClient/PrinterClient/Utils/ByteUtils.cs new file mode 100644 index 0000000..f02411d --- /dev/null +++ b/PrinterClient/PrinterClient/Utils/ByteUtils.cs @@ -0,0 +1,30 @@ +using System; +using System.IO; +using System.Text; +using ProtoBuf; + +namespace PrinterClient +{ + public static class ByteUtils + { + public static byte[] Serialize(this T t) + { + using MemoryStream ms = new(); + Serializer.Serialize(ms, t); + return ms.ToArray(); + } + + public static T Deserialize(this byte[] content, int index, int count) + { + using MemoryStream ms = new(content, index, count); + return Serializer.Deserialize(ms); + } + + public static T Deserialize(this string content) + { + using MemoryStream ms = new(Encoding.UTF8.GetBytes(content)); + return Serializer.Deserialize(ms); + } + } +} + diff --git a/PrinterClient/PrinterClient/Utils/DeviceUtils.cs b/PrinterClient/PrinterClient/Utils/DeviceUtils.cs new file mode 100644 index 0000000..b02c031 --- /dev/null +++ b/PrinterClient/PrinterClient/Utils/DeviceUtils.cs @@ -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; + } + } +} diff --git a/PrinterClient/PrinterClient/Utils/FileUtils.cs b/PrinterClient/PrinterClient/Utils/FileUtils.cs new file mode 100644 index 0000000..f4f06b6 --- /dev/null +++ b/PrinterClient/PrinterClient/Utils/FileUtils.cs @@ -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 { } + } +} \ No newline at end of file diff --git a/PrinterClient/PrinterClient/Utils/LogUtils.cs b/PrinterClient/PrinterClient/Utils/LogUtils.cs new file mode 100644 index 0000000..b3c6a4e --- /dev/null +++ b/PrinterClient/PrinterClient/Utils/LogUtils.cs @@ -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}"); +} \ No newline at end of file diff --git a/PrinterClient/PrinterClient/Utils/TimerUtils.cs b/PrinterClient/PrinterClient/Utils/TimerUtils.cs new file mode 100644 index 0000000..8d322ed --- /dev/null +++ b/PrinterClient/PrinterClient/Utils/TimerUtils.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Concurrent; + +namespace PrinterClient +{ + public class TimerUtils + { + private static ConcurrentDictionary Records = new ConcurrentDictionary(); + + 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; + } + } +} + diff --git a/PrinterClient/PrinterClient/app.config b/PrinterClient/PrinterClient/app.config new file mode 100644 index 0000000..6b84cf3 --- /dev/null +++ b/PrinterClient/PrinterClient/app.config @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/PrinterClient/PrinterClient/protocol.cs b/PrinterClient/PrinterClient/protocol.cs new file mode 100644 index 0000000..9a53c50 --- /dev/null +++ b/PrinterClient/PrinterClient/protocol.cs @@ -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 diff --git a/PrinterClient/物联平台-终端打印盒子TCP协议V1.0.4.docx b/PrinterClient/物联平台-终端打印盒子TCP协议V1.0.4.docx new file mode 100644 index 0000000..2530799 Binary files /dev/null and b/PrinterClient/物联平台-终端打印盒子TCP协议V1.0.4.docx differ diff --git a/TestView/TestView.sln b/TestView/TestView.sln new file mode 100644 index 0000000..599922d --- /dev/null +++ b/TestView/TestView.sln @@ -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 diff --git a/TestView/TestView/App.config b/TestView/TestView/App.config new file mode 100644 index 0000000..5ffd8f8 --- /dev/null +++ b/TestView/TestView/App.config @@ -0,0 +1,6 @@ + + + + + + diff --git a/TestView/TestView/App.xaml b/TestView/TestView/App.xaml new file mode 100644 index 0000000..1ea2fdb --- /dev/null +++ b/TestView/TestView/App.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/TestView/TestView/App.xaml.cs b/TestView/TestView/App.xaml.cs new file mode 100644 index 0000000..b7c8b2f --- /dev/null +++ b/TestView/TestView/App.xaml.cs @@ -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 +{ + /// + /// App.xaml 的交互逻辑 + /// + public partial class App : Application + { + } +} diff --git a/TestView/TestView/FodyWeavers.xml b/TestView/TestView/FodyWeavers.xml new file mode 100644 index 0000000..882317c --- /dev/null +++ b/TestView/TestView/FodyWeavers.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/TestView/TestView/FodyWeavers.xsd b/TestView/TestView/FodyWeavers.xsd new file mode 100644 index 0000000..ff119f7 --- /dev/null +++ b/TestView/TestView/FodyWeavers.xsd @@ -0,0 +1,141 @@ + + + + + + + + + + + + A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks + + + + + A list of assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks. + + + + + A list of runtime assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks + + + + + A list of runtime assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks. + + + + + A list of unmanaged 32 bit assembly names to include, delimited with line breaks. + + + + + A list of unmanaged 64 bit assembly names to include, delimited with line breaks. + + + + + The order of preloaded assemblies, delimited with line breaks. + + + + + + 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. + + + + + Controls if .pdbs for reference assemblies are also embedded. + + + + + Controls if runtime assemblies are also embedded. + + + + + Controls whether the runtime assemblies are embedded with their full path or only with their assembly name. + + + + + Embedded assemblies are compressed by default, and uncompressed when they are loaded. You can turn compression off with this option. + + + + + As part of Costura, embedded assemblies are no longer included as part of the build. This cleanup can be turned off. + + + + + 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. + + + + + 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. + + + + + A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with | + + + + + A list of assembly names to include from the default action of "embed all Copy Local references", delimited with |. + + + + + A list of runtime assembly names to exclude from the default action of "embed all Copy Local references", delimited with | + + + + + A list of runtime assembly names to include from the default action of "embed all Copy Local references", delimited with |. + + + + + A list of unmanaged 32 bit assembly names to include, delimited with |. + + + + + A list of unmanaged 64 bit assembly names to include, delimited with |. + + + + + The order of preloaded assemblies, delimited with |. + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/TestView/TestView/Loading.xaml b/TestView/TestView/Loading.xaml new file mode 100644 index 0000000..20c3aa4 --- /dev/null +++ b/TestView/TestView/Loading.xaml @@ -0,0 +1,99 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/TestView/TestView/Loading.xaml.cs b/TestView/TestView/Loading.xaml.cs new file mode 100644 index 0000000..8f0d804 --- /dev/null +++ b/TestView/TestView/Loading.xaml.cs @@ -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 +{ + /// + /// Loading.xaml 的交互逻辑 + /// + public partial class Loading : UserControl + { + public Loading() + { + InitializeComponent(); + } + } +} diff --git a/TestView/TestView/MainWindow.xaml b/TestView/TestView/MainWindow.xaml new file mode 100644 index 0000000..91afd13 --- /dev/null +++ b/TestView/TestView/MainWindow.xaml @@ -0,0 +1,90 @@ + + + + + + + + + + + +