public FakeTaskDatabaseTest()
 {
   this.task = Substitute.For<Task>(DateTime.Now);
   this.behavior = Substitute.For<TaskDatabase>();
   this.taskDatabase = new FakeTaskDatabase();
   this.taskDatabase.LocalProvider.Value = this.behavior;
 }
 public FakeTaskDatabaseTest()
 {
     this.task         = Substitute.For <Task>(DateTime.Now);
     this.behavior     = Substitute.For <TaskDatabase>();
     this.taskDatabase = new FakeTaskDatabase();
     this.taskDatabase.LocalProvider.Value = this.behavior;
 }
Ejemplo n.º 3
0
        protected TaskRepository()
        {
            // set the db location
            dbLocation = DatabaseFilePath;

            // instantiate the database
            db = new TaskDatabase(dbLocation);
        }
Ejemplo n.º 4
0
        private void taskModifyCategories_Click(object sender, RoutedEventArgs e)
        {
            CategoryEditor editor = new CategoryEditor(() => { return(TaskDatabase.GetCategories()); }, TaskDatabase.AddCategory, TaskDatabase.UpdateCategory, TaskDatabase.DeleteCategory);

            editor.Owner = this;
            editor.ShowDialog();

            tasksView.RefreshCategories();
        }
Ejemplo n.º 5
0
 private void loadfromdb()
 {
     try
     {
         UserTask[] tasks = TaskDatabase.GetTasks();
         Dispatcher.BeginInvoke(new additemsDelegate(additems), new object[] { tasks });
     }
     catch (ThreadAbortException) { Thread.ResetAbort(); }
 }
Ejemplo n.º 6
0
        public void TaskIsLoadedFromDirectory()
        {
            var taskDefinitionDirectory = $@"C:\temp\{Guid.NewGuid()}";

            CreateTestTaskDefinition(taskDefinitionDirectory);
            var logger       = new NullDataProcessingServiceLogger();
            var taskDatabase = new TaskDatabase();
            var sut          = new PeriodicTasksRunner(DataApiClient, taskDatabase, logger);

            sut.Start();
            Assert.That(() => taskDatabase.Tasks.OfType <ScriptPeriodTask>().Count(), Is.EqualTo(1).After(1000, 100));
        }
Ejemplo n.º 7
0
 void CreateNewDatabase()
 {
     if (newBoardName != "" && newBoardName != null && newBoardName != " ")
     {
         m_Task = ScriptableObject.CreateInstance <TaskDatabase>();
         AssetDatabase.CreateAsset(m_Task, DataPath + "TaskData/" + newBoardName + ".asset");
         AssetDatabase.SaveAssets();
         AssetDatabase.Refresh();
         currentBoardName = newBoardName;
         newBoardName     = null;
     }
 }
Ejemplo n.º 8
0
 void CreateNewDatabase()
 {
     if(newBoardName != "" && newBoardName != null && newBoardName != " ")
     {
         m_Task = ScriptableObject.CreateInstance<TaskDatabase>();
         AssetDatabase.CreateAsset(m_Task, DataPath + "TaskData/" + newBoardName + ".asset");
         AssetDatabase.SaveAssets();
         AssetDatabase.Refresh();
         currentBoardName = newBoardName;
         newBoardName = null;
     }
 }
Ejemplo n.º 9
0
        private void deleteTask(TreeViewItem item, bool deleteFromDatabase = true)
        {
            // Delete the task from the file
            if (deleteFromDatabase)
            {
                UserTask task = item.Header as UserTask;
                TaskDatabase.Delete(task);
                ReminderQueue.RemoveItem(task.ID, task.StartDate, ReminderType.Task);
            }
            // else, we just want to use the animation.

            TreeViewItem parent = item.Parent as TreeViewItem;

            if (parent.Items.Count > 1)
            {
                if (Settings.AnimationsEnabled)
                {
                    AnimationHelpers.DeleteAnimation deleteAnim = new AnimationHelpers.DeleteAnimation(item);
                    deleteAnim.OnAnimationCompletedEvent += deleteAnim_OnAnimationCompletedEvent;
                    deleteAnim.Animate();
                }
                else
                {
                    parent.Items.Remove(item);
                }
            }
            else
            {
                if (Settings.AnimationsEnabled)
                {
                    AnimationHelpers.DeleteAnimation parentDeleteAnim = new AnimationHelpers.DeleteAnimation(parent);
                    parentDeleteAnim.OnAnimationCompletedEvent += parentDeleteAnim_OnAnimationCompletedEvent;
                    parentDeleteAnim.Animate();

                    if (tasksTreeView.Items.Count <= 1)
                    {
                        statusText.Text = "We didn't find anything to show here.";
                        new AnimationHelpers.Fade(statusText, AnimationHelpers.FadeDirection.In);
                    }
                }
                else
                {
                    tasksTreeView.Items.Remove(parent);
                    if (tasksTreeView.Items.Count == 0)
                    {
                        statusText.Text       = "We didn't find anything to show here.";
                        statusText.Visibility = Visibility.Visible;
                        statusText.Opacity    = 1;
                    }
                }
            }
        }
Ejemplo n.º 10
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            Args = e.Args;

            CreateJumpList();

            // Make the main process appear connected to the update process
            // in the taskbar.
            try { SetCurrentProcessExplicitAppUserModelID(GlobalAssemblyInfo.AssemblyName); }
            catch { }

            AppointmentDatabase.Load();
            AppointmentDatabase.OnSaveCompletedEvent += AppointmentDatabase_OnSaveCompletedEvent;
            ContactDatabase.Load();
            ContactDatabase.OnSaveCompletedEvent += ContactDatabase_OnSaveCompletedEvent;
            TaskDatabase.Load();
            TaskDatabase.OnSaveCompletedEvent += TaskDatabase_OnSaveCompletedEvent;
            NoteDatabase.Load();
            NoteDatabase.OnSaveCompletedEvent += NoteDatabase_OnSaveCompletedEvent;
            SyncDatabase.Load();
            SyncDatabase.OnSaveCompletedEvent += SyncDatabase_OnSaveCompletedEvent;
            QuoteDatabase.Load();
            QuoteDatabase.OnSaveCompletedEvent += QuoteDatabase_OnSaveCompletedEvent;

            ThemeHelpers.UpdateTheme(true);

            MainWindow mainWindow = new MainWindow();

            mainWindow.ContentRendered += mainWindow_ContentRendered;
            mainWindow.Show();

            SystemEvents.UserPreferenceChanged += SystemEvents_UserPreferenceChanged;
            SystemEvents.TimeChanged           += SystemEvents_TimeChanged;

            if (BackstageEvents.StaticUpdater == null)
            {
                BackstageEvents.StaticUpdater = new BackstageEvents();
            }

            BackstageEvents.StaticUpdater.OnForceUpdateEvent     += StaticUpdater_OnForceUpdateEvent;
            BackstageEvents.StaticUpdater.OnThemeChangedEvent    += StaticUpdater_OnThemeChangedEvent;
            BackstageEvents.StaticUpdater.OnExportEvent          += StaticUpdater_OnExportEvent;
            BackstageEvents.StaticUpdater.OnHelpEvent            += StaticUpdater_OnHelpEvent;
            BackstageEvents.StaticUpdater.OnDocumentRequestEvent += StaticUpdater_OnDocumentRequestEvent;
            BackstageEvents.StaticUpdater.OnPrintStartedEvent    += StaticUpdater_OnPrintStartedEvent;
            BackstageEvents.StaticUpdater.OnImportEvent          += StaticUpdater_OnImportEvent;
            BackstageEvents.StaticUpdater.OnQuotesChangedEvent   += StaticUpdater_OnQuotesChangedEvent;
        }
Ejemplo n.º 11
0
 private void Transform(string inputName, TaskDatabase source)
 {
     if (_options.ListConversionMode == ListConversionMode.ListsAsTags)
     {
         var uniqueList = new TaskList {
             Id = 0, Title = inputName + " import"
         };
         source.Lists = new[] { uniqueList };
         foreach (var task in source.Tasks)
         {
             task.Tags = new[] { task.List.Title };
             task.List = uniqueList;
         }
     }
 }
Ejemplo n.º 12
0
        /// <summary>
        /// View the details about all the users.
        /// </summary>
        /// <param name="model">Specified user to validate permissions to view users.</param>
        /// <returns>A list of grades filled with values from the database.</returns>
        public List <User> Details(User model)
        {
            List <User> users = new List <User>();

            if (model != null)
            {
                if (model.Role == "Member")
                {
                    users = null;
                }
                else
                {
                    try
                    {
                        using (TaskDatabase db = new TaskDatabase())
                        {
                            List <User> query = (from user in db.Users
                                                 where user.Role != "Admin" && user.Id != model.Id
                                                 select user).ToList();

                            if (query != null)
                            {
                                foreach (User _user in query)
                                {
                                    user = new User()
                                    {
                                        Id       = _user.Id,
                                        Username = _user.Username,
                                        Password = _user.Password,
                                        Role     = _user.Role
                                    };

                                    users.Add(user);
                                }
                            }
                        }
                    }
                    catch (Exception)
                    {
                        users = null;
                    }
                }
            }

            return(users);
        }
Ejemplo n.º 13
0
        private void RecoverTask(UserTask task)
        {
            FlowDocument document = task.DetailsDocument;

            task.SaveChangesToDisk = true;
            task.DetailsDocument   = document;

            TaskDatabase.UpdateTask(task);
            new RecoveryDatabase(RecoveryVersion.LastRun).RecoveryTask = null;

            if (tasksView != null)
            {
                tasksView.UpdateTask(task);
            }

            TasksPeekContent.UpdateAll(task);
        }
Ejemplo n.º 14
0
    void DeleteDatabase()
    {
        bool confirm = EditorUtility.DisplayDialog("Close Board?", "Are you sure you want to Close this Task Board?", "Yes", "No");

        if (confirm == true)
        {
            m_Task           = null;
            newBoardName     = null;
            currentBoardName = null;
            n_FileLocation   = null;
            Debug.Log("Closed Board");
        }
        else
        {
            Debug.Log("Cancelled Closing Board");
        }
    }
        /// <summary>
        /// View the details about all the repeating tasks of the specified user.
        /// </summary>
        /// <param name="userId">User id of the task.</param>
        /// <returns>A list of repeating tasks filled with values from the database.</returns>
        public List <RepeatingTask> Details(uint?userId)
        {
            List <RepeatingTask> repeatingTasks = new List <RepeatingTask>();

            if (userId == null)
            {
                repeatingTasks = null;
            }
            else
            {
                try
                {
                    using (TaskDatabase db = new TaskDatabase())
                    {
                        List <RepeatingTask> query = (from repeatingTask in db.RepeatingTasks
                                                      where repeatingTask.UserId == userId
                                                      select repeatingTask).ToList();

                        if (query != null)
                        {
                            foreach (RepeatingTask _repeatingTask in query)
                            {
                                repeatingTask = new RepeatingTask()
                                {
                                    Id       = _repeatingTask.Id,
                                    UserId   = _repeatingTask.UserId,
                                    Title    = _repeatingTask.Title,
                                    Day      = _repeatingTask.Day,
                                    Time     = _repeatingTask.Time,
                                    Duration = _repeatingTask.Duration,
                                    Label    = _repeatingTask.Label
                                };

                                repeatingTasks.Add(repeatingTask);
                            }
                        }
                    }
                }
                catch (Exception)
                {
                    repeatingTasks = null;
                }
            }

            return(repeatingTasks);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// View the details about all the tasks of the specified user.
        /// </summary>
        /// <param name="userId">User id of the task.</param>
        /// <returns>A list of tasks filled with values from the database.</returns>
        public List <Task> Details(uint?userId)
        {
            List <Task> tasks = new List <Task>();

            if (userId == null)
            {
                tasks = null;
            }
            else
            {
                try
                {
                    using (TaskDatabase db = new TaskDatabase())
                    {
                        List <Task> query = (from task in db.Tasks
                                             where task.UserId == userId
                                             select task).ToList();

                        if (query != null)
                        {
                            foreach (Task _task in query)
                            {
                                task = new Task()
                                {
                                    Id       = _task.Id,
                                    UserId   = _task.UserId,
                                    Title    = _task.Title,
                                    Date     = _task.Date,
                                    Duration = _task.Duration,
                                    Label    = _task.Label
                                };

                                tasks.Add(task);
                            }
                        }
                    }
                }
                catch (Exception)
                {
                    tasks = null;
                }
            }

            return(tasks);
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Deletes an existing subject.
        /// </summary>
        /// <param name="model">Subject details to delete.</param>
        /// <returns>0 on failure, 1 on success, 2 on unexpected database error.</returns>
        public int Delete(Subject model)
        {
            int result = 0;

            try
            {
                using (TaskDatabase db = new TaskDatabase())
                {
                    result = db.Delete(model);
                }
            }
            catch (Exception)
            {
                result = 2;
            }

            return(result);
        }
        /// <summary>
        /// Creates a new appointment.
        /// </summary>
        /// <param name="model">Appointment details to create.</param>
        /// <returns>0 on failure, 1 on success, 2 on unexpected database error.</returns>
        public int Create(Appointment model)
        {
            int result = 0;

            try
            {
                using (TaskDatabase db = new TaskDatabase())
                {
                    result = db.Insert(model);
                }
            }
            catch (Exception)
            {
                result = 2;
            }

            return(result);
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Clear the alerts queue, setting all reminders to -1
        /// </summary>
        public static void ClearQueue()
        {
            foreach (Toast each in ToastManager.QueuedToasts)
            {
                Reminder reminder = each.Tag as Reminder;

                if (reminder.ReminderType == ReminderType.Appointment)
                {
                    AppointmentDatabase.NullifyAlarm(reminder.ID, reminder.EventStartDate.Value);
                }
                else if (reminder.ReminderType == ReminderType.Task)
                {
                    TaskDatabase.NullifyAlarm(reminder.ID);
                }
            }

            ToastManager.QueuedToasts.Clear();
        }
        /// <summary>
        /// Edit an existing grade.
        /// </summary>
        /// <param name="model">Grade details to edit.</param>
        /// <returns>0 on failure, 1 on success, 2 on unexpected database error.</returns>
        public int Edit(Grade model)
        {
            int result = 0;

            try
            {
                using (TaskDatabase db = new TaskDatabase())
                {
                    result = db.Update(model);
                }
            }
            catch (Exception)
            {
                result = 2;
            }

            return(result);
        }
        /// <summary>
        /// View the details about all the grades of the specified user.
        /// </summary>
        /// <param name="userId">User id of the grade.</param>
        /// <returns>A list of grades filled with values from the database.</returns>
        public List <Grade> Details(uint?userId)
        {
            List <Grade> grades = new List <Grade>();

            if (userId == null)
            {
                grades = null;
            }
            else
            {
                try
                {
                    using (TaskDatabase db = new TaskDatabase())
                    {
                        List <Grade> query = (from grade in db.Grades
                                              where grade.UserId == userId
                                              select grade).ToList();

                        if (query != null)
                        {
                            foreach (Grade _grade in query)
                            {
                                grade = new Grade()
                                {
                                    Id          = _grade.Id,
                                    UserId      = _grade.UserId,
                                    RowIndex    = _grade.RowIndex,
                                    ColumnIndex = _grade.ColumnIndex,
                                    Number      = _grade.Number
                                };

                                grades.Add(grade);
                            }
                        }
                    }
                }
                catch (Exception)
                {
                    grades = null;
                }
            }

            return(grades);
        }
Ejemplo n.º 22
0
        /// <summary>
        /// View the details about all the subjects of the specified user.
        /// </summary>
        /// <param name="userId">User id of the subject.</param>
        /// <returns>A list of subjects filled with values from the database.</returns>
        public List <Subject> Details(uint?userId)
        {
            List <Subject> subjects = new List <Subject>();

            if (userId == null)
            {
                subjects = null;
            }
            else
            {
                try
                {
                    using (TaskDatabase db = new TaskDatabase())
                    {
                        List <Subject> query = (from subject in db.Subjects
                                                where subject.UserId == userId
                                                select subject).ToList();

                        if (query != null)
                        {
                            foreach (Subject _subject in query)
                            {
                                subject = new Subject()
                                {
                                    Id       = _subject.Id,
                                    UserId   = _subject.UserId,
                                    RowIndex = _subject.RowIndex,
                                    Name     = _subject.Name
                                };

                                subjects.Add(subject);
                            }
                        }
                    }
                }
                catch (Exception)
                {
                    subjects = null;
                }
            }

            return(subjects);
        }
Ejemplo n.º 23
0
        private static void alert_Closed(object sender, EventArgs e)
        {
            Toast _sender = sender as Toast;

            Reminder reminder = _sender.Tag as Reminder;

            //if (_sender.ToastResult != ToastResult.TimedOut)
            if (reminder.ReminderType == ReminderType.Appointment)
            {
                AppointmentDatabase.NullifyAlarm(reminder.ID, reminder.EventStartDate.Value);
            }
            else if (reminder.ReminderType == ReminderType.Task)
            {
                TaskDatabase.NullifyAlarm(reminder.ID);
            }

            Dispatcher.CurrentDispatcher.Invoke(new AlertUpdateEventDelegate(AlertUpdateEvent),
                                                new object[] { reminder, _sender.ToastResult == ToastResult.Activated });
        }
        /// <summary>
        /// View the details about all the appointments of the specified user.
        /// </summary>
        /// <param name="userId">User id of the appointment.</param>
        /// <returns>A list of appointments filled with values from the database.</returns>
        public List <Appointment> Details(uint?userId)
        {
            List <Appointment> appointments = new List <Appointment>();

            if (userId == null)
            {
                appointments = null;
            }
            else
            {
                try
                {
                    using (TaskDatabase db = new TaskDatabase())
                    {
                        List <Appointment> query = (from appointment in db.Appointments
                                                    where appointment.UserId == userId
                                                    select appointment).ToList();

                        if (query != null)
                        {
                            foreach (Appointment _appointment in query)
                            {
                                appointment = new Appointment()
                                {
                                    Id     = _appointment.Id,
                                    UserId = _appointment.UserId,
                                    Name   = _appointment.Name,
                                    Date   = _appointment.Date
                                };

                                appointments.Add(appointment);
                            }
                        }
                    }
                }
                catch (Exception)
                {
                    appointments = null;
                }
            }

            return(appointments);
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Register an unique account.
        /// </summary>
        /// <param name="model">User details to register.</param>
        /// <returns>0 on failure, 1 on success, 2 on unexpected database error.</returns>
        public int Register(User model)
        {
            int  result     = 0;
            bool isUsername = false;

            if (model != null)
            {
                if (!string.IsNullOrEmpty(model.Username))
                {
                    isUsername = Regex.IsMatch(model.Username, @"^(?=.{3,32}$)(?![_-])[a-zA-Z0-9-_ ]+(?<![_-])$", RegexOptions.None);
                }
            }

            if (isUsername == true)
            {
                try
                {
                    using (TaskDatabase db = new TaskDatabase())
                    {
                        User query = (from user in db.Users
                                      where user.Username == model.Username
                                      select user).SingleOrDefault();

                        if (query == null)
                        {
                            model.Password = EncryptionProvider.Encrypt(model.Password);
                            result         = db.Insert(model);
                        }
                    }
                }
                catch (Exception)
                {
                    result = 2;
                }
            }

            return(result);
        }
Ejemplo n.º 26
0
        private void newTaskTextBox_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Return)
            {
                TreeViewItem group = new TreeViewItem();
                group.Header = "Today";

                UserTask task = new UserTask();
                task.Subject = newTaskTextBox.Text;

                AddTask(task, group, true);
                TaskDatabase.Add(task);

                if (TasksView.ApplicationTasksView != null)
                {
                    NewTaskCommand.Execute(task, TasksView.ApplicationTasksView);
                }

                NewTaskCommand.MassExecute(task, LoadedTasksPeekContents, this);

                newTaskTextBox.Clear();
            }
        }
Ejemplo n.º 27
0
        protected override void OnExit(ExitEventArgs e)
        {
            base.OnExit(e);

            //
            // Save databases
            //
            AppointmentDatabase.OnSaveCompletedEvent -= AppointmentDatabase_OnSaveCompletedEvent;
            AppointmentDatabase.Save();
            ContactDatabase.OnSaveCompletedEvent -= AppointmentDatabase_OnSaveCompletedEvent;
            ContactDatabase.Save();
            TaskDatabase.OnSaveCompletedEvent -= TaskDatabase_OnSaveCompletedEvent;
            TaskDatabase.Save();
            NoteDatabase.OnSaveCompletedEvent -= NoteDatabase_OnSaveCompletedEvent;
            NoteDatabase.Save();
            SyncDatabase.OnSaveCompletedEvent -= SyncDatabase_OnSaveCompletedEvent;
            SyncDatabase.Save();

            //
            // Unregister system hooks
            //
            SystemEvents.UserPreferenceChanged -= SystemEvents_UserPreferenceChanged;
            SystemEvents.TimeChanged           -= SystemEvents_TimeChanged;

            //
            // Delete autorecover information
            //
            new RecoveryDatabase(RecoveryVersion.Current).Delete();
            new RecoveryDatabase(RecoveryVersion.LastRun).Delete();

            //
            // Install any updates which may have been downloaded.
            //
            string localPath = (new FileInfo(Process.GetCurrentProcess().MainModule.FileName)).DirectoryName;

            Process.Start(localPath + "\\UpdateManager.exe", "/update " + Process.GetCurrentProcess().Id.ToString());
        }
Ejemplo n.º 28
0
        //#region Task Context Menu

        //private void taskGrid_ContextMenuOpening(object sender, ContextMenuEventArgs e)
        //{
        //	Grid grid = sender as Grid;
        //	TreeViewItem item = (grid.TemplatedParent as ContentPresenter).TemplatedParent as TreeViewItem;
        //	item.IsSelected = true;
        //	Task task = item.Header as Task;

        //	MenuItem menu = grid.ContextMenu.Items[0] as MenuItem;
        //	Image img = new Image();
        //	img.Stretch = Stretch.None;

        //	if (task.Status == Task.StatusPhase.Completed)
        //	{
        //		menu.Header = "_Flag Incomplete";
        //		img.Source = new BitmapImage(new Uri("pack://application:,,,/Daytimer.Images;component/Images/redflag.png", UriKind.Absolute));
        //	}
        //	else
        //	{
        //		menu.Header = "_Mark Complete";
        //		img.Source = new BitmapImage(new Uri("pack://application:,,,/Daytimer.Images;component/Images/greencheck.png", UriKind.Absolute));
        //	}

        //	menu.Icon = img;
        //}

        //private void deleteMenuItem_Click(object sender, RoutedEventArgs e)
        //{
        //	TreeViewItem item = (((sender as MenuItem).Parent as ContextMenu).TemplatedParent as ContentPresenter).TemplatedParent as TreeViewItem;
        //	deleteTask(item);
        //}

        //private void completeMenuItem_Click(object sender, RoutedEventArgs e)
        //{
        //	MarkComplete();
        //}

        //private void collapseAllGroups_Click(object sender, RoutedEventArgs e)
        //{
        //	foreach (TreeViewItem each in tasksTreeView.Items)
        //		each.IsExpanded = false;
        //}

        //private void expandAllGroups_Click(object sender, RoutedEventArgs e)
        //{
        //	foreach (TreeViewItem each in tasksTreeView.Items)
        //		each.IsExpanded = true;
        //}

        //private void deleteGroup_Click(object sender, RoutedEventArgs e)
        //{
        //	TreeViewItem header = (sender as MenuItem).CommandTarget as TreeViewItem;

        //	int count = header.Items.Count;

        //	for (int i = 0; i < count; i++)
        //	{
        //		TreeViewItem item = header.Items[i] as TreeViewItem;

        //		// Delete the task from the file
        //		Task task = item.Header as Task;
        //		TaskDatabase.Delete(task);
        //	}

        //	if (AnimationHelpers.AnimationsEnabled)
        //	{
        //		AnimationHelpers.DeleteAnimation parentDeleteAnim = new AnimationHelpers.DeleteAnimation(header);
        //		parentDeleteAnim.OnAnimationCompletedEvent += parentDeleteAnim_OnAnimationCompletedEvent;
        //		parentDeleteAnim.Animate();

        //		if (tasksTreeView.Items.Count <= 1)
        //		{
        //			statusText.Text = "We didn't find anything to show here.";
        //			AnimationHelpers.Fade fade = new AnimationHelpers.Fade(statusText, AnimationHelpers.FadeDirection.In);
        //		}
        //	}
        //	else
        //	{
        //		tasksTreeView.Items.Remove(header);
        //		if (tasksTreeView.Items.Count == 0)
        //		{
        //			statusText.Text = "We didn't find anything to show here.";
        //			statusText.Visibility = Visibility.Visible;
        //			statusText.Opacity = 1;
        //		}
        //	}
        //}

        //#endregion

        #region Drag-reorder items

        private void tasksTreeView_ItemReorder(object sender, ItemReorderEventArgs e)
        {
            if (!e.OldParent.HasItems)
            {
                tasksTreeView.Items.Remove(e.OldParent);
            }

            int index = e.NewParent.Items.IndexOf(e.Item);

            UserTask task = e.Item.Header as UserTask;

            string header = e.NewParent.Header.ToString();

            // Hardcode "Today" since tasks due in previous days will also be
            // shown under "Today": the user will expect the task dragged in
            // to be changed to DateTime.Now.Date, not some date in the past.
            if (header == "Today")
            {
                task.DueDate = DateTime.Now.Date;
            }
            else
            {
                task.DueDate = e.NewParent.Tag as DateTime?;
            }

            if (task.StartDate > task.DueDate)
            {
                task.StartDate = task.DueDate;
            }

            e.Item.Header = new UserTask(false);
            e.Item.Header = task;

            if (task.IsOverdue && task.Status != UserTask.StatusPhase.Completed)
            {
                e.Item.Foreground = new SolidColorBrush(Color.FromArgb(255, 218, 17, 17));
            }
            else
            {
                e.Item.Foreground = Brushes.Black;
            }

            ItemReorderEventArgs args = new ItemReorderEventArgs(e.Item, e.OldParent, e.NewParent, e.Copied, e.DragDirection);

            if (TasksView.ApplicationTasksView != null)
            {
                TaskReorderCommand.Execute(args, TasksView.ApplicationTasksView);
            }

            TaskReorderCommand.MassExecute(args, LoadedTasksPeekContents, this);

            if (!e.Copied)
            {
                TaskDatabase.Delete(task, false);
            }

            //if (e.OldParent == e.NewParent && e.DragDirection == DragDirection.Up)
            //	TaskDatabase.Insert(index - 1, task);
            //else
            TaskDatabase.Insert(index, task);
        }
Ejemplo n.º 29
0
        public void Write(TaskDatabase value, Stream stream)
        {
            var model = Convert(value);

            ModelWriter.Write(model, stream);
        }
Ejemplo n.º 30
0
 public abstract T Convert(TaskDatabase db);
 public TaskRepository(SQLiteConnection conn, string dbLocation)
 {
     db = new TaskDatabase(conn, dbLocation);
 }
Ejemplo n.º 32
0
 public override IEnumerable <TodoTask> Convert(TaskDatabase db)
 {
     return(db.Tasks.Select(Convert).ToList());
 }
 public TaskRepository(SQLiteConnection conn, string dbLocation)
 {
     // instantiate the database
     db = new TaskDatabase(conn, dbLocation);
 }
Ejemplo n.º 34
0
        /// <summary>
        /// Checks if an existing task exceeds another repeating task or task.
        /// </summary>
        /// <param name="model">Repeating task details to check on.</param>
        /// <returns>0 on nothing exceeds, 3 on DateTime exceeds, 2 on unexpected database error.</returns>
        public int Exceeds(Task model)
        {
            int result = 0;

            int[] totalrecords = new int[4];
            RepeatingTaskController taskController = new RepeatingTaskController();
            List <RepeatingTask>    repeatingTasks = new List <RepeatingTask>();
            List <Task>             tasks          = new List <Task>();

            if (model != null)
            {
                repeatingTasks = taskController.Details(model.UserId);
                tasks          = Details(model.UserId);
            }

            try
            {
                using (TaskDatabase db = new TaskDatabase())
                {
                    List <RepeatingTask> repeatingTaskQuery = (from repeatingTask in repeatingTasks
                                                               where repeatingTask.Day == model.Date.ToString("dddd")
                                                               select repeatingTask).ToList();

                    List <RepeatingTask> repeatingTaskDate = (from repeatingTask in repeatingTaskQuery
                                                              where repeatingTask.Time.Add(new TimeSpan(repeatingTask.Duration - 1, 0, 0)) < new TimeSpan(model.Date.Hour, 0, 0)
                                                              select repeatingTask).ToList();

                    totalrecords[0] = repeatingTaskDate.Count;

                    repeatingTaskDate = (from repeatingTask in repeatingTaskQuery
                                         where repeatingTask.Time > new TimeSpan(model.Date.Hour + model.Duration - 1, 0, 0)
                                         select repeatingTask).ToList();

                    totalrecords[1] = repeatingTaskDate.Count;

                    if (repeatingTaskQuery.Count != totalrecords[0] + totalrecords[1])
                    {
                        result = 3;
                    }
                    else
                    {
                        List <Task> taskQuery = (from task in tasks
                                                 where task.Date.DayOfWeek == model.Date.DayOfWeek && task.Id != model.Id
                                                 select task).ToList();

                        List <Task> taskDate = (from task in taskQuery
                                                where task.Date.AddHours(task.Duration - 1) < model.Date
                                                select task).ToList();

                        totalrecords[2] = taskDate.Count;

                        taskDate = (from task in taskQuery
                                    where task.Date > model.Date.AddHours(model.Duration - 1)
                                    select task).ToList();

                        totalrecords[3] = taskDate.Count;

                        if (taskQuery.Count != totalrecords[2] + totalrecords[3])
                        {
                            result = 3;
                        }
                    }
                }
            }
            catch (Exception)
            {
                result = 2;
            }

            return(result);
        }
Ejemplo n.º 35
0
 void LoadOldDatabase()
 {
     m_Task = (TaskDatabase)AssetDatabase.LoadAssetAtPath( n_FileLocation , typeof(TaskDatabase));
     Debug.Log("Loaded Existing Database");
 }
Ejemplo n.º 36
0
    void DeleteDatabase()
    {
        bool confirm = EditorUtility.DisplayDialog("Close Board?", "Are you sure you want to Close this Task Board?", "Yes", "No");

        if(confirm == true)
        {
            m_Task = null;
            newBoardName = null;
            currentBoardName = null;
            n_FileLocation = null;
            Debug.Log("Closed Board");
        }
        else
        {
            Debug.Log("Cancelled Closing Board");
        }
    }