private void LoadRow(string sheetName, Dictionary <string, string> values) { ValidationIssues issues = generalDet.ValidationIssues; if (sheetName == "DET_PreySurveys") { PreySurveyDTO newDto = new PreySurveyDTO(values); newDto.Validate(); issues.Merge(newDto.ValidationIssues); bool success = generalDet.PreySurveys.Add(newDto); if (!success) { issues.Add(ValidationIssue.Code.NonUniqueKeyCode, string.Format("The prey survey with code {0} is not unique.", newDto.LookupKey)); } } else if (sheetName == "DET_Prey") { PreyDTO newDto = new PreyDTO(values); newDto.Validate(); issues.Merge(newDto.ValidationIssues); bool success = generalDet.Prey.Add(newDto); if (!success) { issues.Add(ValidationIssue.Code.NonUniqueKeyCode, string.Format("The prey 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)); } } else if (sheetName == "LIST_Species") { SpeciesDTO newDto = new SpeciesDTO(values); newDto.Validate(); issues.Merge(newDto.ValidationIssues); bool success = generalDet.Species.Add(newDto); if (!success) { issues.Add(ValidationIssue.Code.NonUniqueKeyCode, string.Format("The species with code {0} is not unique.", newDto.LookupKey)); } } //else if (sheetName == "LIST_LifeStages") //{ // LifeStageDTO newDto = new LifeStageDTO(values); // newDto.Validate(); // issues.Merge(newDto.ValidationIssues); // bool success = generalDet.LifeStages.Add(newDto); // if (!success) // { // issues.Add(ValidationIssue.Code.NonUniqueKeyCode, string.Format("The life stage with code {0} is not unique.", newDto.LookupKey)); // } //} }
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)); } } }
private void LoadRow(string sheetName, Dictionary <string, string> values) { ValidationIssues issues = generalDet.ValidationIssues; if (sheetName == "DET_CatchEffort") { CatchEffortDTO newDto = new CatchEffortDTO(values); newDto.Validate(); issues.Merge(newDto.ValidationIssues); bool success = generalDet.CatchEfforts.Add(newDto); if (!success) { issues.Add(ValidationIssue.Code.NonUniqueKeyCode, string.Format("The catch effort with code {0} is not unique.", newDto.LookupKey)); } } else if (sheetName == "DET_NetHaulEvent") { NetHaulEventDTO newDto = new NetHaulEventDTO(values); newDto.Validate(); issues.Merge(newDto.ValidationIssues); bool success = generalDet.NetHaulEvents.Add(newDto); if (!success) { issues.Add(ValidationIssue.Code.NonUniqueKeyCode, string.Format("The net haul event with code {0} is not unique.", newDto.LookupKey)); } } else if (sheetName == "DET_FishCount") { FishCountDTO newDto = new FishCountDTO(values); newDto.Validate(); issues.Merge(newDto.ValidationIssues); bool success = generalDet.FishCounts.Add(newDto); if (!success) { issues.Add(ValidationIssue.Code.NonUniqueKeyCode, string.Format("The fish count with code {0} is not unique.", newDto.LookupKey)); } } else if (sheetName == "DET_CatchMetric") { CatchMetricDTO newDto = new CatchMetricDTO(values); newDto.Validate(); issues.Merge(newDto.ValidationIssues); bool success = generalDet.CatchMetrics.Add(newDto); if (!success) { issues.Add(ValidationIssue.Code.NonUniqueKeyCode, string.Format("The catch metric with code {0} is not unique.", newDto.LookupKey)); } } else if (sheetName == "DET_Fish") { FishDTO newDto = new FishDTO(values); newDto.Validate(); issues.Merge(newDto.ValidationIssues); bool success = generalDet.Fish.Add(newDto); if (!success) { issues.Add(ValidationIssue.Code.NonUniqueKeyCode, string.Format("The fish with code {0} is not unique.", newDto.LookupKey)); } } else if (sheetName == "DET_IdTags") { IdTagDTO newDto = new IdTagDTO(values); newDto.Validate(); issues.Merge(newDto.ValidationIssues); bool success = generalDet.IdTags.Add(newDto); if (!success) { issues.Add(ValidationIssue.Code.NonUniqueKeyCode, string.Format("The ID tag with code {0} is not unique.", newDto.LookupKey)); } } else if (sheetName == "DET_Genetics") { GeneticDTO newDto = new GeneticDTO(values); newDto.Validate(); issues.Merge(newDto.ValidationIssues); bool success = generalDet.Genetics.Add(newDto); if (!success) { issues.Add(ValidationIssue.Code.NonUniqueKeyCode, string.Format("The genetic with code {0} is not unique.", newDto.LookupKey)); } } else if (sheetName == "DET_Diet") { DietDTO newDto = new DietDTO(values); newDto.Validate(); issues.Merge(newDto.ValidationIssues); bool success = generalDet.Diet.Add(newDto); if (!success) { issues.Add(ValidationIssue.Code.NonUniqueKeyCode, string.Format("The diet with code {0} is not unique.", newDto.LookupKey)); } } else if (sheetName == "LIST_FishSpecies") { FishSpeciesDTO newDto = new FishSpeciesDTO(values); newDto.Validate(); issues.Merge(newDto.ValidationIssues); bool success = generalDet.FishSpecies.Add(newDto); if (!success) { issues.Add(ValidationIssue.Code.NonUniqueKeyCode, string.Format("The fish-species with code {0} is not unique.", newDto.LookupKey)); } } else if (sheetName == "LIST_MacroSpecies") { MacroSpeciesDTO newDto = new MacroSpeciesDTO(values); newDto.Validate(); issues.Merge(newDto.ValidationIssues); bool success = generalDet.MacroSpecies.Add(newDto); if (!success) { issues.Add(ValidationIssue.Code.NonUniqueKeyCode, string.Format("The macro-species 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)); } } else if (sheetName == "LIST_Nets") { NetDTO newDto = new NetDTO(values); newDto.Validate(); issues.Merge(newDto.ValidationIssues); bool success = generalDet.Nets.Add(newDto); if (!success) { issues.Add(ValidationIssue.Code.NonUniqueKeyCode, string.Format("The net with code {0} is not unique.", newDto.LookupKey)); } } }
private void LoadRow(string sheetName, Dictionary <string, string> values) { ValidationIssues issues = generalDet.ValidationIssues; if (sheetName == "DET_Survey") { VegSurveyDTO newDto = new VegSurveyDTO(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_Tree") { VegTreeDTO newDto = new VegTreeDTO(values); newDto.Validate(); issues.Merge(newDto.ValidationIssues); bool success = generalDet.Trees.Add(newDto); if (!success) { issues.Add(ValidationIssue.Code.NonUniqueKeyCode, string.Format("The measurment with code {0} is not unique.", newDto.LookupKey)); } } else if (sheetName == "DET_Herb") { VegHerbDTO newDto = new VegHerbDTO(values); newDto.Validate(); issues.Merge(newDto.ValidationIssues); bool success = generalDet.Herbs.Add(newDto); if (!success) { issues.Add(ValidationIssue.Code.NonUniqueKeyCode, string.Format("The measurment with code {0} is not unique.", newDto.LookupKey)); } } else if (sheetName == "DET_Shrub") { VegShrubDTO newDto = new VegShrubDTO(values); newDto.Validate(); issues.Merge(newDto.ValidationIssues); bool success = generalDet.Shrubs.Add(newDto); if (!success) { issues.Add(ValidationIssue.Code.NonUniqueKeyCode, string.Format("The measurment with code {0} is not unique.", newDto.LookupKey)); } } else if (sheetName == "DET_Elevation") { VegElevationDTO newDto = new VegElevationDTO(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_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)); } } else if (sheetName == "LIST_PlotTypes") { PlotTypeDTO newDto = new PlotTypeDTO(values); newDto.Validate(); issues.Merge(newDto.ValidationIssues); bool success = generalDet.PlotTypes.Add(newDto); if (!success) { issues.Add(ValidationIssue.Code.NonUniqueKeyCode, string.Format("The plottype with code {0} is not unique.", newDto.LookupKey)); } } else if (sheetName == "LIST_NonLiving") { SpeciesDTO newDto = new SpeciesDTO(values); newDto.Validate(); issues.Merge(newDto.ValidationIssues); bool success = generalDet.NonLiving.Add(newDto); if (!success) { issues.Add(ValidationIssue.Code.NonUniqueKeyCode, string.Format("The nonliving with code {0} is not unique.", newDto.LookupKey)); } } else if (sheetName == "LIST_TreeSpecies") { SpeciesDTO newDto = new SpeciesDTO(values); newDto.Validate(); issues.Merge(newDto.ValidationIssues); bool success = generalDet.TreeSpecies.Add(newDto); if (!success) { issues.Add(ValidationIssue.Code.NonUniqueKeyCode, string.Format("The taxa with code {0} is not unique.", newDto.LookupKey)); } } else if (sheetName == "LIST_HerbSpecies") { SpeciesDTO newDto = new SpeciesDTO(values); newDto.Validate(); issues.Merge(newDto.ValidationIssues); bool success = generalDet.HerbSpecies.Add(newDto); if (!success) { issues.Add(ValidationIssue.Code.NonUniqueKeyCode, string.Format("The taxa with code {0} is not unique.", newDto.LookupKey)); } } else if (sheetName == "LIST_ShrubSpecies") { SpeciesDTO newDto = new SpeciesDTO(values); newDto.Validate(); issues.Merge(newDto.ValidationIssues); bool success = generalDet.ShrubSpecies.Add(newDto); if (!success) { issues.Add(ValidationIssue.Code.NonUniqueKeyCode, string.Format("The taxa with code {0} is not unique.", newDto.LookupKey)); } } }