private bool ScannerInitialize() { Utils.Logging("ScannerInitialize"); try { _pr = new Pr22.DocumentReaderDevice(); } catch (Exception ex) { MessageBox.Show("Can't initialize DocumentReaderDevice/n" + ex); /*_socket.Emit(MainConfig.Initialize, new JObject * { * { "status", false }, * { "message", "Can't initialize DocumentReaderDevice/n" + ex }, * { "code", "APPREGISTER100A" } * }.ToString() * );*/ Utils.Logging("ScannerInitialize: Can't initialize DocumentReaderDevice"); return(true); } //Nhận máy quét List <string> Devices = Pr22.DocumentReaderDevice.GetDeviceList(); //Kiểm tra máy quét if (Devices.Count == 0) { MessageBox.Show("No scanner connected"); /* _socket.Emit(MainConfig.Initialize, new JObject * { * { "status", false }, * { "message", "No scanner connected" }, * { "code", "APPREGISTER100B" } * }.ToString() * );*/ Utils.Logging("ScannerInitialize: No scanner connected"); return(true); } //Nếu có máy quét thì thiết lập máy quét _pr.Connection += DeviceConnected; _pr.PresenceStateChanged += DocumentStateChanged; _pr.ImageScanned += ImageScanned; _pr.ScanFinished += ScanFinished; Utils.Logging("ScannerInitialize: Done"); return(false); }
public int prDisconnect() { /* Closing the device */ while (_pr != null) { try { if (ndoc != null) { ndoc.Dispose(); ndoc = null; } _pr.Scanner.CleanUpData(); _pr.Close(); _pr.Dispose(); _pr = null; break; } catch (Exception) { //if (gxSystem.GetErrorCode() == (int)GX_ERROR_CODES.GX_EBUSY) continue; } } return 0; }
public int prConnect() { if (_helper == null) _helper = new Helper(); try { /* Opening the PR system */ _pr = new Pr22.DocumentReaderDevice(); /* Object for the PR system */ _pr.PresenceStateChanged += new EventHandler<Pr22.Events.DetectionEventArgs>(Motdet); /* if (_pr.TestPowerState() != 0) { ErrorMessage = "The power is off"; return -1; } */ /* Validity check */ /* if (!_pr.IsValid()) { ErrorMessage = "Failed to initialize!"; return 1303; } */ /* Connecting to the first device */ _pr.UseDevice(0); } catch (Pr22.Exceptions.General e) { return _helper.GetErrorMessage(e, out _errorMessage); } catch (Exception e) { _errorMessage = e.Message + " --- prConnect()"; return 1305; } return 0; }