public bool ConnectToDevice(IDeviceInfo deviceInfo, out IDevice device) { try { device = deviceInfo.Connect(); return(true); } catch { device = null; return(false); } }
public void Scan(string deviceID, ScanSetting setting = null, bool scanAllPages = false) { if (setting == null) { setting = new ScanSetting(); } int page = 1; IDeviceInfo device = GetDeviceById(deviceID); Device connectedDevice = null; try { connectedDevice = device.Connect(); SetDeviceSettings(connectedDevice, setting); do { page = ScanImage(connectedDevice, page, setting); }while (scanAllPages); } catch (COMException ex) { var excpetion = GetException(ex); _logger?.LogError(ex.ToString()); if (page != 1 && excpetion.Code != ScanXExceptionCodes.NoPaper) { throw excpetion; } } catch (Exception ex) { _logger?.LogError(ex.ToString()); throw new ScanXException($"Error: {ex.ToString()}", ex, ScanXExceptionCodes.UnkownError); } }
public List <DeviceProperty> GetItemDeviceConnectProperties(string id) { List <DeviceProperty> result = new List <DeviceProperty>(); IDeviceInfo device = GetDeviceById(id); var connectedDevice = device.Connect(); foreach (IProperty item in connectedDevice.Items[1].Properties) { result.Add(new DeviceProperty() { Id = item.PropertyID, Name = item.Name, Value = item.get_Value() }); } result = result.OrderBy(a => a.Name).ToList(); return(result); }
public static IEnumerable <Item> GetImgItems(IDeviceInfo deviceInfo) { var device = deviceInfo.Connect(); return(device.Items.Cast <Item>().Where(i => i.Properties["Item Name"].get_Value().ToString().StartsWith("IMG"))); }
public static IEnumerable<Item> GetImgItems(IDeviceInfo deviceInfo) { var device = deviceInfo.Connect(); return device.Items.Cast<Item>().Where(i => i.Properties["Item Name"].get_Value().ToString().StartsWith("IMG")); }