try catch Init printer

Đảo thử tự InitUsers
Kiểm tra đầu đọc QR
This commit is contained in:
Nguyen Dinh Thuan
2024-09-16 15:08:10 +07:00
parent 409d942352
commit 2b4a509e3a
4 changed files with 105 additions and 72 deletions
+27 -34
View File
@@ -1,4 +1,6 @@
using CoreScanner;
using SafeBagDE70.API;
using Serilog;
using System;
using System.Collections.Generic;
using System.Diagnostics;
@@ -16,6 +18,7 @@ using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Xml;
using System.Xml.Linq;
namespace SafeBagDE70
{
@@ -103,31 +106,11 @@ namespace SafeBagDE70
}
private async void PinCodeButton_Click(object sender, RoutedEventArgs e)
{
//var onScreenKeyboardProcess = new ProcessStartInfo("osk.exe")
//{
// UseShellExecute = true
//};
try
{
//var progFiles = @"C:\Program Files\Common Files\Microsoft Shared\ink";
//var keyboardPath = System.IO.Path.Combine(progFiles, "TabTip.exe");
//Process.Start(keyboardPath);
// AutomationElement.FromHandle(-1);
// string keyboardPath = @"C:\Program Files\Common Files\Microsoft Shared\ink\TabTip.exe";
// Process.Start(keyboardPath);
//await Launcher.LaunchUriAsync(new Uri("ms-inputapp://"));
//var onScreenKeyboardProcess = new ProcessStartInfo(@"C:\Program Files\Common Files\Microsoft Shared\ink\TabTip.exe")
//{
// UseShellExecute = true
//};
//Process.Start(onScreenKeyboardProcess);
QrCodePanel.Visibility = Visibility.Collapsed;
PinCodePanel.Visibility = Visibility.Visible;
cCoreScannerClass.BarcodeEvent -= new _ICoreScannerEvents_BarcodeEventEventHandler(OnBarcodeEvent);
}
catch {
@@ -157,21 +140,31 @@ namespace SafeBagDE70
int status; // Extended API return code
cCoreScannerClass.Open(0, scannerTypes, numberOfScannerTypes, out status);
short numberOfScanners; // Number of scanners expect to be used
int[] connectedScannerIDList = new int[255]; // List of scanner IDs to be returned
string outXML;
cCoreScannerClass.GetScanners(out numberOfScanners, connectedScannerIDList, out outXML, out status);
if (numberOfScanners > 0)
{
// Let's subscribe for events
int opcode = 1001; // Method for Subscribe events
//string outXML; // XML Output
string inXML = "<inArgs>" +
"<cmdArgs>" +
"<arg-int>1</arg-int>" + // Number of events you want to subscribe
"<arg-int>1</arg-int>" + // Comma separated event IDs
"</cmdArgs>" +
"</inArgs>";
// Subscribe for barcode events in cCoreScannerClass
// Let's subscribe for events
int opcode = 1001; // Method for Subscribe events
string outXML; // XML Output
string inXML = "<inArgs>" +
"<cmdArgs>" +
"<arg-int>1</arg-int>" + // Number of events you want to subscribe
"<arg-int>1</arg-int>" + // Comma separated event IDs
"</cmdArgs>" +
"</inArgs>";
cCoreScannerClass.ExecCommand(opcode, ref inXML, out outXML, out status);
cCoreScannerClass.ExecCommand(opcode, ref inXML, out outXML, out status);
}
else
{
Log.Information("Không tìm thấy đầu đọc QR");
AppData.DeviceStatus.OtherError = 1;
AppData.DeviceStatus.Description = "Không tìm thấy đầu đọc QR";
APIModels.SendEvent(AppData.DeviceStatus);
}
}
catch (Exception exp)
{