/// <summary> /// Closes the proxy used for Projects contract with the StackHashService. /// </summary> private void closeProjectsServiceProxy() { if (m_StackHashProjectsClient != null) { if (m_StackHashProjectsClient.State == CommunicationState.Faulted) { m_StackHashProjectsClient.Abort(); } else if (m_StackHashProjectsClient.State == CommunicationState.Opened) { m_StackHashProjectsClient.Close(); } m_StackHashProjectsClient = 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 openProjectsServiceProxy() { if (m_StackHashProjectsClient == 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 + "Projects"), identity); m_StackHashProjectsClient = new StackHashServices.ProjectsContractClient("NetTcpBinding_IProjectsContract", epa); NetTcpBinding binding = m_StackHashProjectsClient.ChannelFactory.Endpoint.Binding as NetTcpBinding; binding.MaxReceivedMessageSize = 50000000; binding.MaxBufferSize = 50000000; m_StackHashProjectsClient.InnerChannel.OperationTimeout = new TimeSpan(0, 15, 0); setDataSerializerOperationBehaviour(m_StackHashProjectsClient.ChannelFactory); } else { if (m_StackHashProjectsClient.State != CommunicationState.Opened) { closeProjectsServiceProxy(); openProjectsServiceProxy(); } } }