public void SampleFileDataConstructorTest()
        {
            var sampleFileData = new SampleFileData("test sample code",
                                                    new DateTime(2015, 5, 26),
                                                    "test field ID",
                                                    1.0,
                                                    "test matrix type",
                                                    "test sample type",
                                                    "test parent sample",
                                                    "sdg",
                                                    "test lab name",
                                                    "test lab sample ID",
                                                    "test comment",
                                                    "test lab report number");

            Assert.NotNull(sampleFileData);
            Assert.AreEqual("test sample code", sampleFileData.SampleCode);
            Assert.AreEqual(new DateTime(2015, 5, 26), sampleFileData.SampledDateTime);
            Assert.AreEqual("test field ID", sampleFileData.FieldID);
            Assert.AreEqual(1.0, sampleFileData.SampleDepth);
            Assert.AreEqual("test matrix type", sampleFileData.MatrixType);
            Assert.AreEqual("test sample type", sampleFileData.SampleType);
            Assert.AreEqual("test parent sample", sampleFileData.ParentSample);
            Assert.AreEqual("sdg", sampleFileData.SDG);
            Assert.AreEqual("test lab name", sampleFileData.LabName);
            Assert.AreEqual("test lab sample ID", sampleFileData.LabSampleID);
            Assert.AreEqual("test comment", sampleFileData.Comments);
            Assert.AreEqual("test lab report number", sampleFileData.LabReportNumber);
        }
コード例 #2
0
        private static 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;
        }
コード例 #3
0
        private static SampleFileData MapSampleFileData(Hatfield.EnviroData.Core.Action actionData, Result sampleResultDomain)
        {
            if (sampleResultDomain != null)
            {

                var sampleFileData = new SampleFileData();
                sampleFileData.SampledDateTime = sampleResultDomain.ResultDateTime;

                try
                {
                    sampleFileData.LabName = actionData.Method.Organization.OrganizationName;
                }
                catch (NullReferenceException)
                {
                    sampleFileData.LabName = null;
                }

                //Map data from extension properties
                sampleFileData = MapFromExtensionProperties(sampleFileData, sampleResultDomain.ResultExtensionPropertyValues);

                return sampleFileData;


            }
            else
            {
                return null;
            }
        }