Exemple #1
0
        private IEnumerable <TimeEntry> ConsolidateDay(DayItemViewmodel dayItemViewmodel)
        {
            var consolidatedTimeEntries = new List <TimeEntry>();
            var registeredHours         = dayItemViewmodel.RegisteredHours;
            var timeEntries             = dayItemViewmodel.TimeEntries.ToList();

            var description = dayItemViewmodel.Comment;

            foreach (var localTimeEntry in timeEntries)
            {
                localTimeEntry.Reset();
                consolidatedTimeEntries.Add(localTimeEntry);
            }

            var timeEntry = timeEntries.FirstOrDefault();

            if (timeEntry == null)
            {
                timeEntry           = TimeEntry.Create();
                timeEntry.Task      = dayItemViewmodel.Task;
                timeEntry.StartTime = dayItemViewmodel.Date;

                timeEntry.TimeEntryType = _timeEntryTypeRepository.GetByCompany(timeEntry.Task.Project.Company)
                                          .FirstOrDefault(tt => tt.IsDefault);

                consolidatedTimeEntries.Add(timeEntry);
            }

            timeEntry.Billable     = dayItemViewmodel.Billable;
            timeEntry.EndTime      = timeEntry.StartTime.AddHours(registeredHours.GetValueOrDefault());
            timeEntry.BillableTime = timeEntry.TimeSpent = (timeEntry.EndTime - timeEntry.StartTime);
            timeEntry.Description  = description;
            return(consolidatedTimeEntries);
        }
Exemple #2
0
 private List <TimeEntry> ConvertFromXMLToTimeEntry(IEnumerable <TimeTrackerDataSet.TimeEntriesRow> rows)
 {
     return(rows.Select(t =>
     {
         var task = _taskRepository.GetByGuid(t.TaskId);
         var timeEntryType = _timeEntryTypeRepository.GetById(t.TimeEntryTypeId);
         return TimeEntry.Create(t.Guid, task, timeEntryType, t.TimeSpent, t.BillableTime,
                                 t.Description, t.EntryStartDate, t.EntryStartDate, t.PricePrHour, t.Synced, t.SyncInfo, t.Billable,
                                 new TimeEntryHistory(), true, t.CreateDate, t.ClientSourceId, t.Invoiced);
     })
            .ToList());
 }
Exemple #3
0
        private void InitializeTimer(TimeEntry timeEntry)
        {
            //if the given is null, create a new timer based on the existing timeentry (with same task and project)
            if (timeEntry == null)
            {
                TimeEntry = TimeEntry.Create(TimeEntry);
            }
            //If time is zero, start a new timer based on the given timeentry (with same task and project)
            else if (timeEntry.TimeSpent == TimeSpan.Zero)
            {
                TimeEntry = TimeEntry.Create(timeEntry);
            }
            //Else just continue the timer on the current timeentry
            else
            {
                TimeEntry = timeEntry;
            }
            if (TimerService != null)
            {
                TimerService.Dispose();
                TimerService = null;
            }
            if (ToolTipViewModel == null)
            {
                ToolTipViewModel = new TaskToolTipViewModel(TimeEntry);
            }
            else
            {
                ToolTipViewModel.Update(TimeEntry);
            }
            _applicationStateService.CurrentState.ActiveTimeEntry = TimeEntry;
            _applicationStateService.Save();

            TimerService = new TimeEntryTimerService(TimeEntry);
            TimerService.TimeEntryUpdated  += _timeEntryTimerService_TimeEntryUpdated;
            TimerService.TimerStateChanged += _timeEntryTimerService_TimerStateChanged;
        }
Exemple #4
0
 private static TimeEntry Create(Common.DataTransferObjects.TimeEntryDto timeEntryDto, Core.Model.Task task, TimeEntryType timeEntryType)
 {
     return(TimeEntry.Create(timeEntryDto.Guid,
                             task,
                             timeEntryType,
                             TimeSpan.FromHours(timeEntryDto.TimeSpent),
                             TimeSpan.FromHours(timeEntryDto.BillableTime),
                             timeEntryDto.Description,
                             timeEntryDto.StartTime,
                             timeEntryDto.EndTime,
                             timeEntryDto.PricePrHour,
                             true,
                             string.Empty,
                             timeEntryDto.Billable,
                             new TimeEntryHistory(),
                             true,
                             timeEntryDto.CreateDate,
                             timeEntryDto.ClientSourceId,
                             timeEntryDto.Invoiced));
 }