public void UpdateCase(IDataRecord newDataRecord, IDataRecord existingDataRecord, string instrumentName, string serverParkName)
        {
            var primaryKey = _blaiseApi.GetPrimaryKeyValue(newDataRecord);

            try
            {
                if (_blaiseApi.CaseInUseInCati(existingDataRecord))
                {
                    _loggingService.LogInfo(
                        $"Not processed: NISRA case '{primaryKey}' as the case may be open in Cati for instrument '{instrumentName}'");

                    return;
                }

                var fieldData = GetFieldData(newDataRecord, existingDataRecord);

                _blaiseApi.UpdateCase(existingDataRecord, fieldData, instrumentName, serverParkName);

                if (RecordHasBeenUpdated(primaryKey, newDataRecord, instrumentName, serverParkName))
                {
                    _loggingService.LogInfo(
                        $"NISRA case '{primaryKey}' was successfully updated for instrument '{instrumentName}'");

                    return;
                }

                _loggingService.LogWarn($"NISRA case '{primaryKey}' failed to update - potentially open in Cati at the time of the update for instrument '{instrumentName}'");
            }
            catch (Exception ex)
            {
                _loggingService.LogWarn($"Warning: There was an error updating case '{primaryKey}' - '{ex}'");
            }
        }
예제 #2
0
        public void UpdateExistingCaseWithOnlineData(IDataRecord nisraDataRecord, IDataRecord existingDataRecord,
                                                     string serverParkName, string instrumentName, string primaryKey)
        {
            var nisraOutcome    = _blaiseApi.GetOutcomeCode(nisraDataRecord);
            var existingOutcome = _blaiseApi.GetOutcomeCode(existingDataRecord);

            if (nisraOutcome == 0)
            {
                _loggingService.LogInfo($"Not processed: NISRA case '{primaryKey}' (NISRA HOut = 0) for instrument '{instrumentName}'");

                return;
            }

            if (existingOutcome == 561 || existingOutcome == 562)
            {
                _loggingService.LogInfo(
                    $"Not processed: NISRA case '{primaryKey}' (Existing HOut = '{existingOutcome}' for instrument '{instrumentName}'");

                return;
            }

            if (NisraRecordHasAlreadyBeenProcessed(nisraDataRecord, nisraOutcome, existingDataRecord,
                                                   existingOutcome, primaryKey, instrumentName))
            {
                _loggingService.LogInfo(
                    $"Not processed: NISRA case '{primaryKey}' as is has already been updated on a previous run for instrument '{instrumentName}'");

                return;
            }

            if (_blaiseApi.CaseInUseInCati(existingDataRecord))
            {
                _loggingService.LogInfo(
                    $"Not processed: NISRA case '{primaryKey}' as the case may be open in Cati for instrument '{instrumentName}'");

                return;
            }

            if (existingOutcome > 0 && existingOutcome < nisraOutcome)
            {
                _loggingService.LogInfo(
                    $"Not processed: NISRA case '{primaryKey}' (Existing HOut = '{existingOutcome}' < '{nisraOutcome}')  for instrument '{instrumentName}'");

                return;
            }

            UpdateCase(nisraDataRecord, existingDataRecord, instrumentName,
                       serverParkName, nisraOutcome, existingOutcome, primaryKey);
        }