Get Upcoming Project Task Using CSOM in Project Server 2013

Upcoming Project Task Using CSOM:-

Get Upcoming Project Task Using CSOM in Project Server 2013. In this post, I will describe for you how to get Upcoming Project Task Using CSOM.The upcoming task is those task which will start in next 7 days or more.Means the task has been assigned but not start. Below is code to get Upcoming Project Task Using CSOM

[AdSense-A]

string PWAPath = "pwa path";
string UserName = "user name";
string PassWord = "password";
SecureString SecureStringPassword = new SecureString();
using (ProjectContext ProjectContext = new ProjectContext(PWAPath))
{
foreach (char Char in PassWord.ToCharArray()) SecureStringPassword.AppendChar(Char);
ProjectContext.Credentials = new SharePointOnlineCredentials(UserName, SecureStringPassword);
ProjectContext.Load(ProjectContext.Projects,
Pro => Pro.IncludeWithDefaultProperties(projectDetail => projectDetail.StartDate, projectDetail => projectDetail.FinishDate, projectDetail => projectDetail.Tasks, projectDetail => projectDetail.PercentComplete, projectDetail => projectDetail.ProjectResources, projectDetail => projectDetail.CustomFields, projectDetail => projectDetail.EnterpriseProjectType));
ProjectContext.ExecuteQuery();
foreach (PublishedProject Project in ProjectContext.Projects)
{
foreach (var Multask in Project.Tasks)
{
var current = DateTime.Now.Date;
var previous = Convert.ToDateTime(Multask.Start).Date;

if (previous > current)
{
Console.WriteLine(Project.Name); Console.WriteLine(Multask.Name); Console.WriteLine(Multask.Start);
Console.WriteLine(Multask.Finish);
Console.WriteLine(Multask.PercentComplete);
}
}
}
}

 


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

error: Content is protected !!