Advertisement
souldown

add a stop watch

Jul 10th, 2014
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.41 KB | None | 0 0
  1.  
  2.         /// <summary>
  3.         /// will assign a stopwatch to a task.... returns The result
  4.         /// </summary>
  5.         /// <param name="clarizen"></param>
  6.         /// <param name="User"></param>
  7.         /// <param name="Task"></param>
  8.         /// <returns></returns>
  9.         public static Result addStopWatchToTask(Clarizen clarizen, String UserId, Task Task)
  10.         {
  11.             //task entity
  12.             GenericEntity task = new GenericEntity();
  13.             task.Id = new EntityId() { TypeName = "Task", Value = Task.Id };
  14.  
  15.             //stopwatch entity link
  16.             GenericEntity link = new GenericEntity();
  17.             link.Id = new EntityId() { TypeName = "Stopwatch" };
  18.  
  19.             //get the work item field in the task item
  20.             FieldValue workItemField = new FieldValue() { FieldName = "WorkItem", Value = task.Id };
  21.  
  22.             //add user to the rescource field (stop watch rescource is called user)
  23.             FieldValue stopWatchField = new FieldValue() { FieldName = "User", Value = new EntityId() { TypeName = "User", Value = UserId } };
  24.             //link that shit
  25.             link.Values = new FieldValue[] { workItemField, stopWatchField };
  26.             CreateMessage createCustomerLinkMessage = new CreateMessage() { Entity = link };
  27.             Result[] result = clarizen.Execute(new BaseMessage[] { createCustomerLinkMessage });
  28.  
  29.             return result[0];
  30.  
  31.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement