Esempio n. 1
0
        private void _SyncTaskSeries(Project localProject, TaskSeries localTaskSeries, TaskSeries serverTaskSeries)
        {
            // Update if newer.
            if (localTaskSeries.Modified < serverTaskSeries.Modified)
            {
                localTaskSeries.Created = serverTaskSeries.Created;
                localTaskSeries.Modified = serverTaskSeries.Modified;
                localTaskSeries.Name = serverTaskSeries.Name;
                localTaskSeries.Project = localProject;

                if (serverTaskSeries.RepeatRule != null)
                    localTaskSeries.RepeatRule = mainDB.RepeatRules.Where(rr => rr.Rule == serverTaskSeries.RepeatRule.Rule).FirstOrDefault() ?? serverTaskSeries.RepeatRule;

                localTaskSeries.Source = serverTaskSeries.Source;
                localTaskSeries.Tags = serverTaskSeries.Tags;
                localTaskSeries.Url = serverTaskSeries.Url;

                foreach (Task serverTask in serverTaskSeries.Tasks)
                {
                    var localTask = localTaskSeries.Tasks.Where(tt => tt.Id == serverTask.Id).FirstOrDefault();

                    if (localTask == null)
                        localTaskSeries.Tasks.Add(serverTask);
                    else
                        _SyncTask(localTask, serverTask);
                }
            }
        }
Esempio n. 2
0
        // Add a task series to the database and collections.
        public void AddTaskSeries(TaskSeries newTaskSeries)
        {
            // Add a project to the data context.
            mainDB.TaskSeries.InsertOnSubmit(newTaskSeries);

            // Save changes to the database.
            mainDB.SubmitChanges();

            // Add a project to the "all" observable collection.
            newTaskSeries.Tasks.ToList().ForEach(t => AllTasks.Add(t));
        }