예제 #1
0
파일: Model.cs 프로젝트: ruly-rudel/ruly
        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;
        }
예제 #2
0
        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;
            }
        }
예제 #3
0
 public void Update(TaskData task)
 {
     m_db.Update(task);
     UpdateTaskList();
 }
예제 #4
0
 public void Insert(TaskData task)
 {
     m_db.Insert(task);
     UpdateTaskList();
 }
예제 #5
0
파일: Model.cs 프로젝트: ruly-rudel/ruly
 public void Update(TaskData task)
 {
     m_db.Update (task);
     UpdateTaskList ();
 }
예제 #6
0
파일: Model.cs 프로젝트: ruly-rudel/ruly
 public void Insert(TaskData task)
 {
     m_db.Insert (task);
     UpdateTaskList ();
 }
예제 #7
0
파일: Model.cs 프로젝트: ruly-rudel/ruly
        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;
            }
        }
예제 #8
0
 public PersistentModelData()
 {
     state        = 0;           // idle
     current_exec = null;
     current_task = null;
 }
예제 #9
0
 public static TaskData PrepareNewTask()
 {
     SelectedTask = new TaskData ();
     me.m_state = 0;	// idle
     return SelectedTask;
 }