private void LoadRow(string sheetName, Dictionary <string, string> values) { ValidationIssues issues = generalDet.ValidationIssues; if (sheetName == "DET_Deployments") { DeploymentDTO newDto = new DeploymentDTO(values); newDto.Validate(); //issues.Merge(newDto.ValidationIssues); issues.Add(newDto.ValidationIssues.Collapse("Deployment " + newDto.DeployCode)); bool success = generalDet.Deployments.Add(newDto); if (!success) { issues.Add(ValidationIssue.Code.NonUniqueKeyCode, string.Format("The deployment with code {0} is not unique.", newDto.LookupKey)); } } else if (sheetName == "DET_Measurements") { values["measuredatetime"] = ExcelBaseDet.ParseDate(values["measuredatetime"]); MeasurementDTO newDto = new MeasurementDTO(values); newDto.Validate(); //issues.Merge(newDto.ValidationIssues); issues.Add(newDto.ValidationIssues.Collapse("Measurement " + newDto.DeployCode + " " + newDto.MeasureDateTime)); bool success = generalDet.Measurements.Add(newDto); if (!success) { issues.Add(ValidationIssue.Code.NonUniqueKeyCode, string.Format("The measurment with code {0} is not unique.", newDto.LookupKey)); } } else if (sheetName == "LIST_Sites") { SiteDTO newDto = new SiteDTO(values); newDto.Validate(); //issues.Merge(newDto.ValidationIssues); issues.Add(newDto.ValidationIssues.Collapse("Site " + newDto.Key)); bool success = generalDet.Sites.Add(newDto); if (!success) { issues.Add(ValidationIssue.Code.NonUniqueKeyCode, string.Format("The site with code {0} is not unique.", newDto.LookupKey)); } } else if (sheetName == "LIST_Sensors") { InstrumentDTO newDto = new InstrumentDTO(values); newDto.Validate(); //issues.Merge(newDto.ValidationIssues); issues.Add(newDto.ValidationIssues.Collapse("Instrument " + newDto.Key)); bool success = generalDet.Instruments.Add(newDto); if (!success) { issues.Add(ValidationIssue.Code.NonUniqueKeyCode, string.Format("The instrument with code {0} is not unique.", newDto.LookupKey)); } } }
private void LoadRow(string sheetName, Dictionary <string, string> values) { ValidationIssues issues = generalDet.ValidationIssues; if (sheetName == "DET_Surveys") { CrossSectionSurveyDTO newDto = new CrossSectionSurveyDTO(values); newDto.Validate(); issues.Merge(newDto.ValidationIssues); bool success = generalDet.Surveys.Add(newDto); if (!success) { issues.Add(ValidationIssue.Code.NonUniqueKeyCode, string.Format("The survey with code {0} is not unique.", newDto.LookupKey)); } } else if (sheetName == "DET_Elevations") { CrossSectionElevationDTO newDto = new CrossSectionElevationDTO(values); newDto.Validate(); issues.Merge(newDto.ValidationIssues); bool success = generalDet.Elevations.Add(newDto); if (!success) { issues.Add(ValidationIssue.Code.NonUniqueKeyCode, string.Format("The elevation with code {0} is not unique.", newDto.LookupKey)); } } else if (sheetName == "LIST_Instruments") { InstrumentDTO newDto = new InstrumentDTO(values); newDto.Validate(); issues.Merge(newDto.ValidationIssues); bool success = generalDet.Instruments.Add(newDto); if (!success) { issues.Add(ValidationIssue.Code.NonUniqueKeyCode, string.Format("The instrument with code {0} is not unique.", newDto.LookupKey)); } } else if (sheetName == "LIST_Sites") { SiteDTO newDto = new SiteDTO(values); newDto.Validate(); issues.Merge(newDto.ValidationIssues); bool success = generalDet.Sites.Add(newDto); if (!success) { issues.Add(ValidationIssue.Code.NonUniqueKeyCode, string.Format("The site with code {0} is not unique.", newDto.LookupKey)); } } }