Task and Assignments

E

Esfer

Hi!!

I'm trying to improve a little application to show resource's assignments
for current TimeSheet.

Now I can show each project and every task on it but I can't know the real
"task tree" (their parents, grandparents... etc) and I have to show all of
them at the same level (every task is son of the project...).

For example if I have this project with these tasks:

-Test Project
--Public
---Main Page
---Info Page
--Private
---Admin Page
---Info Page
---Admin Forum

When I show this I just can take:
-Test Project
--Main Page
--Info Page
--Admin Page
--Info Page
--Admin Forum

So I'm loosing that tree...

I'm getting data from TimeSheet through PSI and I can take TaskUID so I
expected to complete the tree by myself getting all data from Project (with
ReadProject() I can take TaskParentUID and every "level" data is accesible).

My problem is that some TimeSheet TaskUID seems to be different than Project
TaskUID :-( (and they are the same Task, same name, same project...).

Does anybody know how to make it work? Is there any relation between those
TaskUID (I think they should be the same :-S). Should I take this data other
way?

Thanks in advance!! ;-)
 
E

Esfer

To load current resource timesheet tasks I use this:


-------------------------------------
List<Task> tasks = new List<Task>();

HashSet<Guid> tasksUID = new HashSet<Guid>();

TimesheetDataSet taskData =
projectServerTimeSheet.GetCurrentTimeSheet(user.ProjectServerGUID,
DateTime.Today.Date);
// This takes data with:
// timeSheetWS.ReadTimesheet(timeSheetID);
// after find the current time sheet ID

for (int i = 0; i < taskData.Tables["Lines"].Rows.Count; i++)
{
DataRow row = taskData.Tables["Lines"].Rows;
ProjectControl2.Data.ProjectControl.Task.Task task = new
ServerTask(this);
task.ProjectServerAssignationGuid = (Guid)row["ASSN_UID"];
task.ProjectServerTaskGuid = (Guid)row["TASK_UID"];
task.ProjectServerProjectGuid = (Guid)row["PROJ_UID"];
task.Name = row["TS_LINE_CACHED_ASSIGN_NAME"].ToString();

if ((!tasksUID.Contains(task.ProjectServerTaskGuid)) &&
((Guid)row["PROJ_UID"] == project.ProjectServerGuid))
{
tasksUID.Add(task.ProjectServerTaskGuid);
tasks.Add(task);
}
}

return tasks;

-------------------------------------

After this I try to get more data for each task with something like this:

-------------------------------------

List<Task> leveledTask = new List<Task>();
DataTable tasks = projectServerProject.GetTasks(projectUID);
//this is getting data via
// this.project = projectWS.ReadProject(idProject,
WebProject.DataStoreEnum.PublishedStore);

foreach (DataRow task in tasks.Rows)
{
Task newTask = new ServerTask(this);

newTask.Name = task["TASK_NAME"].ToString();
newTask.ProjectServerTaskGuid = (Guid)task["TASK_UID"];
newTask.ParentGuid = (Guid)task["TASK_PARENT_UID"];
newTask.ProjectServerProjectGuid = (Guid)task["PROJ_UID"];

leveledTask.Add(newTask);
}
return leveledTask;

-------------------------------------

Once I have the first list (tasks I want to show) and the second list (more
task data, every level task, parent UID...) I try to mix them.

Here is where I find the problem but only with several tasks. When I search
TaskUID in the "detailed list" for each task... sometimes there is no
coincidence between TaskUID in each list (the task exist in both lists but
TaskUID doesn't match :-()

-------------------------------------
foreach (Task task in tasks)
{
IEnumerable<Task> sameTask = from sameTasks in leveledTasks
where
sameTasks.ProjectServerTaskGuid == task.ProjectServerTaskGuid
select sameTasks;

if (sameTask.Count<Task>() > 0)
{
task.ParentGuid = sameTask.ElementAt<Task>(0).ParentGuid;
}
}
 
S

Stephen Sanderlin

Can you check whether TS_LINE_VALIDATION_TYPE = 1 on the mismatched
lines?



Also, you should really be using the strongly-typed DataRow objects
(e.g. TimesheetDataSet.LinesRow and ProjectDataSet.TaskRow) instead of
generic DataRow objects.


--

Stephen Sanderlin

Principal Consultant

MSProjectExperts



For Project Server Consulting: http://www.msprojectexperts.com

For Project Server Training: http://www.projectservertraining.com



Read my blog at: http://www.projectserverhelp.com/

Join the community at: http://forums.epmfaq.com





To load current resource timesheet tasks I use this:


-------------------------------------
List<Task> tasks = new List<Task>();

HashSet<Guid> tasksUID = new HashSet<Guid>();

TimesheetDataSet taskData =
projectServerTimeSheet.GetCurrentTimeSheet(user.ProjectServerGUID,
DateTime.Today.Date);
// This takes data with:
// timeSheetWS.ReadTimesheet(timeSheetID);
// after find the current time sheet ID

for (int i = 0; i < taskData.Tables["Lines"].Rows.Count; i++)
{
DataRow row = taskData.Tables["Lines"].Rows;
ProjectControl2.Data.ProjectControl.Task.Task task = new
ServerTask(this);
task.ProjectServerAssignationGuid = (Guid)row["ASSN_UID"];
task.ProjectServerTaskGuid = (Guid)row["TASK_UID"];
task.ProjectServerProjectGuid = (Guid)row["PROJ_UID"];
task.Name = row["TS_LINE_CACHED_ASSIGN_NAME"].ToString();

if ((!tasksUID.Contains(task.ProjectServerTaskGuid)) &&
((Guid)row["PROJ_UID"] == project.ProjectServerGuid))
{
tasksUID.Add(task.ProjectServerTaskGuid);
tasks.Add(task);
}
}

return tasks;

-------------------------------------

After this I try to get more data for each task with something like this:

-------------------------------------

List<Task> leveledTask = new List<Task>();
DataTable tasks = projectServerProject.GetTasks(projectUID);
//this is getting data via
// this.project = projectWS.ReadProject(idProject,
WebProject.DataStoreEnum.PublishedStore);

foreach (DataRow task in tasks.Rows)
{
Task newTask = new ServerTask(this);

newTask.Name = task["TASK_NAME"].ToString();
newTask.ProjectServerTaskGuid = (Guid)task["TASK_UID"];
newTask.ParentGuid = (Guid)task["TASK_PARENT_UID"];
newTask.ProjectServerProjectGuid = (Guid)task["PROJ_UID"];

leveledTask.Add(newTask);
}
return leveledTask;

-------------------------------------

Once I have the first list (tasks I want to show) and the second list (more
task data, every level task, parent UID...) I try to mix them.

Here is where I find the problem but only with several tasks. When I search
TaskUID in the "detailed list" for each task... sometimes there is no
coincidence between TaskUID in each list (the task exist in both lists but
TaskUID doesn't match :-()

-------------------------------------
foreach (Task task in tasks)
{
IEnumerable<Task> sameTask = from sameTasks in leveledTasks
where
sameTasks.ProjectServerTaskGuid == task.ProjectServerTaskGuid
select sameTasks;

if (sameTask.Count<Task>() > 0)
{
task.ParentGuid = sameTask.ElementAt<Task>(0).ParentGuid;
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top