private List <NavStageNode> GetStageNodes(Guid wellGuid, string wellName) { List <NavStageNode> stageNodes = new List <NavStageNode>(); using (var seismosContext = new seismosEntities()) { var tempTreatments = seismosContext.Treatments.Where(tr => tr.WellId == wellGuid).ToList(); foreach (var tempTreatment in tempTreatments) { if (!(tempTreatment is HydraulicFracturingTreatment)) { continue; } var hfTreatment = (HydraulicFracturingTreatment)tempTreatment; var tempStages = seismosContext.Stages .Where(st => st.HydraulicFracturingTreatmentId == hfTreatment.Id) .OrderBy(st => st.Number) .ToList(); foreach (var tempStage in tempStages) { stageNodes.Add(new NavStageNode() { Id = tempStage.Id, Name = $"Stage {tempStage.Number}{(tempTreatments.Count > 1 ? " HFT " + tempTreatments.Count : "")}" }); } } } return(stageNodes); }
public WellEntry GetWellEntry(Guid wellId) { Well getWell; using (var seismosContext = new seismosEntities()) { getWell = seismosContext.Wells.Where(w => w.Id == wellId).Include(w => w.WellBore.Cylinders).FirstOrDefault(); } if (getWell == null) { return(null); } double surfaceVolume = getWell.WellBore?.SurfaceVolume ?? 0.0; double totalVolume = getWell.WellBore?.TotalVolume ?? 0.0; var wellEntry = new WellEntry() { Id = getWell.Id, Name = getWell.WellName, SurfaceVolume = surfaceVolume, TotalVolume = totalVolume, CylinderEntries = new ObservableCollection <CylinderEntry>(GetCylinderEntries(getWell.WellBore)) }; return(wellEntry); }
private List <NavWellNode> GetWellNodes(Guid projectGuid) { List <NavWellNode> wellNodes = new List <NavWellNode>(); using (var seismosContext = new seismosEntities()) { var tempWells = seismosContext.Wells.Where(w => w.SeismosProject.Id == projectGuid) .OrderBy(w => w.WellName).ToList(); foreach (var tempWell in tempWells) { wellNodes.Add(new NavWellNode() { Id = tempWell.Id, Name = tempWell.WellName }); } } foreach (var navWellNode in wellNodes) { navWellNode.Stages = GetStageNodes(navWellNode.Id, navWellNode.Name); } return(wellNodes); }
public Guid UpdateSeismosClient(KeyValueEntity seismosKeyValueEntity) { Guid retGuid; using (var seismosContext = new seismosEntities()) { SeismosClient updateSeismosClient; bool bNew = false; if (seismosKeyValueEntity.Id == Guid.Empty) { updateSeismosClient = new SeismosClient { Id = Guid.NewGuid() }; bNew = true; } else { updateSeismosClient = seismosContext.SeismosClients.FirstOrDefault(sc => sc.Id == seismosKeyValueEntity.Id); } if (updateSeismosClient == null) { return(Guid.Empty); } foreach (var keyValuePair in seismosKeyValueEntity.KeyValuePairs) { switch (keyValuePair.Id) { case ClientName: updateSeismosClient.ClientName = keyValuePair.Text.ToString(); break; case ContactName: updateSeismosClient.Contact = keyValuePair.Text.ToString(); break; case EmailAddress: updateSeismosClient.Email = keyValuePair.Text.ToString(); break; case PhoneNumber: updateSeismosClient.PhoneNumber = keyValuePair.Text.ToString(); break; } } if (bNew) { seismosContext.SeismosClients.Add(updateSeismosClient); } retGuid = updateSeismosClient.Id; seismosContext.SaveChanges(); } return(retGuid); }
public string GetStateValue(string key) { string result; using (var seismosContext = new seismosEntities()) { var state = seismosContext.SavedStates.FirstOrDefault(ss => ss.SavedKey == key); result = state?.SavedValue; } return(result); }
private void LoadCasingChart() { using (var seismosContext = new seismosEntities()) { casingChart = new List <CasingChartRecord>(); foreach (var chartLookup in seismosContext.CasingChartLookups) { casingChart.Add(new CasingChartRecord() { Grade = chartLookup.Grade, InnerDiameter = chartLookup.InnerDiameter, OuterDiameter = chartLookup.OuterDiameter, Weight = chartLookup.Weight }); } } }
public List <KeyValueEntity> GetSeismosClients() { List <SeismosClient> seismosClients; using (var seismosContext = new seismosEntities()) { seismosClients = seismosContext.SeismosClients.ToList(); } List <KeyValueEntity> keyValueEntities = new List <KeyValueEntity> { new KeyValueEntity() { Id = Guid.Empty, Name = String.Empty, KeyValuePairs = new List <KeyValueMutable <string, object> >() { new KeyValueMutable <string, object>(ClientName, String.Empty), new KeyValueMutable <string, object>(ContactName, String.Empty), new KeyValueMutable <string, object>(EmailAddress, String.Empty), new KeyValueMutable <string, object>(PhoneNumber, String.Empty) } } }; foreach (var seismosClient in seismosClients) { keyValueEntities.Add(new KeyValueEntity() { Id = seismosClient.Id, Name = seismosClient.ClientName, KeyValuePairs = new List <KeyValueMutable <string, object> >() { new KeyValueMutable <string, object>(ClientName, seismosClient.ClientName), new KeyValueMutable <string, object>(ContactName, seismosClient.Contact), new KeyValueMutable <string, object>(EmailAddress, seismosClient.Email), new KeyValueMutable <string, object>(PhoneNumber, seismosClient.PhoneNumber) } }); } return(keyValueEntities); }
public List <WellEntry> GetWellEntries() { List <WellEntry> wellEntries = new List <WellEntry>(); List <Well> wells; using (var seismosContext = new seismosEntities()) { wells = seismosContext.Wells.Include(w => w.WellBore.Cylinders).ToList(); } wellEntries.AddRange(wells.Select(well => new WellEntry() { Id = well.Id, Name = well.WellName, SurfaceVolume = well.WellBore.SurfaceVolume, TotalVolume = well.WellBore.TotalVolume, CylinderEntries = new ObservableCollection <CylinderEntry>(GetCylinderEntries(well.WellBore)) })); return(wellEntries); }
public KeyValueEntity GetWellNamesEntity(Guid seismosProjectId) { KeyValueEntity wellsEntity = new KeyValueEntity(); SeismosProject targetProject; List <Well> wells; using (var seismosContext = new seismosEntities()) { targetProject = seismosContext.SeismosProjects.FirstOrDefault(sp => sp.Id == seismosProjectId); if (targetProject == null) { return(null); } // wells = seismosContext.Wells.Where(w => w.SeismosProject.Id == targetProject.Id).ToList(); wells = targetProject.Wells.ToList(); wellsEntity.Id = targetProject.Id; wellsEntity.Name = targetProject.Name; foreach (var well in wells) { int numStages = 0; var treatments = seismosContext.Treatments.Where(tr => tr.WellId == well.Id).ToList(); foreach (var treatment in treatments) { if (treatment is HydraulicFracturingTreatment fracturingTreatment) { numStages += fracturingTreatment.Stages.Count(); } } wellsEntity.KeyValuePairs.Add(new KeyValueMutable <string, object>(well.WellName, numStages.ToString())); } } return(wellsEntity); }
public void AddState(string key, string value) { using (var seismosContext = new seismosEntities()) { var state = seismosContext.SavedStates.FirstOrDefault(ss => ss.SavedKey == key); if (state == null) { SavedState savedState = new SavedState() { Id = Guid.NewGuid(), SavedKey = key, SavedValue = value }; seismosContext.SavedStates.Add(savedState); } else { state.SavedValue = value; } seismosContext.SaveChanges(); } }
public NavProjectNode GetProjectNode(Guid projectGuid) { NavProjectNode projectNode = null; using (var seismosContext = new seismosEntities()) { var tempProject = seismosContext.SeismosProjects.FirstOrDefault(sp => sp.Id == projectGuid); if (tempProject == null) { return(null); } projectNode = new NavProjectNode() { Id = tempProject.Id, Name = tempProject.Name }; } projectNode.Wells = GetWellNodes(projectNode.Id); return(projectNode); }
public List <NavProjectNode> GetProjectNodes(Guid clientGuid) { List <NavProjectNode> projectNodes = new List <NavProjectNode>(); using (var seismosContext = new seismosEntities()) { var projects = seismosContext.SeismosProjects.Where(sp => sp.SeismosClientId == clientGuid).OrderBy(sp => sp.Name).ToList(); foreach (var seismosProject in projects) { projectNodes.Add(new NavProjectNode() { Id = seismosProject.Id, Name = seismosProject.Name }); } } foreach (var projectNode in projectNodes) { projectNode.Wells = GetWellNodes(projectNode.Id); } return(projectNodes); }
public List <KeyValueEntity> GetSeismosProjects(Guid seismosClientId) { List <KeyValueEntity> keyValueEntities = new List <KeyValueEntity> { new KeyValueEntity() { Id = Guid.Empty, Name = String.Empty, KeyValuePairs = new List <KeyValueMutable <string, object> >() { new KeyValueMutable <string, object>(ProjectName, String.Empty), new KeyValueMutable <string, object>(Field, String.Empty), new KeyValueMutable <string, object>(Pad, String.Empty), new KeyValueMutable <string, object>(JobNum, String.Empty), new KeyValueMutable <string, object>(AFENum, String.Empty), new KeyValueMutable <string, object>(Formation, String.Empty), new KeyValueMutable <string, object>(County, String.Empty), new KeyValueMutable <string, object>(State, String.Empty), new KeyValueMutable <string, object>(StartDate, DateTime.Now), new KeyValueMutable <string, object>(EndDate, DateTime.Now), new KeyValueMutable <string, object>(LastModified, DateTime.Now), new KeyValueMutable <string, object>(LastModifiedBy, String.Empty) } } }; List <SeismosProject> seismosProjects; if (seismosClientId == Guid.Empty) { return(keyValueEntities); } using (var seismosContext = new seismosEntities()) { seismosProjects = seismosContext.SeismosProjects.Where(sp => sp.SeismosClientId == seismosClientId).ToList(); } foreach (var seismosProject in seismosProjects) { keyValueEntities.Add(new KeyValueEntity() { Id = seismosProject.Id, Name = seismosProject.Name, KeyValuePairs = new List <KeyValueMutable <string, object> >() { new KeyValueMutable <string, object>(ProjectName, seismosProject.Name ?? String.Empty), new KeyValueMutable <string, object>(Field, seismosProject.Field ?? String.Empty), new KeyValueMutable <string, object>(Pad, seismosProject.Pad ?? String.Empty), new KeyValueMutable <string, object>(JobNum, seismosProject.JobNum ?? String.Empty), new KeyValueMutable <string, object>(AFENum, seismosProject.AFENum ?? String.Empty), new KeyValueMutable <string, object>(Formation, seismosProject.Formation ?? String.Empty), new KeyValueMutable <string, object>(County, seismosProject.County ?? String.Empty), new KeyValueMutable <string, object>(State, seismosProject.State ?? String.Empty), new KeyValueMutable <string, object>(StartDate, seismosProject.StartDate), new KeyValueMutable <string, object>(EndDate, seismosProject.EndDate), new KeyValueMutable <string, object>(LastModified, seismosProject.LastModified), new KeyValueMutable <string, object>(LastModifiedBy, seismosProject.LastModifiedBy ?? String.Empty) } }); } return(keyValueEntities); }
public void AddWells(KeyValueEntity wells, Guid targetProjectId) { SeismosProject targetProject; using (var seismosContext = new seismosEntities()) { targetProject = seismosContext.SeismosProjects.FirstOrDefault(sp => sp.Id == targetProjectId); if (targetProject == null) { return; } var currWells = targetProject.Wells.ToList(); foreach (var wellsKeyValuePair in wells.KeyValuePairs) { if (wellsKeyValuePair == null) { continue; } var existingWell = currWells.FirstOrDefault(cw => cw.WellName == wellsKeyValuePair.Id); if (existingWell != null) { continue; } if (!Int32.TryParse(wellsKeyValuePair.Text.ToString(), out var iStagesToCreate)) { iStagesToCreate = 0; } var insertWell = new Well { Id = Guid.NewGuid(), WellName = wellsKeyValuePair.Id, SeismosProject = targetProject }; var hfTreatment = new HydraulicFracturingTreatment() { Id = Guid.NewGuid(), Name = insertWell.WellName + " HF", Type = TreatmentTypeEnum.HydraulicFracturing, Stages = new List <Stage>() }; for (int index = 0; index < iStagesToCreate; index++) { hfTreatment.Stages.Add(new Stage() { Id = Guid.NewGuid(), Number = index, StartTime = DateTime.Now, StopTime = DateTime.Now }); } insertWell.Treatments.Add(hfTreatment); seismosContext.Wells.Add(insertWell); } seismosContext.SaveChanges(); } }
public Guid UpdateSeismosProject(KeyValueEntity seismosKeyValueEntity, Guid seismosClientId) { Guid retGuid; using (var seismosContext = new seismosEntities()) { SeismosProject updateSeismoProject; bool bNew = false; if (seismosKeyValueEntity.Id == Guid.Empty) { updateSeismoProject = new SeismosProject { Id = Guid.NewGuid() }; bNew = true; } else { updateSeismoProject = seismosContext.SeismosProjects.FirstOrDefault(sc => sc.Id == seismosKeyValueEntity.Id); } if (updateSeismoProject == null) { return(Guid.Empty); } updateSeismoProject.SeismosClientId = seismosClientId; foreach (var keyValuePair in seismosKeyValueEntity.KeyValuePairs) { switch (keyValuePair.Id) { case ProjectName: updateSeismoProject.Name = keyValuePair.Text.ToString(); break; case Field: updateSeismoProject.Field = keyValuePair.Text.ToString(); break; case Pad: updateSeismoProject.Pad = keyValuePair.Text.ToString(); break; case JobNum: updateSeismoProject.JobNum = keyValuePair.Text.ToString(); break; case AFENum: updateSeismoProject.AFENum = keyValuePair.Text.ToString(); break; case Formation: updateSeismoProject.Formation = keyValuePair.Text.ToString(); break; case County: updateSeismoProject.County = keyValuePair.Text.ToString(); break; case State: updateSeismoProject.State = keyValuePair.Text.ToString(); break; case StartDate: updateSeismoProject.StartDate = (DateTime)keyValuePair.Text; break; case EndDate: updateSeismoProject.EndDate = (DateTime)keyValuePair.Text; break; case LastModified: updateSeismoProject.LastModified = (DateTime)keyValuePair.Text; break; case LastModifiedBy: updateSeismoProject.LastModifiedBy = keyValuePair.Text.ToString(); break; } } if (bNew) { seismosContext.SeismosProjects.Add(updateSeismoProject); } retGuid = updateSeismoProject.Id; seismosContext.SaveChanges(); } return(retGuid); }
public void UpdateWellEntry(WellEntry wellEntry) { using (var seismosContext = new seismosEntities()) { var currWell = seismosContext.Wells.Where(w => w.Id == wellEntry.Id).Include(w => w.WellBore.Cylinders).FirstOrDefault(); if (currWell == null) { return; } currWell.WellName = wellEntry.Name; if (currWell.WellBore == null) { currWell.WellBore = new WellBore { Id = Guid.NewGuid() }; } currWell.WellBore.Name = wellEntry.Name; currWell.WellBore.SurfaceVolume = wellEntry.SurfaceVolume; currWell.WellBore.TotalVolume = wellEntry.TotalVolume; foreach (var cylinderEntry in wellEntry.CylinderEntries) { if (cylinderEntry.CalculatedVolume.ApproxEquals(0.0)) { break; } if (cylinderEntry.Id == Guid.Empty) { cylinderEntry.Id = Guid.NewGuid(); } bool isNew = false; var wellBoreCylinder = currWell.WellBore.Cylinders.FirstOrDefault(cy => cy.Id == cylinderEntry.Id); if (wellBoreCylinder == null) { wellBoreCylinder = new Cylinder { Id = Guid.NewGuid() }; isNew = true; } wellBoreCylinder.CalculatedVolume = cylinderEntry.CalculatedVolume; wellBoreCylinder.CasingOrderType = (CasingOrderTypeEnum)Enum.Parse(typeof(CasingOrderTypeEnum), cylinderEntry.CasingOrderType); wellBoreCylinder.Grade = cylinderEntry.Grade; wellBoreCylinder.InnerDiameter = cylinderEntry.InnerDiameter; wellBoreCylinder.MeasuredDepth = cylinderEntry.MeasuredDepth; wellBoreCylinder.OuterDiameter = cylinderEntry.OuterDiameter; wellBoreCylinder.TopOfLiner = cylinderEntry.TopOfLiner; wellBoreCylinder.Weight = cylinderEntry.Weight; if (isNew) { currWell.WellBore.Cylinders.Add(wellBoreCylinder); } } seismosContext.SaveChanges(); } }
public void AddWellEntry(WellEntry wellEntry, Guid targetProjectId) { using (var seismosContext = new seismosEntities()) { var targetProject = seismosContext.SeismosProjects.FirstOrDefault(sp => sp.Id == targetProjectId); if (targetProject == null) { return; } var insertWell = new Well { Id = Guid.NewGuid(), WellName = wellEntry.Name, SeismosProject = targetProject, WellBore = new WellBore { Id = Guid.NewGuid(), Name = wellEntry.Name, SurfaceVolume = wellEntry.SurfaceVolume, TotalVolume = wellEntry.TotalVolume } }; foreach (var wellEntryCylinderEntry in wellEntry.CylinderEntries) { var wellBoreCylinder = new Cylinder { Id = Guid.NewGuid(), CalculatedVolume = wellEntryCylinderEntry.CalculatedVolume, CasingOrderType = (CasingOrderTypeEnum)Enum.Parse(typeof(CasingOrderTypeEnum), wellEntryCylinderEntry.CasingOrderType), Grade = wellEntryCylinderEntry.Grade, InnerDiameter = wellEntryCylinderEntry.InnerDiameter, MeasuredDepth = wellEntryCylinderEntry.MeasuredDepth, OuterDiameter = wellEntryCylinderEntry.OuterDiameter, TopOfLiner = wellEntryCylinderEntry.TopOfLiner, Weight = wellEntryCylinderEntry.Weight, InnerInterfaceState = InterfaceStateTypeEnum.NoSlip, OuterInterfaceState = InterfaceStateTypeEnum.NoSlip }; insertWell.WellBore.Cylinders.Add(wellBoreCylinder); } // var hfTreatment = new HydraulicFracturingTreatment() // { // Id = Guid.NewGuid(), // Name = insertWell + " HF", // Type = TreatmentTypeEnum.HydraulicFracturing, // Stages = new List<Stage>() // }; // // // for (int index = 0; index < wellEntry.NumberOfStages; index++) // { // hfTreatment.Stages.Add(new Stage(){Id = Guid.NewGuid(), Number = index, StartTime = DateTime.Now, StopTime = DateTime.Now}); // } // // insertWell.Treatments.Add(hfTreatment); seismosContext.Wells.Add(insertWell); seismosContext.SaveChanges(); } }