예제 #1
0
        private SampleFileData MapFromExtensionProperties(SampleFileData sampleFileData, ICollection <ResultExtensionPropertyValue> extensionPropertyValues)
        {
            var propertyValueDictionary = extensionPropertyValues.ToDictionary(x => x.ExtensionProperty.PropertyName, x => x.PropertyValue);

            sampleFileData.SampleCode = propertyValueDictionary.ContainsKey(ESDATSampleCollectionConstants.ResultExtensionPropertyValueKeySampleCode) ?
                                        propertyValueDictionary[ESDATSampleCollectionConstants.ResultExtensionPropertyValueKeySampleCode] :
                                        string.Empty;

            sampleFileData.FieldID = propertyValueDictionary.ContainsKey(ESDATSampleCollectionConstants.ResultExtensionPropertyValueKeyFieldID) ?
                                     propertyValueDictionary[ESDATSampleCollectionConstants.ResultExtensionPropertyValueKeyFieldID] :
                                     string.Empty;

            sampleFileData.SampleDepth = propertyValueDictionary.ContainsKey(ESDATSampleCollectionConstants.ResultExtensionPropertyValueKeySampleDepth) ?
                                         MappingHelper.ToNullableDouble(propertyValueDictionary[ESDATSampleCollectionConstants.ResultExtensionPropertyValueKeySampleDepth]) :
                                         null;

            sampleFileData.MatrixType = propertyValueDictionary.ContainsKey(ESDATSampleCollectionConstants.ResultExtensionPropertyValueKeyMatrixType) ?
                                        propertyValueDictionary[ESDATSampleCollectionConstants.ResultExtensionPropertyValueKeyMatrixType] :
                                        string.Empty;

            sampleFileData.SampleType = propertyValueDictionary.ContainsKey(ESDATSampleCollectionConstants.ResultExtensionPropertyValueKeySampleType) ?
                                        propertyValueDictionary[ESDATSampleCollectionConstants.ResultExtensionPropertyValueKeySampleType] :
                                        string.Empty;

            sampleFileData.ParentSample = propertyValueDictionary.ContainsKey(ESDATSampleCollectionConstants.ResultExtensionPropertyValueKeyParentSample) ?
                                          propertyValueDictionary[ESDATSampleCollectionConstants.ResultExtensionPropertyValueKeyParentSample] :
                                          string.Empty;

            sampleFileData.SDG = propertyValueDictionary.ContainsKey(ESDATSampleCollectionConstants.ResultExtensionPropertyValueKeySDG) ?
                                 propertyValueDictionary[ESDATSampleCollectionConstants.ResultExtensionPropertyValueKeySDG] :
                                 string.Empty;

            sampleFileData.LabSampleID = propertyValueDictionary.ContainsKey(ESDATSampleCollectionConstants.ResultExtensionPropertyValueKeyLabSampleID) ?
                                         propertyValueDictionary[ESDATSampleCollectionConstants.ResultExtensionPropertyValueKeyLabSampleID] :
                                         string.Empty;

            sampleFileData.Comments = propertyValueDictionary.ContainsKey(ESDATSampleCollectionConstants.ResultExtensionPropertyValueKeyComments) ?
                                      propertyValueDictionary[ESDATSampleCollectionConstants.ResultExtensionPropertyValueKeyComments] :
                                      string.Empty;

            sampleFileData.LabReportNumber = propertyValueDictionary.ContainsKey(ESDATSampleCollectionConstants.ResultExtensionPropertyValueKeyLabReportNumber) ?
                                             propertyValueDictionary[ESDATSampleCollectionConstants.ResultExtensionPropertyValueKeyLabReportNumber] :
                                             string.Empty;

            return(sampleFileData);
        }
        private ChemistryFileData MapChemistryFileData(Hatfield.EnviroData.Core.Action action, Result result, MeasurementResultValue measurementResultValue)
        {
            var chemistryFileData = new ChemistryFileData();

            chemistryFileData.ExtractionDate   = action.BeginDateTime;
            chemistryFileData.AnalysedDate     = action.EndDateTime.HasValue ? action.EndDateTime.Value : DateTime.MinValue;
            chemistryFileData.Result           = measurementResultValue.DataValue;
            chemistryFileData.ResultUnit       = result.MeasurementResult.Unit.UnitsName;
            chemistryFileData.OriginalChemName = result.Variable.VariableDefinition;
            chemistryFileData.ChemCode         = result.Variable.VariableCode;
            chemistryFileData.MethodName       = action.Method.MethodName;
            chemistryFileData.MethodType       = action.Method.MethodDescription;

            var propertyValueDictionary = result.ResultExtensionPropertyValues.ToDictionary(x => x.ExtensionProperty.PropertyName, x => x.PropertyValue);

            chemistryFileData.SampleCode = propertyValueDictionary.ContainsKey(ESDATChemistryConstants.ResultExtensionPropertyValueKeySampleCode) ?
                                           propertyValueDictionary[ESDATChemistryConstants.ResultExtensionPropertyValueKeySampleCode] :
                                           string.Empty;

            chemistryFileData.Prefix = propertyValueDictionary.ContainsKey(ESDATChemistryConstants.ResultExtensionPropertyValueKeyPrefix) ?
                                       propertyValueDictionary[ESDATChemistryConstants.ResultExtensionPropertyValueKeyPrefix] :
                                       string.Empty;

            chemistryFileData.TotalOrFiltered = propertyValueDictionary.ContainsKey(ESDATChemistryConstants.ResultExtensionPropertyValueKeyTotalOrFiltered) ?
                                                propertyValueDictionary[ESDATChemistryConstants.ResultExtensionPropertyValueKeyTotalOrFiltered] :
                                                string.Empty;

            chemistryFileData.ResultType = propertyValueDictionary.ContainsKey(ESDATChemistryConstants.ResultExtensionPropertyValueKeyResultType) ?
                                           propertyValueDictionary[ESDATChemistryConstants.ResultExtensionPropertyValueKeyResultType] :
                                           string.Empty;

            chemistryFileData.EQL = propertyValueDictionary.ContainsKey(ESDATChemistryConstants.ResultExtensionPropertyValueKeyEQL) ?
                                    MappingHelper.ToNullableDouble(propertyValueDictionary[ESDATChemistryConstants.ResultExtensionPropertyValueKeyEQL]) :
                                    null;

            chemistryFileData.EQLUnits = propertyValueDictionary.ContainsKey(ESDATChemistryConstants.ResultExtensionPropertyValueKeyEQLUnits) ?
                                         propertyValueDictionary[ESDATChemistryConstants.ResultExtensionPropertyValueKeyEQLUnits] :
                                         string.Empty;

            chemistryFileData.Comments = propertyValueDictionary.ContainsKey(ESDATChemistryConstants.ResultExtensionPropertyValueKeyComments) ? propertyValueDictionary[ESDATChemistryConstants.ResultExtensionPropertyValueKeyComments] : string.Empty;
            chemistryFileData.UCL      = propertyValueDictionary.ContainsKey(ESDATChemistryConstants.ResultExtensionPropertyValueKeyUCL) ? MappingHelper.ToNullableDouble(propertyValueDictionary[ESDATChemistryConstants.ResultExtensionPropertyValueKeyUCL]) : null;
            chemistryFileData.LCL      = propertyValueDictionary.ContainsKey(ESDATChemistryConstants.ResultExtensionPropertyValueKeyLCL) ? MappingHelper.ToNullableDouble(propertyValueDictionary[ESDATChemistryConstants.ResultExtensionPropertyValueKeyLCL]) : null;

            return(chemistryFileData);
        }