Beispiel #1
0
        /// <summary>
        /// queue data to be sent
        /// this gets the data from the db and updates status to running
        /// it also places it on a queue for another thread to process
        /// </summary>
        /// <param name="xCancelToken">cancellation token</param>
        /// <param name="xProcessingQueue">processing queue</param>
        /// <param name="xExportDataCategoryID">category id</param>
        public void QueueDataToExport(CancellationTokenSource xCancelToken, BlockingCollection <ExportData> xProcessingQueue)
        {
            ExportData        exportData     = new ExportData();
            List <ExportData> exportDataList = exportData.GetAllScheduledToRun();

            if (exportDataList.Count > 0)
            {
                _log.Debug($"Schedules found : {exportDataList.Count} Queuing...");
                foreach (ExportData dataToQueue in exportDataList)
                {
                    if (xCancelToken.IsCancellationRequested)
                    {
                        break;
                    }
                    else
                    {
                        //set status to queued
                        dataToQueue.RunStatusID = (int)ExportDataStatus.STATUS.RUNNING;
                        dataToQueue.Save();

                        xProcessingQueue.Add(dataToQueue);
                        _log.Info(dataToQueue.ExportDataID + " id queued for delivery");
                    }
                }
            }
        }