public Reminders() { InitializeComponent(); if (mySession != null && mySession.IsOpen) { mySession.Close(); } if (mySessionFactory != null && !mySessionFactory.IsClosed) { mySessionFactory.Close(); } // Initializing NHibernate myConfiguration = new Configuration(); myConfiguration.Configure(); mySessionFactory = myConfiguration.BuildSessionFactory(); mySession = mySessionFactory.OpenSession(); //Show TaskNameFromDatabase in ListBox using (mySession.BeginTransaction()) { ICriteria criteria = mySession.CreateCriteria <ToDo>(); IList <ToDo> list = criteria.List <ToDo>().Where(a => a.Status == "ToDo" && (DateTime.Now < a.StartDate)) .OrderBy(a => a.StartDate).OrderBy(a => a.EndDate).ToList(); foreach (var item in list) { listView_reminders.Items.Add(item.TaskName); listView_reminders.Items.Add(item.StartDate.ToString("dd/MM/yyyy")); listView_reminders.Items.Add(item.EndDate.ToString("dd/MM/yyyy")); } } ChangeView(); }
public static void CloseSessionFactory() { if (_sessionFactory != null) { _sessionFactory.Close(); } }
public void InitializingHibernate() { if (mySession != null && mySession.IsOpen) { mySession.Close(); } if (mySessionFactory != null && !mySessionFactory.IsClosed) { mySessionFactory.Close(); } myConfiguration = new Configuration(); myConfiguration.Configure(); mySessionFactory = myConfiguration.BuildSessionFactory(); mySession = mySessionFactory.OpenSession(); }
public void reminder() { DateTime date = DateTime.Now; DateTime date_plusOne = date.AddDays(1); if (mySession != null && mySession.IsOpen) { mySession.Close(); } if (mySessionFactory != null && !mySessionFactory.IsClosed) { mySessionFactory.Close(); } // Initializing NHibernate myConfiguration = new Configuration(); myConfiguration.Configure(); mySessionFactory = myConfiguration.BuildSessionFactory(); mySession = mySessionFactory.OpenSession(); int i = 0; //I'm checking if there are any new tasks tomorrow using (mySession.BeginTransaction()) { ICriteria criteria = mySession.CreateCriteria <ToDo>(); IList <ToDo> list = criteria.List <ToDo>().Where(a => a.Status == "ToDo" && (date <= a.StartDate && date_plusOne >= a.StartDate)).ToList(); i = 0; foreach (var item in list) { i++; } } if (i > 0) { Alert alert = new Alert(); alert.showAlert("Jutro masz nowe zadania do zrobienia !"); } button_TodoList.Text = "Rzeczy \ndo zrobienia"; }