Exemplo n.º 1
0
        private void LoadTasksFromCategory(IceCategory category)
        {
            TaskEntry [] taskEntries = null;
            try {
                taskEntries = deskIceDaemon.GetTaskEntries(category.Folder.ID);
            } catch (Exception e) {
                Logger.Warn("Exception loading tasks from category: {0}", e.Message);
                return;
            }

            foreach (TaskEntry entry in taskEntries)
            {
                IceTask      task = new IceTask(this, category, entry);
                Gtk.TreeIter iter;
                if (taskIters.ContainsKey(task.Id))
                {
                    iter = taskIters [task.Id];
                }
                else
                {
                    iter = tasks.Append();
                    taskIters [task.Id] = iter;
                }

                tasks.SetValue(iter, 0, task);
            }
        }
Exemplo n.º 2
0
        public IceTask(IceBackend iceBackend,
                       IceCategory iceCategory,
                       TaskEntry taskEntry)
        {
            this.backend  = iceBackend;
            this.category = iceCategory;
            this.entry    = taskEntry;
            if (entry.Status == TaskStatus.Completed)
            {
                this.state = TaskState.Completed;
            }
            else if (entry.Status == TaskStatus.Cancelled)
            {
                this.state = TaskState.Inactive;                 // TODO: Is this the right thing to do?
            }
            else
            {
                this.state = TaskState.Active;
            }

            // Construct a unique id in the format of
            // <team-id>-<team-folder-id>-<task-entry-id>
            id = string.Format("{0}-{1}-{2}",
                               iceCategory.Team.ID,
                               iceCategory.Folder.ID,
                               taskEntry.ID);
        }
Exemplo n.º 3
0
        public bool ContainsTask(ITask task)
        {
            if (task == null)
            {
                return(false);
            }

            IceCategory iceCategory = task.Category as IceCategory;

            if (iceCategory == null)
            {
                return(false);
            }

            if (Id.CompareTo(iceCategory.Id) == 0)
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 4
0
        public void SaveAndUpdateTask(IceTask task)
        {
            // Send new values to the server and then update the task in the
            // TreeModel.

            try {
                IceCategory iceCategory = task.Category as IceCategory;
                deskIceDaemon.UpdateTask(iceCategory.Folder.ID,
                                         task.Entry.ID,
                                         task.Name,
                                         task.Entry.Description,
                                         task.IceDesktopStatus,
                                         int.Parse(task.Entry.Priority),
                                         int.Parse(task.Entry.PercentComplete),
                                         task.DueDateString);
            } catch (Exception e) {
                Logger.Warn("Error calling deskIceDaemon.UpdateTask: {0}",
                            e.Message);
                return;
            }

            UpdateTask(task);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Create a new task.
        /// </summary>
        public ITask CreateTask(string taskName, ICategory category)
        {
            IceTask     task        = null;
            IceCategory iceCategory = category as IceCategory;

            if (taskName == null || taskName.Trim() == string.Empty ||
                category == null)
            {
                Logger.Warn("Cannot call IceBackend.CreateTask () with null/empty arguments.");
                return(null);
            }

            string taskId = null;

            try {
                taskId =
                    deskIceDaemon.CreateTask(iceCategory.Folder.ID,
                                             taskName,
                                             string.Empty,                                      // description
                                             5,                                                 // Lowest Priority/None
                                             TaskStatus.NeedsAction,
                                             string.Empty,                                      // start date
                                             string.Empty);                                     // due date
            } catch (Exception e) {
                Logger.Error("Exception calling deskIceDaemon.CreateTask (): {0}", e.Message);
                return(null);
            }

            TaskEntry taskEntry = new TaskEntry(taskId, taskName);

            task = new IceTask(this, iceCategory, taskEntry);

            UpdateTask(task);

            return(task);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Refreshes the backend.
        /// </summary>
        public void Refresh()
        {
            // TODO: Eventually don't clear out existing entries, but match up
            // the updates
//			categories.Clear ();

            // TODO: Eventually don't clear out existing tasks, but match them
            // up with the updates
//			tasks.Clear ();

            Teamspace [] teams = null;
            try {
                teams = deskIceDaemon.GetTeamList();
            } catch {
                Logger.Warn("Exception thrown getting team list");
                return;
            }

            foreach (Teamspace team in teams)
            {
                Logger.Debug("Team Found: {0} ({1})", team.Name, team.ID);

                // Check to see if the team has tasks enabled
                TaskFolder [] taskFolders = null;
                try {
                    taskFolders = deskIceDaemon.GetTaskFolders(team.ID);
                } catch {
                    Logger.Warn("Exception thrown getting task folders");
                    return;
                }

                foreach (TaskFolder taskFolder in taskFolders)
                {
                    // Create an IceCategory for each folder
                    IceCategory  category = new IceCategory(team, taskFolder);
                    Gtk.TreeIter iter;
                    if (categoryIters.ContainsKey(category.Id))
                    {
                        iter = categoryIters [category.Id];
                    }
                    else
                    {
                        iter = categories.Append();
                        categoryIters [category.Id] = iter;
                    }

                    categories.SetValue(iter, 0, category);

                    LoadTasksFromCategory(category);
                }
            }

            // TODO: Wrap this in a try/catch
            if (BackendSyncFinished != null)
            {
                try {
                    BackendSyncFinished();
                } catch (Exception e) {
                    Logger.Warn("Error calling BackendSyncFinished handler: {0}", e.Message);
                }
            }
        }