using System;
using NLog;
namespace NzbDrone.Core.Model.Notification
{
public class ProgressNotification : IDisposable
{
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
public ProgressNotification(string title)
{
Title = title;
CurrentStatus = String.Empty;
Id = Guid.NewGuid();
ProgressMax = 100;
ProgressValue = 0;
}
///
/// Gets or sets the unique id.
///
/// The Id.
public Guid Id { get; private set; }
///
/// Gets or sets the title for this notification.
///
/// The title.
public String Title { get; set; }
///
/// Gets or sets the current status of this task. this field could be use to show the currently processing item in a long running task.
///
/// The current status.
public String CurrentStatus { get; set; }
///
/// Gets or sets the completion status in percent.
///
/// The percent complete.
public int PercentComplete
{
get
{
return Convert.ToInt32(Convert.ToDouble(ProgressValue) / Convert.ToDouble(ProgressMax) * 100);
}
}
///
/// Gets or sets the total number of items that need to be completed
///
/// The progress max.
public int ProgressMax { get; set; }
///
/// Gets or sets the number of items successfully completed.
///
/// The progress value.
public int ProgressValue { get; set; }
///
/// Gets or sets the status.
///
/// The status.
public ProgressNotificationStatus Status { get; set; }
public void Dispose()
{
if (Status == ProgressNotificationStatus.InProgress)
{
Logger.Warn("Background task '{0}' was unexpectedly abandoned.", Title);
Status = ProgressNotificationStatus.Failed;
}
}
}
}