public void Save([NotNull] XmlTextWriter output) { Assert.ArgumentNotNull(output, nameof(output)); var blowFish = new BlowFish(BlowFish.CipherKey); var encryptedPassword = blowFish.Encrypt_ECB(Password); output.WriteStartElement(@"binding"); output.WriteAttributeString(@"hostName", HostName); output.WriteAttributeString(@"useWindowsAuth", UseWindowsAuth ? @"true" : @"false"); output.WriteAttributeString(@"userName", UserName); output.WriteAttributeString(@"password", encryptedPassword); output.WriteAttributeString(@"dataService", DataServiceName); output.WriteAttributeString(@"webRootPath", WebRootPath); output.WriteAttributeString(@"description", Description); output.WriteAttributeString(@"isRemoteSitecore", IsRemoteSitecore ? @"true" : @"false"); output.WriteAttributeString(@"automaticallyUpdate", AutomaticallyUpdate ? @"true" : @"false"); output.WriteAttributeString(@"isHidden", IsHidden ? @"true" : @"false"); output.WriteAttributeString(@"hostNameComparisonMode", HostNameComparisonMode.ToString()); output.WriteAttributeString(@"receiveTimeout", ReceiveTimeout.ToString()); output.WriteAttributeString(@"sendTimeout", SendTimeout.ToString()); output.WriteAttributeString(@"openTimeout", OpenTimeout.ToString()); output.WriteAttributeString(@"closeTimeout", CloseTimeout.ToString()); output.WriteAttributeString(@"maxReceivedMessageSize", MaxReceivedMessageSize.ToString()); output.WriteAttributeString(@"maxBufferSize", MaxBufferSize.ToString()); output.WriteAttributeString(@"maxBufferPoolSize", MaxBufferPoolSize.ToString()); output.WriteAttributeString(@"maxStringContentLength", MaxStringContentLength.ToString()); output.WriteAttributeString(@"transferMode", TransferMode.ToString()); output.WriteAttributeString(@"messageEncoding", MessageEncoding.ToString()); output.WriteAttributeString(@"textEncoding", TextEncoding.WebName); output.WriteAttributeString(@"bypassProxyOnLocal", BypassProxyOnLocal ? @"true" : @"false"); output.WriteAttributeString(@"useDefaultWebProxy", UseDefaultWebProxy ? @"true" : @"false"); if (ProxyAddress != null) { output.WriteAttributeString(@"proxyAddress", ProxyAddress.ToString()); } else { output.WriteAttributeString(@"proxyAddress", string.Empty); } output.WriteEndElement(); }
private void openTCPConnection() { string msg = IpAddress + ":" + PortNumber.ToString(); if (ConnectionType == SocketTransactorType.server) { IPEndPoint localEndPoint = new IPEndPoint(IPAddress.Parse(IpAddress), PortNumber); Socket listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); try { listener.Bind(localEndPoint); listener.Listen(MaxNumConnections); while (RunningInBG) { allDone.Reset(); listener.BeginAccept(new AsyncCallback(AcceptCallback), listener); allDone.WaitOne(); } // bye-bye if (listener.Connected) { listener.Shutdown(SocketShutdown.Both); } listener.Close(); OnTcpDisconnected(EventArgs.Empty); AppLogger.Log(LogLevel.VERBOSE, String.Format("{0} closed.", ConnectionType.ToString())); } catch (Exception e) { AppLogger.Log(LogLevel.ERROR, String.Format("Problem {0} {1} opening connection: {2}", ConnectionType.ToString(), msg, e.Message)); } } else if (ConnectionType == SocketTransactorType.client) { string cxnMsg = String.Empty; try { IPEndPoint remoteEP = new IPEndPoint(IPAddress.Parse(IpAddress), PortNumber); tcpSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); tcpSocket.BeginConnect(remoteEP, new AsyncCallback(ConnectCallback), tcpSocket); connectDone.WaitOne(); //OnTcpConnected(EventArgs.Empty); AppLogger.Log(LogLevel.DEBUG, String.Format("{0} {1} {2}", ConnectionType.ToString(), msg, MessageEncoding.ToString())); Receive(); // non-blocking due to callbacks receiveDone.WaitOne(); // TODO: revisit these later to debug //tcpSocket.Shutdown(SocketShutdown.Both); //tcpSocket.Close(); //OnTcpDisconnected(EventArgs.Empty); } catch (Exception e) { AppLogger.Log(LogLevel.ERROR, String.Format("Error client connecting to {0}: {1}", tcpSocket.RemoteEndPoint.ToString(), e.Message)); } } }