using System;
using System.Collections.Generic;
using System.Linq;
namespace MediaBrowser.Controller.Providers
{
public class MetadataStatus
{
///
/// Gets or sets the item identifier.
///
/// The item identifier.
public Guid ItemId { get; set; }
///
/// Gets or sets the name of the item.
///
/// The name of the item.
public string ItemName { get; set; }
///
/// Gets or sets the name of the series.
///
/// The name of the series.
public string SeriesName { get; set; }
///
/// Gets or sets the date last metadata refresh.
///
/// The date last metadata refresh.
public DateTime? DateLastMetadataRefresh { get; set; }
///
/// Gets or sets the date last images refresh.
///
/// The date last images refresh.
public DateTime? DateLastImagesRefresh { get; set; }
///
/// Gets or sets the last result.
///
/// The last result.
public ProviderRefreshStatus LastStatus { get; set; }
///
/// Gets or sets the last result error message.
///
/// The last result error message.
public string LastErrorMessage { get; set; }
///
/// Gets or sets the providers refreshed.
///
/// The providers refreshed.
public List MetadataProvidersRefreshed { get; set; }
public List ImageProvidersRefreshed { get; set; }
public void AddStatus(ProviderRefreshStatus status, string errorMessage)
{
if (LastStatus != status)
{
IsDirty = true;
}
if (string.IsNullOrEmpty(LastErrorMessage))
{
LastErrorMessage = errorMessage;
}
if (LastStatus == ProviderRefreshStatus.Success)
{
LastStatus = status;
}
}
public MetadataStatus()
{
LastStatus = ProviderRefreshStatus.Success;
MetadataProvidersRefreshed = new List();
ImageProvidersRefreshed = new List();
}
public bool IsDirty { get; private set; }
public void SetDateLastMetadataRefresh(DateTime date)
{
if (date != (DateLastMetadataRefresh ?? DateTime.MinValue))
{
IsDirty = true;
}
DateLastMetadataRefresh = date;
}
public void SetDateLastImagesRefresh(DateTime date)
{
if (date != (DateLastImagesRefresh ?? DateTime.MinValue))
{
IsDirty = true;
}
DateLastImagesRefresh = date;
}
public void AddImageProvidersRefreshed(List providerIds)
{
var count = ImageProvidersRefreshed.Count;
providerIds.AddRange(ImageProvidersRefreshed);
ImageProvidersRefreshed = providerIds.Distinct().ToList();
if (ImageProvidersRefreshed.Count != count)
{
IsDirty = true;
}
}
public void AddMetadataProvidersRefreshed(List providerIds)
{
var count = MetadataProvidersRefreshed.Count;
providerIds.AddRange(MetadataProvidersRefreshed);
MetadataProvidersRefreshed = providerIds.Distinct().ToList();
if (MetadataProvidersRefreshed.Count != count)
{
IsDirty = true;
}
}
}
}