private static void OpenChannel() { try { objDistributed = new DocumentManagmentClient(); objDistributed.Open(); } catch (Exception ex) { new CustomLog().Exception(ex); new CustomLog().ProxyException(System.Reflection.MethodBase.GetCurrentMethod().Name, 0, true); throw; } }
private static void CloseChannel() { try { if (objDistributed != null) { if (objDistributed.State != CommunicationState.Faulted) { objDistributed.Close(); } else { objDistributed.Abort(); } } } catch (CommunicationException ex) { new CustomLog().CommunicationException(ex); new CustomLog().ProxyException(System.Reflection.MethodBase.GetCurrentMethod().Name, 0, true); // Communication exceptions are normal when // closing the connection. objDistributed.Abort(); } catch (TimeoutException ex) { new CustomLog().TimeoutException(ex, Types.ErrorLevel.Error); new CustomLog().ProxyException(System.Reflection.MethodBase.GetCurrentMethod().Name, 0, true); // Timeout exceptions are normal when closing // the connection. objDistributed.Abort(); } catch (Exception ex) { new CustomLog().Exception(ex, Types.ErrorLevel.Error); // Any other exception and you should // abort the connection and rethrow to // allow the exception to bubble upwards. objDistributed.Abort(); throw; } finally { // This is just to stop you from trying to // close it again (with the null check at the start). // This may not be necessary depending on // your architecture. objDistributed = null; } }
/// <summary> /// Metodo Dispose da Classe /// </summary> public void Dispose() { objDistributed = null; System.GC.SuppressFinalize(this); }