Example #1
0
        /// <summary>
        /// Deletes all event journal records from the database for the specified serial numbers.
        /// </summary>
        /// <param name="serialNumbers"></param>
        /// <param name="trx"></param>
        private void RemoveEventJournals(IList <string> serialNumbers, DataAccessTransaction trx)
        {
            // Delete all EventJournals matching the serial numbers.
            // We do so in batches for better performance.

            const int batchSize = 25;

            EventJournalDataAccess eventJournalDataAccess = new EventJournalDataAccess();

            Queue <string> snQueue = new Queue <string>(serialNumbers);

            while (snQueue.Count > 0)
            {
                IList <string> snbatch = GetBatch(snQueue, batchSize);
                eventJournalDataAccess.DeleteBySerialNumbers(snbatch, trx);
            }
        }
Example #2
0
        /// <summary>
        /// Deletes all event journal records from the database older than the specified amount of time.
        /// </summary>
        /// <param name="journalAge"></param>
        /// <param name="trx"></param>
        private void RemoveEventJournals(TimeSpan journalAge, DataAccessTransaction trx)
        {
            EventJournalDataAccess eventJournalDataAccess = new EventJournalDataAccess();

            eventJournalDataAccess.DeleteByTime(journalAge, trx);
        }
Example #3
0
        private bool SaveEventJournals(DockingStationEvent dsEvent, DateTime lastDockedTime, DataAccessTransaction trx)
        {
            if (dsEvent.EventCode == null)
            {
                return(true);
            }

            EventJournalDataAccess ejDataAccess = new EventJournalDataAccess();

            EventJournal eventJournal = null;

            // If the event implements IPassed, then use the result of its
            // Passed property.  Otherwise, just default to true.
            bool passed = ((dsEvent is IPassed)) ? ((IPassed)dsEvent).Passed : true;

            if (dsEvent is InstrumentEvent)
            {
                // special case for // bump & cals... need to save a separate
                // event journal for every sensor involved in gas operation.
                // Note that in this situation, we also do NOT save an entry for the instrument itself.
                if (dsEvent is InstrumentGasResponseEvent && !(dsEvent is InstrumentManualOperationsDownloadEvent))
                {
                    InstrumentGasResponseEvent gasResponseTestEvent = (InstrumentGasResponseEvent)dsEvent;
                    if (gasResponseTestEvent.GasResponses.Count <= 0)
                    {
                        return(true);
                    }

                    bool allSaved = true;
                    foreach (SensorGasResponse sgr in gasResponseTestEvent.GasResponses)
                    {
                        eventJournal = new EventJournal(gasResponseTestEvent.EventCode.Code, sgr.Uid,
                                                        gasResponseTestEvent.DockedInstrument.SerialNumber,
                                                        sgr.Time, dsEvent.Time, sgr.Passed,
                                                        sgr.Position, gasResponseTestEvent.DockedInstrument.SoftwareVersion);
                        allSaved &= ejDataAccess.Save(eventJournal, trx);
                    }
                    // If gasResponseEvent is a InstrumentBumpTestEvent, it might have calibration gas responses due to O2 high bump test failure.
                    // If there are any gas responses in HighBumpFailCalGasResponses, store them to the event journals.
                    foreach (SensorGasResponse sgr in gasResponseTestEvent.HighBumpFailCalGasResponses)
                    {
                        eventJournal = new EventJournal(EventCode.Calibration, sgr.Uid,
                                                        gasResponseTestEvent.DockedInstrument.SerialNumber,
                                                        sgr.Time, dsEvent.Time, sgr.Passed,
                                                        sgr.Position, gasResponseTestEvent.DockedInstrument.SoftwareVersion);
                        allSaved &= ejDataAccess.Save(eventJournal, trx);
                    }
                    return(allSaved);
                }
                else
                {
                    eventJournal = new EventJournal(dsEvent.EventCode, ((InstrumentEvent)dsEvent).DockedInstrument.SerialNumber, dsEvent.Time, dsEvent.Time, passed, ((InstrumentEvent)dsEvent).DockedInstrument.SoftwareVersion);
                }
            }
            else // DockingStationEvent
            {
                eventJournal = new EventJournal(dsEvent.EventCode, dsEvent.DockingStation.SerialNumber, dsEvent.Time, dsEvent.Time, passed, dsEvent.DockingStation.SoftwareVersion);
            }

            return(ejDataAccess.Save(eventJournal, trx));  // Update/insert EventJournal record for the event.
        }