internal WorkItemProcessInfo Build() { var updatedObject = tempObject; tempObject = null; // So that build cannot be invoked again, not an ideal solution but works for us return(updatedObject); }
/// <summary> /// Copy constructor /// </summary> /// <param name="other">Object to copy from</param> internal WorkItemProcessInfo(WorkItemProcessInfo other) { if (null == other) { throw new ArgumentNullException("other"); } this.WorkItemId = other.WorkItemId; this.DueDateTime = other.DueDateTime; this.WorkItemQueueRunType = other.WorkItemQueueRunType; }
public virtual async Task ProcessFailureHandle(StatefulService statefulService, TimeSpan timeout, CancellationToken cancellationToken, string processQueueTypeTrace) { WorkItemProcessInfo workItemProcessInfo = await workItemInProcessStore.GetValueAsync(this.WorkItemGuid); BaseWorkItemQueue baseWorkItemQueue = await BaseWorkItemQueue.GetNextWorkItemQueue(workItemProcessInfo.WorkItemQueueRunType, statefulService); using (ITransaction transaction = statefulService.StateManager.CreateTransaction()) { await workItemInProcessStore.DeleteValueAsync(this.WorkItemGuid, timeout, cancellationToken, transaction); await baseWorkItemQueue.AddWorkItem(workItemProcessInfo, timeout, cancellationToken, transaction); await transaction.CommitAsync(); BackupRestoreTrace.TraceSource.WriteInfo(processQueueTypeTrace, "Process Failure Handle WorkItemInProcessStore Delete WorkItem {0} And Enqueue in {1} ", this, baseWorkItemQueue.GetType()); } }
internal async Task <bool> AddWorkItem(WorkItem workItem, TimeSpan timeout, CancellationToken cancellationToken, ITransaction transaction = null) { WorkItemProcessInfo workItemProcessInfo = new WorkItemProcessInfo(workItem.WorkItemGuid, DateTime.UtcNow); if (transaction == null) { using (transaction = this.StatefulService.StateManager.CreateTransaction()) { await this.WorkItemStore.AddAsync(workItem.WorkItemGuid, workItem, transaction); await this.AddWorkItem(workItemProcessInfo, timeout, cancellationToken, transaction); await transaction.CommitAsync(); } } else { await this.WorkItemStore.AddAsync(workItem.WorkItemGuid, workItem, transaction); await this.AddWorkItem(workItemProcessInfo, timeout, cancellationToken, transaction); } return(true); }
internal async Task <bool> AddWorkItem(WorkItemProcessInfo workItemProcessInfo, TimeSpan timeout, CancellationToken cancellationToken, ITransaction transaction = null) { BackupRestoreTrace.TraceSource.WriteInfo(TraceType, "Adding Work Item Id:{0} , DueDateTime:{1} , WorkItemQueueRunType : {2} ", workItemProcessInfo.WorkItemId, workItemProcessInfo.DueDateTime, workItemProcessInfo.WorkItemQueueRunType); if (this.MaxWaitTimeInMilliSeconds != FastQueueWaitTime) { workItemProcessInfo = workItemProcessInfo.ToBuilder() .WithDueDateTime(DateTime.UtcNow.AddMilliseconds(this.MaxWaitTimeInMilliSeconds)) .WithWorkItemQueueRunTimeType(this.workItemQueueRunType) .Build(); } else { workItemProcessInfo = workItemProcessInfo.ToBuilder() .WithWorkItemQueueRunTimeType(this.workItemQueueRunType) .Build(); } BackupRestoreTrace.TraceSource.WriteInfo(TraceType, "Adding Work Item Id:{0} , UpdatedDueDateTime:{1} , UpdatedWorkItemQueueRunType : {2} ", workItemProcessInfo.WorkItemId, workItemProcessInfo.DueDateTime, workItemProcessInfo.WorkItemQueueRunType); if (transaction == null) { using (transaction = this.StatefulService.StateManager.CreateTransaction()) { await this.WorkItemReliableQueue.EnqueueAsync(transaction, workItemProcessInfo, timeout, cancellationToken); await transaction.CommitAsync(); } } else { await this.WorkItemReliableQueue.EnqueueAsync(transaction, workItemProcessInfo, timeout, cancellationToken); } BackupRestoreTrace.TraceSource.WriteInfo(TraceType, "Added Work Item Id:{0} , UpdatedDueDateTime:{1} , WorkItemQueueRunType : {2} ", workItemProcessInfo.WorkItemId, workItemProcessInfo.DueDateTime, workItemProcessInfo.WorkItemQueueRunType); return(true); }
internal Builder(WorkItemProcessInfo originalObject) { this.tempObject = new WorkItemProcessInfo(originalObject); }