/// <summary> /// Closes the proxy used for Admin contract with the StackHashService. /// </summary> private void closeAdminServiceProxy() { if ((m_StackHashAdminClient != null) && (m_StackHashAdminClient.State != CommunicationState.Closed)) { if (m_StackHashAdminClient.State == CommunicationState.Faulted) { m_StackHashAdminClient.Abort(); } else if (m_StackHashAdminClient.State == CommunicationState.Opened) { m_StackHashAdminClient.Close(); } m_StackHashAdminClient = null; } }
/// <summary> /// Creates a proxy for communicating with the StackHash service Admin contract. /// The proxy is only created once. Trying to call more than once will have no /// additionaly effect. If the service is faulted then call CloseServiceProxy /// and then call this function again. /// A proxy is faulted if... /// Proxy.State == System.ServiceModel.CommunicationState.Faulted. /// </summary> private void openAdminServiceProxy() { if (m_StackHashAdminClient == null) { // create custom endpoint address in code - based on input in the textbox EndpointIdentity identity = EndpointIdentity.CreateSpnIdentity(m_ServicePrincipalName); EndpointAddress epa = new EndpointAddress(new Uri(m_ServiceEndpoint + "Admin"), identity); // This class implements the admin callback. InstanceContext context = new InstanceContext(this); m_StackHashAdminClient = new StackHashServices.AdminContractClient(context, "NetTcpBinding_IAdminContract", epa); m_StackHashAdminClient.InnerChannel.OperationTimeout = new TimeSpan(0, 15, 0); } else { if (m_StackHashAdminClient.State != CommunicationState.Opened) { closeAdminServiceProxy(); openAdminServiceProxy(); } } }