public Model() { // prepare model state/data m_data = new PersistentModelData (); // prepare DB // Log.Debug ("Ruly", "ext sd: " + Android.OS.Environment.ExternalStorageDirectory); // string folder = Environment.GetFolderPath (Environment.SpecialFolder.Personal); string folder = Android.OS.Environment.ExternalStorageDirectory + "/ruly/ruly.db"; Util.EnsureDirectory (System.IO.Path.GetDirectoryName (folder)); m_db = new SQLiteConnection (folder); m_db.CreateTable<TaskData>(); m_db.CreateTable<TaskHistory>(); m_db.CreateTable<TaskAlarm> (); m_unknown_task = new TaskData () { Id = -1, Title = "休憩" }; // create ViewModel I/F datasets Tasks = new ObservableCollection<TaskData>(); TaskHistories = new ObservableCollection<CombinedTaskHistory> (); RawTaskHistories = new ObservableCollection<CombinedTaskHistory> (); UpdateTaskList (); // show today task at default // this result in call UpdateTaskHistoryList(); ShowDate = DateTime.Today; }
public void Go(TaskData task) { if (task != null) { m_data.current_task = task; } if (m_data.current_task == null) { throw new NotImplementedException(); } switch (m_data.state) { case 0: // idle case 2: // pause m_data.current_exec = new TaskHistory(); m_data.current_exec.TaskId = m_data.current_task.Id; m_data.current_exec.Begin = DateTime.Now; m_data.current_exec.End = new DateTime(); Insert(m_data.current_exec); m_data.state = 1; // working break; case 1: // working m_data.current_exec.End = DateTime.Now; Update(m_data.current_exec); m_data.current_exec = new TaskHistory(); m_data.current_exec.TaskId = m_data.current_task.Id; m_data.current_exec.Begin = DateTime.Now; m_data.current_exec.End = new DateTime(); Insert(m_data.current_exec); break; default: break; } }
public void Update(TaskData task) { m_db.Update(task); UpdateTaskList(); }
public void Insert(TaskData task) { m_db.Insert(task); UpdateTaskList(); }
public void Update(TaskData task) { m_db.Update (task); UpdateTaskList (); }
public void Insert(TaskData task) { m_db.Insert (task); UpdateTaskList (); }
public void Go(TaskData task) { if (task != null) { m_data.current_task = task; } if (m_data.current_task == null) throw new NotImplementedException (); switch (m_data.state) { case 0: // idle case 2: // pause m_data.current_exec = new TaskHistory (); m_data.current_exec.TaskId = m_data.current_task.Id; m_data.current_exec.Begin = DateTime.Now; m_data.current_exec.End = new DateTime (); Insert (m_data.current_exec); m_data.state = 1; // working break; case 1: // working m_data.current_exec.End = DateTime.Now; Update (m_data.current_exec); m_data.current_exec = new TaskHistory (); m_data.current_exec.TaskId = m_data.current_task.Id; m_data.current_exec.Begin = DateTime.Now; m_data.current_exec.End = new DateTime (); Insert (m_data.current_exec); break; default: break; } }
public PersistentModelData() { state = 0; // idle current_exec = null; current_task = null; }
public static TaskData PrepareNewTask() { SelectedTask = new TaskData (); me.m_state = 0; // idle return SelectedTask; }