/// <summary>
        /// Async helper method, grabs the Queue that is set to be "running" for this application and processes.
        /// </summary>
        private static void RunSlugGenerationQueueItem()
        {
            //EventLogProvider.LogInformation("DynamicRouteTesting", "AsyncBuildStart", eventDescription: DateTime.Now.ToString() + " " + DateTime.Now.Millisecond.ToString());
            // Get the current thread ID and the item to run
            SlugGenerationQueueInfo ItemToRun = SlugGenerationQueueInfoProvider.GetSlugGenerationQueues()
                                                .WhereEquals("SlugGenerationQueueRunning", 1)
                                                .WhereEquals("SlugGenerationQueueApplicationID", SystemHelper.ApplicationIdentifier)
                                                .WhereEmpty("SlugGenerationQueueThreadID")
                                                .FirstOrDefault();

            if (ItemToRun == null)
            {
                return;
            }

            // Update item with thread and times
            ItemToRun.SlugGenerationQueueThreadID = Thread.CurrentThread.ManagedThreadId;
            ItemToRun.SlugGenerationQueueStarted  = DateTime.Now;
            ItemToRun.SetValue("SlugGenerationQueueErrors", null);
            ItemToRun.SetValue("SlugGenerationQueueEnded", null);
            SlugGenerationQueueInfoProvider.SetSlugGenerationQueueInfo(ItemToRun);

            // Get the NodeItem from the SlugGenerationQueueItem
            var      serializer = new XmlSerializer(typeof(NodeItem));
            NodeItem QueueItem;

            using (TextReader reader = new StringReader(ItemToRun.SlugGenerationQueueNodeItem))
            {
                QueueItem = (NodeItem)serializer.Deserialize(reader);
            }
            // Build and Save Items
            try
            {
                QueueItem.BuildChildren();
                QueueItem.SaveChanges();

                // If completed successfully, delete the item
                ItemToRun.Delete();

                // Now that we are 'finished' call the Check again to processes next item.
                CheckUrlSlugGenerationQueue();
            }
            catch (Exception ex)
            {
                ItemToRun.SlugGenerationQueueErrors  = EventLogProvider.GetExceptionLogMessage(ex);
                ItemToRun.SlugGenerationQueueRunning = false;
                ItemToRun.SlugGenerationQueueEnded   = DateTime.Now;
                SlugGenerationQueueInfoProvider.SetSlugGenerationQueueInfo(ItemToRun);

                // Commit transaction so next check will see this change
                CommitTransaction(true);

                // Now that we are 'finished' call the Check again to processes next item.
                CheckUrlSlugGenerationQueue();
            }
            //EventLogProvider.LogInformation("DynamicRouteTesting", "AsyncBuildComplete", eventDescription: DateTime.Now.ToString()+" "+DateTime.Now.Millisecond.ToString());
        }
        /// <summary>
        /// Runs the Generation on the given Slug Generation Queue, runs regardless of whether or not any other queues are running.
        /// </summary>
        /// <param name="SlugGenerationQueueID"></param>
        public static void RunSlugGenerationQueueItem(int SlugGenerationQueueID)
        {
            SlugGenerationQueueInfo ItemToRun = SlugGenerationQueueInfoProvider.GetSlugGenerationQueues()
                                                .WhereEquals("SlugGenerationQueueID", SlugGenerationQueueID)
                                                .FirstOrDefault();

            if (ItemToRun == null)
            {
                return;
            }

            // Update item with thread and times
            ItemToRun.SlugGenerationQueueThreadID      = Thread.CurrentThread.ManagedThreadId;
            ItemToRun.SlugGenerationQueueStarted       = DateTime.Now;
            ItemToRun.SlugGenerationQueueRunning       = true;
            ItemToRun.SlugGenerationQueueApplicationID = SystemHelper.ApplicationIdentifier;
            ItemToRun.SetValue("SlugGenerationQueueErrors", null);
            ItemToRun.SetValue("SlugGenerationQueueEnded", null);
            SlugGenerationQueueInfoProvider.SetSlugGenerationQueueInfo(ItemToRun);

            // Get the NodeItem from the SlugGenerationQueueItem
            var      serializer = new XmlSerializer(typeof(NodeItem));
            NodeItem QueueItem;

            using (TextReader reader = new StringReader(ItemToRun.SlugGenerationQueueNodeItem))
            {
                QueueItem = (NodeItem)serializer.Deserialize(reader);
            }

            // Build and Save Items
            try
            {
                QueueItem.BuildChildren();
                QueueItem.SaveChanges();
            }
            catch (Exception ex)
            {
                ItemToRun.SlugGenerationQueueErrors  = EventLogProvider.GetExceptionLogMessage(ex);
                ItemToRun.SlugGenerationQueueRunning = false;
                ItemToRun.SlugGenerationQueueEnded   = DateTime.Now;
                SlugGenerationQueueInfoProvider.SetSlugGenerationQueueInfo(ItemToRun);
            }
            // If completed successfully, delete the item
            ItemToRun.Delete();
        }
        /// <summary>
        /// Runs the Generation on the given Slug Generation Queue, runs regardless of whether or not any other queues are running.
        /// </summary>
        /// <param name="SlugGenerationQueueID"></param>
        public static void RunSlugGenerationQueueItem(int SlugGenerationQueueID)
        {
            SlugGenerationQueueInfo ItemToRun = SlugGenerationQueueInfoProvider.GetSlugGenerationQueues()
                                                .WhereEquals("SlugGenerationQueueID", SlugGenerationQueueID)
                                                .FirstOrDefault();

            if (ItemToRun == null)
            {
                return;
            }

            // Update item with thread and times
            ItemToRun.SlugGenerationQueueThreadID      = Thread.CurrentThread.ManagedThreadId;
            ItemToRun.SlugGenerationQueueStarted       = DateTime.Now;
            ItemToRun.SlugGenerationQueueRunning       = true;
            ItemToRun.SlugGenerationQueueApplicationID = SystemHelper.ApplicationIdentifier;
            ItemToRun.SetValue("SlugGenerationQueueErrors", null);
            ItemToRun.SetValue("SlugGenerationQueueEnded", null);
            SlugGenerationQueueInfoProvider.SetSlugGenerationQueueInfo(ItemToRun);

            // Get the NodeItem from the SlugGenerationQueueItem
            var      serializer = new XmlSerializer(typeof(NodeItem));
            NodeItem QueueItem;

            using (TextReader reader = new StringReader(ItemToRun.SlugGenerationQueueNodeItem))
            {
                QueueItem = (NodeItem)serializer.Deserialize(reader);
            }

            // Build and Save Items
            try
            {
                QueueItem.BuildChildren();
                if (ErrorOnConflict() && QueueItem.ConflictsExist())
                {
                    ItemToRun.SlugGenerationQueueErrors = $"The Following Conflicts were found:\n\r{string.Join("\n\r", QueueItem.GetConflictItems())}\n\rPlease Correct and re-run queue item.";
                    ItemToRun.SlugGenerationQueueEnded  = DateTime.Now;
                    ItemToRun.SetValue("SlugGenerationQueueThreadID", null);
                    ItemToRun.SetValue("SlugGenerationQueueApplicationID", null);
                    ItemToRun.SlugGenerationQueueRunning = false;
                    SlugGenerationQueueInfoProvider.SetSlugGenerationQueueInfo(ItemToRun);
                    return;
                }
                else
                {
                    QueueItem.SaveChanges();
                    // If completed successfully, delete the item
                    ItemToRun.Delete();
                }
            }
            catch (Exception ex)
            {
                ItemToRun.SlugGenerationQueueErrors  = EventLogProvider.GetExceptionLogMessage(ex);
                ItemToRun.SlugGenerationQueueRunning = false;
                ItemToRun.SlugGenerationQueueEnded   = DateTime.Now;
                SlugGenerationQueueInfoProvider.SetSlugGenerationQueueInfo(ItemToRun);
            }

            // Now that we are 'finished' call the Check again to processes next item.
            CheckUrlSlugGenerationQueue();
        }