コード例 #1
0
        public void RegisterQueueItemProgress(QueueEventType eventType, QueueItemDTO latestItem)
        {
            QueueEventLogDTO eventLogItem = new QueueEventLogDTO
            {
                Message = string.Format("Queue Data Item {0} is {1}", latestItem.BadgeAwardId, eventType.ToString()),
                QueueEventCreated = DateTime.Now,
                QueueEventId = (int)eventType,
                BadgeAwardId = latestItem.BadgeAwardId
            };

            _queueEventLogDAL.Add(eventLogItem);
        }
コード例 #2
0
        public QueueItemDTO Add(QueueItemDTO item)
        {
            using (Entities context = new Entities())
            {
                QueueItem addedItem = context.QueueItems.Add(new QueueItem 
                {
                    BadgeAwardId = item.BadgeAwardId,
                    QueueItemCreated = DateTime.Now
                });

                context.SaveChanges();

                return new QueueItemDTO(addedItem.QueueItemId, addedItem.BadgeAwardId, addedItem.QueueItemCreated);
            }
        }
コード例 #3
0
        public void TestAdd()
        {
            ExecuteWithTransaction(() => 
            {
                IQueueItemDAL queueItemDAL = IoC.Container.Resolve<IQueueItemDAL>();

                QueueItemDTO queueItem = new QueueItemDTO
                {
                    BadgeAwardId = 1
                };

                QueueItemDTO addedItem = queueItemDAL.Add(queueItem);

                Assert.IsTrue(addedItem.QueueItemId > 0);
            });            
        }
コード例 #4
0
        public QueueItemDTO Update(QueueItemDTO item)
        {
            using (Entities context = new Entities())
            {
                QueueItem itemToUpdate = new QueueItem                 
                {
                    QueueItemId = item.QueueItemId,
                    BadgeAwardId = item.BadgeAwardId,                    
                    QueueItemCreated = item.QueueItemCreated
                };

                context.QueueItems.Attach(itemToUpdate);
                context.Entry(itemToUpdate).State = System.Data.Entity.EntityState.Modified;
                
                context.SaveChanges();

                return Get(item.QueueItemId);
            }
        }
コード例 #5
0
        public void ProcessItem(QueueItemDTO latestItem)
        {
            try
            {
                EarnedBadgeItemDTO earnedBadge = _earnedBadgeDAL.GetEarnedBadge(latestItem.BadgeAwardId);

                RegisterQueueItemProgress(QueueEventType.Processing, latestItem);

                PublishUpdates(earnedBadge);

                _queueItemDAL.Delete(latestItem.QueueItemId);

                RegisterQueueItemProgress(QueueEventType.Processed, latestItem);
            }
            catch
            {
                RegisterQueueItemProgress(QueueEventType.Failed, latestItem);
                throw;
            }
        }