public void CreateRemoteUser(string targetQueueFullName, string certificateBinaryData)
        {
            if (string.IsNullOrWhiteSpace(CurrentServer))
            {
                throw new InvalidOperationException(ERROR_SERVER_IS_NOT_DEFINED);
            }

            Guid targetBroker = SqlScripts.GetBrokerId(targetQueueFullName);

            SqlScripts.ExecuteScript(ConnectionString, SqlScripts.CreateRemoteUserScript(targetBroker, certificateBinaryData));
        }
        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));
        }
        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());
        }
        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);
        }
        public void CreateRoute(string name, string sourceQueueFullName, string targetAddress, string targetQueueFullName)
        {
            if (string.IsNullOrWhiteSpace(CurrentServer))
            {
                throw new InvalidOperationException(ERROR_SERVER_IS_NOT_DEFINED);
            }

            Guid   sourceBroker    = SqlScripts.GetBrokerId(sourceQueueFullName);
            Guid   targetBroker    = SqlScripts.GetBrokerId(targetQueueFullName);
            string sourceQueueName = SqlScripts.GetQueueName(sourceQueueFullName);
            string targetQueueName = SqlScripts.GetQueueName(targetQueueFullName);

            string script = SqlScripts.CreateRouteScript(name, sourceBroker, sourceQueueName, targetAddress, targetBroker, targetQueueName);

            SqlScripts.ExecuteScript(ConnectionString, script);
        }