Esempio n. 1
0
        private void CheckHeaders(XlWorksheet worksheet)
        {
            if (worksheet != null)
            {
                Schema        s;
                List <string> h;
                if (worksheet.Name == "DET_Deployments")
                {
                    s = DeploymentDTO.GetSchema();
                }
                else if (worksheet.Name == "DET_Measurements")
                {
                    s = MeasurementDTO.GetSchema();
                }
                else if (worksheet.Name == "LIST_Sites")
                {
                    s = SiteDTO.GetSchema();
                }
                else if (worksheet.Name == "LIST_Sensors")
                {
                    s = SensorDTO.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);
                }
            }
        }
Esempio n. 2
0
        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));
                }
            }
        }
Esempio n. 3
0
 public ExcelPreyAvailabilityDET(PreyAvailabilityDET det)
 {
     generalDet = det;
     myDet      = new ExcelBaseDet(det.Id, det.Owner);
 }
Esempio n. 4
0
        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);
                }
            }
        }
Esempio n. 5
0
 public ExcelFishDET(FishDET det)
 {
     generalDet = det;
     myDet      = new ExcelBaseDet(det.Id, det.Owner);
 }
 public ExcelSedimentAccretionDET(SedimentAccretionDET det)
 {
     generalDet = det;
     myDet      = new ExcelBaseDet(det.Id, det.Owner);
 }
Esempio n. 7
0
 public ExcelWaterQualityDET(WaterQualityDET det)
 {
     generalDet = det;
     myDet      = new ExcelBaseDet(det.Id, det.Owner);
 }
Esempio n. 8
0
 public ExcelCrossSectionDET(CrossSectionDET det)
 {
     generalDet = det;
     myDet      = new ExcelBaseDet(det.Id, det.Owner);
 }