示例#1
0
        public TaskData Import (IDataStoreContext ctx, TaskJson json, Guid? localIdHint = null, TaskData mergeBase = null)
        {
            var data = GetByRemoteId<TaskData> (ctx, json.Id.Value, localIdHint);

            var merger = mergeBase != null ? new TaskMerger (mergeBase) : null;
            if (merger != null && data != null)
                merger.Add (new TaskData (data));

            if (json.DeletedAt.HasValue) {
                if (data != null) {
                    ctx.Delete (data);
                    data = null;
                }
            } else if (merger != null || ShouldOverwrite (data, json)) {
                data = data ?? new TaskData ();
                ImportJson (ctx, data, json);

                if (merger != null) {
                    merger.Add (data);
                    data = merger.Result;
                }

                data = ctx.Put (data);
            }

            return data;
        }
示例#2
0
 public TaskData (TaskData other) : base (other)
 {
     Name = other.Name;
     IsActive = other.IsActive;
     Estimate = other.Estimate;
     WorkspaceId = other.WorkspaceId;
     ProjectId = other.ProjectId;
 }
示例#3
0
 public void Dispose ()
 {
     timeEntryDataList.Clear ();
     timeEntryData = new TimeEntryData ();
     projectData = new ProjectData ();
     clientData = new ClientData ();
     taskData = new TaskData ();
 }
示例#4
0
        public TimeEntryHolder (IEnumerable<TimeEntryData> timeEntryGroup)
        {
            if (timeEntryGroup == null || !timeEntryGroup.Any ()) {
                throw new ArgumentException ("Must be specified", "timeEntryGroup");
            }

            timeEntryDataList.AddRange (timeEntryGroup);
            timeEntryData = new TimeEntryData (timeEntryGroup.Last ());
            projectData = new ProjectData ();
            clientData = new ClientData ();
            taskData = new TaskData ();
        }
示例#5
0
        private static void Merge (IDataStoreContext ctx, TaskData data, TaskJson json)
        {
            var projectId = GetLocalId<ProjectData> (ctx, json.ProjectId);
            var workspaceId = GetLocalId<WorkspaceData> (ctx, json.WorkspaceId);

            data.Name = json.Name;
            data.IsActive = json.IsActive;
            data.Estimate = json.Estimate;
            data.ProjectId = projectId;
            data.WorkspaceId = workspaceId;

            MergeCommon (data, json);
        }
示例#6
0
        public TaskJson Export (IDataStoreContext ctx, TaskData data)
        {
            var projectId = GetRemoteId<ProjectData> (ctx, data.ProjectId);
            var workspaceId = GetRemoteId<WorkspaceData> (ctx, data.WorkspaceId);

            return new TaskJson () {
                Id = data.RemoteId,
                ModifiedAt = data.ModifiedAt.ToUtc (),
                Name = data.Name,
                IsActive = data.IsActive,
                Estimate = data.Estimate,
                ProjectId = projectId,
                WorkspaceId = workspaceId,
            };
        }
        public TaskData Import (IDataStoreContext ctx, TaskJson json, Guid? localIdHint = null, TaskData mergeBase = null)
        {
            var log = ServiceContainer.Resolve<ILogger> ();

            var data = GetByRemoteId<TaskData> (ctx, json.Id.Value, localIdHint);

            var merger = mergeBase != null ? new TaskMerger (mergeBase) : null;
            if (merger != null && data != null) {
                merger.Add (new TaskData (data));
            }

            if (json.DeletedAt.HasValue) {
                if (data != null) {
                    log.Info (Tag, "Deleting local data for {0}.", data.ToIdString ());
                    ctx.Delete (data);
                    data = null;
                }
            } else if (merger != null || ShouldOverwrite (data, json)) {
                data = data ?? new TaskData ();
                ImportJson (ctx, data, json);

                if (merger != null) {
                    merger.Add (data);
                    data = merger.Result;
                }

                if (merger != null) {
                    log.Info (Tag, "Importing {0}, merging with local data.", data.ToIdString ());
                } else {
                    log.Info (Tag, "Importing {0}, replacing local data.", data.ToIdString ());
                }

                data = ctx.Put (data);
            } else {
                log.Info (Tag, "Skipping import of {0}.", json.ToIdString ());
            }

            return data;
        }
示例#8
0
 public static TaskData Import (this TaskJson json, IDataStoreContext ctx,
                                Guid? localIdHint = null, TaskData mergeBase = null)
 {
     var converter = ServiceContainer.Resolve<TaskJsonConverter> ();
     return converter.Import (ctx, json, localIdHint, mergeBase);
 }
 public CommonProjectData (ProjectData dataObject, string clientName, TaskData task = null) : base (dataObject)
 {
     Task = task;
     ClientName = clientName;
 }
示例#10
0
        private static async Task<TaskData> UpdateTask (TimeEntryData newTimeEntry, TaskData oldTaskData)
        {
            if (!newTimeEntry.TaskId.HasValue) {
                return new TaskData ();
            }

            if (oldTaskData == null && newTimeEntry.TaskId.HasValue) {
                return await GetTaskDataAsync (newTimeEntry.TaskId.Value);
            }

            if (newTimeEntry.TaskId.Value != oldTaskData.Id) {
                return await GetTaskDataAsync (newTimeEntry.TaskId.Value);
            }

            return oldTaskData;
        }
示例#11
0
        public async Task UpdateAsync (IEnumerable<TimeEntryData> timeEntryGroup)
        {
            timeEntryData = new TimeEntryData (timeEntryGroup.Last ());
            timeEntryDataList.Clear ();
            timeEntryDataList.AddRange (timeEntryGroup);

            projectData = await UpdateProject (timeEntryData, ProjectData);
            clientData = await UpdateClient (projectData, ClientData);
            taskData = await UpdateTask (timeEntryData, TaskData);
            numberOfTags = await GetNumberOfTagsAsync (timeEntryData.Id);
        }
示例#12
0
        public async Task LoadAsync ()
        {
            numberOfTags = 0;

            if (timeEntryData.ProjectId.HasValue) {
                projectData = await GetProjectDataAsync (timeEntryData.ProjectId.Value);
                if (projectData.ClientId.HasValue) {
                    clientData = await GetClientDataAsync (projectData.ClientId.Value);
                }
            }

            if (timeEntryData.TaskId.HasValue) {
                taskData = await GetTaskDataAsync (timeEntryData.TaskId.Value);
            }
            numberOfTags = await GetNumberOfTagsAsync (timeEntryData.Id);
        }