souldown

Clarizen submit time sheet

Jul 18th, 2014
370
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.25 KB | None | 0 0
  1. public static Result SubmitTimeSheet(TimeSheet ts, Clarizen clarizen)
  2.         {
  3.             Result result = null;
  4.  
  5.             GenericEntity timeSheet = new GenericEntity();
  6.             timeSheet.Id = new EntityId { TypeName = "Timesheet" };
  7.             timeSheet.Values = new FieldValue[]{
  8.             new FieldValue {FieldName = "WorkItem", Value = ts.stopwatch.workItem.Id},
  9.             new FieldValue {FieldName = "ReportedBy", Value = ts.stopwatch.rescource.Id},
  10.             new FieldValue {FieldName = "ReportedDate", Value = DateTime.Now},
  11.             new FieldValue {FieldName = "Comment", Value = ts.notes},
  12.             new FieldValue {FieldName = "Duration", Value = new Duration{Value = ts.time, Unit = DurationUnit.Days}}};
  13.          
  14.  
  15.  
  16.  
  17.             CreateMessage timesheetMessage = new CreateMessage();
  18.             timesheetMessage.Entity = timeSheet;
  19.            
  20.             result = clarizen.Execute(new BaseMessage[] { timesheetMessage })[0];
  21.  
  22.             if (result.Success)
  23.                 Console.WriteLine("Stopwatch marked complete!! " + result.Success.ToString());
  24.            
  25.             else
  26.                 Console.WriteLine("Stopwatch " + result.Error.Message.ToString());
  27.            
  28.             return result;
  29.  
  30.         }
Advertisement
Add Comment
Please, Sign In to add comment