/// <summary> /// Creates wells from DataRows based on ShapeReaderConfiguration /// </summary> /// <param name="DS"></param> /// <param name="SRC"></param> public static void FillInFromNovanaShape(DataRow[] DS, ShapeReaderConfiguration SRC, IWellCollection Wells, IPlantCollection Plants) { bool ReadPumpActivity = false; bool ReadPlants = false; bool ReadLayer = false; if (DS.First().Table.Columns.Contains(SRC.FraAArHeader) & DS.First().Table.Columns.Contains(SRC.TilAArHeader)) ReadPumpActivity = true; if (DS.First().Table.Columns.Contains(SRC.LayerHeader)) ReadLayer = true; if (Plants != null) if (DS.First().Table.Columns.Contains(SRC.PlantIDHeader)) ReadPlants = true; IWell CurrentWell; IIntake CurrentIntake; foreach (DataRow DR in DS) { string wellID = DR[SRC.WellIDHeader].ToString(); //Find the well in the dictionary if (Wells.Contains(wellID)) { CurrentWell = Wells[wellID]; } else { //Add a new well if it was not found CurrentWell = new Well(wellID); CurrentWell.UsedForExtraction = true; Wells.Add(CurrentWell); } int intakeno = Convert.ToInt32(DR[SRC.IntakeNumber]); CurrentIntake = CurrentWell.Intakes.FirstOrDefault(var => var.IDNumber == intakeno); if (CurrentIntake == null) CurrentIntake = CurrentWell.AddNewIntake(intakeno); if (ReadLayer) if (!Convert.IsDBNull(DR[SRC.LayerHeader])) CurrentIntake.Layer = Convert.ToInt32(DR[SRC.LayerHeader]); if (ReadPlants) { Plant CurrentPlant; int PlantID = Convert.ToInt32(DR[SRC.PlantIDHeader]); if (!Plants.TryGetValue(PlantID, out CurrentPlant)) { CurrentPlant = new Plant(PlantID); Plants.Add(CurrentPlant); } PumpingIntake CurrentPumpingIntake = new PumpingIntake(CurrentIntake, CurrentPlant); CurrentPlant.PumpingIntakes.Add(CurrentPumpingIntake); if (ReadPumpActivity) { CurrentPumpingIntake.Start = new DateTime(Convert.ToInt32(DR[SRC.FraAArHeader]), 1, 1); CurrentPumpingIntake.End = new DateTime(Convert.ToInt32(DR[SRC.TilAArHeader]), 12, 31); } } CurrentWell.X = Convert.ToDouble(DR[SRC.XHeader]); CurrentWell.Y = Convert.ToDouble(DR[SRC.YHeader]); CurrentWell.Terrain = Convert.ToDouble(DR[SRC.TerrainHeader]); Screen CurrentScreen = new Screen(CurrentIntake); CurrentScreen.BottomAsKote = Convert.ToDouble(DR[SRC.BOTTOMHeader]); CurrentScreen.TopAsKote = Convert.ToDouble(DR[SRC.TOPHeader]); } }
private static DataRow GetFirstRow(DataTable table) { DataRow[] rows = new DataRow[table.Rows.Count]; table.Rows.CopyTo(rows, 0); return rows.First(); }