예제 #1
0
        internal void ParseCommand(ICommandCallback connection, JobInfo jobInfo)
        {
            if (!CheckConnection(connection))
            {
                return;
            }

            switch (jobInfo.Request.Command)
            {
            case CommandsIndex.PING:
                Ping(connection, Convert.ToBoolean(jobInfo.Request.Payload));
                break;

            case CommandsIndex.FORCE_DISCONNECT:
                ForceDisconnect(jobInfo.Request.Payload);
                break;

            case CommandsIndex.BUILD_SOLUTION:
                BuildSolution(jobInfo);
                break;

            case CommandsIndex.COPY_TO_PATCHES_FOLDER:
                CopyToPatchesFolder(jobInfo.Request.Payload);
                break;
            }
        }
예제 #2
0
 private bool CheckConnection(ICommandCallback connection)
 {
     if (!_commandService.ValidateConnection(connection))
     {
         connection.SendToClientCommand(new DropClientConnectionCommand());
         return(false);
     }
     else
     {
         _commandService.RefreshClientLastSeen(connection);
         return(true);
     }
 }
            public TypeSafeCallbackWrapper(ICommandCallback @delegate)
            {
                _delegate = @delegate;
                Type discoveredParameterType = typeof(object);

                foreach (var m in @delegate.GetType().GetMethods())
                {
                    if (m.IsGenericMethod && m.GetGenericArguments().Length == 2 && m.GetGenericArguments()[1] != typeof(object) && "OnSuccess".Equals(m.Name) && m.IsPublic)
                    {
                        discoveredParameterType = m.GetParameterTypes()[1];
                        if (discoveredParameterType != typeof(object))
                        {
                            break;
                        }
                    }
                }
                _parameterType = discoveredParameterType;
            }
예제 #4
0
        /// <summary>
        /// Executes ADO.NET operations on a command object, created by the provided IDbCommandCreator,
        /// using the interface based callback IDbCommandCallback.
        /// </summary>
        /// <param name="commandCreator">The command creator.</param>
        /// <param name="action">The callback to execute based on IDbCommand</param>
        /// <returns>A result object returned by the action or null</returns>
        public virtual object Execute(IDbCommandCreator commandCreator, ICommandCallback action)
        {
            AssertUtils.ArgumentNotNull(commandCreator, "commandCreator", "IDbCommandCreator must not be null");
            AssertUtils.ArgumentNotNull(action, "action", "Callback object must not be null");

            ConnectionTxPair connectionTxPairToUse = GetConnectionTxPair(DbProvider);


            IDbCommand command = null;
            try
            {
                command = commandCreator.CreateDbCommand(DbProvider);
                command.Connection = connectionTxPairToUse.Connection;
                command.Transaction = connectionTxPairToUse.Transaction;
                ApplyCommandSettings(command);
                //TODO collect warnings...
                //RegisterEventHandlers(command.Connection);
                Object result = action.DoInCommand(command);

                //SqlWarnings sqlWarnings = GetSqlWarnings()
                //ThrowExceptionOnWarningIfNotIgnoringWarnings(sqlWarnings);

                return result;
            }
            catch (Exception e)
            {
                commandCreator = null;
                DisposeCommand(command);
                command = null;
                DisposeConnection(connectionTxPairToUse.Connection, DbProvider);
                connectionTxPairToUse.Connection = null;
                if (DbProvider.IsDataAccessException(e))
                {
                    throw ExceptionTranslator.Translate("CommandCallback", GetCommandText(action), e);
                }
                else
                {
                    throw;
                }
            }
            finally
            {
                DisposeCommand(command);
                DisposeConnection(connectionTxPairToUse.Connection, DbProvider);
            }

        }
 public CommandGatewayFactory RegisterCommandCallback(ICommandCallback callback)
 {
     _commandCallbacks.Add(new TypeSafeCallbackWrapper(callback));
     return(this);
 }
 internal MergeRequestEndPointPOSTCommand(ICommandCallback callback, string endpoint)
 {
     _callback = callback;
     _endpoint = endpoint;
 }
예제 #7
0
 private void Ping(ICommandCallback connection, bool silent)
 {
     connection.SendToClientCommand(new PongCommand(silent));
 }
 public void Send <C, R>(C command, ICommandCallback <R> callback)
 {
     base.Send(command, callback);
 }