Пример #1
0
        protected async Task CommitAsync(string listBlockId, IListBlockItem <TItem> item)
        {
            var singleUpdateRequest = new SingleUpdateRequest()
            {
                TaskId        = new TaskId(_applicationName, _taskName),
                ListBlockId   = listBlockId,
                ListBlockItem = Convert(item)
            };

            Func <SingleUpdateRequest, Task> actionRequest = _listBlockRepository.UpdateListBlockItemAsync;
            await RetryService.InvokeWithRetryAsync(actionRequest, singleUpdateRequest).ConfigureAwait(false);
        }
Пример #2
0
        protected void Commit(string listBlockId, IListBlockItem <TItem> item)
        {
            var singleUpdateRequest = new SingleUpdateRequest()
            {
                TaskId        = new TaskId(_applicationName, _taskName),
                ListBlockId   = listBlockId,
                ListBlockItem = Convert(item)
            };

            Action <SingleUpdateRequest> actionRequest = _listBlockRepository.UpdateListBlockItem;

            RetryService.InvokeWithRetry(actionRequest, singleUpdateRequest);
        }
Пример #3
0
        public async Task UpdateListBlockItemAsync(SingleUpdateRequest singeUpdateRequest)
        {
            try
            {
                using (var connection = await CreateNewConnectionAsync(singeUpdateRequest.TaskId).ConfigureAwait(false))
                {
                    var command = connection.CreateCommand();
                    command.CommandTimeout = ConnectionStore.Instance.GetConnection(singeUpdateRequest.TaskId).QueryTimeoutSeconds;
                    command.CommandText    = ListBlockQueryBuilder.UpdateSingleBlockListItemStatus;
                    command.Parameters.Add("@BlockId", SqlDbType.BigInt).Value         = long.Parse(singeUpdateRequest.ListBlockId);
                    command.Parameters.Add("@ListBlockItemId", SqlDbType.BigInt).Value = long.Parse(singeUpdateRequest.ListBlockItem.ListBlockItemId);
                    command.Parameters.Add("@Status", SqlDbType.TinyInt).Value         = (byte)singeUpdateRequest.ListBlockItem.Status;

                    if (singeUpdateRequest.ListBlockItem.StatusReason == null)
                    {
                        command.Parameters.Add("@StatusReason", SqlDbType.NVarChar, -1).Value = DBNull.Value;
                    }
                    else
                    {
                        command.Parameters.Add("@StatusReason", SqlDbType.NVarChar, -1).Value = singeUpdateRequest.ListBlockItem.StatusReason;
                    }

                    if (!singeUpdateRequest.ListBlockItem.Step.HasValue)
                    {
                        command.Parameters.Add("@Step", SqlDbType.TinyInt).Value = DBNull.Value;
                    }
                    else
                    {
                        command.Parameters.Add("@Step", SqlDbType.TinyInt).Value = singeUpdateRequest.ListBlockItem.Step;
                    }

                    await command.ExecuteNonQueryAsync().ConfigureAwait(false);
                }
            }
            catch (SqlException sqlEx)
            {
                if (TransientErrorDetector.IsTransient(sqlEx))
                {
                    throw new TransientException("A transient exception has occurred", sqlEx);
                }

                throw;
            }
        }
        public void UpdateListBlockItem(SingleUpdateRequest singeUpdateRequest)
        {
            try
            {
                using (var connection = CreateNewConnection(singeUpdateRequest.TaskId))
                {
                    var command = connection.CreateCommand();
                    command.CommandTimeout = ConnectionStore.Instance.GetConnection(singeUpdateRequest.TaskId).QueryTimeoutSeconds;
                    command.CommandText = ListBlockQueryBuilder.UpdateSingleBlockListItemStatus;
                    command.Parameters.Add("@BlockId", SqlDbType.BigInt).Value = long.Parse(singeUpdateRequest.ListBlockId);
                    command.Parameters.Add("@ListBlockItemId", SqlDbType.BigInt).Value = long.Parse(singeUpdateRequest.ListBlockItem.ListBlockItemId);
                    command.Parameters.Add("@Status", SqlDbType.TinyInt).Value = (byte)singeUpdateRequest.ListBlockItem.Status;

                    if (singeUpdateRequest.ListBlockItem.StatusReason == null)
                        command.Parameters.Add("@StatusReason", SqlDbType.NVarChar, -1).Value = DBNull.Value;
                    else
                        command.Parameters.Add("@StatusReason", SqlDbType.NVarChar, -1).Value = singeUpdateRequest.ListBlockItem.StatusReason;

                    if (!singeUpdateRequest.ListBlockItem.Step.HasValue)
                        command.Parameters.Add("@Step", SqlDbType.TinyInt).Value = DBNull.Value;
                    else
                        command.Parameters.Add("@Step", SqlDbType.TinyInt).Value = singeUpdateRequest.ListBlockItem.Step;

                    command.ExecuteNonQuery();
                }
            }
            catch (SqlException sqlEx)
            {
                if (TransientErrorDetector.IsTransient(sqlEx))
                    throw new TransientException("A transient exception has occurred", sqlEx);

                throw;
            }
        }