public static void DoJob(object state) { var app = state as IApplicationBuilder; var settings = app.GetService <IOptionsSnapshot <AppSettings> >().Value; var db = app.GetService <IJsonDataStore <JsonDatabase> >(); var expiredSessions = ClientSessions.SessionsList .Where(client => (DateTime.Now - client.LastReceivedData).Minutes > settings.SessionsSendLogIntervalMinutes); if (expiredSessions.Any()) { foreach (var client in ClientSessions.SessionsList) { if ((DateTime.Now - client.LastReceivedData).Minutes >= settings.SessionsSendLogIntervalMinutes) { client.IsRunning = TextResources.Disconnect; client.Status = Constants.PMDLProStatusDisconnected; client.LastReceivedData = DateTime.Now; } } _db = app.GetService <IJsonDataStore <JsonDatabase> >() as AppJsonDataStore; _db.Database.Sessions = ClientSessions.SessionsList; _db.ApplyChanges(); ViewUpdater.Update(); } }
public static void Initiate(IJsonDataStore <JsonDatabase> db) { _db = db as AppJsonDataStore; SessionsList = _db.Database.Sessions.ToList(); }