Esempio n. 1
0
        protected override void Execute(CodeActivityContext context)
        {
            // Open the config file and get the connection string
            Configuration            config = WebConfigurationManager.OpenWebConfiguration("/RequestWeb");
            ConnectionStringsSection css    =
                (ConnectionStringsSection)config.GetSection("connectionStrings");
            string connectionString = css.ConnectionStrings["Request"].ConnectionString;

            // Lookup the Request
            RequestDataContext dc = new RequestDataContext(connectionString);
            Request            r  = dc.Requests.SingleOrDefault(x => x.RequestKey == RequestKey.Get(context));

            if (r == null)
            {
                throw new InvalidProgramException("The specified request (" + RequestKey.Get(context) + ") was not found");
            }

            r.QC               = true;
            r.AssignedDate     = DateTime.UtcNow;
            r.AssignedOperator = null;

            // Update the Request record
            PersistRequest persist = context.GetExtension <PersistRequest>();

            persist.AddRequest(r);
        }
Esempio n. 2
0
        protected override void Execute(CodeActivityContext context)
        {
            // Open the config file and get the connection string
            Configuration            config = WebConfigurationManager.OpenWebConfiguration("/RequestWeb");
            ConnectionStringsSection css    =
                (ConnectionStringsSection)config.GetSection("connectionStrings");
            string connectionString = css.ConnectionStrings["Request"].ConnectionString;

            // Lookup the Queue
            RequestDataContext dc = new RequestDataContext(connectionString);
            Queue  q     = null;
            string queue = QueueName.Get(context);

            if (queue != null && queue.Length > 0 && queue != "None")
            {
                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");
                }
            }

            // Lookup the Request
            Request r = dc.Requests.SingleOrDefault(x => x.RequestKey == RequestKey.Get(context));

            if (r == null)
            {
                throw new InvalidProgramException("The specified request (" + RequestKey.Get(context) + ") was not found");
            }

            if (q != null)
            {
                r.CurrentQueueID   = q.QueueID;
                r.AssignedDate     = DateTime.UtcNow;
                r.AssignedOperator = null;
            }
            else
            {
                r.CurrentQueueID   = null;
                r.AssignedDate     = null;
                r.AssignedOperator = null;
            }

            // Update the Request record
            PersistRequest persist = context.GetExtension <PersistRequest>();

            persist.AddRequest(r);
        }
Esempio n. 3
0
        // If your activity returns a value, derive from CodeActivity<TResult>
        // and return the value from the Execute method.
        protected override void Execute(CodeActivityContext context)
        {
            // Open the config file and get the connection string
            Configuration            config = WebConfigurationManager.OpenWebConfiguration("/RequestWeb");
            ConnectionStringsSection css    =
                (ConnectionStringsSection)config.GetSection("connectionStrings");
            string connectionString = css.ConnectionStrings["Request"].ConnectionString;

            // Lookup the Queue
            RequestDataContext dc = new RequestDataContext(connectionString);

            var q = dc.Requests.Where(x => x.CurrentQueueID != null)
                    .GroupBy(x => x.Queue.QueueName + "|" + x.QC.ToString());

            // Build the result array
            if (q.Count() > 0)
            {
                QueueDetail[] queueStats = new QueueDetail[q.Count()];
                int           i          = 0;
                foreach (var group in q)
                {
                    // Split the key into the queue name and QC value
                    string   s         = group.Key;
                    char[]   delimiter = { '|' };
                    string[] values    = s.Split(delimiter, 2);

                    // Add a new queue to the stats array
                    QueueDetail det = new QueueDetail();
                    det.Key         = group.Key;
                    det.QueueName   = values[0];
                    det.QC          = bool.Parse(values[1]);
                    det.Count       = group.Count();
                    det.Oldest      = group.Min(x => x.AssignedDate.Value);
                    queueStats[i++] = det;
                }

                // Store the results in the output arguments
                QueueStats.Set(context, queueStats);
            }
        }
Esempio n. 4
0
        protected override void Execute(CodeActivityContext context)
        {
            // Open the config file and get the connection string
            Configuration            config = WebConfigurationManager.OpenWebConfiguration("/RequestWeb");
            ConnectionStringsSection css    =
                (ConnectionStringsSection)config.GetSection("connectionStrings");
            string connectionString = css.ConnectionStrings["Request"].ConnectionString;

            // Lookup the Queue
            RequestDataContext dc = new RequestDataContext(connectionString);

            // Lookup the Request
            dc.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues, dc.Requests);
            Request r = dc.Requests.SingleOrDefault(x => x.RequestKey == RequestKey.Get(context));

            if (r == null)
            {
                throw new InvalidProgramException("The specified request (" + RequestKey.Get(context) + ") was not found");
            }

            if (r.AssignedOperator != null)
            {
                if (r.AssignedOperator != OperatorID.Get(context))
                {
                    Result.Set(context, -1);
                    return;
                }
            }

            r.AssignedOperator = OperatorID.Get(context);
            r.AssignedDate     = DateTime.UtcNow;

            // Update the Request record
            PersistRequest persist = context.GetExtension <PersistRequest>();

            persist.AddRequest(r);

            Result.Set(context, 0);
        }
Esempio n. 5
0
        protected override void Execute(CodeActivityContext context)
        {
            // Open the config file and get the connection string
            Configuration            config = WebConfigurationManager.OpenWebConfiguration("/RequestWeb");
            ConnectionStringsSection css    =
                (ConnectionStringsSection)config.GetSection("connectionStrings");
            string connectionString = css.ConnectionStrings["Request"].ConnectionString;

            // Lookup the Queue
            RequestDataContext dc = new RequestDataContext(connectionString);

            Queue queue = dc.Queues.SingleOrDefault(x => x.QueueName == QueueName.Get(context));

            if (queue == null)
            {
                throw new InvalidProgramException("The specified queue (" + QueueName.Get(context) + ") was not found");
            }

            if (queue.AllowSelection)
            {
                IEnumerable <Request> q = dc.Requests
                                          .Where(x => x.Queue.QueueName == QueueName.Get(context) &&
                                                 x.QC == QC.Get(context) &&
                                                 (x.AssignedOperator == null ||
                                                  x.AssignedOperator == OperatorID.Get(context)))
                                          .OrderBy(x => x.AssignedDate);

                if (q.Count() > 0)
                {
                    Request[] reqList = new Request[q.Count()];
                    int       i       = 0;
                    foreach (Request r in q)
                    {
                        reqList[i++] = r;
                    }

                    RequestList.Set(context, reqList);
                }
            }
            else
            {
                IEnumerable <Request> q = dc.Requests
                                          .Where(x => x.Queue.QueueName == QueueName.Get(context) &&
                                                 x.QC == QC.Get(context) &&
                                                 (x.AssignedOperator == null ||
                                                  x.AssignedOperator == OperatorID.Get(context)))
                                          .OrderBy(x => x.AssignedDate)
                                          .Take(1);

                if (q.Count() > 0)
                {
                    Request r = q.First <Request>();
                    r.AssignedOperator = OperatorID.Get(context);
                    dc.SubmitChanges();

                    Request[] reqList = new Request[1];
                    reqList[0] = r;

                    RequestList.Set(context, reqList);
                }
            }
        }