private bool SendWorkLog(IElmaUser user, IElmaTask task) { if (!CheckToken() && null == AuthorizeUser(user)) { return(false); } try { var entityService = _entityServiceFactory.CreateChannel(); using (new OperationContextScope(entityService)) { OperationContext.Current.OutgoingMessageHeaders.Add(MessageHeader.CreateHeader("AuthToken", "", AuthToken.ToString ())); OperationContext.Current.OutgoingMessageHeaders.Add(MessageHeader.CreateHeader("SessionToken", "", SessionToken)); entityService.Insert(ElmaWorkLog.WorkLogTypeUid, CreateWorkLogData(user, task)); } } catch (FaultException <PublicServiceException> exception) { Log.Error("SendWorkLog, FaultException", exception.Message); return(false); } catch (Exception exception) { Log.Error("SendWorkLog, Exception", exception.Message); return(false); } return(true); }
public bool SendWorkLogAsync(IElmaUser user, IElmaTask task) { if (null == user || null == task) { return(false); } return(SendWorkLog(user, task)); }
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); }
private static WebData CreateTaskData(IElmaTask task) { var data = new WebData { Items = new WebDataItem[4] }; data.Items[0] = new WebDataItem { Name = "Id", Value = task.Id.ToString() }; data.Items[1] = new WebDataItem { Name = "TypeUid", Value = task.TypeUid }; data.Items[2] = new WebDataItem { Name = "Uid", Value = task.Uid.ToString() }; data.Items[3] = new WebDataItem { Name = "Name", Value = task.Subject }; return(data); }
public SendWorklogDialogFragment(IElmaTask task, IElmaTaskProvider taskProvider) { _task = task; _taskProvider = taskProvider; }
private static WebData CreateWorkLogData(IElmaUser user, IElmaTask task) { var data = new WebData { Items = new WebDataItem[12] }; data.Items[0] = new WebDataItem { Name = "Id", Value = null }; data.Items[1] = new WebDataItem { Name = "TypeUid", Value = ElmaWorkLog.WorkLogTypeUid }; data.Items[2] = new WebDataItem { Name = "Uid", Value = null }; data.Items[3] = new WebDataItem { Name = "CreationDate", Value = null }; // TODO: change!!! if (task.UnaccountedWorkLog.WorkTime?.TotalSeconds != null) { data.Items[4] = new WebDataItem { Name = "WorkMinutes", Value = Math.Round((decimal)task.UnaccountedWorkLog.WorkTime?.TotalSeconds) .ToString(CultureInfo.InvariantCulture) } } ; else { data.Items[4] = new WebDataItem { Name = "WorkMinutes", Value = "" } }; data.Items[5] = new WebDataItem { Name = "StartDate", Value = task.UnaccountedWorkLog.StartDate?.ToString("G") }; data.Items[6] = new WebDataItem { Name = "Comment", Value = task.UnaccountedWorkLog.Comment }; data.Items[7] = new WebDataItem { Name = "CreationAuthor", Value = null, Data = CreateUserData(user) }; data.Items[8] = new WebDataItem { Name = "Worker", Value = null, Data = CreateUserData(user) }; data.Items[9] = new WebDataItem { Name = "TaskBase", Value = null, Data = CreateTaskData(task) }; // TODO: change!!! data.Items[10] = new WebDataItem { Name = "Status", Value = "1" }; data.Items[11] = new WebDataItem { Name = "WorkLogItem", Value = null }; return(data); }
public void StartTimer(IElmaTask task) { _chronometer.Base = SystemClock.ElapsedRealtime(); _chronometer.Start(); _currentlyExecutingTask = task; }
public EditSpentTimeDialogFragment(IElmaTask task) { _task = task; }