예제 #1
0
        private void DequeueXmlDataTaskMain(DequeueXmlDataTaskState state)
        {
            Guard.ArgumentNotNull(state, "state");

            using (ICloudQueueStorage workItemQueue = state.StorageProvider.GetQueueStorage(state.Settings.CloudStorageAccount))
                using (SqlAzurePersistenceQueue dbQueue = new SqlAzurePersistenceQueue())
                {
                    dbQueue.Open(WellKnownDatabaseName.PersistenceQueue);

                    using (XmlReader xmlReader = dbQueue.DequeueXmlData(state.QueueItemInfo.QueueItemId, state.HeaderSegments, state.BodySegments, state.FooterSegments, state.NamespaceManager))
                    {
                        if (xmlReader != null)
                        {
                            XDocument batch = XDocument.Load(xmlReader);

                            // Check for presence of any items in the batch.
                            bool batchFound = (batch.XPathSelectElement(state.ItemDetectionXPath) != null);

                            if (batchFound)
                            {
                                workItemQueue.Put <XDocument>(state.Settings.DestinationQueue, batch);
                            }
                        }
                    }
                }
        }
예제 #2
0
        public void TestDequeueXmlData()
        {
            XPathQueryLibrary xPathLib = ApplicationConfiguration.Current.XPathQueries;

            var headerSegments = new List <string>();
            var bodySegments   = new List <string>();
            var footerSegments = new List <string>();

            headerSegments.Add(xPathLib.GetXPathQuery("InventoryHeader"));
            footerSegments.Add(xPathLib.GetXPathQuery("InventorySummary"));
            footerSegments.Add(xPathLib.GetXPathQuery("InventoryIRRSegment"));
            string itemXPath = xPathLib.GetXPathQuery("InventoryItems");

            int       fromItem     = 1;
            int       xmlBatchSize = 50;
            XDocument batch        = null;
            Guid      queueItemId  = Guid.Parse("6DA1B27D-714D-465D-93B8-234B085CF6E4");

            using (SqlAzurePersistenceQueue dbQueue = new SqlAzurePersistenceQueue())
            {
                dbQueue.Open(WellKnownDatabaseName.PersistenceQueue);

                int toItem = fromItem + xmlBatchSize - 1;

                bodySegments.Clear();
                bodySegments.Add(String.Format(xPathLib.GetXPathQuery("InventoryItemBatchTemplate"), fromItem, toItem));

                using (XmlReader xmlReader = dbQueue.DequeueXmlData(queueItemId, headerSegments, bodySegments, footerSegments, xPathLib.Namespaces.NamespaceManager))
                {
                    if (xmlReader != null)
                    {
                        batch = XDocument.Load(xmlReader);
                    }
                }
            }
        }