protected override void LazyInit()
        {
            base.LazyInit();

            _organizationId   = ValidateNonEmptyConfigParameter(CONFIG_ORG_ID);
            _organizationName = ValidateNonEmptyConfigParameter(CONFIG_ORG_NAME);
            TryGetConfigParameter(CONFIG_STORED_PROC_NAME, ref _storedProcName);
            TryGetConfigParameter(CONFIG_STORED_PROC_TIMEOUT, ref _storedProcTimeout);

            string lookupTableFilePath = null;

            TryGetConfigParameter(CONFIG_LOOKUP_TABLES_FILE_PATH, ref lookupTableFilePath);
            if (!string.IsNullOrEmpty(lookupTableFilePath))
            {
                WQXFlatFileParser.GetLookups(lookupTableFilePath, out _resultAnalyticalMethodLookups, out _sampleCollectionMethodLookups);
                AppendAuditLogEvent("Found {0} SampleCollectionMethod lookup(s) and {1} ResultAnalyticalMethod lookup(s) in the lookup tables file \"{2}\".",
                                    CollectionUtils.Count(_sampleCollectionMethodLookups).ToString(),
                                    CollectionUtils.Count(_resultAnalyticalMethodLookups).ToString(),
                                    lookupTableFilePath);
            }
            else
            {
                AppendAuditLogEvent("No lookup tables file specified.");
            }

            if (!string.IsNullOrEmpty(_storedProcName))
            {
                _storedProcBaseDao = ValidateDBProvider(DATA_SOURCE_STORED_PROC, typeof(NamedNullMappingDataReader));
            }

            AppendAuditLogEvent("Config parameters: {0} ({1}), {2} ({3}), {4} ({5})", CONFIG_ORG_ID, _organizationId,
                                CONFIG_ORG_NAME, _organizationName, CONFIG_STORED_PROC_NAME, _storedProcName ?? "None");
        }
        protected override WQXDataType GetWQXData(string transactionId, string docId,
                                                  out Windsor.Node2008.WNOSPlugin.WQX1XsdOrm.WQXDataType data1,
                                                  out WQXDeleteDataType deleteData, out string attachmentsFolderPath)
        {
            WQXDataType data = null;

            data1                 = null;
            deleteData            = null;
            attachmentsFolderPath = null;
            string tempFolderPath = Path.Combine(_settingsProvider.TempFolderPath, Guid.NewGuid().ToString());

            try
            {
                AppendAuditLogEvent("Extracting contents of document with id \"{0}\" to temporary folder", docId);
                _compressionHelper.UncompressDirectory(_documentManager.GetContent(transactionId, docId), tempFolderPath);

                string projectsFile, monitoringFile, resultsFile;
                GetFlatFiles(tempFolderPath, out projectsFile, out monitoringFile, out resultsFile);

                AppendAuditLogEvent("Generating WQX data from flat files for Organization Id \"{0}\" and Name \"{1}\"",
                                    _organizationId, _organizationName);

                Dictionary <string, MonitoringLocationDataType> monitoringLocations =
                    WQXFlatFileParser.ParseMonitoringLocations(monitoringFile);
                if (CollectionUtils.IsNullOrEmpty(monitoringLocations))
                {
                    throw new InvalidDataException(string.Format("The document does not contain any monitoring locations inside the flat file"));
                }

                Dictionary <string, ProjectDataType> projects =
                    WQXFlatFileParser.ParseProjects(projectsFile);
                if (CollectionUtils.IsNullOrEmpty(projects))
                {
                    throw new InvalidDataException(string.Format("The document does not contain any projects inside the flat file"));
                }

                Dictionary <string, ActivityDataType> activities =
                    WQXFlatFileParser.ParseResults(resultsFile, projects, monitoringLocations, _resultAnalyticalMethodLookups,
                                                   _sampleCollectionMethodLookups, false);

                data = new WQXDataType();
                data.Organization = new OrganizationDataType();
                data.Organization.OrganizationDescription = new OrganizationDescriptionDataType();
                data.Organization.OrganizationDescription.OrganizationIdentifier = _organizationId;
                data.Organization.OrganizationDescription.OrganizationFormalName = _organizationName;

                if (!CollectionUtils.IsNullOrEmpty(monitoringLocations))
                {
                    data.Organization.MonitoringLocation = new List <MonitoringLocationDataType>(monitoringLocations.Values).ToArray();
                }
                if (!CollectionUtils.IsNullOrEmpty(projects))
                {
                    data.Organization.Project = new List <ProjectDataType>(projects.Values).ToArray();
                }
                if (!CollectionUtils.IsNullOrEmpty(activities))
                {
                    data.Organization.Activity = new List <ActivityDataType>(activities.Values).ToArray();
                }
                SaveDataFileToTransaction(transactionId, data);
            }
            finally
            {
                FileUtils.SafeDeleteDirectory(tempFolderPath);
            }
            return(data);
        }