private async Task GetPausedActivitiesAsync() { var result2 = await UserService.Instance.GetActivitiesByStatus(StatusType.Pause); foreach (var activity in result2) { var parts = await UserService.Instance.GetPartsOfActivityByActivityId(activity.ActivityId); var time = parts.Sum(part => long.Parse(part.Duration)); var t = TimeSpan.FromMilliseconds(time); var item = new MainPageListItem { MyImageSource = ImageChoice(activity.Status), ActivityId = activity.ActivityId, Duration = $"{t.Hours:D2}:{t.Minutes:D2}:{t.Seconds:D2}", Time = time, Status = StatusType.Start }; if (activity.TaskId == 0) { item.Name = "Nowa Aktywność " + activity.ActivityId; } else { var task = await UserService.Instance.GetTaskById(activity.TaskId); item.TaskId = task.TaskId; item.Name = task.Name; item.Description = activity.Comment; } _activeTasksList.Add(item); } }
private async void FastTaskButton_OnClicked(object sender, EventArgs e) { if (_activeTasksList.Count == 0) { ActiveTasks.IsVisible = true; } var activity = new ActivitiesDto { Guid = Guid.NewGuid().ToString(), Status = StatusType.Start, UserId = UserService.Instance.GetLoggedUser().UserId, GroupId = 1, TaskId = 0 }; activity.ActivityId = await UserService.Instance.SaveActivity(activity); var now = DateTime.Now; var part = new PartsOfActivityDto { ActivityId = activity.ActivityId, Start = now.ToString("HH:mm:ss dd/MM/yyyy"), Stop = "", Duration = "0" }; part.PartId = await UserService.Instance.SavePartOfActivity(part); StopwatchesService.Instance.AddStopwatch(part.PartId); var t = TimeSpan.FromMilliseconds(0); var item = new MainPageListItem { MyImageSource = ImageChoice(activity.Status), Name = "Nowa Aktywność " + activity.ActivityId, ActivityId = activity.ActivityId, PartId = part.PartId, Duration = $"{t.Hours:D2}:{t.Minutes:D2}:{t.Seconds:D2}", Time = 0 }; _activeTasksList.Add(item); UpdateList(); _listTimer.Start(); }