/// <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(); } }
public async Task MigrateDbAsync() { var cn = new SqlConnection(_connectionString); await cn.OpenAsync(); var tx = cn.BeginTransaction(); try { var queueConfigurations = new[] { _configProvider.GetByQueue(QueueType.Workflow), _configProvider.GetByQueue(QueueType.Event), _configProvider.GetByQueue(QueueType.Index) }; foreach (var item in queueConfigurations) { await CreateMessageType(cn, tx, item.MsgType); await CreateContract(cn, tx, item.ContractName, item.MsgType); await CreateQueue(cn, tx, item.QueueName); await CreateService(cn, tx, item.InitiatorService, item.QueueName, item.ContractName); await CreateService(cn, tx, item.TargetService, item.QueueName, item.ContractName); } tx.Commit(); } catch { tx.Rollback(); throw; } finally { cn.Close(); } }