public ChangeDescription ChangeTerrainOnWell(IWell well, double NewValue) { ChangeDescription change = GetWellChange(well); change.ChangeValues.Add(new Change("ELEVATION", NewValue.ToString(), well.Terrain.ToString())); return(change); }
public ChangeDescription ChangeYOnWell(IWell well, double NewValue) { ChangeDescription change = GetWellChange(well); change.ChangeValues.Add(new Change("YUTM", NewValue.ToString(), well.Y.ToString())); return(change); }
public bool TryGetIntakeNoTimeOfMeas(IWell w, int WatLevelNo, out int IntakeNo, out DateTime TimeOfMeasure) { IntakeNo = -1; TimeOfMeasure = DateTime.MinValue; string sql = "SELECT INTAKENO, TIMEOFMEAS, WATLEVGRSU, WATLEVMSL, SITUATION FROM WATLEVEL where BOREHOLENO ='" + w.ID + "' and WATLEVELNO = " + WatLevelNo; using (OleDbCommand command = new OleDbCommand(sql, odb)) { try { using (OleDbDataReader reader2 = command.ExecuteReader()) { reader2.Read(); if (!reader2.HasRows) { return(false); } else { IntakeNo = reader2.GetInt32(0); TimeOfMeasure = reader2.GetDateTime(1); return(true); } } } catch (OleDbException E) { throw new Exception("Make sure that the database is in JupiterXL-format, Access 2000"); } } }
public static bool CanFixErrors(this IWell well) { if (well.X == 0 || well.Y == 0) { return(false); } if (!well.HasScreenErrors()) { return(false); } if (well.Depth.HasValue) { return(true); } var IntakesWithScreenErrors = well.Intakes.Where(var => var.Screens.Any(var2 => var2.HasMissingData())); if (IntakesWithScreenErrors.Count() > 0 & IntakesWithScreenErrors.All(var3 => var3.Depth.HasValue)) { return(true); } var ScreensWithErrors = well.Intakes.SelectMany(var => var.Screens).Where(var2 => var2.HasMissingData()); if (ScreensWithErrors.Count() > 0 & ScreensWithErrors.All(var3 => var3.CanFixError())) { return(true); } return(false); }
/// <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> /// Constructs a new JupiterWell based on the other Well. Also construct new JupiterIntakes; /// </summary> /// <param name="Well"></param> public JupiterWell(IWell Well) : base(Well.ID, Well.X, Well.Y) { this.Description = Well.Description; this.Terrain = Well.Terrain; foreach (IIntake I in Well.Intakes) { this.AddNewIntake(I); } }
/// <summary> /// Constructs a new JupiterWell based on the other Well. Also construct new JupiterIntakes; /// </summary> /// <param name="Well"></param> public JupiterWell(IWell Well) : base(Well.ID,Well.X,Well.Y) { this.Description = Well.Description; this.Terrain = Well.Terrain; foreach (IIntake I in Well.Intakes) { this.AddNewIntake(I); } }
private ChangeDescription GetWellChange(IWell well) { ChangeDescription change = new ChangeDescription(JupiterTables.BOREHOLE); change.User = UserName; change.Project = ProjectName; change.Action = TableAction.EditValue; change.PrimaryKeys["BOREHOLENO"] = well.ID; return change; }
private ChangeDescription GetWellChange(IWell well) { ChangeDescription change = new ChangeDescription(JupiterTables.BOREHOLE); change.User = UserName; change.Project = ProjectName; change.Action = TableAction.EditValue; change.PrimaryKeys["BOREHOLENO"] = well.ID; return(change); }
private void uxSave_Click(object sender, EventArgs e) { production = IWellFactories.GetFactory(IWellType.Production).CreateIWell(); production.Id = Convert.ToInt32(uxProductionID.Text); production.SpudDate = uxDate.Value.Date; ProductionWell prod = production as ProductionWell; prod.DailyProduction = new List <IOilProduction>(); var ID = Convert.ToInt32(uxWellPad.SelectedValue); var WellPad = FacilityManager.FacilityMng.FindWell(ID); WellPad.Wells.Add(production); FacilityManager.FacilityMng.SaveData(); RefreshGridData(); }
private void uxSave_Click(object sender, EventArgs e) { inject = IWellFactories.GetFactory(IWellType.Injection).CreateIWell(); inject.Id = Convert.ToInt32(uxInjectionID.Text); inject.SpudDate = uxDate.Value.Date; InjectionWell inj = inject as InjectionWell; inj.WaterType = (WaterType)uxWaterType.SelectedIndex; var ID = Convert.ToInt32(uxWellPad.SelectedValue); var wellPad = FacilityManager.FacilityMng.FindWell(ID); wellPad.Wells.Add(inject); FacilityManager.FacilityMng.SaveData(); RefreshGridData(); }
public IWell InitializeWell(SubWellTypes wellType) { IWell well = null; switch (wellType) { case SubWellTypes.InjectionWell: well = new InjectionWell(); break; case SubWellTypes.ProductionWell: well = new ProductionWell(); break; } return(well); }
public ChangeDescription ChangeTerrainOnWell(IWell well, double NewValue) { ChangeDescription change = GetWellChange(well); change.ChangeValues.Add(new Change("ELEVATION", NewValue.ToString(), well.Terrain.ToString())); return change; }
public ChangeDescription ChangeYOnWell(IWell well, double NewValue) { ChangeDescription change = GetWellChange(well); change.ChangeValues.Add(new Change("YUTM", NewValue.ToString(), well.Y.ToString())); return change; }
public WellViewModel(IWell Well, ChangesViewModel cvm) { _well = Well; CVM = cvm; Name = _well.ID; }
public static string FixErrors(this IWell well) { StringBuilder Returnstring = new StringBuilder(); if (well.CanFixErrors()) { foreach (IIntake I in well.Intakes) { //No screen but we have well or intake depth if (I.Screens.Count == 0) { if (I.Depth.HasValue || well.Depth.HasValue) { Screen sc = new Screen(I); Returnstring.AppendLine("Added screen in Intake number " + I.IDNumber + "."); } } //Make sure it does not enter if no screen was added above if (I.Screens.Count > 0) { foreach (Screen sc in I.Screens) { if (!sc.DepthToTop.HasValue) { if (sc.DepthToBottom.HasValue) { sc.DepthToTop = Math.Max(0, sc.DepthToBottom.Value - DefaultScreenLength); Returnstring.AppendLine(String.Format("Top of screen number {0} in Intake number {1} was set from bottom of screen.", sc.Number, I.IDNumber)); } else if (I.Depth.HasValue) { sc.DepthToTop = I.Depth; Returnstring.AppendLine(String.Format("Top of screen number {0} in Intake number {1} was set to bottom of intake.", sc.Number, I.IDNumber)); } else if (well.Depth.HasValue) { sc.DepthToTop = Math.Max(0, well.Depth.Value - DefaultScreenLength); Returnstring.AppendLine(String.Format("Top of screen number {0} in Intake number {1} was set to {2} m above well bottom.", sc.Number, I.IDNumber, DefaultScreenLength)); } else { Returnstring.AppendLine("Could not autocorrect depth to screen top"); } } if (!sc.DepthToBottom.HasValue) { if (sc.DepthToTop.HasValue) { sc.DepthToBottom = sc.DepthToTop + DefaultScreenLength; Returnstring.AppendLine(String.Format("Bottom of screen number {0} in Intake number {1} was set from top of screen.", sc.Number, I.IDNumber)); } else if (well.Depth.HasValue) { sc.DepthToBottom = well.Depth; Returnstring.AppendLine(String.Format("Bottom of screen number {0} in Intake number {1} was set to well depth", sc.Number, I.IDNumber)); } else if (I.Depth.HasValue) { sc.DepthToBottom = I.Depth.Value + DefaultScreenLength; Returnstring.AppendLine(String.Format("Bottom of screen number {0} in Intake number {1} was set to {2} m below intake depth.", sc.Number, I.IDNumber, DefaultScreenLength)); } else { Returnstring.AppendLine("Could not autocorrect depth to screen bottom"); } } } } } return(Returnstring.ToString()); } return("Could not fix error"); }
private static bool HasScreenErrors(this IWell well) { return(well.Intakes.Sum(var => var.Screens.Count) == 0 || well.Intakes.SelectMany(var => var.Screens).Any(var => var.HasMissingData())); }
public void AcceptFlowFrom(IWell well) { this.wells.Add(well); }
public bool TryGetIntakeNoTimeOfMeas(IWell w, int WatLevelNo, out int IntakeNo, out DateTime TimeOfMeasure) { IntakeNo = -1; TimeOfMeasure = DateTime.MinValue; string sql = "SELECT INTAKENO, TIMEOFMEAS, WATLEVGRSU, WATLEVMSL, SITUATION FROM WATLEVEL where BOREHOLENO ='" + w.ID + "' and WATLEVELNO = " + WatLevelNo; using (OleDbCommand command = new OleDbCommand(sql, odb)) { try { using (OleDbDataReader reader2 = command.ExecuteReader()) { reader2.Read(); if (!reader2.HasRows) return false; else { IntakeNo = reader2.GetInt32(0); TimeOfMeasure = reader2.GetDateTime(1); return true; } } } catch (OleDbException E) { throw new Exception("Make sure that the database is in JupiterXL-format, Access 2000"); } } }
private void PopulateListView(TreeNode node) { uxListView.Items.Clear(); switch (node.Level) { case 0: List <wellpad_listview> wells_list = node.Tag as List <wellpad_listview>; int producwellcount = 0, injectcount = 0; foreach (wellpad_listview wellpads in wells_list) { foreach (WellPads Well in wellpads.wells) { injectcount = Well.Wells .Where(o => o.GetType() == typeof(InjectionWell)) .Count(); producwellcount = Well.Wells .Where(o => o.GetType() == typeof(ProductionWell)) .Count(); } string[] datas = new string[] { wellpads.Province.ToString(), producwellcount.ToString(), injectcount.ToString() }; ListViewItem items = new ListViewItem(datas); uxListView.Items.Add(items); } break; case 1: wellpad_listview locations = node.Tag as wellpad_listview; foreach (WellPads Well in locations.wells) { var productionCount = Well.Wells .Where(o => o.GetType() == typeof(ProductionWell)) .Count() .ToString(); var injectionCount = Well.Wells .Where(o => o.GetType() == typeof(InjectionWell)) .Count() .ToString(); string[] datas = new string[] { Well.Location, productionCount, injectionCount }; ListViewItem items = new ListViewItem(datas); uxListView.Items.Add(items); } break; case 2: WellPads well = node.Tag as WellPads; var productionWells = well.Wells .OrderByDescending(o => o.SpudDate) .Where(o => o.GetType() == typeof(ProductionWell)) .ToList(); var InjectionWells = well.Wells .OrderByDescending(o => o.SpudDate) .Where(o => o.GetType() == typeof(InjectionWell)) .ToList(); foreach (ProductionWell productionWell in productionWells) { string[] Datas = new string[] { productionWell.SpudDate.ToShortDateString(), productionWell.DailyProduction .Select(o => o.BarrelsProduced) .Sum() .ToString() }; ListViewItem Items = new ListViewItem(Datas); uxListView.Items.Add(Items); } foreach (InjectionWell injectionWell in InjectionWells) { string[] Datas = new string[] { injectionWell.SpudDate.ToShortDateString(), "0 barrels (Injection Well)" }; ListViewItem Items = new ListViewItem(Datas); uxListView.Items.Add(Items); } break; case 3: IWell iwells = node.Tag as IWell; ProductionWell productwells = iwells as ProductionWell; try { //get a collection of oil production from production wells (with production dates sorted in descending order) var Production = productwells.DailyProduction.OrderByDescending(o => o.ProductionDate).ToList(); foreach (OilProduction production in Production) { string[] productions = new string[] { production.ProductionDate.ToShortDateString(), production.BarrelsProduced.ToString() }; ListViewItem producItems = new ListViewItem(productions); uxListView.Items.Add(producItems); } } catch { string[] InjectionData = new string[] { "N/A", "0 barrels" }; ListViewItem items = new ListViewItem(InjectionData); uxListView.Items.Add(items); return; } break; } }
public LsIntake(IWell well, int IntakeNumber) : base() { this.well = well; this.IDNumber = IntakeNumber; }
public ChangeDescription ChangeDepthOnWell(IWell well, double NewValue) { ChangeDescription change = GetWellChange(well); change.ChangeValues.Add(new Change("DRILLDEPTH", NewValue.ToString(), well.Terrain.ToString())); return change; }
/// <summary> /// Returns true if the well has missing data. /// x,y==0 /// </summary> public static bool HasMissingData(this IWell well) { return(well.X == 0 || well.Y == 0); }
/// <summary> /// register service by T /// </summary> /// <typeparam name="T"></typeparam> /// <param name="well"></param> /// <param name="t"></param> /// <returns></returns> public static IWell RegisterService <T>(this IWell well, T t) where T : class { well.Register <T>(t); return(well); }
/// <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); } }
/// <summary> /// register service by func /// </summary> /// <typeparam name="T"></typeparam> /// <param name="well"></param> /// <param name="func"></param> /// <returns></returns> public static IWell RegisterService <T>(this IWell well, Func <T> func) where T : class { well.Register(new Lazy <T>(func, true).Value);//thread safe return(well); }
/// <summary> /// Constructs a new intake /// </summary> /// <param name="Well"></param> /// <param name="IDNumber"></param> internal Intake(IWell Well, int IDNumber) : this() { this.well = Well; this.IDNumber = IDNumber; }
public LsIntake(IWell well, int IntakeNumber):base() { this.well = well; this.IDNumber = IntakeNumber; }