コード例 #1
0
ファイル: TaskHelper.cs プロジェクト: fqncom/tomcraporigami
 public static List<TaskReminder> CalculateTaskReminder(Tasks task)
 {
     List<TaskReminder> taskReminders = new List<TaskReminder>();
     if (task.DueDate == null)
     {
         task.Reminders = new List<TaskReminder>();
         return taskReminders;
     }
     if (!task.HasReminder())
     {
         return taskReminders;
     }
     long dueTime = GetTaskDueTime(task.DueDate.Value, task.IsAllDay);
     foreach (TaskReminder reminder in task.Reminders)
     {
         DateTime? remindTime = DateTimeUtils.CalculateRemindTime(reminder.Duration, dueTime);
         if (remindTime != null)
         {
             TaskReminder taskReminder = new TaskReminder(reminder);
             taskReminder.RemindTime = remindTime.Value;
             taskReminders.Add(taskReminder);
         }
     }
     return taskReminders;
 }
コード例 #2
0
ファイル: TaskHelper.cs プロジェクト: fqncom/tomcraporigami
        // TODO 这里有问题 返回taskremindstatus
        public static int IsRemindTask(Tasks task)
        {

            if (task.DueDate == null)
            {
                return TaskRemindStatus.NO_DUE_DATE;
            }

            if (task.Deleted != ModelStatusEnum.DELETED_NO)
            {
                return TaskRemindStatus.TASK_DELETED;
            }

            if (task.IsCompleted)
            {
                return TaskRemindStatus.TASK_COMPLETED;
            }

            if (!task.HasReminder())
            {
                return TaskRemindStatus.NO_REMINDER;
            }

            if (task.IsRepeatTask())
            {
                return TaskRemindStatus.VALID;
            }

            if (HasValidReminder(task.Reminders, task.DueDate.Value, task.IsAllDay))
            {
                return TaskRemindStatus.VALID;
            }

            if (IsValidSnoozeReminder(task.SnoozeRemindTime.Value))
            {
                return TaskRemindStatus.VALID;
            }

            return TaskRemindStatus.OVERDUE;
        }
コード例 #3
0
ファイル: TaskTransfer.cs プロジェクト: fqncom/tomcraporigami
        public static TasksServer ConvertLocalToServer(Tasks localTask)
        {
            TasksServer task = new TasksServer();
            task.Id = localTask.SId;
            task.CreatedTime = localTask.CreatedTime;
            task.ModifiedTime = localTask.ModifiedTime;
            task.Etag = localTask.Etag;
            task.ProjectId = localTask.ProjectSid;
            task.Title = localTask.Title;
            task.Content = localTask.Content;
            task.SortOrder = localTask.SortOrder;
            task.Priority = localTask.Priority;
            task.DueDate = localTask.DueDate;
            task.RepeatFirstDate = localTask.RepeatFirstDate;
            //task.Reminder = localTask.Reminder;
            task.RepeatFlag = localTask.RepeatFlag;
            task.RepeatTaskId = localTask.RepeatTaskId;
            // TODO task.setUserCount=UserCount);
            task.CompletedTime = localTask.CompletedTime;
            task.Status = localTask.TaskStatus;
            task.TimeZone = localTask.TimeZone;

            if (localTask.IsChecklistMode())
            {
                task.Items = ChecklistItemTransfer.ConvertCheckListItemLocalToServer(localTask.ChecklistItems);
            }
            else
            {
                task.Items = null;
            }
            if (localTask.HasLocation())
            {
                task.Location = LocationTransfer.ConvertLocationLocalToServer(localTask.Location);
            }
            //if (localTask.Attachments != null && localTask.Attachments.Count > 0)
            //{
            //    //task.Attachments =AttachmentTransfer.ConvertAttachmentLocalToServer(localTask.Attachments);
            //}

            if (localTask.HasReminder())
            {
                //DateTime? reminderTime = localTask.SnoozeRemindTime;
                //if (reminderTime == null)
                //{
                //    reminderTime = DateTimeUtils.CalculateReminderTime(localTask.Reminder, localTask.DueDate.Value);
                //}
                //task.RemindTime = reminderTime;
                task.Reminders = ReminderTransfer.ConvertLocalToServer(localTask.Reminders);
            }
            if (localTask.DueDate != null)
            {
                task.IsAllDay = localTask.IsAllDay;
            }
            task.RemindTime = localTask.SnoozeRemindTime;
            task.RepeatFrom = localTask.RepeatFrom;
            task.Assignee = localTask.Assignee;
            //task.Tags = localTask.Tags;
            return task;
        }