Пример #1
0
        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);
        }
Пример #2
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();
            }
        }
Пример #3
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();
            }
        }