예제 #1
0
        public void OnReceive(TaskStatusCompletedMessage message)
        {
            var task = MyTasks.FirstOrDefault(x => x.id == message.Id);

            if (task != null)
            {
                MyTasks.Remove(task);
            }

            task = DueTodayTasks.FirstOrDefault(x => x.id == message.Id);
            if (task != null)
            {
                DueTodayTasks.Remove(task);
            }

            task = DueTomorrowTasks.FirstOrDefault(x => x.id == message.Id);
            if (task != null)
            {
                DueTomorrowTasks.Remove(task);
            }

            task = DueWeekendTasks.FirstOrDefault(x => x.id == message.Id);
            if (task != null)
            {
                DueWeekendTasks.Remove(task);
            }
        }
예제 #2
0
        async Task LoadTasksFromDb(bool onlyMyTasks = false)
        {
            if (SettingsService.CurrentUserId.HasValue)
            {
                var myTasks = await new StorageService().GetActiveTasksByUser(SettingsService.CurrentUserId.Value);
                foreach (var asanaTask in myTasks)
                {
                    FillTaskCommands(asanaTask);
                    await MapperService.FillTaskInfo(asanaTask);
                }

                Dispatcher.RunAsync(() =>
                {
                    MyTasks.Clear();
                    MyTasks.AddRange(myTasks);
                });
            }

            if (!onlyMyTasks)
            {
                var dueTodayTasks = await new StorageService().GetDueTodayTasks();

                foreach (var asanaTask in dueTodayTasks)
                {
                    FillTaskCommands(asanaTask);
                    await MapperService.FillTaskInfo(asanaTask);

                    if (asanaTask.assigneeid > 0)
                    {
                        var user = await new StorageService().Find <AsanaUser>(asanaTask.assigneeid);

                        if (user != null)
                        {
                            asanaTask.UserName = user.name;
                        }
                    }
                }


                Dispatcher.RunAsync(() =>
                {
                    DueTodayTasks.Clear();
                    DueTodayTasks.AddRange(dueTodayTasks);
                });

                var tomorrowTasks = await new StorageService().GetDueTomorrowTasks();

                foreach (var asanaTask in tomorrowTasks)
                {
                    FillTaskCommands(asanaTask);
                    await MapperService.FillTaskInfo(asanaTask);

                    if (asanaTask.assigneeid > 0)
                    {
                        var user = await new StorageService().Find <AsanaUser>(asanaTask.assigneeid);

                        if (user != null)
                        {
                            asanaTask.UserName = user.name;
                        }
                    }
                }


                Dispatcher.RunAsync(() =>
                {
                    DueTomorrowTasks.Clear();
                    DueTomorrowTasks.AddRange(tomorrowTasks);
                });

                var weekendTasks = await new StorageService().GetDueWeekendTasks();

                foreach (var asanaTask in weekendTasks)
                {
                    FillTaskCommands(asanaTask);
                    await MapperService.FillTaskInfo(asanaTask);

                    if (asanaTask.assigneeid > 0)
                    {
                        var user = await new StorageService().Find <AsanaUser>(asanaTask.assigneeid);
                        if (user != null)
                        {
                            asanaTask.UserName = user.name;
                        }
                    }
                }


                Dispatcher.RunAsync(() =>
                {
                    DueWeekendTasks.Clear();
                    DueWeekendTasks.AddRange(weekendTasks);
                });
            }
        }