public void Stop() { var messageQueueName = Configuration.MessageQueueName; MessageQueue.Delete(messageQueueName); if (_pdfGenerator.IsSaved) { return; } try { _pdfGenerator.SaveDocument(); AppData.CountGeneratedPDFFiles++; AppDataManager.WrireToFile(Configuration.AppFileName, AppData); } catch (Exception exception) { Console.WriteLine(exception.Message); } }
private void OnTimedSaveDocumentEvent(object source, ElapsedEventArgs e) { var milliseconds = _pdfGenerator.LastImageDateTime.HasValue ? (DateTime.Now - _pdfGenerator.LastImageDateTime.Value).Minutes : -1; if (milliseconds == -1 || milliseconds < StatisticsData.TimeInterval || _pdfGenerator.PreprocessedImagesCount <= 0 || _pdfGenerator.IsSaved) { return; } try { _pdfGenerator.SaveDocument(); AppData.CountGeneratedPDFFiles++; AppDataManager.WrireToFile(Configuration.AppFileName, AppData); } catch (Exception exception) { Console.WriteLine(exception.Message); } }