protected override void Execute(CodeActivityContext context) { // Get the connection string DBConnection ext = context.GetExtension <DBConnection>(); if (ext == null) { throw new InvalidProgramException("No connection string available"); } // Lookup the QueueInstance UserTasksDataContext dc = new UserTasksDataContext(ext.ConnectionString); dc.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues, dc.QueueInstances); QueueInstance qi = dc.QueueInstances.SingleOrDefault(x => x.QueueInstanceKey == QueueInstanceKey.Get(context)); if (qi == null) { throw new InvalidProgramException("The specified request (" + QueueInstanceKey.Get(context) + ") was not found"); } if (qi.AssignedOperatorID != null) { qi.AssignedOperatorID = null; qi.AssignedDate = null; // Update the QueueInstance record PersistQueueInstance persist = context.GetExtension <PersistQueueInstance>(); persist.AddQueueInstance(qi); } // Add a custom track record CustomTrackingRecord userRecord = new CustomTrackingRecord("UnAssign") { Data = { { "QueueInstanceKey", qi.QueueInstanceKey }, { "SubQueueID", qi.CurrentSubQueueID }, { "QC", qi.QC } } }; // Emit the custom tracking record context.Track(userRecord); }
protected override void Execute(CodeActivityContext context) { // Get the connection string DBConnection ext = context.GetExtension <DBConnection>(); if (ext == null) { throw new InvalidProgramException("No connection string available"); } // Lookup the Queue UserTasksDataContext dc = new UserTasksDataContext(ext.ConnectionString); Queue q = dc.Queues.SingleOrDefault(x => x.QueueName == QueueName.Get(context)); if (q == null) { throw new InvalidProgramException("The specified queue (" + QueueName.Get(context) + ") was not found"); } SubQueue s = dc.SubQueues .SingleOrDefault(x => x.QueueID == q.QueueID && x.SubQueueName == SubQueueName.Get(context)); if (s == null) { throw new InvalidProgramException("The specified sub-queue (" + SubQueueName.Get(context) + ") was not found"); } // Create and initialize a QueueInstance object QueueInstance qi = new QueueInstance(); qi.QueueInstanceKey = Guid.NewGuid(); qi.CurrentSubQueueID = s.SubQueueID; qi.CreateDate = DateTime.UtcNow; qi.InstanceID = context.WorkflowInstanceId; // Setup the initial values qi.AssignedDate = null; qi.AssignedOperatorID = null; qi.QC = false; qi.Priority = null; // Insert the Request record PersistQueueInstance persist = context.GetExtension <PersistQueueInstance>(); persist.AddQueueInstance(qi); // Return the QueueInstance object QueueInstanceKey.Set(context, qi.QueueInstanceKey); CustomTrackingRecord userRecord = new CustomTrackingRecord("Start") { Data = { { "QueueInstanceKey", qi.QueueInstanceKey }, { "SubQueueID", qi.CurrentSubQueueID } } }; // Emit the custom tracking record context.Track(userRecord); }
protected override void Execute(CodeActivityContext context) { // Get the connection string DBConnection ext = context.GetExtension <DBConnection>(); if (ext == null) { throw new InvalidProgramException("No connection string available"); } UserTasksDataContext dc = new UserTasksDataContext(ext.ConnectionString); Queue q = null; SubQueue sq = null; int queueID = 0; int subQueueID = 0; if (QueueName.Get(context) != "" && SubQueueName.Get(context) != "None") { // Lookup the queue and subqueue q = dc.Queues.SingleOrDefault(x => x.QueueName == QueueName.Get(context)); if (q == null) { throw new InvalidProgramException("The specified queue (" + QueueName.Get(context) + ") was not found"); } sq = dc.SubQueues.SingleOrDefault(x => x.QueueID == q.QueueID && x.SubQueueName == SubQueueName.Get(context)); if (sq == null) { throw new InvalidProgramException("The specified subqueue (" + QueueName.Get(context) + " - " + SubQueueName.Get(context) + ") was not found"); } queueID = q.QueueID; subQueueID = sq.SubQueueID; } // Lookup the QueueInstance dc.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues, dc.QueueInstances); QueueInstance qi = dc.QueueInstances.SingleOrDefault(x => x.QueueInstanceKey == QueueInstanceKey.Get(context)); if (qi == null) { throw new InvalidProgramException("The specified request (" + QueueInstanceKey.Get(context) + ") was not found"); } // Assign the QueueInstance to this subqueue if (sq != null) { qi.CurrentSubQueueID = sq.SubQueueID; } else { qi.CurrentSubQueueID = null; } qi.AssignedDate = null; qi.AssignedOperatorID = null; qi.QC = false; qi.Priority = null; // Update the QueueInstance record PersistQueueInstance persist = context.GetExtension <PersistQueueInstance>(); persist.AddQueueInstance(qi); // Add a custom track record CustomTrackingRecord userRecord = new CustomTrackingRecord("Route") { Data = { { "QueueInstanceKey", qi.QueueInstanceKey }, { "SubQueueID", qi.CurrentSubQueueID } } }; // Emit the custom tracking record context.Track(userRecord); }