public static GeneticDTO CreatePhonyGenetic(int count) { GeneticDTO dto = new GeneticDTO(); dto.FishId = String.Format("FishId {0}", count); dto.GeneticSampleId = String.Format("GeneticSampleId {0}", count); dto.LabSampleId = String.Format("LabSampleId {0}", count); dto.BestStockEstimate = String.Format("BestStockEstimate {0}", count); dto.ProbabilityBest = Parsing.ParseDouble(""); dto.SecondStockEstimate = String.Format("SecondStockEstimate {0}", count); dto.ProbabilitySecondBest = Parsing.ParseDouble(""); dto.ThirdStockEstimate = String.Format("ThirdStockEstimate {0}", count); dto.ProbabilityThirdBest = Parsing.ParseDouble(""); dto.Comments = String.Format("Comments {0}", count); return(dto); }
private DataTab GeneticsDataTab() { return(new DataTab("DET_Genetics", XlColor.White, GeneticDTO.GetSchema(), generalDet.Genetics.Values)); }
private void CheckHeaders(XlWorksheet worksheet) { if (worksheet != null) { Schema s; List <string> h; if (worksheet.Name == "DET_CatchEffort") { s = CatchEffortDTO.GetSchema(); } else if (worksheet.Name == "DET_NetHaulEvent") { s = NetHaulEventDTO.GetSchema(); } else if (worksheet.Name == "DET_FishCount") { s = FishCountDTO.GetSchema(); } else if (worksheet.Name == "DET_CatchMetric") { s = CatchMetricDTO.GetSchema(); } else if (worksheet.Name == "DET_Fish") { s = FishDTO.GetSchema(); } else if (worksheet.Name == "DET_IdTags") { s = IdTagDTO.GetSchema(); } else if (worksheet.Name == "DET_Genetics") { s = GeneticDTO.GetSchema(); } else if (worksheet.Name == "DET_Diet") { s = DietDTO.GetSchema(); } else if (worksheet.Name == "LIST_FishSpecies") { s = FishSpeciesDTO.GetSchema(); } else if (worksheet.Name == "LIST_MacroSpecies") { s = MacroSpeciesDTO.GetSchema(); } else if (worksheet.Name == "LIST_Sites") { s = SiteDTO.GetSchema(); } else if (worksheet.Name == "LIST_Nets") { s = NetDTO.GetSchema(); } else { return; } h = new List <string>(); List <string> hdrs = ExcelBaseDet.Headers(worksheet); bool bad = false; for (int i = 0; i < hdrs.Count - 1; i++) { string t = hdrs[i]; for (int j = i + 1; j < hdrs.Count; j++) { if (t == hdrs[j]) { bad = true; break; //inner } } if (bad) { break; //outer } } if (bad) { generalDet.ValidationIssues.Add(ValidationIssue.Code.DuplicateHeader, "Duplicate column header in " + worksheet.Name); } foreach (SchemaEntry c in s) { h.Add(c.LowerColumnName); } if (!ExcelBaseDet.HasHeaders(hdrs, h)) { generalDet.ValidationIssues.Add(ValidationIssue.Code.MissingFieldHeader, "Missing column header in " + worksheet.Name); } } }
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)); } } }