public void UpdatePRSErrorMonitorTable(DateTime dateTime, int prsUnavailableErrors, int prsTimeoutErrors)
        {
            tbPRSErrorMonitor _prsErrorMonitorRow = new tbPRSErrorMonitor();
            _prsErrorMonitorRow.DateTime = dateTime;
            _prsErrorMonitorRow.PRSUnavailableErrors = prsUnavailableErrors;
            _prsErrorMonitorRow.PRSTimeoutErrors = prsTimeoutErrors;

            _reportingEntityContext.tbPRSErrorMonitor.AddObject(_prsErrorMonitorRow);
            _reportingEntityContext.SaveChanges();
        }
        public static tbPRSErrorMonitor AddTableRow(DateTime dateTime, int numPrsUnavailableErrors, int numPrsTimeoutErrors)
        {
            tbPRSErrorMonitor row = new tbPRSErrorMonitor
            {
                DateTime = dateTime,
                PRSUnavailableErrors = numPrsUnavailableErrors,
                PRSTimeoutErrors = numPrsTimeoutErrors
            };

            return row;
        }
        public static tbPRSErrorMonitor AddTableRow()
        {
            tbPRSErrorMonitor row = new tbPRSErrorMonitor
            {
                DateTime = DateTime.Now,
                PRSUnavailableErrors = 0,
                PRSTimeoutErrors = 0
            };

            return row;
        }
Exemplo n.º 4
0
        public void UpdatePRSErrorMonitorTable(DateTime dateTime, int prsUnavailableErrors, int prsTimeoutErrors)
        {
            tbPRSErrorMonitor _prsErrorMonitorRow = new tbPRSErrorMonitor();

            _prsErrorMonitorRow.DateTime             = dateTime;
            _prsErrorMonitorRow.PRSUnavailableErrors = prsUnavailableErrors;
            _prsErrorMonitorRow.PRSTimeoutErrors     = prsTimeoutErrors;

            _reportingEntityContext.tbPRSErrorMonitor.AddObject(_prsErrorMonitorRow);
            _reportingEntityContext.SaveChanges();
        }
        public CheckPrsErrorLevels(IRepository repository, IConfigFileHelper configFileHelper, ILogger log)
        {
            _repository       = repository;
            _configFileHelper = configFileHelper;
            _log = log;

            _prsUnavailableErrorLimit = _configFileHelper.PrsUnavailableErrorLimit;
            _prsTimeoutErrorLimit     = _configFileHelper.PrsTimeoutErrorLimit;
            _prsTotalErrorLimit       = _configFileHelper.PrsTotalErrorLimit;

            // If check is to be run every minute, just grab the latest row from tbPrsErrorMonitor
            if (_configFileHelper.PrsErrorCheckFrequency == 1)
            {
                tbPRSErrorMonitor _resultsFromLatestPrsCheck = _repository.RetrieveLatestRowFromPrsErrorMonitorTable();
                _numberOfPrsUnavailableErrors = _resultsFromLatestPrsCheck.PRSUnavailableErrors;
                _numberOfPrsTimeoutErrors     = _resultsFromLatestPrsCheck.PRSTimeoutErrors;
                _totalNumberOfPrsErrors       = _numberOfPrsUnavailableErrors + _numberOfPrsTimeoutErrors;
            }
            else  // Grab all the rows created since check was last ran
            {
                // Been thinking about changing this to retrieive all records more recent than the lastTimeCheckWasRan
                // value in the config file as its more accurate and probably the same speed.....?
                IList <tbPRSErrorMonitor> _prsErrorDetailsSinceLastCheck =
                    _repository.RetrieveRowsFromPrsErrorMonitorTableForTimeSpecified(_configFileHelper.PrsErrorCheckFrequency);

                foreach (var tableRow in _prsErrorDetailsSinceLastCheck)
                {
                    _numberOfPrsUnavailableErrors += tableRow.PRSUnavailableErrors;
                    _numberOfPrsTimeoutErrors     += tableRow.PRSTimeoutErrors;
                }

                _totalNumberOfPrsErrors = _numberOfPrsUnavailableErrors + _numberOfPrsTimeoutErrors;
            }

            // Update the config file with the time check was run
            _configFileHelper.UpdateTimeLastPrsErrorCheckWasRun();
        }