Ejemplo n.º 1
0
        /// <summary>
        /// Simple routine for failing a <see cref="WorkItem"/> and rescheduling it at a specified time.
        /// </summary>
        /// <param name="failureType"></param>
        /// <param name="failureTime">The time to reschedule the WorkItem if it isn't a fatal error. </param>
        /// <param name="maxRetryCount">The maximum number of times the WorkItem should be retried before a fatal error occurs.</param>
        public void Fail(WorkItemFailureType failureType, DateTime failureTime, int maxRetryCount)
        {
            using (var context = new DataAccessContext(DataAccessContext.WorkItemMutex))
            {
                var workItemBroker = context.GetWorkItemBroker();

                Item = workItemBroker.GetWorkItem(Item.Oid);
                DateTime now = Platform.Time;

                Item.Progress     = Progress;
                Item.FailureCount = Item.FailureCount + 1;
                Item.DeleteTime   = now.AddMinutes(WorkItemServiceSettings.Default.DeleteDelayMinutes);

                if (Item.FailureCount >= maxRetryCount ||
                    failureType == WorkItemFailureType.Fatal)
                {
                    Item.Status         = WorkItemStatusEnum.Failed;
                    Item.ExpirationTime = now;
                }
                else
                {
                    Item.ProcessTime = failureTime;
                    if (Item.ExpirationTime < Item.ProcessTime)
                    {
                        Item.ExpirationTime = Item.ProcessTime;
                    }
                    Item.Status = WorkItemStatusEnum.Pending;
                }

                context.Commit();
            }

            Publish(false);
            Platform.Log(LogLevel, "Failing {0} WorkItem for OID {1}: {2}", Item.Type, Item.Oid, Item.Request.ActivityDescription);
        }
Ejemplo n.º 2
0
        public override void Fail(WorkItemFailureType failureType, DateTime failureTime, int maxRetryCount)
        {
            using (var ctx = new WorkItemContext())
            {
                Item = (from row in ctx.WorkItems
                        where row.Oid == Item.Oid
                        select row).FirstOrDefault();

                if (Item != null)
                {
                    Item.Progress     = Progress;
                    Item.FailureCount = Item.FailureCount + 1;
                    Item.DeleteTime   = DateTime.Now.AddMinutes(240);

                    if (Item.FailureCount >= maxRetryCount ||
                        failureType == WorkItemFailureType.Fatal)
                    {
                        Item.Status         = WorkItemStatusEnum.Failed;
                        Item.ExpirationTime = DateTime.Now;
                    }
                    else
                    {
                        Item.ProcessTime = failureTime;
                        if (Item.ExpirationTime < Item.ProcessTime)
                        {
                            Item.ExpirationTime = Item.ProcessTime;
                        }
                        Item.Status = WorkItemStatusEnum.Pending;
                    }
                }

                ctx.SaveChanges();
            }

            Publish(false);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Simple routine for failing a <see cref="WorkItem"/> and save a reason.
 /// </summary>
 /// <param name="reason">A non-localized reason for the failure.</param>
 /// <param name="failureType">The type of failure.</param>
 public void Fail(string reason, WorkItemFailureType failureType)
 {
     Progress.StatusDetails = reason;
     Fail(failureType);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// SImple routine for failing a <see cref="WorkItem"/>
 /// </summary>
 /// <param name="failureType"></param>
 public void Fail(WorkItemFailureType failureType)
 {
     Fail(failureType, Platform.Time.AddSeconds(WorkItemServiceSettings.Default.PostponeSeconds), WorkItemServiceSettings.Default.RetryCount);
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Simple routine for failing a <see cref="WorkItem"/> and save a reason.
 /// </summary>
 /// <param name="reason">A non-localized reason for the failure.</param>
 /// <param name="failureType">The type of failure.</param>
 /// <param name="scheduledTime">The time to reschedule the WorkItem if it isn't a fatal error. </param>
 /// <param name="retryCount"> </param>
 public void Fail(string reason, WorkItemFailureType failureType, DateTime scheduledTime, int retryCount)
 {
     Progress.StatusDetails = reason;
     Fail(failureType, scheduledTime, retryCount);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Simple routine for failing a <see cref="WorkItem"/> and save a reason.
 /// </summary>
 /// <param name="reason">A non-localized reason for the failure.</param>
 /// <param name="failureType">The type of failure.</param>
 /// <param name="scheduledTime">The time to reschedule the WorkItem if it isn't a fatal error. </param>
 public void Fail(string reason, WorkItemFailureType failureType, DateTime scheduledTime)
 {
     Progress.StatusDetails = reason;
     Fail(failureType, scheduledTime, WorkItemServiceSettings.Default.RetryCount);
 }
Ejemplo n.º 7
0
 /// <summary>
 /// SImple routine for failing a <see cref="WorkItem"/>
 /// </summary>
 /// <param name="failureType"></param>
 public void Fail(WorkItemFailureType failureType)
 {
     Fail(failureType, System.DateTime.Now.AddSeconds(PostponeSecond), MaxRetryCount);
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Simple routine for failing a <see cref="WorkItem"/> and rescheduling it at a specified time.
 /// </summary>
 /// <param name="failureType"></param>
 /// <param name="failureTime">The time to reschedule the WorkItem if it isn't a fatal error. </param>
 /// <param name="maxRetryCount">The maximum number of times the WorkItem should be retried before a fatal error occurs.</param>
 public abstract void Fail(WorkItemFailureType failureType, DateTime failureTime, int maxRetryCount);
Ejemplo n.º 9
0
 /// <summary>
 /// Simple routine for failing a <see cref="WorkItem"/> and save a reason.
 /// </summary>
 /// <param name="reason">A non-localized reason for the failure.</param>
 /// <param name="failureType">The type of failure.</param>
 /// <param name="scheduledTime">The time to reschedule the WorkItem if it isn't a fatal error. </param>
 public void Fail(string reason, WorkItemFailureType failureType, DateTime scheduledTime)
 {
     Progress.StatusDetails = reason;
     Fail(failureType, scheduledTime, WorkItemServiceSettings.Default.RetryCount);
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Simple routine for failing a <see cref="WorkItem"/> and save a reason.
 /// </summary>
 /// <param name="reason">A non-localized reason for the failure.</param>
 /// <param name="failureType">The type of failure.</param>
 public void Fail(string reason, WorkItemFailureType failureType)
 {
     Progress.StatusDetails = reason;
     Fail(failureType);
 }
Ejemplo n.º 11
0
        /// <summary>
        /// Simple routine for failing a <see cref="WorkItem"/> and rescheduling it at a specified time.
        /// </summary>
        /// <param name="failureType"></param>
        /// <param name="failureTime">The time to reschedule the WorkItem if it isn't a fatal error. </param>
        /// <param name="maxRetryCount">The maximum number of times the WorkItem should be retried before a fatal error occurs.</param>
        public void Fail(WorkItemFailureType failureType, DateTime failureTime, int maxRetryCount)
        {
            using (var context = new DataAccessContext(DataAccessContext.WorkItemMutex))
            {
                var workItemBroker = context.GetWorkItemBroker();

                Item = workItemBroker.GetWorkItem(Item.Oid);
                DateTime now = Platform.Time;

                Item.Progress = Progress;
                Item.FailureCount = Item.FailureCount + 1;
                Item.DeleteTime = now.AddMinutes(WorkItemServiceSettings.Default.DeleteDelayMinutes);

                if (Item.FailureCount >= maxRetryCount
                    || failureType == WorkItemFailureType.Fatal )
                {
                    Item.Status = WorkItemStatusEnum.Failed;
                    Item.ExpirationTime = now;
                }
                else
                {
                    Item.ProcessTime = failureTime;
                    if (Item.ExpirationTime < Item.ProcessTime)
                        Item.ExpirationTime = Item.ProcessTime;
                    Item.Status = WorkItemStatusEnum.Pending;
                }

                context.Commit();
            }

            Publish(false);
            Platform.Log(LogLevel, "Failing {0} WorkItem for OID {1}: {2}", Item.Type, Item.Oid, Item.Request.ActivityDescription);
        }
Ejemplo n.º 12
0
 /// <summary>
 /// SImple routine for failing a <see cref="WorkItem"/>
 /// </summary>
 /// <param name="failureType"></param>
 public void Fail(WorkItemFailureType failureType)
 {
     Fail(failureType, Platform.Time.AddSeconds(WorkItemServiceSettings.Default.PostponeSeconds),WorkItemServiceSettings.Default.RetryCount);
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Simple routine for failing a <see cref="WorkItem"/> and save a reason.
 /// </summary>
 /// <param name="reason">A non-localized reason for the failure.</param>
 /// <param name="failureType">The type of failure.</param>
 /// <param name="scheduledTime">The time to reschedule the WorkItem if it isn't a fatal error. </param>
 /// <param name="retryCount"> </param>
 public void Fail(string reason, WorkItemFailureType failureType, DateTime scheduledTime, int retryCount)
 {
     Progress.StatusDetails = reason;
     Fail(failureType, scheduledTime, retryCount);
 }