Ejemplo n.º 1
0
        public static Task createNewTask(Task parent, TaskCollection taskCollection)
        {
            Task newTask = null;

            foreach (Task subtask in parent.Leaves)
            {
                if (subtask.Name.Equals(taskCollection.status))
                {
                    newTask = subtask;
                }
            }
            if (newTask == null && taskCollection.taskHeaders.Count > 0)
            {
                SprintSearchCollection searchResult = findSprintTaskID(parent);
                newTask = CreateTask(parent, parent.Project.UniqueID, taskCollection.status, searchResult);
                if (newTask == null)
                {
                    return(null);
                }
            }

            if (taskCollection.taskHeaders.Count > 0)
            {
                if (!newTask.GetCustomColumnValue("Item count").Equals(taskCollection.taskHeaders.Count.ToString()))
                {
                    newTask.SetCustomColumnValue("Item count", taskCollection.taskHeaders.Count.ToString());
                }

                if (parent.Points > 0)
                {
                    parent.Points = 0;
                }
                if (newTask.Points != taskCollection.totalPoints)
                {
                    newTask.Points        = taskCollection.totalPoints;
                    newTask.WorkRemaining = taskCollection.totalPoints - taskCollection.completedPoints;
                }
                if (!newTask.Status.Text.Equals(taskCollection.status))
                {
                    newTask.Status = HansoftEnumValue.FromString(parent.ProjectID, EHPMProjectDefaultColumn.ItemStatus, taskCollection.status);
                    try
                    {
                        SessionManager.Session.TaskSetCompleted(newTask.UniqueTaskID, taskCollection.status.Equals("Completed"), true);
                    }
                    catch (Exception)
                    {
                    }
                }
            }
            else if (newTask != null)
            {
                try
                {
                    SessionManager.Session.TaskDelete(newTask.UniqueTaskID);
                }
                catch (Exception)
                {
                }
            }

            return(newTask);
        }
        public static Task createNewTask(Task parent, TaskCollection taskCollection)
        {
            Task newTask = null;

            foreach (Task subtask in parent.Leaves)
            {
                if (subtask.Name.Equals(taskCollection.status))
                {
                    newTask = subtask;
                }
            }
            if (newTask == null && taskCollection.taskHeaders.Count > 0)
            {
                SprintSearchCollection searchResult = findSprintTaskID(parent);
                newTask = CreateTask(parent, parent.Project.UniqueID, taskCollection.status, searchResult);
                if (newTask == null)
                {
                    return null;
                }
            }

            if (taskCollection.taskHeaders.Count > 0)
            {
                if (!newTask.GetCustomColumnValue("Item count").Equals(taskCollection.taskHeaders.Count.ToString()))
                {
                    newTask.SetCustomColumnValue("Item count", taskCollection.taskHeaders.Count.ToString());
                }

                if (parent.Points > 0)
                {
                    parent.Points = 0;
                }
                if (newTask.Points != taskCollection.totalPoints)
                {
                    newTask.Points = taskCollection.totalPoints;
                    newTask.WorkRemaining = taskCollection.totalPoints - taskCollection.completedPoints;
                }
                if (!newTask.Status.Text.Equals(taskCollection.status))
                {
                    newTask.Status = HansoftEnumValue.FromString(parent.ProjectID, EHPMProjectDefaultColumn.ItemStatus, taskCollection.status);
                    try
                    {
                        SessionManager.Session.TaskSetCompleted(newTask.UniqueTaskID, taskCollection.status.Equals("Completed"), true);
                    }
                    catch (Exception)
                    {

                    }
                }
            }
            else if (newTask != null)
            {
                try
                {
                    SessionManager.Session.TaskDelete(newTask.UniqueTaskID);
                }
                catch (Exception)
                {
                }
            }

            return newTask;
        }