public ScannerInfo(ScannerInfo info) : this(info.SerialNumber, info.IpAddress) { }
public void OpenIncomingInteractionChannel(string localSerialNumber, string localIpAddress) { CodeContract.Requires(!string.IsNullOrEmpty(localSerialNumber)); CodeContract.Requires(!string.IsNullOrEmpty(localIpAddress)); if (_hostChannel != null) return; _localScannerInfo = new ScannerInfo(localSerialNumber, localIpAddress); try { IDictionary props = new Hashtable(); props["name"] = "BpcTcpChannel"; props["port"] = REMOTE_INTERACTION_PORT; _hostChannel = new TcpChannel( props, new BinaryClientFormatterSinkProvider(), new BinaryServerFormatterSinkProvider()); ChannelServices.RegisterChannel(_hostChannel, false); Logger.LogInfo(Message.SyncChannelOpened, localIpAddress); } catch (Exception ex) { Logger.LogError(Message.SyncOpenInteractionChannelError, ex); } }
private void ScannerManager_RemoteScannerConnected(object sender, ScannerEventArgs e) { lock (s_remoteScannerSync) { if (IsRemoteScannerConnected) { Logger.LogVerbose(Message.SyncIgnoreRemoteScannerConnectedEvent); return; } _remoteScannerInfo = new ScannerInfo(e.SerialNumber, e.IpAddress); } if (_localScannerInfo == null) return; try { Logger.LogVerbose(Message.SyncTryOpenConnection); var uri = GetUriForRemoteInteraction(e.IpAddress); var connector = GetRemoteScannerConnector(uri); var allowed = connector.IsRemoteConnectionAllow( _localScannerInfo.SerialNumber, _localScannerInfo.IpAddress); if (!allowed) { Logger.LogVerbose(Message.SyncRemoteConnectionNotAllow); return; } _remoteScannerInterface.SetInteractionChannel(connector, _remoteScannerInfo); Logger.LogInfo(Message.SyncRemoteConnectionSuccess, e.SerialNumber, e.IpAddress); _remoteScannerDisconnected.Reset(); _remoteScannerConnected.Set(); RemoteScannerConnected.RaiseEvent(this); } catch (ThreadAbortException) { throw; } catch (Exception ex) { if (ex is RemotingException || ex is SocketException) Logger.LogInfo(Message.SyncCannotConnectToRemoteScanner, ex.Message); else Logger.LogError(Message.SyncConnectRemoteScannerError, ex); } }
public List<ScannerInfo> GetScannerInfos() { lock (s_votesSync) { var resultList = new List<ScannerInfo>(); foreach (VoteKey key in _votes.Keys) { if (key.ScannerSerialNumber == null) continue; var scannerInfo = new ScannerInfo(key.ScannerSerialNumber.ToString(), null); if (!resultList.Contains(scannerInfo)) resultList.Add(scannerInfo); } return resultList; } }