private void CreateService(SqlConnection cn, SqlTransaction tx, string name, string queueName, string contractName)
        {
            var cmdtext  = @"select name from sys.services where name=@name";
            var existing = _sqlCommandExecutor.ExecuteScalar <string>(cn, tx, cmdtext, new SqlParameter("@name", name));

            if (!string.IsNullOrEmpty(existing))
            {
                return;
            }

            _sqlCommandExecutor.ExecuteCommand(cn, tx, $"CREATE SERVICE [{name}] ON QUEUE [{queueName}]([{contractName}]);");
        }
Beispiel #2
0
        /// <inheritdoc />
        /// <summary>
        /// Write a new id to the specified queue
        /// </summary>
        /// <param name="id"></param>
        /// <param name="queue"></param>
        /// <returns></returns>
        public async Task QueueWork(string id, QueueType queue)
        {
            if (string.IsNullOrEmpty(id))
            {
                throw new ArgumentNullException(nameof(id), "Param id must not be null");
            }

            SqlConnection cn = new SqlConnection(_connectionString);

            try
            {
                cn.Open();
                var par = _config.GetByQueue(queue);

                _sqlCommandExecutor.ExecuteCommand(cn, null, _queueWorkCommand,
                                                   new SqlParameter("@initiatorService", par.InitiatorService),
                                                   new SqlParameter("@targetService", par.TargetService),
                                                   new SqlParameter("@contractName", par.ContractName),
                                                   new SqlParameter("@msgType", par.MsgType),
                                                   new SqlParameter("@RequestMessage", id)
                                                   );
            }
            finally
            {
                cn.Close();
            }
        }