public void Use(Action <ISMSMessagingService> action) { NetTcpBinding binding = new NetTcpBinding(); string endpointUrl = _config["WCFExternalServices:SMSMessagingService:EndpointAddress"]; EndpointAddress endpoint = new EndpointAddress(endpointUrl); ISMSMessagingService client = ProxyManager <ISMSMessagingService> .GetProxy(nameof(ISMSMessagingService), binding, endpoint); var user = new User(); user.userID = 88; client.SetCurrentUserAsync(user).Wait(); bool success = false; try { action(client); ((IClientChannel)client).Close(); success = true; } catch (FaultException) { ((IClientChannel)client).Close(); throw; } catch (TimeoutException) { } catch (Exception ex) { ((IClientChannel)client).Abort(); throw; } finally { if (!success) { ((IClientChannel)client).Abort(); } ((IClientChannel)client).Close(); ((IClientChannel)client).Dispose(); } }
public ProcessTransaction(ITollCollectionRepository repo, ISMSMessagingService sms) { _repo = repo; _sms = sms; _chargeService = new ChargeLogService(_repo); }