Ejemplo n.º 1
0
        public void TestConnectionCollection()
        {
            var items = new ConnectionCollection {
                _conn, _connHost, _connFalse, _connJustTrueServer
            };

            items["Test"] = _conn;

            Assert.AreEqual(items["Test"].ConnectionString, _conn.ConnectionString);

            foreach (var cm in items.Select(x => new ConnectionManager(x)))
            {
                TestTools.ExceptException <SqlException>(() =>
                {
                    cm.Open();
                    Assert.IsTrue(cm.State == ConnectionState.Open);
                });
            }
        }
Ejemplo n.º 2
0
        public void TestConnectionCollection()
        {
            var items = new ConnectionCollection { _conn, _connHost, _connFalse, _connJustTrueServer };

            items["Test"] = _conn;

            Assert.AreEqual(items["Test"].ConnectionString, _conn.ConnectionString);

            foreach (var cm in items.Select(x => new ConnectionManager(x)))
            {
                TestTools.ExceptException<SqlException>(() =>
                {
                    cm.Open();
                    Assert.IsTrue(cm.State == ConnectionState.Open);
                });
            }
        }
        public IEnumerable <GatewayConnectionContext> GetVirtualNetworkConnectionCommandProcess()
        {
            IEnumerable <GatewayConnectionContext> gatewayConnectionContexts;
            Func <string, ConnectionCollection>    func = null;

            using (OperationContextScope operationContextScope = new OperationContextScope((IContextChannel)base.Channel))
            {
                try
                {
                    GetAzureVNetConnectionCommand getAzureVNetConnectionCommand = this;
                    if (func == null)
                    {
                        func = (string s) => base.Channel.ListVirtualNetworkConnections(s, this.VNetName);
                    }
                    ConnectionCollection connectionCollection = ((CmdletBase <IGatewayServiceManagement>)getAzureVNetConnectionCommand).RetryCall <ConnectionCollection>(func);
                    Operation            operation            = base.WaitForGatewayOperation(base.CommandRuntime.ToString());
                    gatewayConnectionContexts = connectionCollection.Select <Connection, GatewayConnectionContext>((Connection c) => {
                        string str;
                        string str1;
                        string str2;
                        GatewayConnectionContext gatewayConnectionContext = new GatewayConnectionContext();
                        gatewayConnectionContext.OperationId               = operation.OperationTrackingId;
                        gatewayConnectionContext.OperationDescription      = this.CommandRuntime.ToString();
                        gatewayConnectionContext.OperationStatus           = operation.Status;
                        gatewayConnectionContext.ConnectivityState         = c.ConnectivityState;
                        gatewayConnectionContext.EgressBytesTransferred    = c.EgressBytesTransferred;
                        gatewayConnectionContext.IngressBytesTransferred   = c.IngressBytesTransferred;
                        gatewayConnectionContext.LastConnectionEstablished = c.LastConnectionEstablished;
                        GatewayConnectionContext gatewayConnectionContext1 = gatewayConnectionContext;
                        if (c.LastEvent != null)
                        {
                            int id = c.LastEvent.Id;
                            str    = id.ToString();
                        }
                        else
                        {
                            str = null;
                        }
                        gatewayConnectionContext1.LastEventID = str;
                        GatewayConnectionContext gatewayConnectionContext2 = gatewayConnectionContext;
                        if (c.LastEvent != null)
                        {
                            str1 = c.LastEvent.Message.ToString();
                        }
                        else
                        {
                            str1 = null;
                        }
                        gatewayConnectionContext2.LastEventMessage         = str1;
                        GatewayConnectionContext gatewayConnectionContext3 = gatewayConnectionContext;
                        if (c.LastEvent != null)
                        {
                            DateTime timestamp = c.LastEvent.Timestamp;
                            str2 = timestamp.ToString();
                        }
                        else
                        {
                            str2 = null;
                        }
                        gatewayConnectionContext3.LastEventTimeStamp  = str2;
                        gatewayConnectionContext.LocalNetworkSiteName = c.LocalNetworkSiteName;
                        return(gatewayConnectionContext);
                    }
                                                                                                                   );
                    return(gatewayConnectionContexts);
                }
                catch (CommunicationException communicationException1)
                {
                    CommunicationException communicationException = communicationException1;
                    if (communicationException as EndpointNotFoundException == null || base.IsVerbose())
                    {
                        this.WriteErrorDetails(communicationException);
                    }
                    else
                    {
                        gatewayConnectionContexts = null;
                        return(gatewayConnectionContexts);
                    }
                }
                return(null);
            }
            return(gatewayConnectionContexts);
        }