internal CloseOneAndOpenAnotherOperation(Connection toClose, Connection toOpen)
		{
			this._connectionToClose = toClose;
			this._connectionToOpen = toOpen;
			this._connectionToClose.CloseCompleted += new EventHandler(this.HandleCloseCompleted);
			this._connectionToOpen.OpenCompleted += new EventHandler(this.HandleOpenCompleted);
		}
Exemplo n.º 2
0
        internal CloseOneAndOpenAnotherOperation(Connection toClose, Connection toOpen)
        {
            _connectionToClose = toClose;
            _connectionToOpen = toOpen;

            _connectionToClose.CloseCompleted += HandleCloseCompleted;
            _connectionToOpen.OpenCompleted += HandleOpenCompleted;
        }
Exemplo n.º 3
0
 internal CloseOperation(Connection connection)
 {
     _connection = connection;
     _connection.CloseCompleted += HandleCloseCompleted;
 }
Exemplo n.º 4
0
 internal OpenOperation(Connection connection)
 {
     _connection = connection;
     _connection.OpenCompleted += HandleOpenCompleted;
 }
Exemplo n.º 5
0
            /// <summary>
            /// 
            /// </summary>
            /// <returns></returns>
            public bool MoveNext()
            {
                while (true)
                {
                    if (_connectionEnumerator != null && _connectionEnumerator.MoveNext())
                    {
                        Guid key = (Guid) _connectionEnumerator.Current;
                        _currentConnection = null;
                        _currentConnections.TryGetValue(key, out _currentConnection);
                        if (_currentConnection != null)
                            return true;
                        else
                            continue;
                    }

                    if (_configEnumerator != null && _configEnumerator.MoveNext())
                    {
                        string configName = (string)_configEnumerator.Current;
                        _currentTable.TryGetValue(configName, out _currentConnections);
                        _connectionEnumerator = _currentConnections.Keys.GetEnumerator();

                        Debug.Assert(_connectionEnumerator != null, "Enumerator should not be null");

                        continue;
                    }

                    if (_tableEnumerator.MoveNext())
                    {
                        string tableName = (string)_tableEnumerator.Current;
                        _connectionPool.TryGetValue(tableName, out _currentTable);
                        _configEnumerator = _currentTable.Keys.GetEnumerator();
                        Debug.Assert(_configEnumerator != null, "Enumerator should not be null");
                        continue;
                    }

                    break;
                }

                return false;
            }
Exemplo n.º 6
0
        /// <summary>
        /// Service the request using the available connection
        /// </summary>
        /// <param name="requestInfo">request to service</param>
        /// <param name="connection">connection to use for servicing</param>
        private void AssignConnection(RequestInfo requestInfo, Connection connection)
        {
            IAsyncResult asyncResult = requestInfo.AsyncResult;
            GetRunspaceAsyncResult result = asyncResult as GetRunspaceAsyncResult;
            Debug.Assert(result != null, "IAsyncResult should be GetRunspaceAsyncResult");

            connection.Busy = true;

            connection.AsyncResult = result;
            result.Connection = connection;

            AddToPendingCallback(result);
        }
Exemplo n.º 7
0
        private static bool ValidateConnection(RequestInfo requestInfo, Connection connection)
        {
            if (connection.Runspace.RunspaceStateInfo.State != RunspaceState.Opened ) return false;

            WSManConnectionInfo connectionInfo = requestInfo.ConnectionInfo;

            // when validation is called the Connection will have a runspace populated
            WSManConnectionInfo connectionInfo2 = connection.Runspace.OriginalConnectionInfo as WSManConnectionInfo;

            // Runspace.OriginalConnectionInfo is null for disconnected runspace after process crash
            if(connectionInfo2 == null)
                connectionInfo2 = connection.Runspace.ConnectionInfo as WSManConnectionInfo;

            if (connectionInfo2 == null) return false;
            
            // check URI related stuff
            if (!WorkflowUtils.CompareConnectionUri(connectionInfo, connectionInfo2))
            {
                return false;
            }

            // compare shell URI
            if (!WorkflowUtils.CompareShellUri(connectionInfo.ShellUri, connectionInfo2.ShellUri))
            {
                return false;
            }

            // check authentication
            if (!WorkflowUtils.CompareAuthentication(connectionInfo.AuthenticationMechanism, connectionInfo2.AuthenticationMechanism))
            {
                return false;
            }

            // check credentials if present
            if(!WorkflowUtils.CompareCredential(connectionInfo.Credential, connectionInfo2.Credential))
            {
                return false;
            }

            //check certificate thumbprint
            if (!WorkflowUtils.CompareCertificateThumbprint(connectionInfo.CertificateThumbprint, connectionInfo2.CertificateThumbprint))
            {
                return false;
            }

            //check proxy settings 
            if (!WorkflowUtils.CompareProxySettings(connectionInfo, connectionInfo2))
            {
                return false;
            }

            //check rest of wsman settings 
            if (!WorkflowUtils.CompareOtherWSManSettings(connectionInfo, connectionInfo2))
            {
                return false;
            }

            // check open timeout
            if (connectionInfo2.IdleTimeout < connectionInfo.IdleTimeout)
                return false;

            return true;
        }
Exemplo n.º 8
0
			public bool MoveNext()
			{
				do
				{
				Label0:
					if (this._connectionEnumerator == null || !this._connectionEnumerator.MoveNext())
					{
						if (this._configEnumerator == null || !this._configEnumerator.MoveNext())
						{
							if (!this._tableEnumerator.MoveNext())
							{
								return false;
							}
							else
							{
								string current = (string)this._tableEnumerator.Current;
								this._connectionPool.TryGetValue(current, out this._currentTable);
								this._configEnumerator = this._currentTable.Keys.GetEnumerator();
								goto Label0;
							}
						}
						else
						{
							string str = (string)this._configEnumerator.Current;
							this._currentTable.TryGetValue(str, out this._currentConnections);
							this._connectionEnumerator = this._currentConnections.Keys.GetEnumerator();
							goto Label0;
						}
					}
					else
					{
						Guid guid = (Guid)this._connectionEnumerator.Current;
						this._currentConnection = null;
						this._currentConnections.TryGetValue(guid, out this._currentConnection);
					}
				}
				while (this._currentConnection == null);
				return true;
			}
Exemplo n.º 9
0
		internal DisconnectOperation(Connection connection)
		{
			this._connection = connection;
			this._connection.DisconnectCompleted += new EventHandler(this.HandleDisconnectCompleted);
		}
Exemplo n.º 10
0
		internal CloseOperation(Connection connection)
		{
			this._connection = connection;
			this._connection.CloseCompleted += new EventHandler(this.HandleCloseCompleted);
		}
Exemplo n.º 11
0
		internal OpenOperation(Connection connection)
		{
			this._connection = connection;
			this._connection.OpenCompleted += new EventHandler(this.HandleOpenCompleted);
		}
Exemplo n.º 12
0
		private Connection CreateConnection(ConnectionManager.RequestInfo requestInfo, ConcurrentDictionary<Guid, Connection> connections)
		{
			Connection connection = new Connection(this);
			connection.ConnectionInfo = requestInfo.ConnectionInfo;
			connection.RetryCount = requestInfo.RetryCount;
			connection.RetryInterval = requestInfo.RetryInterval;
			connection.RetryAttempt = 0;
			connection.AsyncResult = requestInfo.AsyncResult;
			connection.Busy = true;
			Connection connection1 = connection;
			connections.TryAdd(connection1.InstanceId, connection1);
			ConnectionManager connectionManager = this;
			connectionManager._createdConnections = connectionManager._createdConnections + 1;
			ConnectionManager._perfCountersMgr.UpdateCounterByValue(PSWorkflowPerformanceCounterSetInfo.CounterSetId, 27, (long)1, true);
			return connection1;
		}
Exemplo n.º 13
0
		private void AssignConnection(ConnectionManager.RequestInfo requestInfo, Connection connection)
		{
			IAsyncResult asyncResult = requestInfo.AsyncResult;
			GetRunspaceAsyncResult getRunspaceAsyncResult = asyncResult as GetRunspaceAsyncResult;
			connection.Busy = true;
			connection.AsyncResult = getRunspaceAsyncResult;
			getRunspaceAsyncResult.Connection = connection;
			this.AddToPendingCallback(getRunspaceAsyncResult);
		}
Exemplo n.º 14
0
 internal DisconnectOperation(Connection connection)
 {
     _connection = connection;
     _connection.DisconnectCompleted += HandleDisconnectCompleted;
 }
Exemplo n.º 15
0
        private Connection CreateConnection(RequestInfo requestInfo, ConcurrentDictionary<Guid, Connection> connections)
        {
            Connection connection = new Connection(this)
            {
                ConnectionInfo = requestInfo.ConnectionInfo,
                RetryCount = requestInfo.RetryCount,
                RetryInterval = requestInfo.RetryInterval,
                RetryAttempt = 0,
                AsyncResult = requestInfo.AsyncResult,
                Busy = true
            };

            // the busy status should be set before adding to the
            // collection so that this connection is accounted in
            // the total and is not assigned to another request
            connections.TryAdd(connection.InstanceId, connection);

            _createdConnections++;
            _perfCountersMgr.UpdateCounterByValue(
                    PSWorkflowPerformanceCounterSetInfo.CounterSetId,
                    PSWorkflowPerformanceCounterIds.PSRemotingConnectionsCreatedCount);
            return connection;
        }
Exemplo n.º 16
0
 internal ReconnectOperation(Connection connection)
 {
     _connection = connection;
     _connection.ReconnectCompleted += HandleReconnectCompleted;
 }
Exemplo n.º 17
0
		private static bool ValidateConnection(ConnectionManager.RequestInfo requestInfo, Connection connection)
		{
			if (connection.Runspace.RunspaceStateInfo.State == RunspaceState.Opened)
			{
				WSManConnectionInfo connectionInfo = requestInfo.ConnectionInfo;
				WSManConnectionInfo originalConnectionInfo = connection.Runspace.OriginalConnectionInfo as WSManConnectionInfo;
				if (originalConnectionInfo != null)
				{
					if (WorkflowUtils.CompareConnectionUri(connectionInfo, originalConnectionInfo))
					{
						if (WorkflowUtils.CompareShellUri(connectionInfo.ShellUri, originalConnectionInfo.ShellUri))
						{
							if (WorkflowUtils.CompareAuthentication(connectionInfo.AuthenticationMechanism, originalConnectionInfo.AuthenticationMechanism))
							{
								if (WorkflowUtils.CompareCredential(connectionInfo.Credential, originalConnectionInfo.Credential))
								{
									if (WorkflowUtils.CompareCertificateThumbprint(connectionInfo.CertificateThumbprint, originalConnectionInfo.CertificateThumbprint))
									{
										if (WorkflowUtils.CompareProxySettings(connectionInfo, originalConnectionInfo))
										{
											if (WorkflowUtils.CompareOtherWSManSettings(connectionInfo, originalConnectionInfo))
											{
												if (originalConnectionInfo.IdleTimeout >= connectionInfo.IdleTimeout)
												{
													return true;
												}
												else
												{
													return false;
												}
											}
											else
											{
												return false;
											}
										}
										else
										{
											return false;
										}
									}
									else
									{
										return false;
									}
								}
								else
								{
									return false;
								}
							}
							else
							{
								return false;
							}
						}
						else
						{
							return false;
						}
					}
					else
					{
						return false;
					}
				}
				else
				{
					return false;
				}
			}
			else
			{
				return false;
			}
		}