Exemplo n.º 1
0
        public bool CreateQueue(QueueInfo queue, out string errorMessage)
        {
            errorMessage = string.Empty;

            if (string.IsNullOrWhiteSpace(CurrentServer))
            {
                errorMessage = ERROR_SERVER_IS_NOT_DEFINED;
                return(false);
            }
            if (string.IsNullOrWhiteSpace(CurrentDatabase))
            {
                errorMessage = ERROR_DATABASE_IS_NOT_DEFINED;
                return(false);
            }

            try
            {
                Guid brokerId = SqlScripts.ExecuteScalar <Guid>(ConnectionString, SqlScripts.SelectServiceBrokerIdentifierScript(CurrentDatabase));
                SqlScripts.ExecuteScript(ConnectionString, SqlScripts.CreateServiceQueueScript(brokerId, queue));
            }
            catch (Exception ex)
            {
                errorMessage = ExceptionHelper.GetErrorText(ex);
            }

            return(string.IsNullOrEmpty(errorMessage));
        }
Exemplo n.º 2
0
 public int GetServiceBrokerPortNumber()
 {
     if (string.IsNullOrWhiteSpace(CurrentServer))
     {
         throw new InvalidOperationException(ERROR_SERVER_IS_NOT_DEFINED);
     }
     return(SqlScripts.ExecuteScalar <int>(ConnectionString, SqlScripts.SelectServiceBrokerPortNumberScript()));
 }
Exemplo n.º 3
0
 public bool DaJetMQExists()
 {
     if (string.IsNullOrWhiteSpace(CurrentServer))
     {
         throw new InvalidOperationException(ERROR_SERVER_IS_NOT_DEFINED);
     }
     return(SqlScripts.ExecuteScalar <bool>(ConnectionString, SqlScripts.DaJetMQExistsScript()));
 }
Exemplo n.º 4
0
        public string GetUserCertificateBinaryData()
        {
            if (string.IsNullOrWhiteSpace(CurrentServer))
            {
                throw new InvalidOperationException(ERROR_SERVER_IS_NOT_DEFINED);
            }

            return(SqlScripts.ExecuteScalar <string>(ConnectionString, SqlScripts.SelectCertificateBinaryDataScript()));
        }
Exemplo n.º 5
0
        public void CreateQueue(string name)
        {
            if (string.IsNullOrWhiteSpace(CurrentServer))
            {
                throw new InvalidOperationException(ERROR_SERVER_IS_NOT_DEFINED);
            }

            Guid brokerId = SqlScripts.ExecuteScalar <Guid>(ConnectionString, SqlScripts.SelectServiceBrokerIdentifierScript());

            SqlScripts.ExecuteScript(ConnectionString, SqlScripts.CreateServiceQueueScript(brokerId, name));
        }
Exemplo n.º 6
0
        public string ReceiveMessage(string queueFullName)
        {
            if (string.IsNullOrWhiteSpace(CurrentServer))
            {
                throw new InvalidOperationException(ERROR_SERVER_IS_NOT_DEFINED);
            }

            string connectionString = AlterDatabaseConnectionString();
            string message          = SqlScripts.ExecuteScalar <string>(connectionString, SqlScripts.SimpleReceiveMessageScript(queueFullName));

            return(message);
        }
Exemplo n.º 7
0
        public IMessageConsumer CreateMessageConsumer(string queueName)
        {
            if (string.IsNullOrWhiteSpace(CurrentServer))
            {
                throw new InvalidOperationException(ERROR_SERVER_IS_NOT_DEFINED);
            }

            Guid   brokerId      = SqlScripts.ExecuteScalar <Guid>(ConnectionString, SqlScripts.SelectServiceBrokerIdentifierScript());
            string queueFullName = SqlScripts.CreateQueueName(brokerId, queueName);

            return(new MessageConsumer(CurrentServer, queueFullName));
        }
Exemplo n.º 8
0
        public void SetupServiceBroker()
        {
            if (string.IsNullOrWhiteSpace(CurrentServer))
            {
                throw new InvalidOperationException(ERROR_SERVER_IS_NOT_DEFINED);
            }

            SqlScripts.ExecuteScript(ConnectionString, SqlScripts.CreateDatabaseScript());
            Guid brokerId = SqlScripts.ExecuteScalar <Guid>(ConnectionString, SqlScripts.SelectServiceBrokerIdentifierScript());

            SqlScripts.ExecuteScript(ConnectionString, SqlScripts.CreateDatabaseUserScript(brokerId));
            SqlScripts.ExecuteScript(ConnectionString, SqlScripts.CreateChannelsTableScript());
        }
Exemplo n.º 9
0
        public void SendMessage(string routeName, string payload)
        {
            if (string.IsNullOrWhiteSpace(CurrentServer))
            {
                throw new InvalidOperationException(ERROR_SERVER_IS_NOT_DEFINED);
            }

            Guid   handle = SqlScripts.ExecuteScalar <Guid>(ConnectionString, SqlScripts.SelectDialogHandleScript(routeName));
            string sql    = SqlScripts.SendMessageToChannelScript();
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters.Add("handle", handle);
            parameters.Add("message", payload);
            SqlScripts.ExecuteScript(ConnectionString, sql, parameters);
        }
Exemplo n.º 10
0
        public bool DaJetMQExists()
        {
            if (string.IsNullOrWhiteSpace(CurrentServer))
            {
                throw new InvalidOperationException(ERROR_SERVER_IS_NOT_DEFINED);
            }
            bool result = false;

            try
            {
                result = SqlScripts.ExecuteScalar <bool>(ConnectionString, SqlScripts.DaJetMQExistsScript());
            }
            catch (Exception error)
            {
                // TODO: handle error
                result = false;
            }
            return(result);
        }