コード例 #1
0
        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));
                }
            }
        }
コード例 #2
0
 private DataTab ShrubDataTab()
 {
     return(new DataTab("DET_Shrub", XlColor.White, VegShrubDTO.GetSchema(), generalDet.Shrubs.Values));
 }