Exemplo n.º 1
0
        ///<summary>Gets all Read Reminders in a TaskList/Task hierarchy that the user was not already subscribed to.</summary>
        private static List <Task> GetNewReadReminders(List <long> listExistingSubscriptions, long taskListNum, long curUserNum)
        {
            List <Task> listReminders = new List <Task>();

            if (taskListNum.In(listExistingSubscriptions))
            {
                //We are only looking for Reminders that we were not already subscribed to.
                return(listReminders);
            }
            long userNumInbox = TaskLists.GetMailboxUserNum(taskListNum);          //Can be 0, not a user inbox.

            foreach (TaskList taskList in TaskLists.RefreshChildren(taskListNum, curUserNum, userNumInbox, TaskType.Reminder))
            {
                listReminders.AddRange(GetNewReadReminders(listExistingSubscriptions, taskList.TaskListNum, curUserNum));
            }
            listReminders.AddRange(Tasks.RefreshChildren(taskListNum, false, DateTime.MinValue, curUserNum, userNumInbox, TaskType.Reminder, false
                                                         , GlobalTaskFilterType.None).Where(x => !x.IsUnread));//IsUnread field set accurately by Tasks.RefreshChildren(...)
            return(listReminders);
        }
Exemplo n.º 2
0
        public static string GetChangesDescription(TaskHist taskCur, TaskHist taskNext)
        {
            if (taskCur.Descript.StartsWith("This task was cut from task list ") || taskCur.Descript.StartsWith("This task was copied from task "))
            {
                return(taskCur.Descript);
            }
            if (taskCur.DateTimeEntry == DateTime.MinValue)
            {
                return(Lans.g("TaskHists", "New task."));
            }
            StringBuilder strb = new StringBuilder();

            strb.Append("");
            if (taskNext.TaskListNum != taskCur.TaskListNum)
            {
                string   descOne  = Lans.g("TaskHists", "(DELETED)");
                string   descTwo  = Lans.g("TaskHists", "(DELETED)");
                TaskList taskList = TaskLists.GetOne(taskCur.TaskListNum);
                if (taskList != null)
                {
                    descOne = taskList.Descript;
                }
                taskList = TaskLists.GetOne(taskNext.TaskListNum);
                if (taskList != null)
                {
                    descTwo = taskList.Descript;
                }
                strb.Append(Lans.g("TaskHists", "Task list changed from") + " " + descOne + " " + Lans.g("TaskHists", "to") + " " + descTwo + ".\r\n");
            }
            if (taskNext.ObjectType != taskCur.ObjectType)
            {
                strb.Append(Lans.g("TaskHists", "Task attachment changed from") + " "
                            + taskCur.ObjectType.ToString() + " " + Lans.g("TaskHists", "to") + " " + taskNext.ObjectType.ToString() + ".\r\n");
            }
            if (taskNext.KeyNum != taskCur.KeyNum)
            {
                strb.Append(Lans.g("TaskHists", "Task account attachment changed.") + "\r\n");
            }
            if (taskNext.Descript != taskCur.Descript && !taskNext.Descript.StartsWith("This task was cut from task list ") &&
                !taskNext.Descript.StartsWith("This task was copied from task "))
            {
                //We change the description of a task when it is cut/copied.
                //This prevents the history grid from showing a description changed when it wasn't changed by the user.
                strb.Append(Lans.g("TaskHists", "Task description changed.") + "\r\n");
            }
            if (taskNext.TaskStatus != taskCur.TaskStatus)
            {
                strb.Append(Lans.g("TaskHists", "Task status changed from") + " "
                            + taskCur.TaskStatus.ToString() + " " + Lans.g("TaskHists", "to") + " " + taskNext.TaskStatus.ToString() + ".\r\n");
            }
            if (taskNext.DateTimeEntry != taskCur.DateTimeEntry)
            {
                strb.Append(Lans.g("TaskHists", "Task date added changed from") + " "
                            + taskCur.DateTimeEntry.ToString()
                            + " " + Lans.g("TaskHists", "to") + " "
                            + taskNext.DateTimeEntry.ToString() + ".\r\n");
            }
            if (taskNext.UserNum != taskCur.UserNum)
            {
                strb.Append(Lans.g("TaskHists", "Task author changed from ")
                            + Userods.GetUser(taskCur.UserNum).UserName
                            + " " + Lans.g("TaskHists", "to") + " "
                            + Userods.GetUser(taskNext.UserNum).UserName + ".\r\n");
            }
            if (taskNext.DateTimeFinished != taskCur.DateTimeFinished)
            {
                strb.Append(Lans.g("TaskHists", "Task date finished changed from") + " "
                            + taskCur.DateTimeFinished.ToString()
                            + " " + Lans.g("TaskHists", "to") + " "
                            + taskNext.DateTimeFinished.ToString() + ".\r\n");
            }
            if (taskNext.PriorityDefNum != taskCur.PriorityDefNum)
            {
                strb.Append(Lans.g("TaskHists", "Task priority changed from") + " "
                            + Defs.GetDef(DefCat.TaskPriorities, taskCur.PriorityDefNum).ItemName
                            + " " + Lans.g("TaskHists", "to") + " "
                            + Defs.GetDef(DefCat.TaskPriorities, taskNext.PriorityDefNum).ItemName + ".\r\n");
            }
            if (taskCur.IsNoteChange)              //Using taskOld because the notes changed from the old one to the new one.
            {
                strb.Append(Lans.g("TaskHists", "Task notes changed."));
            }
            return(strb.ToString());
        }