如何将GS1数据矩阵代码(带分隔符)导入C# winforms应用程序

kadbb459  于 2023-11-21  发布在  C#
关注(0)|答案(1)|浏览(277)

我使用条形码扫描仪读取medicine GS1 datamatrix代码。我需要整个数据序列,包括Group Separators来解析代码,以寻找应用程序标识符(AI)并获得相应的数据。目标是一个winforms C#应用程序,它将调用NMVS服务来检查medicines状态。实际上,我将TextBox作为目标控件,但其内容不再包含GS。
谢谢你的帮助
如果我用0x1D(ASCII 29)字符手动填充文本框作为分隔符,它就像一个魔咒。GS 1解析器找到AI,我可以提取数据。如果我打开Notepad++并将焦点放在它上面,然后扫描代码,特殊字符就会出现。我设置我的扫描仪,NETUM C750型号,以Map功能键,以便将分隔符包含在缓冲区中。

n6lpvg4x

n6lpvg4x1#

由于条形码扫描器被认为是一个键盘,我发现捕捉按键事件,使我填写一个字符列表。

  1. List<char> charList = new List<char>();
  2. private void textEditCode_KeyPress(object sender, KeyPressEventArgs e)
  3. {
  4. charList.Add(e.KeyChar);
  5. }
  6. string datamatrix = new string(charList.ToArray()); //charList is filled by pressing the keys, or when receiving data from the scanner
  7. Aii = gS1.Parse(datamatrix); // Aii = new Dictionary<string, string>();

字符串
之后,我将字符列表解析为GS1内容,并可以调用NMVS服务:

  1. string Batch = gS1.GetValue(EGS1AI.Batch);
  2. string ProductCode = gS1.GetValue(EGS1AI.GTIN);
  3. System.DateTime ExpDate = gS1.GetValue(EGS1AI.ExpirationDate);
  4. string SerialNumber = gS1.GetValue(EGS1AI.SerialNumber);
  5. string dat = ExpDate.ToString("yyMMdd");
  6. Log log = new Log(App.LogFolder(), App.AppName);
  7. G110Response response = G110.G110Verify(ProductCode, Batch, dat,
  8. SerialNumber, log);


然后处理响应

展开查看全部

相关问题