コード例 #1
0
ファイル: ScannerInfo.cs プロジェクト: nico-izo/KOIB
 public ScannerInfo(ScannerInfo info)
     : this(info.SerialNumber, info.IpAddress)
 {
 }
コード例 #2
0
ファイル: ScannerInfo.cs プロジェクト: xoposhiy/KOIB
 public ScannerInfo(ScannerInfo info)
     : this(info.SerialNumber, info.IpAddress)
 {
 }
コード例 #3
0
 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);
     }
 }
コード例 #4
0
 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);
     }
 }
コード例 #5
0
ファイル: VotingResults.cs プロジェクト: nico-izo/KOIB
 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;
     }
 }