Exemple #1
0
        /// <summary>
        /// Process all rows in the books table
        /// Public interface should use RunHarvestAll() function instead. (So that we can guarantee that the class instance is properly disposed).
        /// </summary>
        ///
        /// <param name="maxBooksToProcess"></param>
        private void HarvestAll(int maxBooksToProcess = -1, string queryWhereJson = "")
        {
            _logger.TrackEvent("HarvestAll Start");
            var methodStopwatch = new Stopwatch();

            methodStopwatch.Start();

            int numBooksProcessed = 0;

            IEnumerable <Book> bookList = _parseClient.GetBooks(queryWhereJson);

            foreach (var book in bookList)
            {
                ProcessOneBook(book);
                ++numBooksProcessed;

                if (maxBooksToProcess > 0 && numBooksProcessed >= maxBooksToProcess)
                {
                    break;
                }
            }

            _parseClient.FlushBatchableOperations();
            methodStopwatch.Stop();
            Console.Out.WriteLine($"HarvestAll took {methodStopwatch.ElapsedMilliseconds / 1000.0} seconds.");

            _logger.TrackEvent("HarvestAll End - Success");
        }
Exemple #2
0
 // Suggest that this be used to log more significant things like actions to the Events table as opposed to Traces which can represent diagnostic/debugging log messages
 public void TrackEvent(string eventName)
 {
     _telemetry.TrackEvent(eventName);
     _fileLogger.TrackEvent(eventName);
     Console.Error.WriteLine($"Event: {eventName}");
 }