示例#1
0
        /// <summary>
        ///     Deletes the specified pending event from the queue.
        /// </summary>
        /// <param name="partitionKey">The partition key of the event.</param>
        /// <param name="rowKey">The partition key of the event.</param>
        /// <param name="successCallback">
        ///     The callback that will be called if the data is successfully retrieved.
        ///     The argument specifies if the row was deleted. If false, it means that the row did not exist.
        /// </param>
        /// <param name="exceptionCallback">The callback used if there is an exception that does not allow to continue.</param>
        public void DeletePendingAsync(string partitionKey, string rowKey, Action <bool> successCallback, Action <Exception> exceptionCallback)
        {
            var context = tableClient.GetDataServiceContext();
            var item    = new EventTableServiceEntity {
                PartitionKey = partitionKey, RowKey = rowKey
            };

            context.AttachTo(tableName, item, "*");
            context.DeleteObject(item);

            pendingEventsQueueRetryPolicy.ExecuteAction(
                ac => context.BeginSaveChanges(ac, null),
                ar => {
                try {
                    context.EndSaveChanges(ar);
                    return(true);
                } catch (DataServiceRequestException ex) {
                    // ignore if entity was already deleted.
                    var inner = ex.InnerException as DataServiceClientException;
                    if (inner == null || inner.StatusCode != (int)HttpStatusCode.NotFound)
                    {
                        throw;
                    }

                    return(false);
                }
            },
                successCallback,
                exceptionCallback);
        }
示例#2
0
        /// <summary>
        /// Deletes the specified pending event from the queue.
        /// </summary>
        /// <param name="partitionKey">The partition key of the event.</param>
        /// <param name="rowKey">The partition key of the event.</param>
        /// <param name="successCallback">The callback that will be called if the data is successfully retrieved.
        /// The argument specifies if the row was deleted. If false, it means that the row did not exist.
        /// </param>
        /// <param name="exceptionCallback">The callback used if there is an exception that does not allow to continue.</param>
        public void DeletePendingAsync(string partitionKey, string rowKey, Action <bool> successCallback,
                                       Action <Exception> exceptionCallback)
        {
            var context = this.tableClient.GetTableReference(this.tableName);
            var item    = new EventTableServiceEntity {
                PartitionKey = partitionKey, RowKey = rowKey
            };
            TableOperation deleteOperation = TableOperation.Delete(item);

            this.pendingEventsQueueRetryPolicy.ExecuteAction(
                ac => context.BeginExecute(deleteOperation, ac, null),
                ar =>
            {
                try
                {
                    context.EndExecute(ar);
                    return(true);
                }
                catch
                {
                    // ignore if entity was already deleted.
                    //var inner = ex.InnerException as DataServiceClientException;
                    //if (inner == null || inner.StatusCode != (int) HttpStatusCode.NotFound)
                    //{
                    //    throw;
                    //}

                    return(false);
                }
            },
                successCallback,
                exceptionCallback);
        }
示例#3
0
        /// <summary>
        /// Deletes the specified pending event from the queue.
        /// </summary>
        /// <param name="partitionKey">The partition key of the event.</param>
        /// <param name="rowKey">The partition key of the event.</param>
        /// <param name="successCallback">The callback that will be called if the data is successfully retrieved.
        /// The argument specifies if the row was deleted. If false, it means that the row did not exist.
        /// </param>
        /// <param name="exceptionCallback">The callback used if there is an exception that does not allow to continue.</param>
        public void DeletePendingAsync(string partitionKey, string rowKey, Action <bool> successCallback, Action <Exception> exceptionCallback)
        {
            var tableReference = this.tableClient.GetTableReference(this.tableName);
            var item           = new EventTableServiceEntity {
                PartitionKey = partitionKey, RowKey = rowKey, ETag = "*"
            };

            try
            {
                tableReference.Execute(TableOperation.Delete(item), blockingRequestOptions);
                successCallback(true);
            }
            catch (StorageException ex)
            {
                if (ex.RequestInformation.HttpStatusCode == (int)HttpStatusCode.NotFound)
                {
                    successCallback(false);
                    return;
                }

                exceptionCallback(ex);
            }
        }
示例#4
0
 public void DeletePending(string partitionKey, string rowKey)
 {
     var context = this.tableClient.GetDataServiceContext();
     var item = new EventTableServiceEntity { PartitionKey = partitionKey, RowKey = rowKey };
     context.AttachTo(this.tableName, item, "*");
     context.DeleteObject(item);
     this.pendingEventsQueueRetryPolicy.ExecuteAction(() => context.SaveChanges());
 }
示例#5
0
        /// <summary>
        /// Deletes the specified pending event from the queue.
        /// </summary>
        /// <param name="partitionKey">The partition key of the event.</param>
        /// <param name="rowKey">The partition key of the event.</param>
        /// <param name="successCallback">The callback that will be called if the data is successfully retrieved.
        /// The argument specifies if the row was deleted. If false, it means that the row did not exist.
        /// </param>
        /// <param name="exceptionCallback">The callback used if there is an exception that does not allow to continue.</param>
        public void DeletePendingAsync(string partitionKey, string rowKey, Action<bool> successCallback,
            Action<Exception> exceptionCallback)
        {
            try
            {
                var context = this.tableClient.GetTableReference(this.tableName);
                var item = new EventTableServiceEntity { PartitionKey = partitionKey, RowKey = rowKey,ETag="*" };
                TableOperation deleteOperation = TableOperation.Delete(item);

                this.pendingEventsQueueRetryPolicy.ExecuteAction(
                    ac => context.BeginExecute(deleteOperation, ac, null),
                    ar =>
                    {
                        try
                        {
                            context.EndExecute(ar);
                            return true;
                        }
                        catch (StorageException ex)
                        {

                            var requestInformation = ex.RequestInformation;

                            Trace.WriteLine(requestInformation.HttpStatusMessage);

                            // get more details about the exception
                            var information = requestInformation.ExtendedErrorInformation;

                            // if you have aditional information, you can use it for your logs
                            if (information == null)
                                throw;

                            var errorCode = information.ErrorCode;

                            if (errorCode != null && errorCode == "Not Found ")
                            {
                                throw;
                            }

                            return false;
                        }
                    },
                    successCallback,
                    exceptionCallback);

            }
            catch (Exception ex)
            {
                string msg = ex.Message;

                throw;
            }
        }
示例#6
0
        /// <summary>
        /// Deletes the specified pending event from the queue.
        /// </summary>
        /// <param name="partitionKey">The partition key of the event.</param>
        /// <param name="rowKey">The partition key of the event.</param>
        /// <param name="successCallback">The callback that will be called if the data is successfully retrieved.
        /// The argument specifies if the row was deleted. If false, it means that the row did not exist.
        /// </param>
        /// <param name="exceptionCallback">The callback used if there is an exception that does not allow to continue.</param>
        public void DeletePendingAsync(string partitionKey, string rowKey, Action<bool> successCallback, Action<Exception> exceptionCallback)
        {
            var context = this.tableClient.GetDataServiceContext();
            var item = new EventTableServiceEntity { PartitionKey = partitionKey, RowKey = rowKey };
            context.AttachTo(this.tableName, item, "*");
            context.DeleteObject(item);

            this.pendingEventsQueueRetryPolicy.ExecuteAction(
                ac => context.BeginSaveChanges(ac, null),
                ar => 
                    {
                        try
                        {
                            context.EndSaveChanges(ar);
                            return true;
                        }
                        catch (DataServiceRequestException ex)
                        {
                            // ignore if entity was already deleted.
                            var inner = ex.InnerException as DataServiceClientException;
                            if (inner == null || inner.StatusCode != (int)HttpStatusCode.NotFound)
                            {
                                throw;
                            }

                            return false;
                        }
                    },
                successCallback,
                exceptionCallback);
        }
示例#7
0
        /// <summary>
        /// Deletes the specified pending event from the queue.
        /// </summary>
        /// <param name="partitionKey">The partition key of the event.</param>
        /// <param name="rowKey">The partition key of the event.</param>
        /// <param name="successCallback">The callback that will be called if the data is successfully retrieved.
        /// The argument specifies if the row was deleted. If false, it means that the row did not exist.
        /// </param>
        /// <param name="exceptionCallback">The callback used if there is an exception that does not allow to continue.</param>
        public void DeletePendingAsync(string partitionKey, string rowKey, Action<bool> successCallback, Action<Exception> exceptionCallback)
        {
            var tableReference = this.tableClient.GetTableReference(this.tableName);
            var item = new EventTableServiceEntity { PartitionKey = partitionKey, RowKey = rowKey, ETag = "*" };

            try
            {
                tableReference.Execute(TableOperation.Delete(item), blockingRequestOptions);
                successCallback(true);
            }
            catch (StorageException ex)
            {
                if (ex.RequestInformation.HttpStatusCode == (int)HttpStatusCode.NotFound)
                {
                    successCallback(false);
                    return;
                }

                exceptionCallback(ex);
            }
        }