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

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

            await _sqlCommandExecutor.ExecuteCommandAsync(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
            {
                await cn.OpenAsync();

                var par = _config.GetByQueue(queue);

                await _sqlCommandExecutor.ExecuteCommandAsync(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();
            }
        }