Пример #1
0
        public async Task ProcessRecordsAsync(IHelper helper, IDBContext eddsDbContext, IRsapiRepositoryGroup repositoryGroup, ISqlQueryHelper sqlQueryHelper, ImportWorkerQueueRecord record, List <ImportJobError> errors)
        {
            var          currentRecordErrors = new List <ImportJobError>();
            IAdminObject migrationObject     = null;

            try
            {
                migrationObject = await _serializationHelper.DeserializeToAdminObjectAsync(record.MetaData);
            }
            catch (Exception ex)
            {
                var serializationError = new ImportJobError()
                {
                    Message = Constant.ErrorMessages.GeneralDeSerializationError, Details = ex.ToString(), Type = Constant.ImportUtilityJob.ErrorType.DataLevel, LineNumber = record.ImportRowID
                };
                currentRecordErrors.Add(serializationError);
            }

            if (migrationObject != null && !currentRecordErrors.Any())
            {
                var violations = new List <String>();
                violations.AddRange(await migrationObject.ValidateAsync(_apiOptions, repositoryGroup, _artifactQueryHelper, eddsDbContext, sqlQueryHelper));
                if (record.JobType == Constant.ImportUtilityJob.JobType.VALIDATE_SUBMIT && !violations.Any())
                {
                    violations.AddRange(await migrationObject.ImportAsync(_apiOptions, repositoryGroup, _artifactQueryHelper, helper, eddsDbContext, sqlQueryHelper));
                }

                currentRecordErrors.AddRange(
                    violations.Select(x => new ImportJobError()
                {
                    Message = x, Type = Constant.ImportUtilityJob.ErrorType.DataLevel, LineNumber = record.ImportRowID
                })
                    );
            }
            errors.AddRange(currentRecordErrors);
        }