|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace hmlib.Web.UI.Controls
{
public partial class Progress
{
static List<Progress> _list = new List<Progress>();
public static Progress Find(string id)
{
Progress.CleanUp();
return _list.Find(a => a.ID == id);
}
public static Progress FindOrCreate(string id)
{
return Progress.Find(id) ?? new Progress(id);
}
public static object GetResponse(string progressId)
{
Progress item = Progress.Find(progressId);
if (item == null) return null;
if (item.NewLines.Count > 1000) throw new Exception("Too many lines");
var result = new
{
value = item.Value,
lines = item.NewLines.ToArray()
};
item.NewLines.Clear();
return result;
}
internal static void CleanUp()
{
_list.RemoveAll(a => (DateTime.Now - a.CreatedOn).TotalDays > 1);
//_list.RemoveAll(a => a.Value == 1 && (DateTime.Now - a.ChangedOn).TotalSeconds > 5);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.