public bool SendTaskWorklog(IElmaTask task) { if (task.LoggingState == TaskLoggingState.NotLogging) { return(false); } task.LoggingState = TaskLoggingState.NotLogging; _timer.StopTimer(); // TODO: DateTime.Now probably have to be changed to UtcNow // TODO: add form for changing StartDate and Comment if (null == task.UnaccountedWorkLog) { task.UnaccountedWorkLog = new ElmaWorkLog(0, Guid.Empty) { StartDate = DateTime.Now, Comment = "Sent from mobile app", WorkTime = task.UnaccountedWorkTime }; } else { if (null == task.UnaccountedWorkLog.WorkTime) { task.UnaccountedWorkLog.WorkTime = new TimeSpan(); } if (task.UnaccountedWorkTime != null) { task.UnaccountedWorkLog.WorkTime += task.UnaccountedWorkTime.Value; } } if (_wcfService.SendWorkLogAsync(_user, task) == false) { // TODO: add some message for user about that and change green cloud to red cross or smth.. OnTasksChangedEvent?.Invoke(this, EventArgs.Empty); return(false); } task.UnaccountedWorkTime = null; task.UnaccountedWorkLog = null; OnTasksChangedEvent?.Invoke(this, EventArgs.Empty); return(true); }
public bool PauseTaskExecution(IElmaTask task, bool emitChanged = true) { if (task.LoggingState != TaskLoggingState.Logging) { return(false); } task.LoggingState = TaskLoggingState.Paused; _timer.StopTimer(); if (emitChanged) { OnTasksChangedEvent?.Invoke(this, EventArgs.Empty); } return(true); }
public bool StartTaskExecution(IElmaTask task, bool emitChanged = true) { foreach (var t in GetAllTasks().Where(t => t.Id != task.Id)) { PauseTaskExecution(t, false); } task.LoggingState = TaskLoggingState.Logging; _timer.StartTimer(task); if (emitChanged) { OnTasksChangedEvent?.Invoke(this, EventArgs.Empty); } return(true); }