/// <summary> /// Opens a Jupiter database and reads requested data /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void ReadJupiter(string FileName) { DataBaseFileName = FileName; CanReadJupiter = false; CanReadMikeShe = true; Reader R = new Reader(FileName); Task t = Task.Factory.StartNew(() => wells = R.ReadWellsInSteps()); t.Wait(); //Start reading the remaining well data Task t4 = Task.Factory.StartNew(() => R.ReadLithology(wells)); JupiterXLFastReader jxf = new JupiterXLFastReader(FileName); CVM.SetDataBaseConnection(jxf); Task t5 = Task.Factory.StartNew(() => jxf.ReadWaterLevels(wells)); t5.ContinueWith((tt) => WellsRead()); //Read plants Task t2 = Task.Factory.StartNew(() => Plants = R.ReadPlants(wells)); t2.Wait(); BuildPlantList(); var t3 = t2.ContinueWith((tt) => R.FillInExtractionWithCount(Plants)); t3.ContinueWith((tt) => PlantsRead()); }
/// <summary> /// Reads all water levels and assign them to the wells in the collection /// </summary> /// <param name="Wells"></param> public void ReadWaterLevels(IWellCollection Wells) { IWell CurrentWell = Wells.FirstOrDefault(); IIntake CurrentIntake; JXL.ReadWaterLevels(false); foreach (var WatLev in JXL.WATLEVEL) { if (CurrentWell.ID == WatLev.BOREHOLENO) { CurrentIntake = CurrentWell.Intakes.FirstOrDefault(var => var.IDNumber == WatLev.INTAKENO) as JupiterIntake; if (CurrentIntake is JupiterIntake) { ((JupiterIntake)CurrentIntake).RefPoint = WatLev.REFPOINT; } FillInWaterLevel(CurrentIntake, WatLev); } else { if (Wells.Contains(WatLev.BOREHOLENO)) { CurrentIntake = Wells[WatLev.BOREHOLENO].Intakes.FirstOrDefault(var => var.IDNumber == WatLev.INTAKENO) as JupiterIntake; if (CurrentIntake is JupiterIntake) { ((JupiterIntake)CurrentIntake).RefPoint = WatLev.REFPOINT; } FillInWaterLevel(CurrentIntake, WatLev); } } } JXL.WATLEVEL.Clear(); }
/// <summary> /// Read in water levels from a Jupiter access database. /// Entries with blank dates of waterlevels are skipped. /// </summary> /// <param name="DataBaseFile"></param> /// <param name="CreateWells"></param> public void Waterlevels(IWellCollection Wells, bool OnlyRo) { JXL.ReadWaterLevels(OnlyRo); foreach (var WatLev in JXL.WATLEVEL) { //Find the well in the dictionary if (Wells.Contains(WatLev.BOREHOLENO)) { IIntake I = Wells[WatLev.BOREHOLENO].Intakes.FirstOrDefault(var => var.IDNumber == WatLev.INTAKENO); if (I != null) { FillInWaterLevel(I, WatLev); } } } JXL.WATLEVEL.Clear(); foreach (Well W in Wells) { foreach (Intake I in W.Intakes) { I.HeadObservations.Sort(); } } }
private void buttonReadMshe_Click(object sender, EventArgs e) { openFileDialog2.Filter = "Known file types (*.she)|*.she"; openFileDialog2.ShowReadOnly = true; openFileDialog2.Title = "Select a .she file with MikeShe setup"; if (openFileDialog2.ShowDialog() == DialogResult.OK) { LC.MikeSheFileName = openFileDialog2.FileName; if (Wells == null) { Wells = new IWellCollection(); foreach (IWell W in HeadObservations.ReadInDetailedTimeSeries(LC.MShe)) { Wells.Add(W); } LC.Wells = Wells; } LC.DistributeIntakesOnLayers(); if (LC.WellsOutSideModelDomain.Count > 0) { if (DialogResult.Yes == MessageBox.Show(LC.WellsOutSideModelDomain.Count + " wells found outside horizontal MikeShe model domain.\n Remove these wells from list?", "Wells outside model domain", MessageBoxButtons.YesNo)) { foreach (IWell W in LC.WellsOutSideModelDomain) { Wells.Remove(W.ID); } } } UpdateListsAndListboxes(); } }
/// <summary> /// Opens a Jupiter database and reads requested data /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ReadButton_Click(object sender, EventArgs e) { openFileDialog2.Filter = "Known file types (*.mdb)|*.mdb"; this.openFileDialog2.ShowReadOnly = true; this.openFileDialog2.Title = "Select an Access file with data in JupiterXL format"; if (openFileDialog2.ShowDialog() == DialogResult.OK) { JupiterFilter jd = new JupiterFilter(); jd.ReadWells = (Wells == null); string FileName = openFileDialog2.FileName; if (DialogResult.OK == jd.ShowDialog()) { JupiterReader = new Reader(FileName); if (Wells == null) { Wells = JupiterReader.WellsForNovana(jd.ReadLithology, jd.ReadPejlinger, jd.ReadChemistry, jd.OnlyRo); LC.Wells = Wells; } else { if (jd.ReadPejlinger) { JupiterReader.Waterlevels(Wells, jd.OnlyRo); } } if (jd.ReadExtration) { if (DPlants == null) { DPlants = JupiterReader.ReadPlants(Wells); } JupiterReader.FillInExtraction(DPlants); if (jd.ReadWells) { buttonNovanaExtract.Enabled = true; } buttonMsheExt.Enabled = true; } if (jd.ReadPejlinger) { if (jd.ReadWells) { buttonNovanaShape.Enabled = true; } buttonLSFile.Enabled = true; buttonMSheObs.Enabled = true; } UpdateListsAndListboxes(); } } }
public SiteViewModel( GeoRefData Area, IWellCollection Wells) { area = Area; site = area.Geometry as XYPolygon; this.Wells = Wells; DisplayName = Area.Data[0].ToString(); Samples = new ObservableCollection<Sample>(); }
public SiteViewModel(GeoRefData Area, IWellCollection Wells) { area = Area; site = area.Geometry as XYPolygon; this.Wells = Wells; DisplayName = Area.Data[0].ToString(); Samples = new ObservableCollection <Sample>(); }
/// <summary> /// Opens a Jupiter database and reads requested data /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ReadButton_Click(object sender, EventArgs e) { openFileDialog2.Filter = "Known file types (*.mdb)|*.mdb"; this.openFileDialog2.ShowReadOnly = true; this.openFileDialog2.Title = "Select an Access file with data in JupiterXL format"; if (openFileDialog2.ShowDialog() == DialogResult.OK) { JupiterFilter jd = new JupiterFilter(); jd.ReadWells = (Wells == null); string FileName = openFileDialog2.FileName; if (DialogResult.OK == jd.ShowDialog()) { JupiterReader = new Reader(FileName); if (Wells == null) { Wells = JupiterReader.WellsForNovana(jd.ReadLithology, jd.ReadPejlinger, jd.ReadChemistry, jd.OnlyRo); LC.Wells = Wells; } else { if (jd.ReadPejlinger) { JupiterReader.Waterlevels(Wells, jd.OnlyRo); } } if (jd.ReadExtration) { if (DPlants == null) DPlants = JupiterReader.ReadPlants(Wells); JupiterReader.FillInExtraction(DPlants); if (jd.ReadWells) buttonNovanaExtract.Enabled = true; buttonMsheExt.Enabled = true; } if (jd.ReadPejlinger) { if (jd.ReadWells) buttonNovanaShape.Enabled = true; buttonLSFile.Enabled = true; buttonMSheObs.Enabled = true; } UpdateListsAndListboxes(); } } }
/// <summary> /// Read in water levels from a Jupiter access database. /// Entries with blank dates of waterlevels are skipped. /// </summary> /// <param name="DataBaseFile"></param> /// <param name="CreateWells"></param> public void Waterlevels(IWellCollection Wells, bool OnlyRo) { JXL.ReadWaterLevels(OnlyRo); foreach (var WatLev in JXL.WATLEVEL) { //Find the well in the dictionary if (Wells.Contains(WatLev.BOREHOLENO)) { IIntake I = Wells[WatLev.BOREHOLENO].Intakes.FirstOrDefault(var => var.IDNumber == WatLev.INTAKENO); if (I != null) FillInWaterLevel(I, WatLev); } } JXL.WATLEVEL.Clear(); foreach (Well W in Wells) foreach (Intake I in W.Intakes) I.HeadObservations.Sort(); }
/// <summary> /// Reads the lithology and assign to all the JupiterWells in the collection /// </summary> /// <param name="Wells"></param> public void ReadLithology(IWellCollection Wells) { JupiterWell CurrentWell; JXL.ReadInLithology(); CurrentWell = Wells.FirstOrDefault() as JupiterWell; //Loop the lithology foreach (var Lith in JXL.LITHSAMP) { if (CurrentWell.ID == Lith.BOREHOLENO) { Lithology L = new Lithology(); L.Bottom = Lith.BOTTOM; L.Top = Lith.TOP; L.RockSymbol = Lith.ROCKSYMBOL; L.RockType = Lith.ROCKTYPE; L.TotalDescription = Lith.TOTALDESCR; CurrentWell.LithSamples.Add(L); } else { if (Wells.Contains(Lith.BOREHOLENO)) { CurrentWell = Wells[Lith.BOREHOLENO] as JupiterWell; Lithology L = new Lithology(); L.Bottom = Lith.BOTTOM; L.Top = Lith.TOP; L.RockSymbol = Lith.ROCKSYMBOL; L.RockType = Lith.ROCKTYPE; L.TotalDescription = Lith.TOTALDESCR; CurrentWell.LithSamples.Add(L); } } } JXL.LITHSAMP.Clear(); }
/// <summary> /// Applies the change in the description to a plant or a well. /// Returns true if the change could be applied. /// No checks on previous values or dates. /// </summary> /// <param name="plants"></param> /// <param name="wells"></param> /// <param name="cd"></param> /// <returns></returns> public bool ApplySingleChange(IPlantCollection plants, IWellCollection wells, ChangeDescription cd) { string wellid = ""; int plantid; int intakeno = -1; IWell CurrentWell; bool succeded = false; switch (cd.Table) { case JupiterTables.BOREHOLE: wellid = cd.PrimaryKeys["BOREHOLENO"]; if (wells.TryGetValue(wellid, out CurrentWell)) { foreach (var c in cd.ChangeValues) { switch (c.Column.ToUpper()) { case "XUTM": CurrentWell.X = double.Parse(c.NewValue); succeded = true; break; case "YUTM": CurrentWell.Y = double.Parse(c.NewValue); succeded = true; break; case "ELEVATION": CurrentWell.Terrain = double.Parse(c.NewValue); succeded = true; break; default: break; } } } break; case JupiterTables.SCREEN: wellid = cd.PrimaryKeys["BOREHOLENO"]; if (wells.TryGetValue(wellid, out CurrentWell)) { int screenNumber = int.Parse(cd.PrimaryKeys["SCREENNO"]); if (cd.Action == TableAction.EditValue) { var screen = CurrentWell.Intakes.SelectMany(var => var.Screens).FirstOrDefault(var2 => var2.Number == screenNumber); if (screen != null) { foreach (var cv in cd.ChangeValues) { if (cv.Column == "TOP") screen.DepthToTop = double.Parse(cv.NewValue); else if (cv.Column == "BOTTOM") screen.DepthToBottom = double.Parse(cv.NewValue); succeded = true; } } } else if (cd.Action == TableAction.InsertRow) { intakeno = int.Parse(cd.ChangeValues.Single(var => var.Column == "INTAKENO").NewValue); IIntake CurrentIntake = CurrentWell.Intakes.Single(var => var.IDNumber == intakeno); if (CurrentIntake != null) { Screen sc = new Screen(CurrentIntake); sc.DepthToTop = double.Parse(cd.ChangeValues.Single(var => var.Column == "TOP").NewValue); sc.DepthToBottom = double.Parse(cd.ChangeValues.Single(var => var.Column == "BOTTOM").NewValue); succeded = true; } } } break; case JupiterTables.DRWPLANTINTAKE: if (cd.Action == TableAction.EditValue || cd.Action == TableAction.DeleteRow) { int tableid; if (int.TryParse(cd.PrimaryKeys.First().Value, out tableid)) { if (DataBaseConnection.TryGetPlant(tableid, out plantid, out wellid, out intakeno)) succeded = true; } else //No ID Change of a change { if (cd.Action == TableAction.EditValue) { if (int.TryParse(cd.ChangeValues[0].NewValue, out plantid)) { wellid = cd.ChangeValues[1].NewValue; if (int.TryParse(cd.ChangeValues[2].NewValue, out intakeno)) succeded = true; } } else if (int.TryParse(cd.ChangeValues[0].OldValue, out plantid)) { wellid = cd.ChangeValues[1].OldValue; if (int.TryParse(cd.ChangeValues[2].OldValue, out intakeno)) succeded = true; } } if (succeded) { var pi = plants[plantid].PumpingIntakes.FirstOrDefault(var => var.Intake.well.ID == wellid & var.Intake.IDNumber == intakeno); if (pi != null) { if (cd.Action == TableAction.DeleteRow) plants[plantid].PumpingIntakes.Remove(pi); else { var start = cd.ChangeValues.SingleOrDefault(var => var.Column == "STARTDATE"); if (start != null) pi.StartNullable = DateTime.Parse(start.NewValue); var end = cd.ChangeValues.SingleOrDefault(var => var.Column == "ENDDATE"); if (end != null) pi.EndNullable = DateTime.Parse(end.NewValue); } succeded = true; } } } else //insertrow { plantid = int.Parse(cd.ChangeValues.First(var => var.Column == "PLANTID").NewValue); Plant p; if (plants.TryGetValue(plantid, out p)) { wellid = cd.ChangeValues.First(var => var.Column == "BOREHOLENO").NewValue; IWell w; if (wells.TryGetValue(wellid, out w)) { intakeno = int.Parse(cd.ChangeValues.First(var => var.Column == "INTAKENO").NewValue); IIntake I = w.Intakes.First(var => var.IDNumber == intakeno); if (I != null) { PumpingIntake pi = new PumpingIntake(I, p); var s = cd.ChangeValues.FirstOrDefault(var => var.Column == "STARTDATE"); if (s != null) pi.StartNullable = DateTime.Parse(s.NewValue); s = cd.ChangeValues.FirstOrDefault(var => var.Column == "ENDDATE"); if (s != null) pi.EndNullable = DateTime.Parse(s.NewValue); p.PumpingIntakes.Add(pi); succeded = true; } } } } break; case JupiterTables.WATLEVEL: wellid = cd.PrimaryKeys["BOREHOLENO"]; if (wells.TryGetValue(wellid, out CurrentWell)) { DateTime TimeOfMeasure; int WatlevelNo = int.Parse(cd.PrimaryKeys["WATLEVELNO"]); if (DataBaseConnection.TryGetIntakeNoTimeOfMeas(CurrentWell, WatlevelNo, out intakeno, out TimeOfMeasure)) { IIntake CurrentIntake = CurrentWell.Intakes.SingleOrDefault(var => var.IDNumber == intakeno); if (CurrentIntake != null) { var item = CurrentIntake.HeadObservations.Items.FirstOrDefault(var => var.Time == TimeOfMeasure); if (item != null) { CurrentIntake.HeadObservations.Items.Remove(item); succeded = true; } } } } break; default: break; } return succeded; }
/// <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 IPlantCollection ReadPlants(IWellCollection Wells) { List <Plant> Plants = new List <Plant>(); IPlantCollection DPlants = new IPlantCollection(); JXL.ReadPlantData(); 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(CurrentPlant); if (Anlaeg.IsPLANTNAMENull()) { CurrentPlant.Name = "<no name in database>"; } else { CurrentPlant.Name = Anlaeg.PLANTNAME; } CurrentPlant.Address = Anlaeg.PLANTADDRESS; CurrentPlant.PostalCode = Anlaeg.PLANTPOSTALCODE; if (!Anlaeg.IsSUPPLANTNull()) { CurrentPlant.SuperiorPlantNumber = Anlaeg.SUPPLANT; } CurrentPlant.NewCommuneNumber = Anlaeg.MUNICIPALITYNO2007; CurrentPlant.OldCommuneNumber = Anlaeg.MUNICIPALITYNO; var cmp = Anlaeg.GetDRWPLANTCOMPANYTYPERows().LastOrDefault(); if (cmp != null) { CurrentPlant.CompanyType = cmp.COMPANYTYPE; } if (!Anlaeg.IsPERMITDATENull()) { CurrentPlant.PermitDate = Anlaeg.PERMITDATE; } if (!Anlaeg.IsPERMITEXPIREDATENull()) { CurrentPlant.PermitExpiryDate = Anlaeg.PERMITEXPIREDATE; } if (Anlaeg.IsPERMITAMOUNTNull()) { CurrentPlant.Permit = 0; } else { CurrentPlant.Permit = Anlaeg.PERMITAMOUNT; } if (!Anlaeg.IsSUPPLANTNull()) { SubPlants.Add(new Tuple <int, Plant>(Anlaeg.SUPPLANT, CurrentPlant)); } if (!Anlaeg.IsXUTMNull()) { CurrentPlant.X = Anlaeg.XUTM; } if (!Anlaeg.IsYUTMNull()) { CurrentPlant.Y = Anlaeg.YUTM; } //Loop the intakes. Only add intakes from wells already in table foreach (var IntakeData in Anlaeg.GetDRWPLANTINTAKERows()) { if (Wells.Contains(IntakeData.BOREHOLENO)) { JupiterWell jw = Wells[IntakeData.BOREHOLENO] as JupiterWell; CurrentIntake = jw.Intakes.FirstOrDefault(var => var.IDNumber == IntakeData.INTAKENO); if (CurrentIntake != null) { PumpingIntake CurrentPumpingIntake = new PumpingIntake(CurrentIntake, CurrentPlant); CurrentPlant.PumpingIntakes.Add(CurrentPumpingIntake); if (!IntakeData.IsSTARTDATENull()) { CurrentPumpingIntake.StartNullable = IntakeData.STARTDATE; } else if (jw.StartDate.HasValue) { CurrentPumpingIntake.StartNullable = jw.StartDate; } else if (CurrentIntake.Screens.Where(var => var.StartDate.HasValue).Count() != 0) { CurrentPumpingIntake.StartNullable = CurrentIntake.Screens.Where(var => var.StartDate.HasValue).Min(var => var.StartDate); } if (!IntakeData.IsENDDATENull()) { CurrentPumpingIntake.EndNullable = IntakeData.ENDDATE; } else if (jw.EndDate.HasValue) { CurrentPumpingIntake.EndNullable = jw.EndDate; } else if (CurrentIntake.Screens.Where(var => var.EndDate.HasValue).Count() != 0) { CurrentPumpingIntake.EndNullable = CurrentIntake.Screens.Where(var => var.EndDate.HasValue).Max(var => var.EndDate); } } } } } //Now attach the subplants foreach (Tuple <int, Plant> KVP in SubPlants) { Plant Upper; if (DPlants.TryGetValue(KVP.Item1, out Upper)) { if (Upper == KVP.Item2) { string l = "what"; } else { Upper.SubPlants.Add(KVP.Item2); foreach (PumpingIntake PI in KVP.Item2.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); } } } } } JXL.DRWPLANT.Dispose(); JXL.DRWPLANTINTAKE.Dispose(); return(DPlants); }
/// <summary> /// Opens a point shape /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button2_Click(object sender, EventArgs e) { openFileDialog2.Filter = "Known file types (*.shp)|*.shp"; this.openFileDialog2.ShowReadOnly = true; this.openFileDialog2.Title = "Select a shape file with data for wells or intakes"; if (openFileDialog2.ShowDialog() == DialogResult.OK) { string FileName = openFileDialog2.FileName; ShapeReader SR = new ShapeReader(FileName); DataTable FullDataSet = SR.Data.Read(); //Launch a data selector DataSelector DS = new DataSelector(FullDataSet); if (DS.ShowDialog() == DialogResult.OK) { if (ShpConfig == null) { XmlSerializer x = new XmlSerializer(typeof(ShapeReaderConfiguration)); string InstallationPath = Path.GetDirectoryName(this.GetType().Assembly.Location); string config = Path.Combine(InstallationPath, "ShapeReaderConfig.xml"); using (FileStream fs = new FileStream(config, FileMode.Open)) { ShpConfig = (ShapeReaderConfiguration)x.Deserialize(fs); if (CheckColumn(FullDataSet, ShpConfig.WellIDHeader, config)) { if (CheckColumn(FullDataSet, ShpConfig.IntakeNumber, config)) { if (CheckColumn(FullDataSet, ShpConfig.XHeader, config)) { if (CheckColumn(FullDataSet, ShpConfig.YHeader, config)) { if (CheckColumn(FullDataSet, ShpConfig.TOPHeader, config)) { if (CheckColumn(FullDataSet, ShpConfig.BOTTOMHeader, config)) { Wells = new IWellCollection(); if (FullDataSet.Columns.Contains(ShpConfig.PlantIDHeader)) { DPlants = new IPlantCollection(); HeadObservations.FillInFromNovanaShape(DS.SelectedRows, ShpConfig, Wells, DPlants); } else { HeadObservations.FillInFromNovanaShape(DS.SelectedRows, ShpConfig, Wells); } UpdateListsAndListboxes(); } } } } } } } } } SR.Dispose(); } }
/// <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]); } }
/// <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) { FillInFromNovanaShape(DS, SRC, Wells, null); }
/// <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 IPlantCollection ReadPlants(IWellCollection Wells) { List<Plant> Plants = new List<Plant>(); IPlantCollection DPlants = new IPlantCollection(); JXL.ReadPlantData(); 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(CurrentPlant); if (Anlaeg.IsPLANTNAMENull()) CurrentPlant.Name = "<no name in database>"; else CurrentPlant.Name = Anlaeg.PLANTNAME; CurrentPlant.Address = Anlaeg.PLANTADDRESS; CurrentPlant.PostalCode = Anlaeg.PLANTPOSTALCODE; if (!Anlaeg.IsSUPPLANTNull()) CurrentPlant.SuperiorPlantNumber = Anlaeg.SUPPLANT; CurrentPlant.NewCommuneNumber = Anlaeg.MUNICIPALITYNO2007; CurrentPlant.OldCommuneNumber = Anlaeg.MUNICIPALITYNO; var cmp =Anlaeg.GetDRWPLANTCOMPANYTYPERows().LastOrDefault(); if(cmp !=null) CurrentPlant.CompanyType = cmp.COMPANYTYPE; if (!Anlaeg.IsPERMITDATENull()) CurrentPlant.PermitDate = Anlaeg.PERMITDATE; if (!Anlaeg.IsPERMITEXPIREDATENull()) CurrentPlant.PermitExpiryDate = Anlaeg.PERMITEXPIREDATE; if (Anlaeg.IsPERMITAMOUNTNull()) CurrentPlant.Permit = 0; else CurrentPlant.Permit = Anlaeg.PERMITAMOUNT; if (!Anlaeg.IsSUPPLANTNull()) SubPlants.Add(new Tuple<int, Plant>(Anlaeg.SUPPLANT, CurrentPlant)); if (!Anlaeg.IsXUTMNull()) CurrentPlant.X = Anlaeg.XUTM; if (!Anlaeg.IsYUTMNull()) CurrentPlant.Y = Anlaeg.YUTM; //Loop the intakes. Only add intakes from wells already in table foreach (var IntakeData in Anlaeg.GetDRWPLANTINTAKERows()) { if (Wells.Contains(IntakeData.BOREHOLENO)) { JupiterWell jw = Wells[IntakeData.BOREHOLENO] as JupiterWell; CurrentIntake = jw.Intakes.FirstOrDefault(var => var.IDNumber == IntakeData.INTAKENO); if (CurrentIntake != null) { PumpingIntake CurrentPumpingIntake = new PumpingIntake(CurrentIntake, CurrentPlant); CurrentPlant.PumpingIntakes.Add(CurrentPumpingIntake); if (!IntakeData.IsSTARTDATENull()) CurrentPumpingIntake.StartNullable = IntakeData.STARTDATE; else if (jw.StartDate.HasValue) CurrentPumpingIntake.StartNullable = jw.StartDate; else if (CurrentIntake.Screens.Where(var => var.StartDate.HasValue).Count() != 0) CurrentPumpingIntake.StartNullable = CurrentIntake.Screens.Where(var => var.StartDate.HasValue).Min(var => var.StartDate); if (!IntakeData.IsENDDATENull()) CurrentPumpingIntake.EndNullable = IntakeData.ENDDATE; else if (jw.EndDate.HasValue) CurrentPumpingIntake.EndNullable = jw.EndDate; else if (CurrentIntake.Screens.Where(var => var.EndDate.HasValue).Count() != 0) CurrentPumpingIntake.EndNullable = CurrentIntake.Screens.Where(var => var.EndDate.HasValue).Max(var => var.EndDate); } } } } //Now attach the subplants foreach (Tuple<int, Plant> KVP in SubPlants) { Plant Upper; if (DPlants.TryGetValue(KVP.Item1, out Upper)) { if (Upper == KVP.Item2) { string l = "what"; } else { Upper.SubPlants.Add(KVP.Item2); foreach (PumpingIntake PI in KVP.Item2.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); } } } } JXL.DRWPLANT.Dispose(); JXL.DRWPLANTINTAKE.Dispose(); return DPlants; }
/// <summary> /// Reads all water levels and assign them to the wells in the collection /// </summary> /// <param name="Wells"></param> public void ReadWaterLevels(IWellCollection Wells) { IWell CurrentWell = Wells.FirstOrDefault(); IIntake CurrentIntake; JXL.ReadWaterLevels(false); foreach (var WatLev in JXL.WATLEVEL) { if (CurrentWell.ID == WatLev.BOREHOLENO) { CurrentIntake = CurrentWell.Intakes.FirstOrDefault(var => var.IDNumber == WatLev.INTAKENO) as JupiterIntake; if (CurrentIntake is JupiterIntake) ((JupiterIntake)CurrentIntake).RefPoint = WatLev.REFPOINT; FillInWaterLevel(CurrentIntake, WatLev); } else { if (Wells.Contains(WatLev.BOREHOLENO)) { CurrentIntake = Wells[WatLev.BOREHOLENO].Intakes.FirstOrDefault(var => var.IDNumber == WatLev.INTAKENO) as JupiterIntake; if (CurrentIntake is JupiterIntake) ((JupiterIntake)CurrentIntake).RefPoint = WatLev.REFPOINT; FillInWaterLevel(CurrentIntake, WatLev); } } } JXL.WATLEVEL.Clear(); }
/// <summary> /// Applies the change in the description to a plant or a well. /// Returns true if the change could be applied. /// No checks on previous values or dates. /// </summary> /// <param name="plants"></param> /// <param name="wells"></param> /// <param name="cd"></param> /// <returns></returns> public bool ApplySingleChange(IPlantCollection plants, IWellCollection wells, ChangeDescription cd) { string wellid = ""; int plantid; int intakeno = -1; IWell CurrentWell; bool succeded = false; switch (cd.Table) { case JupiterTables.BOREHOLE: wellid = cd.PrimaryKeys["BOREHOLENO"]; if (wells.TryGetValue(wellid, out CurrentWell)) { foreach (var c in cd.ChangeValues) { switch (c.Column.ToUpper()) { case "XUTM": CurrentWell.X = double.Parse(c.NewValue); succeded = true; break; case "YUTM": CurrentWell.Y = double.Parse(c.NewValue); succeded = true; break; case "ELEVATION": CurrentWell.Terrain = double.Parse(c.NewValue); succeded = true; break; default: break; } } } break; case JupiterTables.SCREEN: wellid = cd.PrimaryKeys["BOREHOLENO"]; if (wells.TryGetValue(wellid, out CurrentWell)) { int screenNumber = int.Parse(cd.PrimaryKeys["SCREENNO"]); if (cd.Action == TableAction.EditValue) { var screen = CurrentWell.Intakes.SelectMany(var => var.Screens).FirstOrDefault(var2 => var2.Number == screenNumber); if (screen != null) { foreach (var cv in cd.ChangeValues) { if (cv.Column == "TOP") { screen.DepthToTop = double.Parse(cv.NewValue); } else if (cv.Column == "BOTTOM") { screen.DepthToBottom = double.Parse(cv.NewValue); } succeded = true; } } } else if (cd.Action == TableAction.InsertRow) { intakeno = int.Parse(cd.ChangeValues.Single(var => var.Column == "INTAKENO").NewValue); IIntake CurrentIntake = CurrentWell.Intakes.Single(var => var.IDNumber == intakeno); if (CurrentIntake != null) { Screen sc = new Screen(CurrentIntake); sc.DepthToTop = double.Parse(cd.ChangeValues.Single(var => var.Column == "TOP").NewValue); sc.DepthToBottom = double.Parse(cd.ChangeValues.Single(var => var.Column == "BOTTOM").NewValue); succeded = true; } } } break; case JupiterTables.DRWPLANTINTAKE: if (cd.Action == TableAction.EditValue || cd.Action == TableAction.DeleteRow) { int tableid; if (int.TryParse(cd.PrimaryKeys.First().Value, out tableid)) { if (DataBaseConnection.TryGetPlant(tableid, out plantid, out wellid, out intakeno)) { succeded = true; } } else //No ID Change of a change { if (cd.Action == TableAction.EditValue) { if (int.TryParse(cd.ChangeValues[0].NewValue, out plantid)) { wellid = cd.ChangeValues[1].NewValue; if (int.TryParse(cd.ChangeValues[2].NewValue, out intakeno)) { succeded = true; } } } else if (int.TryParse(cd.ChangeValues[0].OldValue, out plantid)) { wellid = cd.ChangeValues[1].OldValue; if (int.TryParse(cd.ChangeValues[2].OldValue, out intakeno)) { succeded = true; } } } if (succeded) { var pi = plants[plantid].PumpingIntakes.FirstOrDefault(var => var.Intake.well.ID == wellid & var.Intake.IDNumber == intakeno); if (pi != null) { if (cd.Action == TableAction.DeleteRow) { plants[plantid].PumpingIntakes.Remove(pi); } else { var start = cd.ChangeValues.SingleOrDefault(var => var.Column == "STARTDATE"); if (start != null) { pi.StartNullable = DateTime.Parse(start.NewValue); } var end = cd.ChangeValues.SingleOrDefault(var => var.Column == "ENDDATE"); if (end != null) { pi.EndNullable = DateTime.Parse(end.NewValue); } } succeded = true; } } } else //insertrow { plantid = int.Parse(cd.ChangeValues.First(var => var.Column == "PLANTID").NewValue); Plant p; if (plants.TryGetValue(plantid, out p)) { wellid = cd.ChangeValues.First(var => var.Column == "BOREHOLENO").NewValue; IWell w; if (wells.TryGetValue(wellid, out w)) { intakeno = int.Parse(cd.ChangeValues.First(var => var.Column == "INTAKENO").NewValue); IIntake I = w.Intakes.First(var => var.IDNumber == intakeno); if (I != null) { PumpingIntake pi = new PumpingIntake(I, p); var s = cd.ChangeValues.FirstOrDefault(var => var.Column == "STARTDATE"); if (s != null) { pi.StartNullable = DateTime.Parse(s.NewValue); } s = cd.ChangeValues.FirstOrDefault(var => var.Column == "ENDDATE"); if (s != null) { pi.EndNullable = DateTime.Parse(s.NewValue); } p.PumpingIntakes.Add(pi); succeded = true; } } } } break; case JupiterTables.WATLEVEL: wellid = cd.PrimaryKeys["BOREHOLENO"]; if (wells.TryGetValue(wellid, out CurrentWell)) { DateTime TimeOfMeasure; int WatlevelNo = int.Parse(cd.PrimaryKeys["WATLEVELNO"]); if (DataBaseConnection.TryGetIntakeNoTimeOfMeas(CurrentWell, WatlevelNo, out intakeno, out TimeOfMeasure)) { IIntake CurrentIntake = CurrentWell.Intakes.SingleOrDefault(var => var.IDNumber == intakeno); if (CurrentIntake != null) { var item = CurrentIntake.HeadObservations.Items.FirstOrDefault(var => var.Time == TimeOfMeasure); if (item != null) { CurrentIntake.HeadObservations.Items.Remove(item); succeded = true; } } } } break; default: break; } return(succeded); }
private void buttonReadMshe_Click(object sender, EventArgs e) { openFileDialog2.Filter = "Known file types (*.she)|*.she"; openFileDialog2.ShowReadOnly = true; openFileDialog2.Title = "Select a .she file with MikeShe setup"; if (openFileDialog2.ShowDialog() == DialogResult.OK) { LC.MikeSheFileName = openFileDialog2.FileName; if (Wells == null) { Wells = new IWellCollection(); foreach (IWell W in HeadObservations.ReadInDetailedTimeSeries(LC.MShe)) Wells.Add(W); LC.Wells = Wells; } LC.DistributeIntakesOnLayers(); if (LC.WellsOutSideModelDomain.Count > 0) { if (DialogResult.Yes == MessageBox.Show(LC.WellsOutSideModelDomain.Count + " wells found outside horizontal MikeShe model domain.\n Remove these wells from list?", "Wells outside model domain", MessageBoxButtons.YesNo)) { foreach (IWell W in LC.WellsOutSideModelDomain) { Wells.Remove(W.ID); } } } UpdateListsAndListboxes(); } }
public IWellCollection ReadWellsInSteps() { string[] NotExtractionPurpose = new string[] { "A", "G", "I", "J", "L", "R", "U", "M", "P" }; string[] ExtractionUse = new string[] { "C", "V", "VA", "VD", "VH", "VI", "VM", "VP", "VV" }; string[] NotExtractionUse = new string[] { "A", "G", "I", "J", "L", "R", "U", "M", "P" }; IWellCollection Wells = new IWellCollection(); JupiterWell CurrentWell; JupiterIntake CurrentIntake; #region Borehole JXL.ReadWellsOnly(); //Loop the wells foreach (var Boring in JXL.BOREHOLE) { CurrentWell = new JupiterWell(Boring.BOREHOLENO); Wells.Add(CurrentWell); if (!Boring.IsXUTMNull()) { CurrentWell.X = Boring.XUTM; } else //If no x set x to 0! { CurrentWell.X = 0; } if (!Boring.IsYUTMNull()) { CurrentWell.Y = Boring.YUTM; } else { CurrentWell.Y = 0; } CurrentWell.Description = Boring.LOCATION; if (Boring.ELEVATION == -999 & Boring.CTRPELEVA != -999) { CurrentWell.Terrain = Boring.CTRPELEVA; } else { CurrentWell.Terrain = Boring.ELEVATION; } if (!Boring.IsDRILLDEPTHNull()) { CurrentWell.Depth = Boring.DRILLDEPTH; } CurrentWell.UsedForExtraction = true; CurrentWell.Use = Boring.USE; CurrentWell.Purpose = Boring.PURPOSE; //Hvis USE er noget andet end indvinding if (NotExtractionUse.Contains(Boring.USE.ToUpper())) { CurrentWell.UsedForExtraction = false; } //Hvis den er oprettet med et andet formål og USE ikke er sat til indvinding er det ikke en indvindingsboring if (NotExtractionPurpose.Contains(Boring.PURPOSE.ToUpper()) & !ExtractionUse.Contains(Boring.USE.ToUpper())) { CurrentWell.UsedForExtraction = false; } if (!Boring.IsDRILENDATENull()) { CurrentWell.StartDate = Boring.DRILENDATE; } if (!Boring.IsABANDONDATNull()) { CurrentWell.EndDate = Boring.ABANDONDAT; } } JXL.BOREHOLE.Clear(); #endregion #region Intakes //Intakes JXL.ReadIntakes(); foreach (var Intake in JXL.INTAKE) { if (Wells.Contains(Intake.BOREHOLENO)) { JupiterIntake I = Wells[Intake.BOREHOLENO].AddNewIntake(Intake.INTAKENO) as JupiterIntake; if (I != null) { if (!Intake.IsSTRINGNONull()) { I.StringNo = Intake.STRINGNO; I.ResRock = Intake.RESERVOIRROCK; } } } } foreach (var Casing in JXL.CASING) { if (Wells.Contains(Casing.BOREHOLENO)) { if (!Casing.IsSTRINGNONull()) { IIntake I = Wells[Casing.BOREHOLENO].Intakes.FirstOrDefault(var => ((JupiterIntake)var).StringNo == Casing.STRINGNO); if (I != null) { if (!Casing.IsBOTTOMNull()) { I.Depth = Casing.BOTTOM; } } } } } JXL.INTAKE.Clear(); JXL.CASING.Clear(); #endregion #region Screens //Screens JXL.ReadScreens(); foreach (var screen in JXL.SCREEN) { if (Wells.Contains(screen.BOREHOLENO)) { CurrentIntake = Wells[screen.BOREHOLENO].Intakes.FirstOrDefault(var => var.IDNumber == screen.INTAKENO) as JupiterIntake; if (CurrentIntake != null) { Screen CurrentScreen = new Screen(CurrentIntake); if (!screen.IsTOPNull()) { CurrentScreen.DepthToTop = screen.TOP; } if (!screen.IsBOTTOMNull()) { CurrentScreen.DepthToBottom = screen.BOTTOM; } CurrentScreen.Number = screen.SCREENNO; if (!screen.IsSTARTDATENull()) { CurrentScreen.StartDate = screen.STARTDATE; } if (!screen.IsENDDATENull()) { CurrentScreen.EndDate = screen.ENDDATE; } } } } JXL.SCREEN.Clear(); #endregion return(Wells); }
/// <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]); } }
/// <summary> /// Reads the water levels into the collection of wells /// </summary> /// <param name="Wells"></param> public int ReadWaterLevels(IWellCollection Wells) { string sql = "SELECT BOREHOLENO, INTAKENO, TIMEOFMEAS, WATLEVGRSU, WATLEVMSL, REFPOINT, SITUATION FROM WATLEVEL"; using (OleDbCommand command = new OleDbCommand(sql, odb)) { OleDbDataReader reader2; try { reader2 = command.ExecuteReader(); } catch (OleDbException E) { throw new Exception("Make sure that the database is in JupiterXL-format, Access 2000"); } IWell CurrentWell = null; IIntake CurrentIntake = null; //Get the ordinals int BoreHoleOrdinal = reader2.GetOrdinal("BOREHOLENO"); int IntakeOrdinal = reader2.GetOrdinal("INTAKENO"); int TimeOrdinal = reader2.GetOrdinal("TIMEOFMEAS"); int WatLevGroundOrdinal = reader2.GetOrdinal("WATLEVGRSU"); int WaterLevKoteOrdinal = reader2.GetOrdinal("WATLEVMSL"); int RefPointOrdinal = reader2.GetOrdinal("REFPOINT"); int SituationOrdinal = reader2.GetOrdinal("SITUATION"); string previousWellID = ""; int k = 0; //Now loop the data while (reader2.Read()) { k++; string WellID = reader2.GetString(BoreHoleOrdinal); if (previousWellID != WellID) { Wells.TryGetValue(WellID, out CurrentWell); previousWellID = WellID; CurrentIntake = null; } if (CurrentWell != null) { int IntakeNo = reader2.GetInt32(IntakeOrdinal); if (CurrentIntake == null || CurrentIntake.IDNumber != IntakeNo) { CurrentIntake = CurrentWell.Intakes.FirstOrDefault(var => var.IDNumber == IntakeNo); if (CurrentIntake is JupiterIntake) { if (!reader2.IsDBNull(RefPointOrdinal)) ((JupiterIntake)CurrentIntake).RefPoint = reader2.GetString(RefPointOrdinal); } } if (CurrentIntake != null) { string Description; if (reader2.IsDBNull(SituationOrdinal)) Description = "Unknown"; else { if (reader2.GetInt32(SituationOrdinal) == 0) Description = "Ro"; else Description = "Drift"; } ///NOTE!!! Description has been removed if (!reader2.IsDBNull(TimeOrdinal)) //No time data if (!reader2.IsDBNull(WaterLevKoteOrdinal)) //No kote data CurrentIntake.HeadObservations.Items.Add(new TimeStampValue(reader2.GetDateTime(TimeOrdinal), reader2.GetDouble(WaterLevKoteOrdinal))); else if (!reader2.IsDBNull(WatLevGroundOrdinal)) //No ground data CurrentIntake.HeadObservations.Items.Add(new TimeStampValue(reader2.GetDateTime(TimeOrdinal), CurrentIntake.well.Terrain - reader2.GetDouble(WatLevGroundOrdinal))); } } } reader2.Close(); return k; } }
/// <summary> /// Opens a point shape /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button2_Click(object sender, EventArgs e) { openFileDialog2.Filter = "Known file types (*.shp)|*.shp"; this.openFileDialog2.ShowReadOnly = true; this.openFileDialog2.Title = "Select a shape file with data for wells or intakes"; if (openFileDialog2.ShowDialog() == DialogResult.OK) { string FileName = openFileDialog2.FileName; ShapeReader SR = new ShapeReader(FileName); DataTable FullDataSet = SR.Data.Read(); //Launch a data selector DataSelector DS = new DataSelector(FullDataSet); if (DS.ShowDialog() == DialogResult.OK) { if (ShpConfig == null) { XmlSerializer x = new XmlSerializer(typeof(ShapeReaderConfiguration)); string InstallationPath = Path.GetDirectoryName(this.GetType().Assembly.Location); string config = Path.Combine(InstallationPath, "ShapeReaderConfig.xml"); using (FileStream fs = new FileStream(config, FileMode.Open)) { ShpConfig = (ShapeReaderConfiguration)x.Deserialize(fs); if (CheckColumn(FullDataSet, ShpConfig.WellIDHeader, config)) if (CheckColumn(FullDataSet, ShpConfig.IntakeNumber, config)) if (CheckColumn(FullDataSet, ShpConfig.XHeader, config)) if (CheckColumn(FullDataSet, ShpConfig.YHeader, config)) if (CheckColumn(FullDataSet, ShpConfig.TOPHeader, config)) if (CheckColumn(FullDataSet, ShpConfig.BOTTOMHeader, config)) { Wells = new IWellCollection(); if (FullDataSet.Columns.Contains(ShpConfig.PlantIDHeader)) { DPlants = new IPlantCollection(); HeadObservations.FillInFromNovanaShape(DS.SelectedRows, ShpConfig, Wells, DPlants); } else HeadObservations.FillInFromNovanaShape(DS.SelectedRows, ShpConfig, Wells); UpdateListsAndListboxes(); } } } } SR.Dispose(); } }
public IWellCollection ReadWellsInSteps() { string[] NotExtractionPurpose = new string[] { "A", "G", "I", "J", "L", "R", "U", "M", "P"}; string[] ExtractionUse = new string[]{"C","V","VA","VD","VH","VI","VM","VP","VV"}; string[] NotExtractionUse = new string[] { "A", "G", "I", "J", "L", "R", "U", "M", "P"}; IWellCollection Wells = new IWellCollection(); JupiterWell CurrentWell; JupiterIntake CurrentIntake; #region Borehole JXL.ReadWellsOnly(); //Loop the wells foreach (var Boring in JXL.BOREHOLE) { CurrentWell = new JupiterWell(Boring.BOREHOLENO); Wells.Add(CurrentWell); if (!Boring.IsXUTMNull()) CurrentWell.X = Boring.XUTM; else //If no x set x to 0! CurrentWell.X = 0; if (!Boring.IsYUTMNull()) CurrentWell.Y = Boring.YUTM; else CurrentWell.Y = 0; CurrentWell.Description = Boring.LOCATION; if (Boring.ELEVATION ==-999 & Boring.CTRPELEVA!=-999) CurrentWell.Terrain = Boring.CTRPELEVA; else CurrentWell.Terrain = Boring.ELEVATION; if (!Boring.IsDRILLDEPTHNull()) CurrentWell.Depth = Boring.DRILLDEPTH; CurrentWell.UsedForExtraction = true; CurrentWell.Use = Boring.USE; CurrentWell.Purpose = Boring.PURPOSE; //Hvis USE er noget andet end indvinding if (NotExtractionUse.Contains(Boring.USE.ToUpper())) CurrentWell.UsedForExtraction = false; //Hvis den er oprettet med et andet formål og USE ikke er sat til indvinding er det ikke en indvindingsboring if (NotExtractionPurpose.Contains(Boring.PURPOSE.ToUpper()) & !ExtractionUse.Contains(Boring.USE.ToUpper())) CurrentWell.UsedForExtraction = false; if (!Boring.IsDRILENDATENull()) CurrentWell.StartDate = Boring.DRILENDATE; if (!Boring.IsABANDONDATNull()) CurrentWell.EndDate = Boring.ABANDONDAT; } JXL.BOREHOLE.Clear(); #endregion #region Intakes //Intakes JXL.ReadIntakes(); foreach (var Intake in JXL.INTAKE) { if (Wells.Contains(Intake.BOREHOLENO)) { JupiterIntake I = Wells[Intake.BOREHOLENO].AddNewIntake(Intake.INTAKENO) as JupiterIntake; if (I != null) { if (!Intake.IsSTRINGNONull()) { I.StringNo = Intake.STRINGNO; I.ResRock = Intake.RESERVOIRROCK; } } } } foreach( var Casing in JXL.CASING) { if (Wells.Contains(Casing.BOREHOLENO)) { if (!Casing.IsSTRINGNONull()) { IIntake I = Wells[Casing.BOREHOLENO].Intakes.FirstOrDefault(var => ((JupiterIntake)var).StringNo == Casing.STRINGNO); if (I != null) if (!Casing.IsBOTTOMNull()) I.Depth = Casing.BOTTOM; } } } JXL.INTAKE.Clear(); JXL.CASING.Clear(); #endregion #region Screens //Screens JXL.ReadScreens(); foreach (var screen in JXL.SCREEN) { if (Wells.Contains(screen.BOREHOLENO)) { CurrentIntake = Wells[screen.BOREHOLENO].Intakes.FirstOrDefault(var => var.IDNumber == screen.INTAKENO) as JupiterIntake; if (CurrentIntake != null) { Screen CurrentScreen = new Screen(CurrentIntake); if (!screen.IsTOPNull()) CurrentScreen.DepthToTop = screen.TOP; if (!screen.IsBOTTOMNull()) CurrentScreen.DepthToBottom = screen.BOTTOM; CurrentScreen.Number = screen.SCREENNO; if (!screen.IsSTARTDATENull()) CurrentScreen.StartDate = screen.STARTDATE; if (!screen.IsENDDATENull()) CurrentScreen.EndDate = screen.ENDDATE; } } } JXL.SCREEN.Clear(); #endregion return Wells; }
/// <summary> /// Reads the water levels into the collection of wells /// </summary> /// <param name="Wells"></param> public int ReadWaterLevels(IWellCollection Wells) { string sql = "SELECT BOREHOLENO, INTAKENO, TIMEOFMEAS, WATLEVGRSU, WATLEVMSL, REFPOINT, SITUATION FROM WATLEVEL"; using (OleDbCommand command = new OleDbCommand(sql, odb)) { OleDbDataReader reader2; try { reader2 = command.ExecuteReader(); } catch (OleDbException E) { throw new Exception("Make sure that the database is in JupiterXL-format, Access 2000"); } IWell CurrentWell = null; IIntake CurrentIntake = null; //Get the ordinals int BoreHoleOrdinal = reader2.GetOrdinal("BOREHOLENO"); int IntakeOrdinal = reader2.GetOrdinal("INTAKENO"); int TimeOrdinal = reader2.GetOrdinal("TIMEOFMEAS"); int WatLevGroundOrdinal = reader2.GetOrdinal("WATLEVGRSU"); int WaterLevKoteOrdinal = reader2.GetOrdinal("WATLEVMSL"); int RefPointOrdinal = reader2.GetOrdinal("REFPOINT"); int SituationOrdinal = reader2.GetOrdinal("SITUATION"); string previousWellID = ""; int k = 0; //Now loop the data while (reader2.Read()) { k++; string WellID = reader2.GetString(BoreHoleOrdinal); if (previousWellID != WellID) { Wells.TryGetValue(WellID, out CurrentWell); previousWellID = WellID; CurrentIntake = null; } if (CurrentWell != null) { int IntakeNo = reader2.GetInt32(IntakeOrdinal); if (CurrentIntake == null || CurrentIntake.IDNumber != IntakeNo) { CurrentIntake = CurrentWell.Intakes.FirstOrDefault(var => var.IDNumber == IntakeNo); if (CurrentIntake is JupiterIntake) { if (!reader2.IsDBNull(RefPointOrdinal)) { ((JupiterIntake)CurrentIntake).RefPoint = reader2.GetString(RefPointOrdinal); } } } if (CurrentIntake != null) { string Description; if (reader2.IsDBNull(SituationOrdinal)) { Description = "Unknown"; } else { if (reader2.GetInt32(SituationOrdinal) == 0) { Description = "Ro"; } else { Description = "Drift"; } } if (!reader2.IsDBNull(TimeOrdinal)) //No time data { if (!reader2.IsDBNull(WaterLevKoteOrdinal)) //No kote data { CurrentIntake.HeadObservations.Items.Add(new TimestampValue(reader2.GetDateTime(TimeOrdinal), reader2.GetDouble(WaterLevKoteOrdinal), Description)); } else if (!reader2.IsDBNull(WatLevGroundOrdinal)) //No ground data { CurrentIntake.HeadObservations.Items.Add(new TimestampValue(reader2.GetDateTime(TimeOrdinal), CurrentIntake.well.Terrain - reader2.GetDouble(WatLevGroundOrdinal), Description)); } } } } } reader2.Close(); return(k); } }