コード例 #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);
                }
            }
        }
コード例 #2
0
ファイル: ExcelFishDET.cs プロジェクト: OSRS/Oncor_Base
        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);
                }
            }
        }