Beispiel #1
0
        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 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();
            }
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        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();
            }
        }
Beispiel #5
0
        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();
            }
        }
Beispiel #6
0
        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();
            }
        }