Get Project Plan using CSOM in Project Online

Get Project Plan using CSOM in Project Server 2013:-

Get Project Plan using CSOM in Project Online. In this post, you will learn to Get Project Plan using CSOM in Project Online. Project plan basically we are talking about the projects on a project web application. On a project web app, we can create multiple projects. In this post, we are talking about all properties of Project like project Start Date, Finish Date, Task Name, Resource Name, Project Percentage Complete etc.

Below is code to Get Project Plan using CSOM:-[AdSense-A]

public class ProjectScheduleList
        public string ProjectUID { get; set; }  
        public string ProjectName { get; set; }       
        public string TaskName { get; set; }        
        public DateTime ActualStartDate { get; set; }       
        public DateTime ActualFinishDate { get; set; }        
        public string ResourceName { get; set; }       
        public string PercentComplete { get; set; }
public List ProjectSchedule()
            List ListProjectSchedule = new List();
            string sitename = "PWAurl";
            string usename = "UserName";
            string password = "Password"
            using (ProjectContext cc = new ProjectContext(sitename))
                SecureString passWord2 = new SecureString();
                foreach (char c in password.ToCharArray()) passWord2.AppendChar(c);
                cc.Credentials = new SharePointOnlineCredentials(usename, passWord2);
                 c => c.IncludeWithDefaultProperties(pr => pr.StartDate,pr=>pr.Id, pr => pr.ProjectResources, pr => pr.Assignments, pr => pr.FinishDate, pr => pr.Owner.LoginName, pr => pr.Tasks, pr => pr.ProjectSiteUrl, pr => pr.PercentComplete, pr => pr.ProjectResources, pr => pr.CustomFields, pr => pr.EnterpriseProjectType));
                cc.LoadQuery(cc.Projects.Where(pr => pr.Id == new Guid(ProjSchedule[0].ProjectUID)));
                foreach (PublishedProject pubProj in cc.Projects)
                    string Proj = pubProj.Name;

                    foreach (var task in pubProj.Tasks)
                        cc.Load(task.Assignments, C => C.IncludeWithDefaultProperties(PR => PR.Resource.Name));

                        foreach (var Ass in task.Assignments)
                            ProjectScheduleList BOProjectSchedule = new ProjectScheduleList();
                            BOProjectSchedule.ProjectName = pubProj.Name;
                            BOProjectSchedule.TaskName = task.Name;
                            BOProjectSchedule.PercentComplete = Convert.ToString(task.PercentComplete);
                            BOProjectSchedule.ActualStartDate = task.ActualStart;
                            BOProjectSchedule.ActualFinishDate = task.ActualFinish;
                            BOProjectSchedule.ResourceName = Ass.Resource.Name;



            return ListProjectSchedule;


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 !!