/// <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, Dictionary<string, IWell> Wells, Dictionary<int, Plant> 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) { //Find the well in the dictionary if (!Wells.TryGetValue((string)DR[SRC.WellIDHeader], out CurrentWell)) { //Add a new well if it was not found CurrentWell = new Well(DR[SRC.WellIDHeader].ToString()); CurrentWell.UsedForExtraction = true; Wells.Add(CurrentWell.ID, 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(PlantID, CurrentPlant); } PumpingIntake CurrentPumpingIntake = new PumpingIntake(CurrentIntake); 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]); } }
/// <summary> /// Read Extractions. /// The boolean set dates indicates whether the dates read from the DRWPLANTINTAKE table should be used as Pumpingstart /// and pumpingstop. /// </summary> /// <param name="Plants"></param> /// <param name="Wells"></param> public Dictionary<int, Plant> ReadPlants(Dictionary<string, IWell> Wells) { List<Plant> Plants = new List<Plant>(); Dictionary<int, Plant> DPlants = new Dictionary<int, Plant>(); JXL.ReadExtractions(); IWell CurrentWell; IIntake CurrentIntake = null; Plant CurrentPlant; List<Tuple<int, Plant>> SubPlants = new List<Tuple<int, Plant>>(); foreach (var Anlaeg in JXL.DRWPLANT) { CurrentPlant = new Plant(Anlaeg.PLANTID); DPlants.Add(Anlaeg.PLANTID, CurrentPlant); CurrentPlant.Name = Anlaeg.PLANTNAME; CurrentPlant.Address = Anlaeg.PLANTADDRESS; CurrentPlant.PostalCode = Anlaeg.PLANTPOSTALCODE; if (!Anlaeg.IsPERMITDATENull()) CurrentPlant.PermitDate = Anlaeg.PERMITDATE; if (!Anlaeg.IsPERMITEXPIREDATENull()) CurrentPlant.PermitExpiryDate = Anlaeg.PERMITEXPIREDATE; CurrentPlant.Permit = Anlaeg.PERMITAMOUNT; if (!Anlaeg.IsSUPPLANTNull()) SubPlants.Add(new Tuple<int, Plant>(Anlaeg.SUPPLANT, CurrentPlant)); //Loop the intakes. Only add intakes from wells already in table foreach (var IntakeData in Anlaeg.GetDRWPLANTINTAKERows()) { if (Wells.TryGetValue(IntakeData.BOREHOLENO, out CurrentWell)) { CurrentIntake = CurrentWell.Intakes.FirstOrDefault(var => var.IDNumber == IntakeData.INTAKENO); if (CurrentIntake != null) { PumpingIntake CurrentPumpingIntake = new PumpingIntake(CurrentIntake); CurrentPlant.PumpingIntakes.Add(CurrentPumpingIntake); if (!IntakeData.IsSTARTDATENull()) CurrentPumpingIntake.Start = IntakeData.STARTDATE; else CurrentPumpingIntake.Start = DateTime.MinValue; if (!IntakeData.IsENDDATENull()) CurrentPumpingIntake.End = IntakeData.ENDDATE; else CurrentPumpingIntake.End = DateTime.MaxValue; } } } } //Now attach the subplants foreach (Tuple<int, Plant> KVP in SubPlants) { Plant Upper; if (DPlants.TryGetValue(KVP.First, out Upper)) { Upper.SubPlants.Add(KVP.Second); foreach (PumpingIntake PI in KVP.Second.PumpingIntakes) { PumpingIntake d = Upper.PumpingIntakes.FirstOrDefault(var => var.Intake.well.ID == PI.Intake.well.ID); //Remove pumping intakes from upper plant if they are attached to lower plants. if (d != null) Upper.PumpingIntakes.Remove(d); } } } return DPlants; }