Пример #1
0
 /// <summary>
 /// Add a new sync command to the queue for processing.
 /// </summary>
 /// <param name="sessionGroupId">The GUID that's used as the unique Id of the subject session group.</param>
 /// <param name="newCmd">The new command to be appended to the queue.</param>
 public void AddCommand(Guid sessionGroupId, PipelineSyncCommand newCmd)
 {
     using (RuntimeEntityModel context = RuntimeEntityModel.CreateInstance())
     {
         var sessionGroupQuery =
             from sg in context.RTSessionGroupSet
             where sg.GroupUniqueId.Equals(sessionGroupId)
             select sg;
         Debug.Assert(sessionGroupQuery.Count() == 1, "sessionGroupQuery.Count() != 1");
         if (sessionGroupQuery.Count() != 1)
         {
             // [teyang] TODO add exception desc
             throw new InvalidOperationException();
         }
         var rtSessionGroup             = sessionGroupQuery.First();
         RTOrchestrationCommand command = RTOrchestrationCommand.CreateRTOrchestrationCommand(
             0,                                 // identity column id is auto-generated
             (int)newCmd,
             (int)PipelineSyncCommandState.New);
         command.SessionGroup = rtSessionGroup;
         context.AddToRTOrchestrationCommandSet(command);
         context.TrySaveChanges();
     }
 }