public static void MarkActivity() { using (var db = new SessionsContext()) { if (db.LastActivity.Count() == 0) { var entity = new LastActivityEntity(); entity.Last = DateTime.Now; db.LastActivity.Add(entity); // First Session var session = new SessionEntity(); session.Start = entity.Last.Value; session.Complete = false; session.End = null; db.Sessions.Add(session); } else { var entity = db.LastActivity.ToList().SingleOrDefault(); var previousTime = entity.Last; entity.Last = DateTime.Now; var delta = (entity.Last.Value - previousTime.Value).TotalMinutes; if (delta >= 15.0) { HandleSession(db, entity.Last.Value, previousTime.Value); } } db.SaveChanges(); } }
public static void MarkCurrentPosition(String filePath) { using (var db = new SessionsContext()) { if (db.LastActivity.Count() == 0) { var e = new LastActivityEntity(); e.Last = DateTime.Now; db.LastActivity.Add(e); } var entity = db.LastActivity.ToList().SingleOrDefault(); // Clear up things in case they can't be set again. entity.LastFile = ""; entity.LastProject = ""; entity.LastNamespace = ""; entity.LastClass = ""; entity.LastMethod = ""; String path = filePath; entity.LastFile = path; if (CodeElementMagic.CanSupportFile(filePath)) { try { var activeCodeElement = CodeElementMagic.GetCodeElementFromActivePoint(); if (activeCodeElement != null) { if (activeCodeElement.Kind == EnvDTE.vsCMElement.vsCMElementClass) { var codeKlass = activeCodeElement as EnvDTE.CodeClass; entity.LastNamespace = codeKlass.Namespace.FullName; entity.LastClass = codeKlass.FullName; } else if (activeCodeElement.Kind == EnvDTE.vsCMElement.vsCMElementFunction) { var codeMethod = activeCodeElement as EnvDTE.CodeFunction; var codeKlass = codeMethod.Parent as EnvDTE.CodeClass; if (codeKlass != null) { entity.LastNamespace = codeKlass.Namespace.FullName; entity.LastClass = codeKlass.FullName; } entity.LastMethod = codeMethod.FullName; } } } catch { // COM code likes to crap out } } entity.LastProject = GetCurrentProject(); db.SaveChanges(); } }
private void InitializeWithDTEAndSolutionReady() { m_dte = (EnvDTE.DTE) this.GetService(typeof(EnvDTE.DTE)); if (m_dte == null) { ErrorHandler.ThrowOnFailure(1); } var solutionBase = ""; var solutionName = ""; if (m_dte.Solution != null) { solutionBase = System.IO.Path.GetDirectoryName(m_dte.Solution.FullName); solutionName = System.IO.Path.GetFileNameWithoutExtension(m_dte.Solution.FullName); } //string dbName = string.Format("Ganji.History-{0}.sdf", solutionName); var basePath = PreparePath(); var ganjiContext = new GanjiContext(); ganjiContext.RepositoryPath = System.IO.Path.Combine(basePath, "LocalHistory"); ganjiContext.SolutionPath = solutionBase; CodeElementMagic.m_applicationObject = m_dte; HistoryContext.ConfigureDatabase(basePath); RemindersContext.ConfigureDatabase(basePath); SessionsContext.ConfigureDatabase(basePath); m_saveListener = new SaveListener(); m_saveListener.Register(m_dte, ganjiContext); m_navigateListener = new NavigateListener(); m_navigateListener.Register(m_dte, ganjiContext); m_exceptionListener = new ExceptionListener(); m_exceptionListener.Register(m_dte, ganjiContext); //if (m_version != null) //{ // dbName = string.Format("ActivityDB{0}-{1}.sdf", m_version.ToString(),solutionName); //} //var basePath = PreparePath(); //var path = System.IO.Path.Combine(basePath, dbName); //database = new Database(path); //database.OpenOrCreate(); }
public static void HandleSession(SessionsContext db, DateTime latestTime, DateTime previousTime) { // 1) Close incomplete sessions var previousSession = db.Sessions.Where(s => !s.Complete).OrderBy( s => s.End ).ToList().Last(); if (previousSession != null) { previousSession.End = previousTime; previousSession.Complete = true; db.Sessions.Attach(previousSession); } // 2) start new session var session = new SessionEntity(); session.Id = 0; session.Start = latestTime; session.Complete = false; session.End = null; db.Sessions.Add(session); }
public static void HandleSession(SessionsContext db, DateTime latestTime, DateTime previousTime) { // 1) Close incomplete sessions var previousSession = db.Sessions.Where(s => !s.Complete).OrderBy(s => s.End).ToList().Last(); if (previousSession != null) { previousSession.End = previousTime; previousSession.Complete = true; db.Sessions.Attach(previousSession); } // 2) start new session var session = new SessionEntity(); session.Id = 0; session.Start = latestTime; session.Complete = false; session.End = null; db.Sessions.Add(session); }
public SessionsController1(SessionsContext context) { _context = context; }
public Q20BotController(IOptions <Q20GameBotConfig> botConfig, SessionsContext sessionsContext) : base(botConfig) { context = sessionsContext; }
public SessionsRepository(SessionsContext context) { Context = context; }