public static DetectionQuantitationLimitDataType MapDetectionQuantitationLimit(NamedNullMappingDataReader readerEx) { DetectionQuantitationLimitDataType detectionQuantitationLimit = new DetectionQuantitationLimitDataType(); detectionQuantitationLimit.DetectionQuantitationLimitTypeName = readerEx.GetString("DETECTQUANTLIMITTYPE"); detectionQuantitationLimit.DetectionQuantitationLimitMeasure = GetNullMeasureCompactData(readerEx, "DETECTQUANTLIMITMEASURE", "DETECTQUANTLIMITMEASUNITCODE"); return(detectionQuantitationLimit); }
private void InsertResults(IDbCommand dbCommand, WQXDataType organization) { const string RSLT_UPDATE_COLUMNS = "ActivityIdentifier;DataLoggerLineName;SampleDateTime;ResultDetectionConditionText;CharacteristicName;ResultSampleFractionText;ResultMeasureValue;" + "ResultMeasureUnitCode;ResultStatusIdentifier;StatisticalBaseCode;ResultValueTypeName;ResultWeightBasisText;ResultTimeBasisText;ResultTemperatureBasisText;" + "ResultParticleSizeBasisText;ResultCommentText;BiologicalIntentName;BiologicalIndividualIdentifier;SubjectTaxonomicName;UnidentifiedSpeciesIdentifier;" + "SampleTissueAnatomyName;RGSCWMeasureValue;RGSCWMeasureUnitCode;ResAMMethodIdentifier;ResAMMethodIdentifierContext;ResAMMethodName;LaboratoryName;" + "AnalysisStartDate;AnalysisEndDate;ResultLaboratoryCommentCode;DetectionQuantitationLimitTypeName;RDQLMTMeasureValue;RDQLMTMeasureUnitCode;RLSPRPMethodIdentifier;" + "RLSPRPMethodIdentifierContext;RLSPRPMethodName;LastChangeDate;SubmitToEPA;SubmitToNWIFC;Delete"; const string RSLT_TABLE_NAME = "Result"; const string CHARACTERISTIC_TABLE_NAME = "Characteristic"; const string RESULT_STATUS_TABLE_NAME = "ResultStatus"; if (CollectionUtils.IsNullOrEmpty(organization.Organization.Activity)) { return; } List <ResultDataType> results = new List <ResultDataType>(128); CollectionUtils.ForEach(organization.Organization.Activity, delegate(ActivityDataType activity) { ExceptionUtils.ThrowIfNull(activity, "activity"); CollectionUtils.ForEach(activity.Result, delegate(ResultDataType result) { result.ParentId = activity.ActivityDescription.ActivityIdentifier; // Will be used below results.Add(result); }); }); if (results.Count == 0) { return; } int count = (int)_dao.DoJDBCExecuteScalar("SELECT COUNT(*) FROM " + CHARACTERISTIC_TABLE_NAME, null); Dictionary <string, string> characteristicNames = new Dictionary <string, string>(count); DoSimpleQueryWithRowCallbackDelegate(dbCommand, CHARACTERISTIC_TABLE_NAME, null, null, "CName", delegate(IDataReader reader) { string cName = reader.GetString(0); characteristicNames.Add(cName, cName); }); count = (int)_dao.DoJDBCExecuteScalar("SELECT COUNT(*) FROM " + RESULT_STATUS_TABLE_NAME, null); Dictionary <string, string> resultStatusIds = new Dictionary <string, string>(count); DoSimpleQueryWithRowCallbackDelegate(dbCommand, RESULT_STATUS_TABLE_NAME, null, null, "RSName", delegate(IDataReader reader) { string rsName = reader.GetString(0); resultStatusIds.Add(rsName, rsName); }); int maxColCount = RSLT_UPDATE_COLUMNS.Split(';').Length; object[] values = new object[maxColCount]; try { DoBulkInsert(dbCommand, RSLT_TABLE_NAME, RSLT_UPDATE_COLUMNS, delegate(int currentInsertIndex) { if (currentInsertIndex < results.Count) { ResultDataType result = results[currentInsertIndex]; int valueIndex = 0; values[valueIndex++] = result.ParentId; if (result.ResultDescription != null) { values[valueIndex++] = result.ResultDescription.DataLoggerLineName; values[valueIndex++] = null; // SampleDateTime? values[valueIndex++] = result.ResultDescription.ResultDetectionConditionText; if (string.IsNullOrEmpty(result.ResultDescription.CharacteristicName)) { throw new ArgException("A result is missing a CharacteristicName for Activity: {0}", result.ParentId); } if (!characteristicNames.ContainsKey(result.ResultDescription.CharacteristicName)) { throw new ArgException("A result has an unrecognized CharacteristicName: {0}", result.ResultDescription.CharacteristicName); } values[valueIndex++] = result.ResultDescription.CharacteristicName; values[valueIndex++] = result.ResultDescription.ResultSampleFractionText; if (result.ResultDescription.ResultMeasure != null) { values[valueIndex++] = result.ResultDescription.ResultMeasure.ResultMeasureValue; values[valueIndex++] = result.ResultDescription.ResultMeasure.MeasureUnitCode; } else { values[valueIndex++] = null; values[valueIndex++] = null; } if (string.IsNullOrEmpty(result.ResultDescription.ResultStatusIdentifier)) { throw new ArgException("A result is missing a ResultStatusIdentifier for Activity: {0}", result.ParentId); } if (!resultStatusIds.ContainsKey(result.ResultDescription.ResultStatusIdentifier)) { throw new ArgException("A result has an unrecognized ResultStatusIdentifier: {0}", result.ResultDescription.ResultStatusIdentifier); } values[valueIndex++] = result.ResultDescription.ResultStatusIdentifier; values[valueIndex++] = result.ResultDescription.StatisticalBaseCode; values[valueIndex++] = result.ResultDescription.ResultValueTypeName; values[valueIndex++] = result.ResultDescription.ResultWeightBasisText; values[valueIndex++] = result.ResultDescription.ResultTimeBasisText; values[valueIndex++] = result.ResultDescription.ResultTemperatureBasisText; values[valueIndex++] = result.ResultDescription.ResultParticleSizeBasisText; values[valueIndex++] = result.ResultDescription.ResultCommentText; } else { throw new ArgException("A result is missing a ResultDescription element"); } if (result.BiologicalResultDescription != null) { values[valueIndex++] = result.BiologicalResultDescription.BiologicalIntentName; values[valueIndex++] = result.BiologicalResultDescription.BiologicalIndividualIdentifier; values[valueIndex++] = result.BiologicalResultDescription.SubjectTaxonomicName; values[valueIndex++] = result.BiologicalResultDescription.UnidentifiedSpeciesIdentifier; values[valueIndex++] = result.BiologicalResultDescription.SampleTissueAnatomyName; if (result.BiologicalResultDescription.GroupSummaryCountWeight != null) { values[valueIndex++] = result.BiologicalResultDescription.GroupSummaryCountWeight.MeasureValue; values[valueIndex++] = result.BiologicalResultDescription.GroupSummaryCountWeight.MeasureUnitCode; } else { values[valueIndex++] = null; values[valueIndex++] = null; } } else { values[valueIndex++] = null; values[valueIndex++] = null; values[valueIndex++] = null; values[valueIndex++] = null; values[valueIndex++] = null; values[valueIndex++] = null; values[valueIndex++] = null; } if (result.ResultAnalyticalMethod != null) { values[valueIndex++] = result.ResultAnalyticalMethod.MethodIdentifier; values[valueIndex++] = result.ResultAnalyticalMethod.MethodIdentifierContext; values[valueIndex++] = result.ResultAnalyticalMethod.MethodName; } else { values[valueIndex++] = null; values[valueIndex++] = null; values[valueIndex++] = null; } if (result.ResultLabInformation != null) { values[valueIndex++] = result.ResultLabInformation.LaboratoryName; if (result.ResultLabInformation.AnalysisStartDateSpecified) { values[valueIndex++] = result.ResultLabInformation.AnalysisStartDate; } else { values[valueIndex++] = null; } if (result.ResultLabInformation.AnalysisEndDateSpecified) { values[valueIndex++] = result.ResultLabInformation.AnalysisEndDate; } else { values[valueIndex++] = null; } values[valueIndex++] = result.ResultLabInformation.ResultLaboratoryCommentCode; if (!CollectionUtils.IsNullOrEmpty(result.ResultLabInformation.ResultDetectionQuantitationLimit)) { DetectionQuantitationLimitDataType detectionQuantitationLimitDataType = result.ResultLabInformation.ResultDetectionQuantitationLimit[0]; values[valueIndex++] = detectionQuantitationLimitDataType.DetectionQuantitationLimitTypeName; if (detectionQuantitationLimitDataType.DetectionQuantitationLimitMeasure != null) { values[valueIndex++] = detectionQuantitationLimitDataType.DetectionQuantitationLimitMeasure.MeasureValue; values[valueIndex++] = detectionQuantitationLimitDataType.DetectionQuantitationLimitMeasure.MeasureUnitCode; } else { values[valueIndex++] = null; values[valueIndex++] = null; } } else { values[valueIndex++] = null; values[valueIndex++] = null; values[valueIndex++] = null; } } else { values[valueIndex++] = null; values[valueIndex++] = null; values[valueIndex++] = null; values[valueIndex++] = null; values[valueIndex++] = null; values[valueIndex++] = null; values[valueIndex++] = null; } if (!CollectionUtils.IsNullOrEmpty(result.LabSamplePreparation)) { LabSamplePreparationDataType labSamplePreparationDataType = result.LabSamplePreparation[0]; if (labSamplePreparationDataType.LabSamplePreparationMethod != null) { values[valueIndex++] = labSamplePreparationDataType.LabSamplePreparationMethod.MethodIdentifier; values[valueIndex++] = labSamplePreparationDataType.LabSamplePreparationMethod.MethodIdentifierContext; values[valueIndex++] = labSamplePreparationDataType.LabSamplePreparationMethod.MethodName; } else { values[valueIndex++] = null; values[valueIndex++] = null; values[valueIndex++] = null; } } else { values[valueIndex++] = null; values[valueIndex++] = null; values[valueIndex++] = null; } if (_setLastUpdatedDateTime) { values[valueIndex++] = _lastUpdatedDateTime; } else { values[valueIndex++] = null; } values[valueIndex++] = _submitToEpa ? 1 : 0; values[valueIndex++] = 0; values[valueIndex++] = 0; IncInsertCount(RSLT_TABLE_NAME); return(values); } else { return(null); } }); } catch (Exception) { throw; } }