public static FishDTO CreatePhonyFish(int count) { FishDTO dto = new FishDTO(); dto.FishId = String.Format("FishId {0}", count); dto.CatchId = String.Format("CatchId {0}", count); dto.SpeciesId = String.Format("SpeciesId {0}", count); dto.LengthStandard = Parsing.ParseDouble(""); dto.LengthFork = Parsing.ParseDouble(""); dto.LengthTotal = Parsing.ParseDouble(""); dto.Mass = Parsing.ParseDouble(""); dto.AdClipped = Parsing.ParseBoolean("True"); dto.CodedWireTag = Parsing.ParseBoolean("True"); return(dto); }
static Compatibility LoadCompatibility(FishDTO mainFish, FishDTO selectedFish) { var sql = String.Format("select c.compatible " + "from compatibility c " + "inner join fish f1 " + "on c.fishone = f1.id " + "inner join fish f2 " + "on c.fishtwo = f2.id " + "where f1.name = '{0}' " + "and f2.name = '{1}';", mainFish.Name, selectedFish.Name); var compatible = ConnectionUtils.ExecuteCommand(new PostgreSQLConnection(), sql)[0][0]; return(new Compatibility(selectedFish, compatible)); }
public AnimalDTO ToAnimalDTO(Animal animal) { try { if (animal == null || !(animal is Fish)) { throw new ArgumentException("Пустой объект или не подходящего типа!!!"); } var animalDTO = new FishDTO(); animalDTO.Detachment = (animal as Fish).Detachment; animalDTO.Family = animal.Family; animalDTO.Genus = animal.Genus; animalDTO.Species = animal.Species; return(animalDTO); } catch (ArgumentException) { throw; } }
private DataTab FishDataTab() { return(new DataTab("DET_Fish", XlColor.White, FishDTO.GetSchema(), generalDet.Fish.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)); } } }
public Compatibility(FishDTO selectedFish, string compatible) { SelectedFish = selectedFish; Compatible = compatible; }