I have created a simple console C# application that retrieves TimeSheets of the admin user used in the Sharepoint athentification, but what i want to do is to retrieve all users TimeSheets for a certain period (TimeSheetPeriods), any ideas about how you can do this? any sample code?
here is my code may be i forgot something :
- cntx.Load(cntx.Projects);
- cntx.ExecuteQuery();
- cntx.Load(cntx.TimeSheetPeriods, c => c.Where(p => p.Start <= DateTime.Now && p.End <= DateTime.Now).
- IncludeWithDefaultProperties(p => p.TimeSheet,
- p => p.TimeSheet.Lines.Where(l => l.LineClass == TimeSheetLineClass.StandardLine).
- IncludeWithDefaultProperties(l => l.Assignment,
- l => l.Assignment.Task,
- l => l.Work)));
-
-
- cntx.ExecuteQuery();
- var myPeriod = cntx.TimeSheetPeriods.LastOrDefault();
- if (myPeriod == null)
- throw new Exception("Please create the periods in your server settings");
-
-
- foreach (var line in myPeriod.TimeSheet.Lines)
- {
- Console.WriteLine("ProjectName : "+line.ProjectName);
- Console.WriteLine("TaskName : " + line.TaskName);
-
- foreach (var work in line.Work)
- {
- Console.WriteLine("PlannedWork----->" + work.PlannedWork);
-
- Console.WriteLine("ActualWork----->" + work.ActualWork);
-
- Console.WriteLine("StartDate----->" + work.Start);
-
- Console.WriteLine("TaskComment----->" + work.Comment);
-
- }
-
- }