private static LogItemViewModel header(
            IThreadSafeTimeEntry[] group,
            LogItemVisualizationIntent visualizationIntent,
            DurationFormat durationFormat)
        {
            var sample = group.First();

            return(new LogItemViewModel(
                       groupId: new GroupId(sample),
                       representedTimeEntriesIds: group.Select(timeEntry => timeEntry.Id).ToArray(),
                       visualizationIntent: visualizationIntent,
                       isBillable: sample.Billable,
                       isActive: sample.Project?.Active ?? true,
                       description: sample.Description,
                       duration: DurationAndFormatToString.Convert(
                           TimeSpan.FromSeconds(group.Sum(timeEntry => timeEntry.Duration ?? 0)),
                           durationFormat),
                       projectName: sample.Project?.Name,
                       projectColor: sample.Project?.Color,
                       clientName: sample.Project?.Client?.Name,
                       taskName: sample.Task?.Name,
                       hasTags: sample.Tags.Any(),
                       needsSync: group.Any(timeEntry => timeEntry.SyncStatus == SyncStatus.SyncNeeded),
                       canSync: group.All(timeEntry => timeEntry.SyncStatus != SyncStatus.SyncFailed),
                       isInaccessible: sample.IsInaccessible,
                       indexInLog: 0,
                       dayInLog: 0,
                       daysInThePast: 0,
                       projectIsPlaceholder: sample.Project?.IsPlaceholder() ?? false,
                       taskIsPlaceholder: sample.Task?.IsPlaceholder() ?? false));
        }
Exemple #2
0
        private LogItemViewModel header(
            GroupId groupId,
            IThreadSafeTimeEntry[] group,
            LogItemVisualizationIntent visualizationIntent)
        {
            var sample = group.First();

            return(new LogItemViewModel(
                       groupId: groupId,
                       representedTimeEntriesIds: group.Select(timeEntry => timeEntry.Id).ToArray(),
                       visualizationIntent: visualizationIntent,
                       isBillable: sample.Billable,
                       description: sample.Description,
                       duration: DurationAndFormatToString.Convert(
                           TimeSpan.FromSeconds(group.Sum(timeEntry => timeEntry.Duration ?? 0)),
                           durationFormat),
                       projectName: sample.Project?.Name,
                       projectColor: sample.Project?.Color,
                       clientName: sample.Project?.Client?.Name,
                       taskName: sample.Task?.Name,
                       hasTags: sample.Tags.Any(),
                       needsSync: group.Any(timeEntry => timeEntry.SyncStatus == SyncStatus.SyncNeeded),
                       canSync: group.All(timeEntry => timeEntry.SyncStatus != SyncStatus.SyncFailed),
                       isInaccessible: sample.IsInaccessible));
        }
Exemple #3
0
        public LogItemViewModel(
            GroupId groupId,
            long[] representedTimeEntriesIds,
            LogItemVisualizationIntent visualizationIntent,
            bool isBillable,
            string description,
            string duration,
            string projectName,
            string projectColor,
            string clientName,
            string taskName,
            bool hasTags,
            bool needsSync,
            bool canSync,
            bool isInaccessible)
        {
            GroupId = groupId;
            RepresentedTimeEntriesIds = representedTimeEntriesIds.OrderBy(id => id).ToArray();
            VisualizationIntent       = visualizationIntent;
            IsBillable   = isBillable;
            Description  = description;
            Duration     = duration;
            ProjectName  = projectName ?? string.Empty;
            ProjectColor = projectColor ?? string.Empty;
            ClientName   = clientName ?? string.Empty;
            TaskName     = taskName ?? string.Empty;
            HasTags      = hasTags;
            NeedsSync    = needsSync;
            CanContinue  = canSync && !isInaccessible;

            Identity = IsTimeEntryGroupHeader
                ? new TimeEntriesGroupKey(groupId) as IMainLogKey
                : new SingleTimeEntryKey(representedTimeEntriesIds.Single());
        }
Exemple #4
0
 public static LogItemViewModel ToViewModel(
     this IThreadSafeTimeEntry timeEntry,
     GroupId groupId,
     LogItemVisualizationIntent visualizationIntent,
     DurationFormat durationFormat,
     int indexInLog,
     int dayInLog,
     int daysInThePast)
 => new LogItemViewModel(
     groupId,
     new[] { timeEntry.Id },
     visualizationIntent,
     timeEntry.Billable,
     timeEntry.Description,
     timeEntry.Duration.HasValue
             ? DurationAndFormatToString.Convert(
         TimeSpan.FromSeconds(timeEntry.Duration.Value), durationFormat)
             : string.Empty,
     timeEntry.Project?.DisplayName(),
     timeEntry.Project?.DisplayColor(),
     timeEntry.Project?.Client?.Name,
     timeEntry.Task?.Name,
     timeEntry.TagIds.Any(),
     timeEntry.SyncStatus == SyncStatus.SyncNeeded,
     timeEntry.SyncStatus != SyncStatus.SyncFailed,
     timeEntry.IsInaccessible,
     indexInLog,
     dayInLog,
     daysInThePast);