commit ebdfc31e6585a4d76e8168a5712ed8133c1c1392 Author: SongSong Date: Thu Aug 21 13:14:51 2025 +0900 .NetFw4のバージョン diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1ff0c42 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3c4efe2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,261 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# DNX +project.lock.json +project.fragment.lock.json +artifacts/ + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# TODO: Comment the next line if you want to checkin your web deploy settings +# but database connection strings (with potential passwords) will be unencrypted +#*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config +# NuGet v3's project.json files produces more ignoreable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +node_modules/ +orleans.codegen.cs + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush +.cr/ + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc \ No newline at end of file diff --git a/MLComponentSettings.xml b/MLComponentSettings.xml new file mode 100644 index 0000000..9a2ca06 --- /dev/null +++ b/MLComponentSettings.xml @@ -0,0 +1,13 @@ + + + false + + true + + false + メイリオ + 9 + true + false + 0 + diff --git a/SoM_PrnControl.sln b/SoM_PrnControl.sln new file mode 100644 index 0000000..51f70e5 --- /dev/null +++ b/SoM_PrnControl.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28010.2036 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SoM_PrnControl", "SoM_PrnControl\SoM_PrnControl.csproj", "{40C2B03C-3EFC-4F9E-B942-71D4F94F5A37}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {40C2B03C-3EFC-4F9E-B942-71D4F94F5A37}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {40C2B03C-3EFC-4F9E-B942-71D4F94F5A37}.Debug|Any CPU.Build.0 = Debug|Any CPU + {40C2B03C-3EFC-4F9E-B942-71D4F94F5A37}.Release|Any CPU.ActiveCfg = Release|Any CPU + {40C2B03C-3EFC-4F9E-B942-71D4F94F5A37}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {0192E6C7-D5DE-4580-A09D-A3CAC411C3BC} + EndGlobalSection +EndGlobal diff --git a/SoM_PrnControl/AIDdefine.cs b/SoM_PrnControl/AIDdefine.cs new file mode 100644 index 0000000..0547579 --- /dev/null +++ b/SoM_PrnControl/AIDdefine.cs @@ -0,0 +1,148 @@ +static class AidConst +{ + // 関数戻り値の定義 (APIの戻り値に関する定義) ====================================================================================================== + //---------------------------------------------------------------------------------------------- + // 正常応答 + public const uint NORMALEND = 0x0; // 正常応答(0以外異常) + + //---------------------------------------------------------------------------------------------- + // 異常に関する型、分類に関する定義 + public const uint ERROR_MASK = (0x80000000); // 異常レベル : メインマスク値 + public const uint ERROR_TYPE_SYS = (ERROR_MASK | 0x10000000); // 異常レベル : AIDシステム/コンピュータ + public const uint ERROR_TYPE_FUN = (ERROR_MASK | 0x20000000); // 異常レベル : 機能実行 + public const uint ERROR_TYPE_VAL = (ERROR_MASK | 0x30000000); // 異常レベル : パラメータ + public const uint ERROR_TYPE_RES = (ERROR_MASK | 0x40000000); // 異常レベル : I/F間 + public const uint ERROR_TYPE_CMD = (ERROR_MASK | 0x50000000); // 異常レベル : コマンド実行結果 + public const uint ERROR_TYPE_EX = (ERROR_MASK | 0x60000000); // 異常レベル : 内部系 + public const uint ERROR_MASK_APL = (0x10000); // 異常オブジェクト : API + public const uint ERROR_MASK_CARD = (0x20000); // 異常オブジェクト : カード + public const uint ERROR_MASK_IFD = (0x30000); // 異常オブジェクト : IFD + public const uint ERROR_MASK_STRM = (0x40000); // 異常オブジェクト : ストリーム(通信系) + + + //---------------------------------------------------------------------------------------------- + // APIオブジェクト関連異常応答値 + // システム系異系 + public const uint ERROR_APL_SYSTEM = (ERROR_MASK_APL | ERROR_TYPE_SYS | 0x1); // 判断できない想定外の異常 + public const uint ERROR_APL_RESOURCE = (ERROR_MASK_APL | ERROR_TYPE_SYS | 0x2); // リソースの有無、接続の異常 + public const uint ERROR_APL_AIDFILES = (ERROR_MASK_APL | ERROR_TYPE_SYS | 0x3); // ファイルリソースに接続できない + // 機能実行系 + public const uint ERROR_APL_NOTYET = (ERROR_MASK_APL | ERROR_TYPE_FUN | 0x1); // APLオブジェクトが未設定 + public const uint ERROR_APL_ALREADY = (ERROR_MASK_APL | ERROR_TYPE_FUN | 0x2); // APLオブジェクトが既設定 + // APIパラメータ系 + public const uint ERROR_APL_UNSUPPORT = (ERROR_MASK_APL | ERROR_TYPE_VAL | 0x1); // 未サポート機能への要求 + public const uint ERROR_APL_INVALID_ARG = (ERROR_MASK_APL | ERROR_TYPE_VAL | 0x2); // 引数値、内容に関する異常 + public const uint ERROR_APL_BUFFER_SMALL = (ERROR_MASK_APL | ERROR_TYPE_VAL | 0x3); // 引渡されたバッファ長が短い + + //---------------------------------------------------------------------------------------------- + // カードオブジェクト上での異常値定義 + // システム系異系 + public const uint ERROR_CARD_SYSTEM = (ERROR_MASK_CARD | ERROR_TYPE_SYS | 0x1); // 判断できない想定外の異常 + public const uint ERROR_CARD_RESOURCE = (ERROR_MASK_CARD | ERROR_TYPE_SYS | 0x2); // リソースの有無、接続の異常 + public const uint ERROR_CARD_AIDFILES = (ERROR_MASK_CARD | ERROR_TYPE_SYS | 0x3); // ファイルリソースに接続できない + // 機能実行系 + public const uint ERROR_CARD_NOTYET = (ERROR_MASK_CARD | ERROR_TYPE_FUN | 0x1); // Cardオブジェクトが未設定 + public const uint ERROR_CARD_ALREADY = (ERROR_MASK_CARD | ERROR_TYPE_FUN | 0x2); // Cardオブジェクトが既設定 + // APIパラメータ系 + public const uint ERROR_CARD_UNSUPPORT = (ERROR_MASK_CARD | ERROR_TYPE_VAL | 0x1); // 未サポート機能への要求 + public const uint ERROR_CARD_INVALID_ARG = (ERROR_MASK_CARD | ERROR_TYPE_VAL | 0x2); // 引数値、内容に関する異常 + public const uint ERROR_CARD_BUFFER_SMALL = (ERROR_MASK_CARD | ERROR_TYPE_VAL | 0x3); // 引渡されたバッファ長が短い + // SESSION異常 + public const uint ERROR_CARD_FINED = (ERROR_MASK_CARD | ERROR_TYPE_RES | 0x1); // カード補足が出来なかった + public const uint ERROR_CARD_LOST = (ERROR_MASK_CARD | ERROR_TYPE_RES | 0x2); // カード通信が維持出来い + public const uint ERROR_CARD_FRAME = (ERROR_MASK_CARD | ERROR_TYPE_RES | 0x3); // R/W-カード間通信フレームが識別出来ない + public const uint ERROR_CARD_RECOVER = (ERROR_MASK_CARD | ERROR_TYPE_RES | 0x4); // 上位でのリカバリ可能な異常 + public const uint ERROR_CARD_TARGET = (ERROR_MASK_CARD | ERROR_TYPE_RES | 0x5); // 対象外カードへの要求 + public const uint ERROR_CARD_CANCEL = (ERROR_MASK_CARD | ERROR_TYPE_RES | 0x6); // アプリ要求にて処理を中断した + // その他 + public const uint ERROR_CARD_AUTHENTICATE = (ERROR_MASK_CARD | ERROR_TYPE_EX | 0x8001); // AUTHENTICATE異常 + public const uint ERROR_CARD_MACRO_READ = (ERROR_MASK_CARD | ERROR_TYPE_EX | 0x8002); // マクロコマンドのリードでの異常 + + //---------------------------------------------------------------------------------------------- + // IFDオブジェクト上での異常値定義 + // システム系異系 + public const uint ERROR_IFD_SYSTEM = (ERROR_MASK_IFD | ERROR_TYPE_SYS | 0x1); // 判断できない想定外の異常 + public const uint ERROR_IFD_RESOURCE = (ERROR_MASK_IFD | ERROR_TYPE_SYS | 0x2); // リソースの有無、接続の異常 + public const uint ERROR_IFD_AIDFILES = (ERROR_MASK_IFD | ERROR_TYPE_SYS | 0x3); // ファイルリソースに接続できない + // 機能実行系 + public const uint ERROR_IFD_NOTYET = (ERROR_MASK_IFD | ERROR_TYPE_FUN | 0x1); // IFDオブジェクトが未設定 + public const uint ERROR_IFD_ALREADY = (ERROR_MASK_IFD | ERROR_TYPE_FUN | 0x2); // IFDオブジェクトが既設定 + // APIパラメータ系 + public const uint ERROR_IFD_UNSUPPORT = (ERROR_MASK_IFD | ERROR_TYPE_VAL | 0x1); // 未サポートI/Fへの要求 + public const uint ERROR_IFD_INVALID_ARG = (ERROR_MASK_IFD | ERROR_TYPE_VAL | 0x2); // 引数値、内容に関する異常 + public const uint ERROR_IFD_BUFFER_SMALL = (ERROR_MASK_IFD | ERROR_TYPE_VAL | 0x3); // 引渡されたバッファ長が短い + // SESSION異常 + public const uint ERROR_IFD_FRAME = (ERROR_MASK_IFD | ERROR_TYPE_RES | 0x1); // ホスト-R/W間通信フレームが識別出来ない + public const uint ERROR_IFD_RECOVER = (ERROR_MASK_IFD | ERROR_TYPE_RES | 0x2); // 上位でのリカバリ可能な異常 + public const uint ERROR_IFD_FORMAT = (ERROR_MASK_IFD | ERROR_TYPE_RES | 0x3); // スルー通信用フォーマットが異常 + public const uint ERROR_IFD_FRAME_STRUCT = (ERROR_MASK_IFD | ERROR_TYPE_RES | 0x4); // 通信フレーム構造異常 + // コマンド実行結果の異常 + public const uint ERROR_IFD_SWMISSING = (ERROR_MASK_IFD | ERROR_TYPE_CMD | 0x1); // SWが存在しない(見つからない) + public const uint ERROR_IFD_UNDEFINED = (ERROR_MASK_IFD | ERROR_TYPE_CMD | 0x2); // 未定義のSWを検出した + public const uint ERROR_IFD_WARNING = (ERROR_MASK_IFD | ERROR_TYPE_CMD | 0x6200); // 警告(詳細なし) + public const uint ERROR_IFD_CARDTIMEOUT = (ERROR_MASK_IFD | ERROR_TYPE_CMD | 0x62F0); // R/W側カード通信タイムアウト + public const uint ERROR_IFD_CARDERROR = (ERROR_MASK_IFD | ERROR_TYPE_CMD | 0x62F1); // R/W側カード通信異常 + public const uint ERROR_IFD_EXECUTEERROR = (ERROR_MASK_IFD | ERROR_TYPE_CMD | 0x6400); // コマンドが実行出来ない + public const uint ERROR_IFD_CMDLENERROR = (ERROR_MASK_IFD | ERROR_TYPE_CMD | 0x6700); // コマンド長異常 + public const uint ERROR_IFD_HARDCONDITION = (ERROR_MASK_IFD | ERROR_TYPE_CMD | 0x6900); // ハード的な実行条件異常 + public const uint ERROR_IFD_CMDCONDITION = (ERROR_MASK_IFD | ERROR_TYPE_CMD | 0x6985); // コマンド実行条件異常 + public const uint ERROR_IFD_PARAMERROR = (ERROR_MASK_IFD | ERROR_TYPE_CMD | 0x6A86); // パラメータ値不正 + public const uint ERROR_IFD_PARAMRANGE = (ERROR_MASK_IFD | ERROR_TYPE_CMD | 0x6B00); // パラメータ範囲異常 + public const uint ERROR_IFD_INSERROR = (ERROR_MASK_IFD | ERROR_TYPE_CMD | 0x6D00); // INS異常 + public const uint ERROR_IFD_CLAERROR = (ERROR_MASK_IFD | ERROR_TYPE_CMD | 0x6E00); // CLA異常 + public const uint ERROR_IFD_SELFCHECK = (ERROR_MASK_IFD | ERROR_TYPE_CMD | 0x6F00); // 自己診断異常 + // その他 + public const uint ERROR_IFD_AUTHENTICATE1 = (ERROR_MASK_IFD | ERROR_TYPE_EX | 0x8001); // AUTHENTICATE1異常 + public const uint ERROR_IFD_AUTHENTICATE2 = (ERROR_MASK_IFD | ERROR_TYPE_EX | 0x8002); // AUTHENTICATE2異常 + public const uint ERROR_IFD_SETUPAUTH = (ERROR_MASK_IFD | ERROR_TYPE_EX | 0x8003); // 認証・暗号設定異常 + public const uint WARNING_IFD_RETURN = (ERROR_MASK_IFD | ERROR_TYPE_EX | 0x8100); // 応答検査要求 + + //---------------------------------------------------------------------------------------------- + // STreamオブジェクト上での異常値定義 + // システム系異常 + public const uint ERROR_STRM_SYSTEM = (ERROR_MASK_STRM | ERROR_TYPE_SYS | 0x1); // 判断できない想定外の異常 + public const uint ERROR_STRM_RESOURCE = (ERROR_MASK_STRM | ERROR_TYPE_SYS | 0x2); // リソースの有無、接続の異常 + public const uint ERROR_STRM_AIDFILES = (ERROR_MASK_STRM | ERROR_TYPE_SYS | 0x3); // ファイルリソースに接続できない + public const uint ERROR_STRM_DEVICE = (ERROR_MASK_STRM | ERROR_TYPE_SYS | 0x4); // デバイス内部異常 + public const uint ERROR_STRM_WIN32 = (ERROR_MASK_STRM | ERROR_TYPE_SYS | 0x7); // Win32API上での異常 + // 機能実行系 + public const uint ERROR_STRM_COLLISION = (ERROR_MASK_STRM | ERROR_TYPE_FUN | 0x1); // リソースの競合 + public const uint ERROR_STRM_NOTOPEN = (ERROR_MASK_STRM | ERROR_TYPE_FUN | 0x2); // ポート未オープン + public const uint ERROR_STRM_ALREADYOPEN = (ERROR_MASK_STRM | ERROR_TYPE_FUN | 0x3); // ポートオープン済 + public const uint ERROR_STRM_CURBUSY = (ERROR_MASK_STRM | ERROR_TYPE_FUN | 0x4); // セッション処理中 + // APIパラメータ系 + public const uint ERROR_STRM_UNSUPPORT = (ERROR_MASK_STRM | ERROR_TYPE_VAL | 0x1); // 未サポート機能への要求 + public const uint ERROR_STRM_INVALID_ARG = (ERROR_MASK_STRM | ERROR_TYPE_VAL | 0x2); // DLL呼び出し時の引数異常 + public const uint ERROR_STRM_BUFFER_SMALL = (ERROR_MASK_STRM | ERROR_TYPE_VAL | 0x3); // 応答格納用バッファ長が短い + // SESSION系 + public const uint ERROR_STRM_TIME_OUT = (ERROR_MASK_STRM | ERROR_TYPE_RES | 0x1); // セッションタイムアウト + public const uint ERROR_STRM_RECEIVE = (ERROR_MASK_STRM | ERROR_TYPE_RES | 0x2); // バイナリレベルの受信異常(パリティ等) + public const uint ERROR_STRM_SHORT_FRAME = (ERROR_MASK_STRM | ERROR_TYPE_RES | 0x3); // ショートフレーム異常 + + + + // 定数定義 ======================================================================================================================================== + // StartTransactionのtypeの戻り値 + public const uint CARDTYPE_MIF = 0x2; // Mifareカードが存在 + public const uint CARDTYPE_B = 0x3; // TypeBカードが存在 + public const uint CARDTYPE_FEL = 0x4; // FeliCaカードが存在 + public const uint CARDTYPE_A = 0x6; // TypeAカードが存在 + public const uint CARDTYPE_MORECARD = 0x80000000; // 検出したカード以外のカードが存在 + + // StartTransactionのspeedの設定値 + public const int CARDSPEED_DEFAULT = 0x0; // 初期通信速度を指定 + public const int CARDSPEED_2TIMES = 0x1; // 初期通信速度の2倍を指定 + public const int CARDSPEED_4TIMES = 0x2; // 初期通信速度の4倍を指定 + public const int CARDSPEED_8TIMES = 0x3; // 初期通信速度の8倍を指定 + public const uint CARDSPEED_MAX = 0x80000000; // 通信可能な最大通信速度を指定 + + // シリアル通信速度指定定数 + public const int DEF_9600 = 9600; // 9600bps + public const int DEF_14400 = 14400; // 14400bps + public const int DEF_19200 = 19200; // 19200bps + public const int DEF_28800 = 28800; // 28800bps + public const int DEF_38400 = 38400; // 38400bps + public const int DEF_57600 = 57600; // 57600bps + public const int DEF_115200 = 115200; // 115200bps +} + diff --git a/SoM_PrnControl/App.config b/SoM_PrnControl/App.config new file mode 100644 index 0000000..4bfa005 --- /dev/null +++ b/SoM_PrnControl/App.config @@ -0,0 +1,6 @@ + + + + + + diff --git a/SoM_PrnControl/Form1.Designer.cs b/SoM_PrnControl/Form1.Designer.cs new file mode 100644 index 0000000..0ae45ef --- /dev/null +++ b/SoM_PrnControl/Form1.Designer.cs @@ -0,0 +1,89 @@ +namespace qk30ic +{ + partial class Form1 + { + /// + /// 必要なデザイナー変数です。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 使用中のリソースをすべてクリーンアップします。 + /// + /// マネージド リソースを破棄する場合は true を指定し、その他の場合は false を指定します。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows フォーム デザイナーで生成されたコード + + /// + /// デザイナー サポートに必要なメソッドです。このメソッドの内容を + /// コード エディターで変更しないでください。 + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.button1 = new System.Windows.Forms.Button(); + this.serialPort1 = new System.IO.Ports.SerialPort(this.components); + this.dataGridView1 = new System.Windows.Forms.DataGridView(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); + this.SuspendLayout(); + // + // button1 + // + this.button1.Location = new System.Drawing.Point(414, 382); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(134, 29); + this.button1.TabIndex = 0; + this.button1.Text = "終了"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // serialPort1 + // + this.serialPort1.DataReceived += new System.IO.Ports.SerialDataReceivedEventHandler(this.serialPort1_DataReceived); + // + // dataGridView1 + // + this.dataGridView1.AllowUserToAddRows = false; + this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView1.Location = new System.Drawing.Point(24, 28); + this.dataGridView1.Name = "dataGridView1"; + this.dataGridView1.RowHeadersVisible = false; + this.dataGridView1.RowHeadersWidth = 60; + this.dataGridView1.RowTemplate.Height = 21; + this.dataGridView1.ScrollBars = System.Windows.Forms.ScrollBars.None; + this.dataGridView1.Size = new System.Drawing.Size(947, 330); + this.dataGridView1.TabIndex = 1; + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(994, 450); + this.Controls.Add(this.dataGridView1); + this.Controls.Add(this.button1); + this.Name = "Form1"; + this.Text = "SoMプリンタ制御プログラム"; + this.TopMost = true; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing); + this.Shown += new System.EventHandler(this.Form1_Shown); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Button button1; + private System.IO.Ports.SerialPort serialPort1; + private System.Windows.Forms.DataGridView dataGridView1; + } +} + diff --git a/SoM_PrnControl/Form1.cs b/SoM_PrnControl/Form1.cs new file mode 100644 index 0000000..f6ff995 --- /dev/null +++ b/SoM_PrnControl/Form1.cs @@ -0,0 +1,2206 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using System.Runtime.InteropServices; +using System.Threading; +using System.Threading.Tasks; +using System.Timers; +using System.IO; +using System.IO.Ports; +using MySql.Data.MySqlClient; +using SATO.MLComponent; + +namespace qk30ic +{ + public partial class Form1 : Form + { + // ====== 开关 ====== + // 硬件模拟:true=不连串口/IC卡/打印机;启动“演示二维码喂料器”自动喂入 QRID1234 + private const bool MOCK_HW = true; + + // 数据库模拟:false=真实 MySQL;true=DB 也走假数据(不访问数据库) + private const bool DEMO_DB = false; + + // ★ DB连接状态判断 + private bool IsDbReady => (DBconnect != null && DBconnect.State == ConnectionState.Open); + + private System.Windows.Forms.Timer demoQrTimer; + + // ログファイル名(フルパス)格納用 + static public string LogfileName = ""; + static public string LogfilePath = ""; + public const int OutLogNum = 15; // ログ表示行数 + public const int OutConfNum = 9; // コンフィグファイルの項目数 + + // ログファイルの内容 + static public string[,] koumoku = new string[OutLogNum, 8]; + + // コンフィグファイルの内容読み取り + static public string[] str_Confile = new string[OutConfNum]; + + // レイアウトファイル + static public string str_layoutFile = Path.Combine(Application.StartupPath, "SOM_layout.mllayx"); + + // コンフィグファイル + static public string CONFIG_PATH = Path.Combine(Application.StartupPath, "SLN_config.dat"); + + dynamic ifd = null; // IFDオブジェクト + dynamic mif = null; // MIfareオブジェクト + dynamic icc = null; // Cardオブジェクト + public static string QRdata = ""; // QRコード受信用 + public static string QRdata2 = ""; // QRコード受信用 + public static byte[] vinfBuff = new byte[257]; // Mifareコード受信用 + public static byte[] vinfBuff2 = new byte[257]; // Mifareコード受信用 + public static uint QRresult = 0; // QRコード受信用 + public static string MFCODE = ""; // Mifareコード + public static string MFCODE_CHK = "4400"; // Mifare識別用 + public static int Retry_num = 0; // DBエラー時のリトライ数 + + // 終了処理 + public int EndType = 0; + + // エラーコード + public const int ERROR_CODE_CONFRD = 80; + public const int ERROR_CODE_LOGFRD = 85; + public const int ERROR_CODE_LOGFWR = 87; + public const int ERROR_CODE_DBOPEN = 100; + public const int ERROR_CODE_PAPRNG = 104; + public const int ERROR_CODE_LAYOUT = 110; + public const int ERROR_CODE_PRNINI = 120; + public const int ERROR_CODE_MFIINI = 130; + public const int ERROR_CODE_QRCINI = 140; + public const int ERROR_CODE_DBERR = 150; + public const int ERROR_CODE_PRNERR = 160; + public const int ERROR_CODE_NONMFC = 1; + public const int ERROR_CODE_NONQRC = 3; + public const int ERROR_CODE_NONUID = 5; + public const int ERROR_CODE_QRCERR = 170; + public const int ERROR_CODE_MFIERR = 175; + + // ログ編集用 + public const int LETYPE_NORMAL = 0; + public const int LETYPE_START = 2; + public const int LETYPE_DBOPEN = 10; + public const int LETYPE_LAYOUT = 11; + public const int LETYPE_PRNINI = 12; + public const int LETYPE_MFIINI = 13; + public const int LETYPE_QRCINI = 14; + public const int LETYPE_DBERR = 15; + public const int LETYPE_NONMFC = 20; + public const int LETYPE_NONUID = 21; + public const int LETYPE_NONQRC = 30; + public const int LETYPE_PRNERR = 40; + public const int LETYPE_QRCERR = 50; + public const int LETYPE_MFIERR = 55; + public const int LETYPE_CONFRD = 80; + public const int LETYPE_LOGFRD = 85; + public const int LETYPE_LOGFWR = 87; + + // MySQL 连接串(按需修改账号密码/库名) + public static string connectionParams = string.Format( + "server={0}; user={1}; password={2}; database={3}; charset={4}; SslMode={5}; AllowPublicKeyRetrieval={6}", + "localhost", + "root", + "", // ← 如果有密码填这里 + "so-manager", // ← 你的库名(保留原值) + "utf8", + "None", + "true" + ); + + // DB読み込みクエリ + public string DBREAD_park_name = "select park_name from park where park_id="; + public string DBREAD_city_name = "select city_name from park, city where park.city_id=city.city_id and park.park_id="; + public string DBREAD_ptype_subj = "select ptype_subject from price , ptype where price.price_ptypeid=ptype.ptype_id and price.park_id="; + public string[] DBREAD_utype_sub1 = { + "select usertype_subject1 from user,usertype,regular_contract where regular_contract.user_categoryid=usertype.user_categoryid and user.user_tag_serial =", + "select usertype_subject1 from user,usertype,regular_contract where regular_contract.user_categoryid=usertype.user_categoryid and regular_contract.contract_qr_id=" }; + + public string[] DBREAD_cont_periods = { + "select contract_periods, contract_periode, contract_id from user,regular_contract where user.user_id=regular_contract.user_id and user_tag_serial =", + "select contract_periods, contract_periode, contract_id from regular_contract where contract_qr_id=" }; + + public string[] DBREAD_cont_sissue = { + "select contract_seal_issue from user, regular_contract where user.user_id=regular_contract.user_id and user_tag_serial =", + "select contract_seal_issue from regular_contract where contract_qr_id="}; + + // ログに書き込む項目 + public string[] str_logkm = new string[8]; + + // キープアライブ用 + public static string KpAlive_devid = ""; + + // 印字データ + public string[] str_Prndat = new string[8]; + public static int Prn_MaxNum; // 印字可能数 + public static int Prn_NowNum; // 現在の印字数 + public static int Prn_Alert_num; // 印字残警告数 + public static int Prn_Alert_flg; // プリンタ印字残警告フラグ + public static string Prn_ParkName; // 駐車場名 + + public static MySqlConnection DBconnect = null; // 延迟初始化 + + public static string[] PortList = new string[20]; + + // 受信データ判別 + public static DateTime date1 = new DateTime(2018, 1, 1, 12, 0, 0); + public static DateTime date2 = new DateTime(2018, 1, 1, 1, 0, 0); + + // MLComponent - 延迟初始化以避免启动时错误 + public static MLComponent SO_MLC = null; + + public Form1() + { + InitializeComponent(); + } + + private void Form1_Shown(object sender, EventArgs e) + { + // 本地小工具:只写本地日志(无 DB 时调用) + void LogOnly(int type, int n) + { + EndType = n; + SO_LogEdit(type); + SO_WriteLog(); + } + + // 本地小工具:启动“演示二维码喂料器” + void StartDemoQrFeeder() + { + if (!MOCK_HW) return; + demoQrTimer = new System.Windows.Forms.Timer(); + demoQrTimer.Interval = 3000; // 每3秒来一个二维码 + demoQrTimer.Tick += (s, ev) => + { + QRdata = "藤本"; + QRresult = 1; // 告知主循环“扫到了码” + }; + demoQrTimer.Start(); + } + + try + { + uint MFresult = 0; + uint result = 0; + uint mode = 0; + bool bResult = true; + string str_uid = ""; + string str_qrc = ""; + string[] str_rctbl = new string[8]; + for (int j = 0; j < str_rctbl.Length; j++) str_rctbl[j] = ""; + + // 读取配置 + result = ConRead.ReadConFile(ref str_Confile); + if (result == 1) + { + MessageBox.Show("設定ファイルの読み込みに失敗しました。\nパス: " + CONFIG_PATH, "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error); + Application.Exit(); return; + } + for (int i = 0; i < OutConfNum; i++) + { + if (str_Confile[i] == null) + { + MessageBox.Show("設定ファイルの項目" + i + "が空です。\n設定ファイルに" + OutConfNum + "個の項目が必要です。", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error); + Application.Exit(); return; + } + } + + // MLComponent(即使失败也继续) + try { SO_MLC = new MLComponent(); } + catch (Exception ex) { MessageBox.Show("MLComponentの初期化に失敗しました。\n" + ex.Message, "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); } + + // 日志文件名 + try + { + DateTime dtNow = DateTime.Now; + string stPrompt1 = dtNow.ToString("yyyyMMdd"); + LogfilePath = str_Confile[5]; + LogfileName = str_Confile[5] + str_Confile[6] + "_" + stPrompt1 + ".csv"; + Retry_num = Convert.ToInt32(str_Confile[8]); + } + catch (Exception ex) + { + MessageBox.Show("設定ファイルの内容でエラーが発生しました。\n" + ex.Message, "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error); + Application.Exit(); return; + } + + // 表格外观 + dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing; + dataGridView1.ColumnHeadersHeight = 30; + dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCellsExceptHeaders; + dataGridView1.ColumnCount = 8; + dataGridView1.Columns[0].HeaderText = "処理ログID"; + dataGridView1.Columns[1].HeaderText = "駐輪場ID"; + dataGridView1.Columns[2].HeaderText = "プロセス名"; + dataGridView1.Columns[3].HeaderText = "ジョブ名"; + dataGridView1.Columns[4].HeaderText = "ステータス"; + dataGridView1.Columns[5].HeaderText = "エラーコード"; + dataGridView1.Columns[6].HeaderText = "ステータスコメント"; + dataGridView1.Columns[7].HeaderText = "登録日時"; + dataGridView1.EnableHeadersVisualStyles = false; + dataGridView1.ColumnHeadersDefaultCellStyle.BackColor = Color.ForestGreen; + + // 读取最近日志(失败也继续,但会把错误写到本地日志) + result = Logfile.ReadLogFile(); + if (result == 1) + { + SO_LogEdit(LETYPE_LOGFRD); + SO_WriteLog(); + Application.Exit(); return; + } + for (int i = 0; i < OutLogNum; i++) + dataGridView1.Rows.Add(Form1.koumoku[i, 0], Form1.koumoku[i, 1], Form1.koumoku[i, 2], Form1.koumoku[i, 3], + Form1.koumoku[i, 4], Form1.koumoku[i, 5], Form1.koumoku[i, 6], Form1.koumoku[i, 7]); + + // ===== 初始化 ===== + + // 尝试连接数据库(不受 MOCK_HW 影响) + try + { + // 如果 DEMO_DB=true,会在各 DB 函数里直接短路返回;这里仍尝试打开连接,便于随时切换 + SO_DBOpen(); + } + catch { /* 具体弹窗已在 SO_DBOpen 内部做了 */ } + + // 印字环境(DB 可用时读库;否则用默认值) + try + { + if (!DEMO_DB && IsDbReady) + { + bResult = SO_PrnEnvRead_rty(); + if (!bResult) { SO_CommIniErr(LETYPE_DBERR, 2); Application.Exit(); return; } + } + else + { + Prn_MaxNum = 1000; Prn_NowNum = 0; Prn_Alert_num = 50; Prn_Alert_flg = 0; Prn_ParkName = "デモ駐輪場"; + } + } + catch (Exception ex) + { + MessageBox.Show("印字環境読み取りでエラーが発生しました。\n" + ex.Message + "\n\nデフォルト値で続行します。", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); + Prn_MaxNum = 1000; Prn_NowNum = 0; Prn_Alert_num = 50; Prn_Alert_flg = 0; Prn_ParkName = "デモ駐輪場"; + } + + // 硬件初始化(MOCK_HW=true 则跳过) + if (!MOCK_HW) + { + try + { + bResult = SO_PrnInit(); + if (!bResult) + { + var prnResult = MessageBox.Show("プリンタの初期化に失敗しました。\nプリンタなしで続行しますか?", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); + if (prnResult == DialogResult.No) { SO_CommIniErr(LETYPE_PRNINI, 3); Application.Exit(); return; } + } + } + catch (Exception ex) { MessageBox.Show("プリンタ初期化でエラーが発生しました。\n" + ex.Message + "\n\nプリンタなしで続行します。", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); } + + try + { + bResult = SO_MfifareInit(); + if (!bResult) + { + var mfResult = MessageBox.Show("Mifareリーダの初期化に失敗しました。\nMifareリーダなしで続行しますか?", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); + if (mfResult == DialogResult.No) { SO_CommIniErr(LETYPE_MFIINI, 4); Application.Exit(); return; } + } + } + catch (Exception ex) { MessageBox.Show("Mifareリーダ初期化でエラーが発生しました。\n" + ex.Message + "\n\nMifareリーダなしで続行します。", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); } + + try + { + bResult = SO_QRcordInit(); + if (!bResult) + { + var qrResult = MessageBox.Show("QRコードリーダの初期化に失敗しました。\nQRコードリーダなしで続行しますか?", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); + if (qrResult == DialogResult.No) { SO_CommIniErr(LETYPE_QRCINI, 5); Application.Exit(); return; } + } + } + catch (Exception ex) { MessageBox.Show("QRコードリーダ初期化でエラーが発生しました。\n" + ex.Message + "\n\nQRコードリーダなしで続行します。", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); } + } + else + { + StartDemoQrFeeder(); // 演示:自动“扫”二维码 + } + + // 启动日志:有DB走原逻辑;无DB只写本地文件 + if (!IsDbReady || DEMO_DB) { LogOnly(LETYPE_START, 6); } + else { bResult = SO_ComCont(LETYPE_START, 6); if (!bResult) { Application.Exit(); return; } } + + // KeepAlive + KEEPALIVE.TIM_Main(); + + // ================= 主循环 ================= + while (true) + { + // -------- 等待二维码/Mifare -------- + while (true) + { + Application.DoEvents(); + + if (EndType == 10) { Application.Exit(); return; } + + if (QRresult != 0) + { + if (QRresult == 1) { mode = QRresult; break; } + if (QRresult == 2) + { + if (!IsDbReady || DEMO_DB) { LogOnly(LETYPE_QRCERR, EndType); Application.Exit(); return; } + else { bResult = SO_ComCont(LETYPE_QRCERR, EndType); Application.Exit(); return; } + } + else { QRresult = 0; continue; } + } + else + { + if (MOCK_HW) { continue; } // 演示:完全跳过 Mifare 检查 + MFresult = SO_MfifareCheck(); + if (MFresult == 0) { mode = MFresult; break; } + else if ((MFresult <= 10) || (MFresult == 0xC0020001) || (MFresult == 0xC0020003)) { continue; } + else + { + if (!IsDbReady || DEMO_DB) { LogOnly(LETYPE_MFIERR, EndType); Application.Exit(); return; } + else { bResult = SO_ComCont(LETYPE_MFIERR, EndType); Application.Exit(); return; } + } + } + } + + // 暂停 KeepAlive + KEEPALIVE.MyTimer_stop(); + + // -------- DB 查询重试 -------- + for (int i = 0; i < Retry_num; i++) + { + str_uid = ""; + + if (mode == 1) + { + str_qrc = QRdata; + QRresult = 0; + result = SO_DBChk_qrnum(ref str_qrc, ref str_uid); + } + else + { + result = SO_DBChk_tagnum(ref str_uid); + } + + if (result == 0) + { + result = SO_CommLabelOutput(mode, ref str_uid, ref str_rctbl); + if (result != 0) + { + if (IsDbReady) { try { if (DBconnect.State != ConnectionState.Open) DBconnect.Open(); } catch { } } + continue; + } + break; + } + else if (result == 1) + { + if (IsDbReady) { try { if (DBconnect.State != ConnectionState.Open) DBconnect.Open(); } catch { } } + continue; + } + else + { + break; + } + } + + // -------- 查询结果处理 -------- + switch (result) + { + case 0: bResult = true; break; + case 1: + if (!IsDbReady || DEMO_DB) { LogOnly(LETYPE_DBERR, 6); Application.Exit(); return; } + else { bResult = SO_ComCont(LETYPE_DBERR, 6); Application.Exit(); return; } + case 2: + if (!IsDbReady || DEMO_DB) LogOnly(LETYPE_NONMFC, EndType); + else bResult = SO_ComCont(LETYPE_NONMFC, EndType); + break; + case 3: + if (!IsDbReady || DEMO_DB) LogOnly(LETYPE_NONQRC, EndType); + else bResult = SO_ComCont(LETYPE_NONQRC, EndType); + break; + case 4: + if (!IsDbReady || DEMO_DB) LogOnly(LETYPE_NONUID, EndType); + else bResult = SO_ComCont(LETYPE_NONUID, EndType); + break; + default: bResult = true; break; + } + if (!bResult) { Application.Exit(); return; } + + // -------- 可否与打印 -------- + bResult = SO_PRN_dtatchk(ref str_rctbl); + if (!bResult) break; + + result = SO_PrnOut(); // 演示下始终返回0(成功) + if (result != 0) + { + if (!IsDbReady || DEMO_DB) { LogOnly(LETYPE_PRNERR, EndType); Application.Exit(); return; } + else { bResult = SO_ComCont(LETYPE_PRNERR, EndType); Application.Exit(); return; } + } + + // -------- DB 写入 -------- + Prn_NowNum++; + if (((Prn_MaxNum - Prn_NowNum) < Prn_Alert_num) && (Prn_Alert_flg == 1)) + { + if (IsDbReady && !DEMO_DB) + { + result = SO_DBOpeQue(); + if (result != 0) + { + if (!IsDbReady || DEMO_DB) { LogOnly(LETYPE_DBERR, 6); Application.Exit(); return; } + else { bResult = SO_ComCont(LETYPE_DBERR, 6); Application.Exit(); return; } + } + } + } + else + { + if (IsDbReady && !DEMO_DB) + { + result = SO_DBNowPrnNum_rty(); + if (result != 0) + { + if (!IsDbReady || DEMO_DB) { LogOnly(LETYPE_DBERR, 6); Application.Exit(); return; } + else { bResult = SO_ComCont(LETYPE_DBERR, 6); Application.Exit(); return; } + } + } + } + + // 正常记录 + if (!IsDbReady || DEMO_DB) LogOnly(LETYPE_NORMAL, EndType); + else + { + bResult = SO_ComCont(LETYPE_NORMAL, EndType); + if (!bResult) { Application.Exit(); return; } + } + + KEEPALIVE.MyTimer_start(); + SO_LogFileDelCheck(); + Application.DoEvents(); + } + } + catch (Exception ex) + { + MessageBox.Show("アプリケーションでエラーが発生しました。\n" + ex.Message + "\n\nスタックトレース:\n" + ex.StackTrace, "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error); + Application.Exit(); + } + } + + //==================================================================================================================== + // エラー時共通の終了処理 + //==================================================================================================================== + private void SO_CommIniErr(int type, int n) + { + EndType = n; + SO_LogEdit(type); + + if ((type != LETYPE_DBOPEN) && (type != LETYPE_DBERR)) + { + SO_DBInsert_pjl(); + } + + SO_WriteLog(); + } + + //==================================================================================================================== + // 初期化以降の共通処理 + //==================================================================================================================== + private bool SO_ComCont(int type, int n) + { + uint ret = 0; + + EndType = n; + SO_LogEdit(type); + + if (type != LETYPE_DBERR) + { + bool bret = SO_DBInsert_pjl(); + if ((bret == false) || (n == LETYPE_DBERR)) + { + SO_LogEdit(LETYPE_DBERR); + SO_WriteLog(); + return false; + } + } + + ret = SO_WriteLog(); + if ((ret == 1) && (type == LETYPE_START) || (type == LETYPE_NORMAL)) + { + SO_LogEdit(LETYPE_LOGFWR); + SO_DBInsert_pjl(); + return false; + } + + return true; + } + + //==================================================================================================================== + // ローカルのログファイルに書き込み + //==================================================================================================================== + private uint SO_CommLabelOutput(uint mode, ref string str_uid, ref string[] str_rctbl) + { + uint uret = 0; + + // 利用者ID検索 + uret = SO_DBChk_usrid(str_uid, ref str_rctbl); + if (uret != 0) return 1; + + // 該当レコードなし(利用者ID) + if (str_rctbl[2].Length == 0) return 4; + + // 印刷情報取得 + uret = SO_PrnLabeEdit(mode); + if (uret == 1) return 1; + + return 0; + } + + //==================================================================================================================== + // ログファイル削除チェック + //==================================================================================================================== + private void SO_LogFileDelCheck() + { + int i = 0; + bool bret = true; + DateTime dtNow = DateTime.Now; + string Nowm = dtNow.ToString("yyyyMM"); + string Tgm = ""; + string work = ""; + + DirectoryInfo dir = new DirectoryInfo(Form1.LogfilePath); + if (!dir.Exists) return; + + FileInfo[] files = dir.GetFiles(); + + for (i = 0; i < files.Length; i++) + { + string f = Convert.ToString(files[i]); + work = f.Substring(f.Length - 12, 12); + Tgm = work.Substring(0, 6); + bret = LogFileChk_Mo(Nowm, Tgm); + if (bret == false) + { + System.IO.File.Delete(Form1.LogfilePath + files[i]); + } + } + } + + private bool LogFileChk_Mo(string Nwm, string Tgm) + { + int Ny, Ty; + int Nm, Tm; + int dy, dm, m, bd; + + Ny = Convert.ToInt32(Nwm.Substring(0, 4)); + Ty = Convert.ToInt32(Tgm.Substring(0, 4)); + Nm = Convert.ToInt32(Nwm.Substring(4, 2)); + Tm = Convert.ToInt32(Tgm.Substring(4, 2)); + bd = Convert.ToInt32(str_Confile[7]); + + dm = Nm - Tm; + if (dm < 0) + { + dm += 12; + --Ny; + } + + dy = Ny - Ty; + if (dy < 0) return true; + + m = dy * 12 + dm; + if (m > bd) return false; + + return true; + } + + //==================================================================================================================== + // 印刷可否判定 + //==================================================================================================================== + private bool SO_PRN_dtatchk(ref string[] str_rctbl) + { + string dateNow = Convert.ToString(DateTime.Now); + + if ((str_rctbl[4] != "1") || (str_rctbl[5] != "1")) return false; + + if ((dateNow.CompareTo(str_rctbl[1]) < 0) || (dateNow.CompareTo(str_rctbl[2]) > 0)) return false; + + if (dateNow.CompareTo(str_rctbl[3]) < 0) return false; + + return true; + } + + private void button1_Click(object sender, EventArgs e) + { + EndType = 10; + } + + //==================================================================================================================== + // ログ編集 + //==================================================================================================================== + private void SO_LogEdit(int n) + { + DateTime dtUtcNow = DateTime.Now; + + switch (n) + { + case LETYPE_NORMAL: + str_logkm[0] = " "; + str_logkm[2] = "定期シール発行"; + str_logkm[3] = "シール印刷"; + str_logkm[4] = "正常印刷"; + str_logkm[5] = "0"; + str_logkm[6] = " "; + break; + + case LETYPE_START: + str_logkm[0] = " "; + str_logkm[2] = " "; + str_logkm[3] = " "; + str_logkm[4] = "開始"; + str_logkm[5] = "0"; + str_logkm[6] = "起動しました"; + break; + + case LETYPE_DBERR: + str_logkm[0] = " "; + str_logkm[2] = "定期シール発行"; + str_logkm[3] = "利用者確認"; + str_logkm[4] = "error"; + str_logkm[5] = ERROR_CODE_DBERR.ToString(); + str_logkm[6] = "DBアクセスエラー"; + break; + + case LETYPE_DBOPEN: + str_logkm[0] = " "; + str_logkm[2] = "定期シール発行"; + str_logkm[3] = "初期化処理"; + str_logkm[4] = "DBアタッチエラー"; + str_logkm[5] = ERROR_CODE_DBOPEN.ToString(); + str_logkm[6] = "DB OPENに失敗"; + break; + + case LETYPE_LAYOUT: + str_logkm[2] = "定期シール発行"; + str_logkm[3] = "初期化処理"; + str_logkm[4] = "レイアウトファイルエラー"; + str_logkm[5] = ERROR_CODE_LAYOUT.ToString(); + str_logkm[6] = "レイアウトファイルが見つからない"; + break; + + case LETYPE_PRNINI: + str_logkm[0] = " "; + str_logkm[2] = "定期シール発行"; + str_logkm[3] = "初期化処理"; + str_logkm[4] = "プリンタ初期化エラー"; + str_logkm[5] = ERROR_CODE_PRNINI.ToString(); + str_logkm[6] = "プリンタ初期化に失敗"; + break; + + case LETYPE_MFIINI: + str_logkm[0] = " "; + str_logkm[2] = "定期シール発行"; + str_logkm[3] = "初期化処理"; + str_logkm[4] = "カードリーダ初期化エラー"; + str_logkm[5] = ERROR_CODE_MFIINI.ToString(); + str_logkm[6] = "Mifareリーダ初期化に失敗"; + break; + + case LETYPE_QRCINI: + str_logkm[0] = " "; + str_logkm[2] = "定期シール発行"; + str_logkm[3] = "初期化処理"; + str_logkm[4] = "カードリーダ初期化エラー"; + str_logkm[5] = ERROR_CODE_QRCINI.ToString(); + str_logkm[6] = "QRコードリーダ初期化に失敗"; + break; + + case LETYPE_NONMFC: + str_logkm[0] = " "; + str_logkm[2] = "定期シール発行"; + str_logkm[3] = "利用者確認"; + str_logkm[4] = "error"; + str_logkm[5] = ERROR_CODE_NONMFC.ToString(); + str_logkm[6] = "タグ利用者なし"; + break; + + case LETYPE_NONUID: + str_logkm[0] = " "; + str_logkm[2] = "定期シール発行"; + str_logkm[3] = "利用者確認"; + str_logkm[4] = "error"; + str_logkm[5] = ERROR_CODE_NONUID.ToString(); + str_logkm[6] = "タグ利用者なし"; + break; + + case LETYPE_NONQRC: + str_logkm[0] = " "; + str_logkm[2] = "定期シール発行"; + str_logkm[3] = "利用者確認"; + str_logkm[4] = "error"; + str_logkm[5] = ERROR_CODE_NONQRC.ToString(); + str_logkm[6] = "タグ利用者なし"; + break; + + case LETYPE_PRNERR: + str_logkm[0] = " "; + str_logkm[2] = "定期シール発行"; + str_logkm[3] = "利用者確認"; + str_logkm[4] = "error"; + str_logkm[5] = ERROR_CODE_PRNERR.ToString(); + str_logkm[6] = "プリンタエラー"; + break; + + case LETYPE_QRCERR: + str_logkm[0] = " "; + str_logkm[2] = "定期シール発行"; + str_logkm[3] = "利用者確認"; + str_logkm[4] = "error"; + str_logkm[5] = ERROR_CODE_QRCERR.ToString(); + str_logkm[6] = "QRコード読み取りエラー"; + break; + + case LETYPE_MFIERR: + str_logkm[2] = "定期シール発行"; + str_logkm[3] = "利用者確認"; + str_logkm[4] = "error"; + str_logkm[5] = ERROR_CODE_MFIERR.ToString(); + str_logkm[6] = "Mifare読み取りエラー"; + break; + + case LETYPE_CONFRD: + str_logkm[0] = ""; + str_logkm[2] = "定期シール発行"; + str_logkm[3] = "初期化処理"; + str_logkm[4] = "error"; + str_logkm[5] = ERROR_CODE_CONFRD.ToString(); + str_logkm[6] = "設定ファイル読み込みエラー"; + break; + + case LETYPE_LOGFRD: + str_logkm[2] = "定期シール発行"; + str_logkm[3] = "初期化処理"; + str_logkm[4] = "error"; + str_logkm[5] = ERROR_CODE_LOGFRD.ToString(); + str_logkm[6] = "ログファイル読み込みエラー"; + break; + + case LETYPE_LOGFWR: + str_logkm[0] = " "; + str_logkm[2] = "定期シール発行"; + str_logkm[3] = "利用者確認"; + str_logkm[4] = "error"; + str_logkm[5] = ERROR_CODE_LOGFWR.ToString(); + str_logkm[6] = "ログファイル書き込みエラー"; + break; + + default: + break; + } + + str_logkm[1] = str_Confile[3]; + str_logkm[7] = dtUtcNow.ToString(); + } + + //==================================================================================================================== + // ローカルのログファイルに書き込みと表示 + //==================================================================================================================== + private uint SO_WriteLog() + { + uint ret = 0; + + string str_logrec = str_logkm[0] + "," + str_logkm[1] + "," + str_logkm[2] + "," + str_logkm[3] + "," + str_logkm[4] + "," + str_logkm[5] + "," + str_logkm[6] + "," + str_logkm[7]; + System.Diagnostics.Trace.WriteLine(str_logrec); + + try + { + using (StreamWriter writer = new StreamWriter(LogfileName, true, Encoding.GetEncoding("utf-8"))) + { + writer.WriteLine(str_logrec); + } + } + catch (Exception e) + { + System.Diagnostics.Trace.WriteLine(e.Message); + ret = 1; + } + + for (int i = OutLogNum - 1; i > 0; i--) + { + for (int ii = 0; ii < 8; ii++) + { + dataGridView1[ii, i].Value = dataGridView1[ii, i - 1].Value; + } + } + + dataGridView1[0, 0].Value = str_logkm[0]; + dataGridView1[1, 0].Value = str_logkm[1]; + dataGridView1[2, 0].Value = str_logkm[2]; + dataGridView1[3, 0].Value = str_logkm[3]; + dataGridView1[4, 0].Value = str_logkm[4]; + dataGridView1[5, 0].Value = str_logkm[5]; + dataGridView1[6, 0].Value = str_logkm[6]; + dataGridView1[7, 0].Value = str_logkm[7]; + + this.Refresh(); + + return ret; + } + + //==================================================================================================================== + // DBオープン + //==================================================================================================================== + private bool SO_DBOpen() + { + bool ret = true; + + try + { + if (DBconnect == null) + { + DBconnect = new MySqlConnection(connectionParams); + } + + if (DBconnect.State != System.Data.ConnectionState.Open) + { + DBconnect.Open(); + } + } + catch (MySqlException mysqlEx) + { + System.Diagnostics.Trace.WriteLine("MySQL接続エラー: " + mysqlEx.Message); + + string errorMsg = "データベースへの接続に失敗しました。\n\n"; + errorMsg += "エラー詳細: " + mysqlEx.Message + "\n"; + errorMsg += "エラー番号: " + mysqlEx.Number + "\n\n"; + errorMsg += "以下を確認してください:\n"; + errorMsg += "1. MySQLサーバーが起動しているか\n"; + errorMsg += "2. データベース名が正しいか ('so-manager')\n"; + errorMsg += "3. ユーザー名とパスワードが正しいか\n"; + errorMsg += "4. ネットワーク接続が正常か"; + + MessageBox.Show(errorMsg, "データベース接続エラー", MessageBoxButtons.OK, MessageBoxIcon.Error); + ret = false; + } + catch (Exception e) + { + System.Diagnostics.Trace.WriteLine("データベース接続エラー: " + e.Message); + MessageBox.Show("データベース接続で予期しないエラーが発生しました。\n\nエラー: " + e.Message, + "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error); + ret = false; + } + + return ret; + } + + //==================================================================================================================== + // DB更新:デバイス管理マスタ(device) KeepAlive + //==================================================================================================================== + public static int SO_DBKpAlive(string Insert_SQL) + { + // ★ DEMO_DB or 未接続:什么也不做(返回成功) + if (DEMO_DB || DBconnect == null || DBconnect.State != ConnectionState.Open) return 0; + + var transaction = DBconnect.BeginTransaction(); + try + { + using (var DBcmd = new MySqlCommand(Insert_SQL, DBconnect)) + { + DBcmd.CommandTimeout = 3; + DBcmd.ExecuteNonQuery(); + } + transaction.Commit(); + return 0; + } + catch (Exception e) + { + System.Diagnostics.Trace.WriteLine(e.Message); + return 1; + } + } + + //==================================================================================================================== + // DB更新:駐輪場マスタ(print_number) + //==================================================================================================================== + private uint SO_DBNowPrnNum_rty() + { + if (DEMO_DB || !IsDbReady) return 0; + + uint ret = 0; + for (int i = 0; i < Retry_num; i++) + { + ret = SO_DBNowPrnNum(); + if (ret == 1) + { + try { if (DBconnect.State != ConnectionState.Open) DBconnect.Open(); } catch { } + } + else return 0; + } + return 1; + } + + private uint SO_DBNowPrnNum() + { + if (DEMO_DB || !IsDbReady) return 0; + + using (var transaction = DBconnect.BeginTransaction()) + { + string Update_SQL = "update park set print_number=" + Convert.ToString(Prn_NowNum) + + " where park_id=" + str_Confile[3] + ";"; + System.Diagnostics.Trace.WriteLine(Update_SQL); + try + { + using (var DBcmd = new MySqlCommand(Update_SQL, DBconnect)) { DBcmd.CommandTimeout = 3; DBcmd.ExecuteNonQuery(); } + transaction.Commit(); + return 0; + } + catch (Exception e) + { + System.Diagnostics.Trace.WriteLine(e.Message); + return 1; + } + } + } + + //==================================================================================================================== + // DB追加:オペレータキュー(operator_que) + //==================================================================================================================== + private uint SO_DBOpeQue() + { + if (DEMO_DB || !IsDbReady) return 0; + + using (var transaction = DBconnect.BeginTransaction()) + { + DateTime NowDate = DateTime.Now; + string Insert_SQL = + "INSERT INTO operator_que (park_id, que_class, que_status_comment, work_instructions, created_at, que_status) " + + $"VALUES ({str_Confile[3]},104,'{str_Confile[4]}','{Prn_ParkName}の用紙がもうすぐ無くなります。交換してください','{NowDate}',1);"; + try + { + using (var DBcmd = new MySqlCommand(Insert_SQL, DBconnect)) { DBcmd.CommandTimeout = 3; DBcmd.ExecuteNonQuery(); } + transaction.Commit(); + return 0; + } + catch (Exception e) + { + System.Diagnostics.Trace.WriteLine(e.Message); + return 1; + } + } + } + + //==================================================================================================================== + // DB検索:設定マスタ(setting),デバイス管理マスタ(device) + //==================================================================================================================== + private bool SO_PrnEnvRead_rty() + { + if (DEMO_DB || !IsDbReady) + { + Prn_MaxNum = 1000; Prn_NowNum = 0; Prn_Alert_num = 50; Prn_Alert_flg = 0; Prn_ParkName = "デモ駐輪場"; + return true; + } + for (int i = 0; i < Retry_num; i++) + { + if (SO_PrnEnvRead()) return true; + try { if (DBconnect.State != ConnectionState.Open) DBconnect.Open(); } catch { } + } + return false; + } + + private bool SO_PrnEnvRead() + { + if (DEMO_DB || !IsDbReady) + { + Prn_MaxNum = 1000; Prn_NowNum = 0; Prn_Alert_num = 50; Prn_Alert_flg = 0; Prn_ParkName = "デモ駐輪場"; + return true; + } + + string Select_SQL1 = "select printable_alert_flag,printable_number,printable_alert_number from setting;"; + string Select_SQL2 = "select park_name, print_number from park where park_id=" + str_Confile[3] + ";"; + string Select_SQL3 = "select device_id from device where park_id=" + str_Confile[3] + " and device_type='プリンタ' and device_work=1;"; + + var transaction1 = DBconnect.BeginTransaction(); + MySqlCommand DBcmd1 = new MySqlCommand(Select_SQL1, DBconnect); + DBcmd1.CommandTimeout = 3; + + try + { + MySqlDataReader reader = DBcmd1.ExecuteReader(); + while (reader.Read()) + { + Prn_Alert_flg = Convert.ToInt32(reader["printable_alert_flag"]); + Prn_MaxNum = Convert.ToInt32(reader["printable_number"]); + Prn_Alert_num = Convert.ToInt32(reader["printable_alert_number"]); + } + reader.Close(); + transaction1.Commit(); + } + catch (MySqlException e) + { + System.Diagnostics.Trace.WriteLine(e.Message); + DBconnect.Close(); + DBcmd1.Dispose(); + return false; + } + catch (Exception e) + { + System.Diagnostics.Trace.WriteLine(e.Message); + DBconnect.Close(); + DBcmd1.Dispose(); + return false; + } + + var transaction2 = DBconnect.BeginTransaction(); + MySqlCommand DBcmd2 = new MySqlCommand(Select_SQL2, DBconnect); + DBcmd2.CommandTimeout = 3; + + try + { + MySqlDataReader reader = DBcmd2.ExecuteReader(); + while (reader.Read()) + { + Prn_ParkName = Convert.ToString(reader["park_name"]); + if (reader.IsDBNull(1)) Prn_NowNum = 0; + else Prn_NowNum = Convert.ToInt32(reader["print_number"]); + } + reader.Close(); + transaction2.Commit(); + } + catch (Exception e) + { + System.Diagnostics.Trace.WriteLine(e.Message); + DBconnect.Close(); + DBcmd2.Dispose(); + return false; + } + + var transaction3 = DBconnect.BeginTransaction(); + MySqlCommand DBcmd3 = new MySqlCommand(Select_SQL3, DBconnect); + DBcmd3.CommandTimeout = 3; + + try + { + MySqlDataReader reader = DBcmd3.ExecuteReader(); + while (reader.Read()) + { + KpAlive_devid = Convert.ToString(reader["device_id"]); + } + reader.Close(); + transaction3.Commit(); + } + catch (Exception e) + { + System.Diagnostics.Trace.WriteLine(e.Message); + DBconnect.Close(); + DBcmd3.Dispose(); + return false; + } + + return true; + } + + //==================================================================================================================== + // DB検索:定期契約マスタ(regular_contract) - QR + //==================================================================================================================== + private uint SO_DBChk_qrnum(ref string str_qrc, ref string str_userid) + { + if (DEMO_DB || !IsDbReady) { str_userid = "1001"; return 0; } + + string Select_SQL = "select user_id from regular_contract where contract_qr_id='" + str_qrc + "';"; + var transaction = DBconnect.BeginTransaction(); + MySqlCommand DBcmd = new MySqlCommand(Select_SQL, DBconnect); + DBcmd.CommandTimeout = 3; + + try + { + MySqlDataReader reader = DBcmd.ExecuteReader(); + while (reader.Read()) + { + str_userid = Convert.ToString(reader["user_id"]); + } + reader.Close(); + transaction.Commit(); + } + catch (Exception e) + { + System.Diagnostics.Trace.WriteLine(e.Message); + DBconnect.Close(); + DBcmd.Dispose(); + return 1; + } + + if (str_userid.Length == 0) return 2; + return 0; + } + + //==================================================================================================================== + // DB検索:定期契約マスタ(regular_contract) - by user_id + //==================================================================================================================== + private uint SO_DBChk_usrid(string str_uid, ref string[] str_rctbl) + { + if (DEMO_DB || !IsDbReady) + { + var s = DateTime.Now.AddDays(-1); + var e = DateTime.Now.AddMonths(1).AddDays(-1); + str_rctbl[0] = "RC-DEMO-0001"; + str_rctbl[1] = s.ToString("yyyy/MM/dd HH:mm:ss"); + str_rctbl[2] = e.ToString("yyyy/MM/dd HH:mm:ss"); + str_rctbl[3] = s.ToString("yyyy/MM/dd HH:mm:ss"); + str_rctbl[4] = "1"; + str_rctbl[5] = "1"; + return 0; + } + + string Select_SQL = "select contract_id,contract_periods,contract_periode,printable_date,contract_flag,contract_permission from regular_contract where user_id =" + str_uid + ";"; + MySqlCommand DBcmd = new MySqlCommand(Select_SQL, DBconnect); + DBcmd.CommandTimeout = 3; + + try + { + var transaction = DBconnect.BeginTransaction(); + MySqlDataReader reader = DBcmd.ExecuteReader(); + + while (reader.Read()) + { + str_rctbl[0] = Convert.ToString(reader["contract_id"]); + str_rctbl[1] = Convert.ToString(reader["contract_periods"]); + str_rctbl[2] = Convert.ToString(reader["contract_periode"]); + str_rctbl[3] = Convert.ToString(reader["printable_date"]); + str_rctbl[4] = Convert.ToString(reader["contract_flag"]); + str_rctbl[5] = Convert.ToString(reader["contract_permission"]); + } + + reader.Close(); + transaction.Commit(); + } + catch (Exception e) + { + System.Diagnostics.Trace.WriteLine(e.Message); + DBconnect.Close(); + DBcmd.Dispose(); + return 1; + } + + return 0; + } + + //==================================================================================================================== + // DB検索:プリンタ利用者マスタ(user) - Mifare + //==================================================================================================================== + private uint SO_DBChk_tagnum(ref string str_userid) + { + if (DEMO_DB || !IsDbReady) { str_userid = "1001"; return 0; } + + var transaction = DBconnect.BeginTransaction(); + string Select_SQL = "select user_id from user where user_tag_serial='" + MFCODE + "';"; + MySqlCommand DBcmd = new MySqlCommand(Select_SQL, DBconnect); + DBcmd.CommandTimeout = 3; + + try + { + MySqlDataReader reader = DBcmd.ExecuteReader(); + while (reader.Read()) + { + str_userid = Convert.ToString(reader["user_id"]); + } + reader.Close(); + transaction.Commit(); + } + catch (Exception e) + { + System.Diagnostics.Trace.WriteLine(e.Message); + DBconnect.Close(); + DBcmd.Dispose(); + return 1; + } + + if (str_userid.Length == 0) return 3; + return 0; + } + + //==================================================================================================================== + // 印刷内容読み取り:駐車場名 + //==================================================================================================================== + private int SO_DBPrndat_pname() + { + if (DEMO_DB || !IsDbReady) { str_Prndat[0] = "デモ駐輪場"; return 0; } + + var transaction = DBconnect.BeginTransaction(); + MySqlCommand DBcmd = new MySqlCommand(DBREAD_park_name + str_Confile[3] + ";", DBconnect); + DBcmd.CommandTimeout = 3; + + try + { + MySqlDataReader reader = DBcmd.ExecuteReader(); + while (reader.Read()) + { + str_Prndat[0] = Convert.ToString(reader["park_name"]); + } + reader.Close(); + transaction.Commit(); + } + catch (Exception e) + { + System.Diagnostics.Trace.WriteLine(e.Message); + DBconnect.Close(); + DBcmd.Dispose(); + return 1; + } + + return 0; + } + + //==================================================================================================================== + // 印刷内容読み取り:定期種別 + //==================================================================================================================== + private int SO_DBPrndat_usubj1(uint type) + { + if (DEMO_DB || !IsDbReady) { str_Prndat[1] = " "; return 0; } + string str_Select; + + if (type == 0) + { + str_Select = DBREAD_utype_sub1[type] + "'" + MFCODE + "';"; + } + else + { + str_Select = DBREAD_utype_sub1[type] + "'" + QRdata + "';"; + } + + var transaction = DBconnect.BeginTransaction(); + MySqlCommand DBcmd = new MySqlCommand(str_Select, DBconnect); + DBcmd.CommandTimeout = 3; + + try + { + MySqlDataReader reader = DBcmd.ExecuteReader(); + while (reader.Read()) + { + string str_work = Convert.ToString(reader["usertype_subject1"]); + if (str_work == "学生") str_Prndat[1] = "学"; + else str_Prndat[1] = " "; + } + reader.Close(); + transaction.Commit(); + } + catch (Exception e) + { + System.Diagnostics.Trace.WriteLine(e.Message); + DBconnect.Close(); + DBcmd.Dispose(); + return 1; + } + + return 0; + } + + //==================================================================================================================== + // 印刷内容読み取り:場所種別 + //==================================================================================================================== + private int SO_DBPrndat_contid() + { + if (DEMO_DB || !IsDbReady) { str_Prndat[2] = "一般"; return 0; } + var transaction = DBconnect.BeginTransaction(); + MySqlCommand DBcmd = new MySqlCommand(DBREAD_ptype_subj + str_Confile[3] + ";", DBconnect); + DBcmd.CommandTimeout = 3; + + try + { + MySqlDataReader reader = DBcmd.ExecuteReader(); + while (reader.Read()) + { + str_Prndat[2] = Convert.ToString(reader["ptype_subject"]); + } + reader.Close(); + transaction.Commit(); + } + catch (Exception e) + { + System.Diagnostics.Trace.WriteLine(e.Message); + return 1; + } + + return 0; + } + + //==================================================================================================================== + // 印刷内容読み取り:開始日、終了日、定期契約ID + //==================================================================================================================== + private int SO_DBPrndat_cperiod(uint type) + { + if (DEMO_DB || !IsDbReady) + { + var s = DateTime.Now; + var e = DateTime.Now.AddMonths(1).AddDays(-1); + str_Prndat[3] = ""; Cperiods(s.ToString("yy/MM/dd HH:mm:ss"), ref str_Prndat[3]); + str_Prndat[4] = ""; Cperiode(e.ToString("yy/MM/dd HH:mm:ss"), ref str_Prndat[4]); + str_Prndat[6] = "C-DEMO-01234"; + return 0; + } + string str_Select; + string str_work1 = ""; + string str_work2 = ""; + string str_work3 = ""; + + if (type == 0) + { + str_Select = DBREAD_cont_periods[type] + "'" + MFCODE + "';"; + } + else + { + str_Select = DBREAD_cont_periods[type] + "'" + QRdata + "';"; + } + + var transaction = DBconnect.BeginTransaction(); + MySqlCommand DBcmd = new MySqlCommand(str_Select, DBconnect); + DBcmd.CommandTimeout = 3; + + try + { + MySqlDataReader reader = DBcmd.ExecuteReader(); + while (reader.Read()) + { + str_work1 = Convert.ToString(reader["contract_periods"]); + str_work2 = Convert.ToString(reader["contract_periode"]); + str_work3 = Convert.ToString(reader["contract_id"]); + } + reader.Close(); + transaction.Commit(); + } + catch (Exception e) + { + System.Diagnostics.Trace.WriteLine(e.Message); + DBconnect.Close(); + DBcmd.Dispose(); + return 1; + } + + Cperiods(str_work1, ref str_Prndat[3]); + Cperiode(str_work2, ref str_Prndat[4]); + str_Prndat[6] = str_work3; + + return 0; + } + + private void Cperiods(string str_work, ref string work) + { + int len = str_work.Length; + int mode = 0; + + work = str_work.Substring(2, 2) + "."; + for (int i = 5; i < len; i++) + { + if (mode == 0) + { + if (str_work[i] == '/') + { + work = work + '.'; + mode = 1; + } + else + { + work = work + str_work[i]; + } + } + else if (mode == 1) + { + if (str_work[i] == ' ') + { + break; + } + work = work + str_work[i]; + } + } + } + + private void Cperiode(string str_work, ref string work) + { + int len = str_work.Length; + + for (int i = 5; i < len; i++) + { + if (str_work[i] == '/') + { + break; + } + else + { + work = work + str_work[i]; + } + } + } + + //==================================================================================================================== + // 印刷内容読み取り:再発行 + //==================================================================================================================== + /* private int SO_DBPrndat_sis(uint type) + { + if (DEMO_DB || !IsDbReady) { str_Prndat[5] = "1"; return 0; } + string str_Select; + string str_work = ""; + + if (type == 0) + { + str_Select = DBREAD_cont_sissue[type] + "'" + MFCODE + "';"; + } + else + { + str_Select = DBREAD_cont_sissue[type] + "'" + QRdata + "';"; + } + + var transaction = DBconnect.BeginTransaction(); + MySqlCommand DBcmd = new MySqlCommand(str_Select, DBconnect); + DBcmd.CommandTimeout = 3; + + try + { + MySqlDataReader reader = DBcmd.ExecuteReader(); + while (reader.Read()) + { + str_work = Convert.ToString(reader["contract_seal_issue"]); + } + reader.Close(); + transaction.Commit(); + } + catch (Exception e) + { + System.Diagnostics.Trace.WriteLine(e.Message); + DBconnect.Close(); + DBcmd.Dispose(); + return 1; + } + + int n = Convert.ToInt32(str_work); + if (n > 1) str_Prndat[5] = "再" + str_work; + else str_Prndat[5] = str_work; + + return 0; + }*/ + // 印刷内容読み取り:再発行 (C# 7.3 互換) + private int SO_DBPrndat_sis(uint type) + { + if (DEMO_DB || !IsDbReady) { str_Prndat[5] = "1"; return 0; } + + string str_Select = (type == 0) + ? DBREAD_cont_sissue[0] + "'" + MFCODE + "';" + : DBREAD_cont_sissue[1] + "'" + QRdata + "';"; + + int n = 1; // デフォルト=初回発行 + + try + { + using (var transaction = DBconnect.BeginTransaction()) + using (var DBcmd = new MySqlCommand(str_Select, DBconnect)) + { + DBcmd.CommandTimeout = 3; + // DBcmd.Transaction = transaction; // SELECT なので不要だが付けても良い + + using (var reader = DBcmd.ExecuteReader()) + { + if (reader.Read()) + { + object v = reader["contract_seal_issue"]; + int tmp; + if (v != DBNull.Value && v != null && + int.TryParse(Convert.ToString(v), out tmp)) + { + n = tmp; + } + } + } + + transaction.Commit(); + } + } + catch (Exception e) + { + System.Diagnostics.Trace.WriteLine(e.Message); + try { DBconnect.Close(); } catch { } + return 1; + } + + str_Prndat[5] = (n > 1) ? ("再" + n.ToString()) : n.ToString(); + return 0; + } + + + //==================================================================================================================== + // 印刷内容読み取り:自治体名 + //==================================================================================================================== + private int SO_DBPrndat_cname() + { + if (DEMO_DB || !IsDbReady) { str_Prndat[7] = "デモ市"; return 0; } + var transaction = DBconnect.BeginTransaction(); + MySqlCommand DBcmd = new MySqlCommand(DBREAD_city_name + str_Confile[3] + ";", DBconnect); + DBcmd.CommandTimeout = 3; + + try + { + MySqlDataReader reader = DBcmd.ExecuteReader(); + while (reader.Read()) + { + str_Prndat[7] = Convert.ToString(reader["city_name"]); + } + reader.Close(); + transaction.Commit(); + } + catch (Exception e) + { + System.Diagnostics.Trace.WriteLine(e.Message); + DBconnect.Close(); + DBcmd.Dispose(); + return 1; + } + + return 0; + } + + //==================================================================================================================== + // DB書き込み:プリンタ制御プログラムログ(print_job_log) + //==================================================================================================================== + private bool SO_DBInsert_pjl() + { + if (DEMO_DB || !IsDbReady) return true; + + string Insert_SQL = "insert into print_job_log ( park_id, process_name,job_name, status, error_code, status_comment, created_at) value (" + str_Confile[3] + ",'" + str_logkm[2] + "','" + str_logkm[3] + "','" + str_logkm[4] + "'," + str_logkm[5] + ",'" + str_logkm[6] + "','" + str_logkm[7] + "');"; + MySqlCommand DBcmd1 = new MySqlCommand(Insert_SQL, DBconnect); + MySqlTransaction transaction = DBconnect.BeginTransaction(); + DBcmd1.Transaction = transaction; + DBcmd1.CommandTimeout = 3; + + try + { + DBcmd1.ExecuteNonQuery(); + transaction.Commit(); + } + catch (Exception e) + { + System.Diagnostics.Trace.WriteLine(e.Message); + return false; + } + + string Select_SQL = "select job_log_id from print_job_log where created_at=" + "'" + str_logkm[7] + "';"; + var transaction1 = DBconnect.BeginTransaction(); + MySqlCommand DBcmd = new MySqlCommand(Select_SQL, DBconnect); + DBcmd.CommandTimeout = 3; + + try + { + MySqlDataReader reader = DBcmd.ExecuteReader(); + while (reader.Read()) + { + str_logkm[0] = Convert.ToString(reader["job_log_id"]); + } + reader.Close(); + transaction1.Commit(); + } + catch (Exception e) + { + System.Diagnostics.Trace.WriteLine(e.Message); + DBconnect.Close(); + return false; + } + + return true; + } + + //==================================================================================================================== + // Mfifareリーダ初期化 + //==================================================================================================================== + private bool SO_MfifareInit() + { + if (MOCK_HW) return true; + + uint result = 0; + result = CreateObject_Ex(); + if (result != AidConst.NORMALEND) return false; + + result = ObjectSetUp_Ex(); + if (result != AidConst.NORMALEND) return false; + + result = RW_Authentication_Ex(); + return true; + } + + //==================================================================================================================== + // QRコードリーダ初期化 + //==================================================================================================================== + private bool SO_QRcordInit() + { + if (MOCK_HW) return true; + + bool ret = true; + + try + { + // 优先使用配置文件 + if (!string.IsNullOrWhiteSpace(str_Confile[0])) + serialPort1.PortName = str_Confile[0]; // 例如 COM3 + else + { + // 兜底取最后一个串口 + PortList = SerialPort.GetPortNames(); + int len = PortList.Length; + serialPort1.PortName = "COM" + len.ToString(); + } + + if (int.TryParse(str_Confile[1], out var baud)) serialPort1.BaudRate = baud; + else serialPort1.BaudRate = 9600; + + // StopBits:配置里“1”当作 One + serialPort1.StopBits = StopBits.One; + + serialPort1.DataBits = 8; + serialPort1.Parity = Parity.None; + + serialPort1.Open(); + } + catch (Exception ex) + { + System.Diagnostics.Trace.WriteLine(ex.Message); + ret = false; + } + + return ret; + } + + //==================================================================================================================== + // Mfifareリーダ確認 + //==================================================================================================================== + public uint SO_MfifareCheck() + { + if (MOCK_HW) return 0xC0020001; // 演示:总是当作“未捕捉到卡” + uint result = 0; + uint vmode = 0; + uint vspeed = 0; + uint vtype = 0; + uint vbuffSize = 0; + uint vinfLen = 0; + + vmode = 1000; // 検出タイムアウト時間を1000ms + vspeed = AidConst.CARDSPEED_DEFAULT; + vtype = 0; + vbuffSize = 64; + + result = (uint)icc.StartTransaction(vmode, vspeed, ref vtype, out vinfBuff, vbuffSize, out vinfLen); + if (result != AidConst.NORMALEND) return result; + + if (((uint)vtype & (~AidConst.CARDTYPE_MORECARD)) == AidConst.CARDTYPE_MIF) + { + string chk = string.Format("{0:X2}{1:X2}", vinfBuff[2], vinfBuff[1]); + if (chk == MFCODE_CHK) return 5; + } + else + { + return 5; + } + + if ((vtype & AidConst.CARDTYPE_MORECARD) != 0) return 6; + + date1 = DateTime.Now; + TimeSpan tc = date1 - date2; + int second = tc.Seconds; + + uint ret = bcmp(vinfBuff, vinfBuff2); + if ((second < 2) && (ret == 0)) result = 10; + + vinfBuff2 = vinfBuff; + date2 = date1; + + MFCODE = string.Format("{0:X2}{1:X2}{2:X2}{3:X2}{4:X2}{5:X2}{6:X2}", vinfBuff[2], vinfBuff[3], vinfBuff[4], vinfBuff[5], vinfBuff[6], vinfBuff[7], vinfBuff[8]); + System.Diagnostics.Trace.WriteLine(MFCODE); + return result; + } + + public static uint bcmp(byte[] buf1, byte[] buf2) + { + for (int i = 0; i < 10; i++) + { + if (buf1[i] != buf2[i]) return 1; + } + return 0; + } + + //==================================================================================================================== + // ラベル出力 + //==================================================================================================================== + public uint SO_PrnOut() + { + if (MOCK_HW || SO_MLC == null) + { + System.Diagnostics.Trace.WriteLine("**** [DEMO] 擬似印刷(実機なし) ****"); + return 0; + } + uint Result = 0; + string Status = ""; + + System.Diagnostics.Trace.WriteLine("**** プリンタ起動 ****"); + + if (Result != 0) return Result; + return Result; + } + + //==================================================================================================================== + // プリンタ初期化 + //==================================================================================================================== + private bool SO_PrnInit() + { + if (MOCK_HW || SO_MLC == null) return true; + + int Result = 0; + + SO_MLC.LayoutFile = str_layoutFile; + SO_MLC.PrnData = "1"; + SO_MLC.Setting = "USB:"; + SO_MLC.Protocol = (Protocols)1; + + Result = SO_MLC.OpenPort(1); + if (Result != 0) return false; + + SO_MLC.EjectCut = true; + SO_MLC.MultiCut = 1; + + return true; + } + + //==================================================================================================================== + // ラベル編集 + //==================================================================================================================== + private uint SO_PrnLabeEdit(uint type) + { + if (SO_DBPrndat_pname() != 0) return 1; + if (SO_DBPrndat_usubj1(type) != 0) return 1; + if (SO_DBPrndat_contid() != 0) return 1; + if (SO_DBPrndat_cperiod(type) != 0) return 1; + if (SO_DBPrndat_sis(type) != 0) return 1; + if (SO_DBPrndat_cname() != 0) return 1; + + if (SO_MLC != null) + { + SO_MLC.SetPrnDataField("駐車場名", str_Prndat[0]); + SO_MLC.SetPrnDataField("定期種別", str_Prndat[1]); + SO_MLC.SetPrnDataField("場所種別", str_Prndat[2]); + SO_MLC.SetPrnDataField("開始日", str_Prndat[3]); + SO_MLC.SetPrnDataField("終了月", str_Prndat[4]); + SO_MLC.SetPrnDataField("再発行", str_Prndat[5]); + SO_MLC.SetPrnDataField("定期番号", str_Prndat[6]); + SO_MLC.SetPrnDataField("自治体名", str_Prndat[7]); + SO_MLC.SetPrnDataField("発行枚数", "1"); + SO_MLC.EjectCut = true; + SO_MLC.MultiCut = 1; + } + return 0; + } + + //==================================================================================================================== + // 串口数据到达 + //==================================================================================================================== + private void serialPort1_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e) + { + if (serialPort1.IsOpen == false) + { + QRresult = 2; + return; + } + + try + { + date1 = DateTime.Now; + QRdata = serialPort1.ReadExisting(); + System.Text.Encoding hEncoding = System.Text.Encoding.GetEncoding("utf-32"); + QRresult = 1; + } + catch (Exception ex) + { + QRdata = ex.Message; + QRresult = 2; + } + + date1 = DateTime.Now; + + TimeSpan tc = date1 - date2; + int second = tc.Seconds; + bool isEqual = QRdata.SequenceEqual(QRdata2); + + if ((second < 2) && (isEqual)) + { + QRresult = 10; + } + // 为了方便联调,强制改成固定 QR(可注释掉) + QRdata = "QRID1234"; + + QRdata2 = QRdata; + date2 = date1; + } + + //==================================================================================================================== + // IFD/カード/APIオブジェクトの生成 + //==================================================================================================================== + private uint CreateObject_Ex() + { + if ((ifd != null) || (icc != null) || (mif != null)) ReleaseAid_Ex(); + + ifd = Activator.CreateInstance(Type.GetTypeFromProgID("IFD.RW")); + if (ifd == null) return (1); + + icc = Activator.CreateInstance(Type.GetTypeFromProgID("ICC.Card")); + if (icc == null) return (1); + + mif = Activator.CreateInstance(Type.GetTypeFromProgID("Mifare.API")); + if (mif == null) return (1); + + return (AidConst.NORMALEND); + } + + //==================================================================================================================== + // IFD/カード/APIオブジェクトに対するSetUp + //==================================================================================================================== + private uint ObjectSetUp_Ex() + { + uint result = 0; + string portName = ""; + short i = 0; + + for (i = 1; i <= 9; i++) + { + portName = "COM" + Convert.ToString(i); + result = (uint)ifd.SetUp("PR", ref portName); + if (result == AidConst.NORMALEND) break; + } + if (result != AidConst.NORMALEND) return 1; + + result = (uint)icc.SetUp("AM:MIF", ref ifd); + if (result != AidConst.NORMALEND) return 1; + + result = (uint)mif.SetUp(ref icc); + if (result != AidConst.NORMALEND) return 1; + + return result; + } + + //==================================================================================================================== + // IFD/カード/APIオブジェクトの開放 + //==================================================================================================================== + private void ReleaseAid_Ex() + { + if (mif != null) + { + Marshal.ReleaseComObject(mif); + mif = null; + } + if (icc != null) + { + Marshal.ReleaseComObject(icc); + icc = null; + } + if (ifd != null) + { + Marshal.ReleaseComObject(ifd); + ifd = null; + } + System.GC.Collect(); + } + + //==================================================================================================================== + // ホストとリーダライタ間での相互認証 + //==================================================================================================================== + private uint RW_Authentication_Ex() + { + uint result = 0; + uint vtag; + byte[] vinfBuff = new byte[257]; + uint vbuffSize = 0; + uint vinfLen = 0; + byte[] vvalue = {0x03, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0x00, + 0x00, + 0x00}; + + vtag = 0x4088010; // 制御タグ値 + vbuffSize = 256; + + result = (uint)ifd.SetControl(vtag, ref vvalue, out vinfBuff, vbuffSize, out vinfLen); + if (result != AidConst.NORMALEND) return result; + + Array.Clear(vvalue, 0, vvalue.Length); + vinfLen = 0; + + vtag = 0x4088003; + vvalue[0] = 0; + + result = (uint)ifd.SetControl(ref vtag, ref vvalue, ref vinfBuff, ref vbuffSize, ref vinfLen); + return result; + } + //==================================================================================================================== + // EndTransactionを実行し、カードを開放 + //==================================================================================================================== + private uint ReleaseCard_Ex() + { + uint result; + int vmode; + + + vmode = 0; // 開放条件:モード0 + + // カードオブジェクトを使用したEndTransactionの実行 + result = (uint)icc.EndTransaction(ref vmode); + + return result; + } + + //==================================================================================================================== + // FormClosing + //==================================================================================================================== + private void Form1_FormClosing(object sender, FormClosingEventArgs e) + { + try { if (DBconnect != null && DBconnect.State != ConnectionState.Closed) DBconnect.Close(); } catch { } + + if (EndType < 3) return; + + try { if (SO_MLC != null) SO_MLC.ClosePort(); } catch { } + if (EndType == 3) return; + + try { if (icc != null) ReleaseCard_Ex(); } catch { } + if (EndType == 4) return; + + try { if (serialPort1 != null && serialPort1.IsOpen) serialPort1.Close(); } catch { } + } + } + + //==================================================================================================================== + // コンフィグファイル読み出し + //==================================================================================================================== + class ConRead + { + public static uint ReadConFile(ref string[] con) + { + try + { + using (StreamReader sr1 = new StreamReader(Form1.CONFIG_PATH, System.Text.Encoding.GetEncoding("shift_jis"))) + { + int i = 0; + string a = ""; + while ((a = sr1.ReadLine()) != null && i < con.Length) + { + if (a.Length > 0) + { + string s1 = a.Substring(0, 1); + if (s1 != "#") + { + con[i++] = a; + } + } + } + + if (i < con.Length) + { + System.Diagnostics.Trace.WriteLine("設定ファイルの項目数が不足しています。期待値: " + con.Length + ", 実際: " + i); + return 1; + } + } + } + catch (Exception e) + { + System.Diagnostics.Trace.WriteLine(e.Message); + return 1; + } + + return 0; + } + } + + //==================================================================================================================== + // ログファイル読み出し + //==================================================================================================================== + class Logfile + { + public static uint ReadLogFile() + { + string[,] work = new string[Form1.OutLogNum, 8]; + int ei = 0; + + for (int i = 0; i < Form1.OutLogNum; i++) + { + for (int j = 0; j < 8; j++) + { + work[i, j] = ""; + } + } + + DirectoryInfo dir = new DirectoryInfo(Form1.LogfilePath); + if (!dir.Exists) + { + for (int i = 0; i < Form1.OutLogNum; i++) + { + for (int j = 0; j < 8; j++) + { + Form1.koumoku[i, j] = ""; + } + } + return 0; + } + + FileInfo[] files = dir.GetFiles(); + + if (files.Length == 0) + { + for (int i = 0; i < Form1.OutLogNum; i++) + { + for (int j = 0; j < 8; j++) + { + Form1.koumoku[i, j] = ""; + } + } + return 0; + } + + Array.Sort(files, delegate (FileInfo a, FileInfo b) + { + return a.Name.CompareTo(b.Name); + }); + Array.Reverse(files); + + string DispLogfile = Form1.LogfilePath + files[0].Name; + + try + { + using (var sr = new System.IO.StreamReader(DispLogfile, System.Text.Encoding.GetEncoding("shift_jis"))) + { + int i1 = 0; + while (!sr.EndOfStream && i1 < Form1.OutLogNum) + { + ei = i1; + + var line = sr.ReadLine(); + if (string.IsNullOrEmpty(line)) continue; + + var values = line.Split(','); + int i2 = 0; + foreach (var value in values) + { + if (i2 < 8) + { + work[i1, i2++] = value ?? ""; + } + else + { + break; + } + System.Diagnostics.Trace.WriteLine("{0} ", value); + } + + while (i2 < 8) + { + work[i1, i2++] = ""; + } + + i1++; + } + + for (int i = 0; i < Form1.OutLogNum; i++) + { + if (ei >= 0 && ei < Form1.OutLogNum) + { + for (int j = 0; j < 8; j++) + { + Form1.koumoku[i, j] = work[ei, j] ?? ""; + } + } + else + { + for (int j = 0; j < 8; j++) + { + Form1.koumoku[i, j] = ""; + } + } + ei--; + if (ei < 0) ei = Form1.OutLogNum - 1; + } + } + } + catch (System.Exception e) + { + System.Console.WriteLine(e.Message); + + for (int i = 0; i < Form1.OutLogNum; i++) + { + for (int j = 0; j < 8; j++) + { + Form1.koumoku[i, j] = ""; + } + } + return 1; + } + + return 0; + } + } + + //==================================================================================================================== + // Keep Alive + //==================================================================================================================== + public static class KEEPALIVE + { + public static System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer(); + + public static void TIM_Main() + { + timer.Tick += new EventHandler(MyTimer); + timer.Interval = Convert.ToInt32(Form1.str_Confile[7]) * 60000; + timer.Enabled = true; + System.Diagnostics.Trace.WriteLine("-----------"); + System.Diagnostics.Trace.WriteLine(timer.Interval); + } + + public static void MyTimer_stop() + { + timer.Enabled = false; + } + + public static void MyTimer_start() + { + timer.Enabled = true; + } + + public static void MyTimer(object sender, EventArgs e) + { + MyTimer_stop(); + + DateTime dtNow = DateTime.Now; + string str_stat = ""; + string use_mem = ""; + string free_mem = ""; + + System.Diagnostics.Process p = System.Diagnostics.Process.GetCurrentProcess(); + System.Management.ManagementClass mc = new System.Management.ManagementClass("Win32_OperatingSystem"); + System.Management.ManagementObjectCollection moc = mc.GetInstances(); + + foreach (System.Management.ManagementObject mo in moc) + { + free_mem = Convert.ToString(mo["FreePhysicalMemory"]); + mo.Dispose(); + } + + moc.Dispose(); + mc.Dispose(); + + use_mem = Convert.ToString(p.WorkingSet64 / 1000); + str_stat = "使用メモリ:[" + use_mem + "] 空きメモリ:[" + free_mem + "]"; + + string Insert_SQL = "INSERT INTO hardware_check_log (device_id, status, status_comment, created_at) VALUES (" + Form1.KpAlive_devid + ",1,'" + str_stat + "','" + dtNow + "');"; + + Form1.SO_DBKpAlive(Insert_SQL); + + System.Diagnostics.Trace.WriteLine("-----------"); + System.Diagnostics.Trace.WriteLine(timer.Interval); + + MyTimer_start(); + } + } +} diff --git a/SoM_PrnControl/Form1.resx b/SoM_PrnControl/Form1.resx new file mode 100644 index 0000000..c358324 --- /dev/null +++ b/SoM_PrnControl/Form1.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/SoM_PrnControl/MLComponentSettings.xml b/SoM_PrnControl/MLComponentSettings.xml new file mode 100644 index 0000000..9a2ca06 --- /dev/null +++ b/SoM_PrnControl/MLComponentSettings.xml @@ -0,0 +1,13 @@ + + + false + + true + + false + メイリオ + 9 + true + false + 0 + diff --git a/SoM_PrnControl/Program.cs b/SoM_PrnControl/Program.cs new file mode 100644 index 0000000..b320ff2 --- /dev/null +++ b/SoM_PrnControl/Program.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; +using SATO.MLComponent; + + +namespace qk30ic +{ + static class Program + { + /// + /// アプリケーションのメイン エントリ ポイントです。 + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +} diff --git a/SoM_PrnControl/Properties/AssemblyInfo.cs b/SoM_PrnControl/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..8fef15c --- /dev/null +++ b/SoM_PrnControl/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// アセンブリに関する一般情報は以下の属性セットをとおして制御されます。 +// アセンブリに関連付けられている情報を変更するには、 +// これらの属性値を変更してください。 +[assembly: AssemblyTitle("SoM_PenControl")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("SoM_PenControl")] +[assembly: AssemblyCopyright("Copyright © 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// ComVisible を false に設定すると、このアセンブリ内の型は COM コンポーネントから +// 参照できなくなります。COM からこのアセンブリ内の型にアクセスする必要がある場合は、 +// その型の ComVisible 属性を true に設定してください。 +[assembly: ComVisible(false)] + +// このプロジェクトが COM に公開される場合、次の GUID が typelib の ID になります +[assembly: Guid("40c2b03c-3efc-4f9e-b942-71d4f94f5a37")] + +// アセンブリのバージョン情報は次の 4 つの値で構成されています: +// +// メジャー バージョン +// マイナー バージョン +// ビルド番号 +// Revision +// +// すべての値を指定するか、次を使用してビルド番号とリビジョン番号を既定に設定できます +// 既定値にすることができます: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/SoM_PrnControl/Properties/MLComponentSettings.xml b/SoM_PrnControl/Properties/MLComponentSettings.xml new file mode 100644 index 0000000..9a2ca06 --- /dev/null +++ b/SoM_PrnControl/Properties/MLComponentSettings.xml @@ -0,0 +1,13 @@ + + + false + + true + + false + メイリオ + 9 + true + false + 0 + diff --git a/SoM_PrnControl/Properties/Resources.Designer.cs b/SoM_PrnControl/Properties/Resources.Designer.cs new file mode 100644 index 0000000..ef055da --- /dev/null +++ b/SoM_PrnControl/Properties/Resources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// このコードはツールによって生成されました。 +// ランタイム バージョン:4.0.30319.42000 +// +// このファイルへの変更は、以下の状況下で不正な動作の原因になったり、 +// コードが再生成されるときに損失したりします。 +// +//------------------------------------------------------------------------------ + +namespace SoM_PenControl.Properties { + using System; + + + /// + /// ローカライズされた文字列などを検索するための、厳密に型指定されたリソース クラスです。 + /// + // このクラスは StronglyTypedResourceBuilder クラスが ResGen + // または Visual Studio のようなツールを使用して自動生成されました。 + // メンバーを追加または削除するには、.ResX ファイルを編集して、/str オプションと共に + // ResGen を実行し直すか、または VS プロジェクトをビルドし直します。 + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// このクラスで使用されているキャッシュされた ResourceManager インスタンスを返します。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SoM_PenControl.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// すべてについて、現在のスレッドの CurrentUICulture プロパティをオーバーライドします + /// 現在のスレッドの CurrentUICulture プロパティをオーバーライドします。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/SoM_PrnControl/Properties/Resources.resx b/SoM_PrnControl/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/SoM_PrnControl/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/SoM_PrnControl/Properties/Settings.Designer.cs b/SoM_PrnControl/Properties/Settings.Designer.cs new file mode 100644 index 0000000..0859eba --- /dev/null +++ b/SoM_PrnControl/Properties/Settings.Designer.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// このコードはツールによって生成されました。 +// ランタイム バージョン:4.0.30319.42000 +// +// このファイルへの変更は、以下の状況下で不正な動作の原因になったり、 +// コードが再生成されるときに損失したりします。 +// +//------------------------------------------------------------------------------ + +namespace SoM_PenControl.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.14.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + } +} diff --git a/SoM_PrnControl/Properties/Settings.settings b/SoM_PrnControl/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/SoM_PrnControl/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/SoM_PrnControl/SoM_PrnControl.csproj b/SoM_PrnControl/SoM_PrnControl.csproj new file mode 100644 index 0000000..fc71437 --- /dev/null +++ b/SoM_PrnControl/SoM_PrnControl.csproj @@ -0,0 +1,135 @@ + + + + + Debug + AnyCPU + {40C2B03C-3EFC-4F9E-B942-71D4F94F5A37} + WinExe + SoM_PenControl + SoM_PenControl + v4.8 + 512 + true + true + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\Google.Protobuf.3.5.1\lib\net45\Google.Protobuf.dll + + + False + ..\..\..\ソーリン\ラベル\MLCMP-file-v5_8_4_0\MLComponent.dll + + + False + ..\..\..\ソーリン\ラベル\MLCMP-file-v5_8_4_0\MLComponent.XmlSerializers.dll + + + ..\packages\MySql.Data.8.0.12\lib\net452\MySql.Data.dll + + + + + + + + + + + + + + + + + + + + + + + + Form + + + Form1.cs + + + + + Form1.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + True + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + + False + Microsoft .NET Framework 4.6.1 %28x86 および x64%29 + true + + + False + .NET Framework 3.5 SP1 + false + + + + \ No newline at end of file diff --git a/SoM_PrnControl/packages.config b/SoM_PrnControl/packages.config new file mode 100644 index 0000000..16f1413 --- /dev/null +++ b/SoM_PrnControl/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file