Exemple #1
0
        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);
        }
Exemple #2
0
        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);

            // 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");
            }

            QueueInstance.Set(context, qi);
            ConnectionString.Set(context, ext.ConnectionString);
        }
Exemple #3
0
        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);
        }
Exemple #4
0
        protected override void CollectValues
            (out IDictionary <XName, object> readWriteValues,
            out IDictionary <XName, object> writeOnlyValues)
        {
            // We're not actually providing data to the caller
            readWriteValues = null;
            writeOnlyValues = null;

            //_actions.Clear();

            // See if there is any work to do...
            if (_actions.Count > 0)
            {
                // Get the current transaction
                Transaction t = System.Transactions.Transaction.Current;

                // Setup the DataContext
                UserTasksDataContext dc = new UserTasksDataContext(_connectionString);

                // Open the connection, if necessary
                if (dc.Connection.State == System.Data.ConnectionState.Closed)
                {
                    dc.Connection.Open();
                }

                if (t != null)
                {
                    dc.Connection.EnlistTransaction(t);
                }

                // Process each object in our work queue
                foreach (KeyValuePair <string, QueueInstance> kvp in _actions)
                {
                    QueueInstance qi = kvp.Value as QueueInstance;

                    // Perform the insert
                    if (kvp.Key == "")
                    {
                        dc.QueueInstances.InsertOnSubmit(qi);
                    }

                    // Perform the update
                    else
                    {
                        dc.Refresh(RefreshMode.OverwriteCurrentValues, dc.QueueInstances);
                        QueueInstance qiTmp = dc.QueueInstances.SingleOrDefault <QueueInstance>
                                                  (x => x.QueueInstanceID == qi.QueueInstanceID);

                        if (qiTmp != null)
                        {
                            qiTmp.InstanceID         = qi.InstanceID;
                            qiTmp.AssignedDate       = qi.AssignedDate;
                            qiTmp.AssignedOperatorID = qi.AssignedOperatorID;
                            qiTmp.CurrentSubQueueID  = qi.CurrentSubQueueID;
                            qiTmp.QC = qi.QC;
                        }
                    }
                }

                // Submit all the changes to the database
                dc.SubmitChanges();

                // Remove all objects since the changes have been submitted
                _actions.Clear();
            }
        }