/// <summary> /// Wraps the PCSC function /// LONG SCardEndTransaction( /// SCARDHANDLE hCard, /// DWORD dwDisposition /// ); /// </summary> /// <param name="Disposition">A value from DISCONNECT enum</param> public override void EndTransaction(DISCONNECT Disposition) { if (PCSC.SCardIsValidContext(context) == PCSC.SCARD_S_SUCCESS) { lastError = PCSC.SCardEndTransaction(cardHandle, (UInt32)Disposition); ThrowSmartcardException("SCardEndTransaction", lastError); } }
/// <summary> /// Wraps the PCSC function /// LONG SCardEndTransaction( /// SCARDHANDLE hCard, /// DWORD dwDisposition /// ); /// </summary> /// <param name="Disposition">A value from DISCONNECT enum</param> public override void EndTransaction(DISCONNECT Disposition) { if (m_hCard != IntPtr.Zero) { m_nLastError = SCardEndTransaction(m_hCard, (UInt32)Disposition); if (m_nLastError != 0) { string msg = "SCardEndTransaction error: " + m_nLastError; throw new Exception(msg); } } }
/// <summary> /// Wraps the PCSC function /// LONG SCardEndTransaction( /// SCARDHANDLE hCard, /// DWORD dwDisposition /// ); /// </summary> /// <param name="Disposition">A value from DISCONNECT enum</param> public override void EndTransaction(DISCONNECT Disposition) { if (SCardIsValidContext(m_hContext) == SCARD_S_SUCCESS) { m_nLastError = SCardEndTransaction(m_hCard, (UInt32)Disposition); if (m_nLastError != 0) { string msg = "SCardEndTransaction error: " + m_nLastError; throw new Exception(msg); } } }
/// <summary> /// Wraps the PCSC function /// LONG SCardEndTransaction( /// SCARDHANDLE hCard, /// DWORD dwDisposition /// ); /// </summary> /// <param name="Disposition">A value from DISCONNECT enum</param> public override void EndTransaction(DISCONNECT Disposition) { if (m_hCard != 0) { m_nLastError = SCardEndTransaction(m_hCard, (UInt32)Disposition); if (m_nLastError != 0) { string msg = "SCardEndTransaction error: " + new Win32Exception(m_nLastError).Message; throw new Exception(msg); } } }
/// <summary> /// Wraps the PCSC function /// LONG SCardDisconnect( /// IN SCARDHANDLE hCard, /// IN DWORD dwDisposition /// ); /// </summary> /// <param name="Disposition"></param> public override void Disconnect(DISCONNECT Disposition) { if (m_hCard != IntPtr.Zero) { m_nLastError = SCardDisconnect(m_hCard, (uint)Disposition); m_hCard = IntPtr.Zero; if (m_nLastError != 0) { string msg = "SCardDisconnect error: " + m_nLastError; throw new Exception(msg); } ReleaseContext(); } }
/// <summary> /// Wraps the PCSC function /// LONG SCardDisconnect( /// IN SCARDHANDLE hCard, /// IN DWORD dwDisposition /// ); /// </summary> /// <param name="Disposition"></param> public override void Disconnect(DISCONNECT Disposition) { if (m_hCard != 0) { m_nLastError = SCardDisconnect(m_hCard, (uint)Disposition); m_hCard = 0; if (m_nLastError != 0) { string msg = "SCardDisconnect error: " + new Win32Exception(m_nLastError).Message; throw new Exception(msg); } ReleaseContext(); } }
/// <summary> /// Wraps the PCSC function /// LONG SCardDisconnect( /// IN SCARDHANDLE hCard, /// IN DWORD dwDisposition /// ); /// </summary> /// <param name="Disposition"></param> public override void Disconnect(DISCONNECT Disposition) { if (PCSC.SCardIsValidContext(context) == PCSC.SCARD_S_SUCCESS) { lastError = PCSC.SCardDisconnect(cardHandle, (uint)Disposition); cardHandle = IntPtr.Zero; try { ThrowSmartcardException("SCardDisconnect", lastError); } finally { ReleaseContext(); } } }
public void Disconnect(DISCONNECT disposition) { try { card.Disconnect(disposition); } catch (SmartCardException scEx) { SmartcardFault scFault = new SmartcardFault(scEx); throw new FaultException <SmartcardFault>(scFault); } catch (Exception ex) { GeneralFault genFault = new GeneralFault(ex); throw new FaultException <GeneralFault>(genFault); } }
/// <summary> /// Wraps the PCSC function /// LONG SCardDisconnect( /// IN SCARDHANDLE hCard, /// IN DWORD dwDisposition /// ); /// </summary> /// <param name="Disposition"></param> public override void Disconnect(DISCONNECT Disposition) { if (m_hCard != IntPtr.Zero) { m_nLastError = SCardDisconnect(m_hCard, (uint) Disposition); m_hCard = IntPtr.Zero; if (m_nLastError != 0) { string msg = "SCardDisconnect error: " + m_nLastError; throw new Exception(msg); } ReleaseContext(); } }
public void Disconnect(DISCONNECT disposition) { try { card.Disconnect(disposition); } catch (SmartCardException scEx) { SmartcardFault scFault = new SmartcardFault(scEx); throw new FaultException<SmartcardFault>(scFault); } catch (Exception ex) { GeneralFault genFault = new GeneralFault(ex); throw new FaultException<GeneralFault>(genFault); } }
/// <summary> /// Disconnect the current session /// </summary> /// <param name="Disposition">Action when disconnecting from the card</param> void Disconnect(DISCONNECT disposition) { cardClient.DisconnectAsync((SCardService.DISCONNECT)disposition).Wait(TIMEOUT); }
/// <summary> /// Ends a card transaction /// </summary> void EndTransaction(DISCONNECT disposition) { cardClient.EndTransactionAsync((SCardService.DISCONNECT)disposition).Wait(TIMEOUT); }
/// <summary> /// Wraps the PCSC function /// LONG SCardDisconnect( /// IN SCARDHANDLE hCard, /// IN DWORD dwDisposition /// ); /// </summary> /// <param name="Disposition"></param> public override void Disconnect(DISCONNECT Disposition) { // Off the connection with the card m_itfCard.Detach((SCARD_DISPOSITIONS)Disposition); }
abstract public void Disconnect(DISCONNECT Disposition);
public void Close() { if (!this.closed.Value && !transportFailed.Value) { this.Stop(); } lock (connectedLock) { if (this.closed.Value) { return; } try { Tracer.InfoFormat("Connection[{0}]: Closing Connection Now.", this.ClientId); this.closing.Value = true; Scheduler scheduler = this.scheduler; if (scheduler != null) { try { scheduler.Stop(); } catch (Exception e) { throw NMSExceptionSupport.Create(e); } } lock (sessions.SyncRoot) { foreach (Session session in sessions) { session.Shutdown(); } } sessions.Clear(); // Connected is true only when we've successfully sent our CONNECT // to the broker, so if we haven't announced ourselves there's no need to // inform the broker of a remove, and if the transport is failed, why bother. if (connected.Value && !transportFailed.Value) { DISCONNECT disconnect = new DISCONNECT(); transport.Oneway(disconnect); } executor.Shutdown(); if (!executor.AwaitTermination(TimeSpan.FromMinutes(1))) { Tracer.DebugFormat("Connection[{0}]: Failed to properly shutdown its executor", this.ClientId); } Tracer.DebugFormat("Connection[{0}]: Disposing of the Transport.", this.ClientId); transport.Stop(); transport.Dispose(); } catch (Exception ex) { Tracer.ErrorFormat("Connection[{0}]: Error during connection close: {1}", ClientId, ex); } finally { if (executor != null) { executor.Shutdown(); } this.transport = null; this.closed.Value = true; this.connected.Value = false; this.closing.Value = false; } } }
/// <summary> /// Wraps the PCSC function /// LONG SCardEndTransaction( /// SCARDHANDLE hCard, /// DWORD dwDisposition /// ); /// </summary> /// <param name="Disposition">A value from DISCONNECT enum</param> public override void EndTransaction(DISCONNECT Disposition) { if (SCardIsValidContext(m_hContext) == SCARD_S_SUCCESS) { m_nLastError = SCardEndTransaction(m_hCard, (UInt32)Disposition); ThrowSmartcardException("SCardEndTransaction", m_nLastError); } }
/// <summary> /// Wraps the PCSC function /// LONG SCardDisconnect( /// IN SCARDHANDLE hCard, /// IN DWORD dwDisposition /// ); /// </summary> /// <param name="Disposition"></param> public override void Disconnect(DISCONNECT Disposition) { if (SCardIsValidContext(m_hContext) == SCARD_S_SUCCESS) { m_nLastError = SCardDisconnect(m_hCard, (uint) Disposition); m_hCard = IntPtr.Zero; try { ThrowSmartcardException("SCardDisconnect", m_nLastError); } finally { ReleaseContext(); } } }
/// <summary> /// Ends a card transaction /// </summary> public void EndTransaction(DISCONNECT disposition) { try { cardClient.EndTransactionAsync((SCardService.DISCONNECT)disposition).Wait(TIMEOUT); } catch (AggregateException ax) { throw new Exception(ProcessAggregateException(ax)); } }
/// <summary> /// Wraps the PCSC function /// LONG SCardDisconnect( /// IN SCARDHANDLE hCard, /// IN DWORD dwDisposition /// ); /// </summary> /// <param name="Disposition"></param> public override void Disconnect(DISCONNECT Disposition) { // Off the connection with the card m_itfCard.Detach((SCARD_DISPOSITIONS) Disposition); }
/// <summary> /// Wraps the PCSC function /// LONG SCardEndTransaction( /// SCARDHANDLE hCard, /// DWORD dwDisposition /// ); /// This function is not supported in the COM implementation /// </summary> /// <param name="Disposition">A value from DISCONNECT enum</param> public override void EndTransaction(DISCONNECT Disposition) { throw new NotImplementedException("EndTransaction is not supported in the COM implementation"); }
abstract public void EndTransaction(DISCONNECT Disposition);
public static Command CreateCommand(byte fixedHeader) { Header header = new Header(fixedHeader); Command result = null; switch (header.Type) { case 1: result = new CONNECT(header); break; case 2: result = new CONNACK(header); break; case 3: result = new PUBLISH(header); break; case 4: result = new PUBACK(header); break; case 5: result = new PUBREC(header); break; case 6: result = new PUBREL(header); break; case 7: result = new PUBCOMP(header); break; case 8: result = new SUBSCRIBE(header); break; case 9: result = new SUBACK(header); break; case 10: result = new UNSUBSCRIBE(header); break; case 11: result = new UNSUBACK(header); break; case 12: result = new PINGREQ(header); break; case 13: result = new PINGRESP(header); break; case 14: result = new DISCONNECT(header); break; default: throw new NMSException("Unknown Command received"); } return(result); }