コード例 #1
0
        public ActionResult EditWellCompletionInterval(int id)
        {
            var wellCompletionInterval = new WellCompletionInterval();

            try
            {
                if (id < 1)
                {
                    wellCompletionInterval.Error     = "Invalid Selection!";
                    wellCompletionInterval.ErrorCode = -1;
                    return(Json(wellCompletionInterval, JsonRequestBehavior.AllowGet));
                }

                var myViewObj = new WellCompletionIntervalServices().GetWellCompletionInterval(id);

                if (myViewObj == null || myViewObj.WellCompletionIntervalId < 1)
                {
                    wellCompletionInterval.Error     = "Well Completion Interval  Information could not be retrieved.";
                    wellCompletionInterval.ErrorCode = -1;
                    return(Json(wellCompletionInterval, JsonRequestBehavior.AllowGet));
                }
                Session["_wellCompletionInterval"] = myViewObj;
                myViewObj.ErrorCode = myViewObj.WellCompletionIntervalId;
                return(Json(myViewObj, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message);
                wellCompletionInterval.Error     = "An unknown error was encountered. Well Completion Interval  Information could not be retrieved.";
                wellCompletionInterval.ErrorCode = -1;
                return(Json(wellCompletionInterval, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #2
0
        public ActionResult AddWellCompletionInterval(WellCompletionInterval wellCompletionInterval)
        {
            ModelState.Clear();
            ViewBag.LoadStatus = "0";
            try
            {
                if (!ModelState.IsValid)
                {
                    wellCompletionInterval.Error     = "Please supply all required wellCompletionIntervals and try again";
                    wellCompletionInterval.ErrorCode = -1;
                    return(Json(wellCompletionInterval, JsonRequestBehavior.AllowGet));
                }

                var wx = ValidateControl(wellCompletionInterval);

                if (wx.Code < 1)
                {
                    wellCompletionInterval.Error     = wx.Error;
                    wellCompletionInterval.ErrorCode = -1;
                    return(Json(wellCompletionInterval, JsonRequestBehavior.AllowGet));
                }

                //TimeSpan ts = new TimeSpan(DateTime.Now.TimeOfDay);
                wellCompletionInterval.LastUpdatedTime = DateTime.Now.ToString("hh:mm:ss t z");

                var k = new WellCompletionIntervalServices().AddWellCompletionIntervalCheckDuplicate(wellCompletionInterval);
                if (k < 1)
                {
                    if (k == -3)
                    {
                        wellCompletionInterval.Error     = "WellCompletionInterval  already exists";
                        wellCompletionInterval.ErrorCode = -3;
                        return(Json(wellCompletionInterval, JsonRequestBehavior.AllowGet));
                    }

                    wellCompletionInterval.Error     = "Process Failed! Please contact the Admin or try again later";
                    wellCompletionInterval.ErrorCode = 0;
                    return(Json(wellCompletionInterval, JsonRequestBehavior.AllowGet));
                }
                wellCompletionInterval.DatecomPletedString = wellCompletionInterval.DateCompleted;
                wellCompletionInterval.Error     = "Record was added successfully";
                wellCompletionInterval.ErrorCode = 1;
                wellCompletionInterval.WellCompletionIntervalId = k;
                return(Json(wellCompletionInterval, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message);
                wellCompletionInterval.Error     = "An unknown error was encountered. Request could not be serviced. Please try again later.";
                wellCompletionInterval.ErrorCode = 0;
                return(Json(wellCompletionInterval, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #3
0
        public ViewResult WellCompletionIntervals()
        {
            var wellCompletionList = new WellCompletionServices().GetAllOrderedWellCompletions() ?? new List <WellCompletion>();

            if (!wellCompletionList.Any())
            {
                ViewBag.Edit  = 1;
                ViewBag.Title = "Well Completion SetUp";
                var wellCompletionTypeList = new WellCompletionTypeServices().GetAllOrderedWellCompletionTypes() ?? new List <WellCompletionType>();

                if (!wellCompletionTypeList.Any())
                {
                    ViewBag.Edit  = 0;
                    ViewBag.Title = "Well Completion Type SetUp";
                    return(View("~/Views/WellCompletionType/WellCompletionTypes.cshtml", new List <WellCompletionType>()));
                }
            }

            wellCompletionList.ForEach(m =>
            {
                m.WellName = m.Well.Name;
                m.WellCompletionTypeName = m.WellCompletionType.Type;
                m.EquipmentName          = m.Equipment.Name;
            });

            var wellCompletionIntervalList = new WellCompletionIntervalServices().GetAllOrderedWellCompletionIntervals() ?? new List <WellCompletionInterval>();

            if (!wellCompletionIntervalList.Any())
            {
                ViewBag.Edit  = 0;
                ViewBag.Title = "Well Completion Interval SetUp";
                return(View(Tuple.Create(wellCompletionList, new List <WellCompletionInterval>())));
            }

            wellCompletionIntervalList.ForEach(m =>
            {
                m.DatecomPletedString = m.DateCompleted;
                m.WellName            = wellCompletionList.Find(x => x.WellId == m.WellCompletion.WellId).Well.Name;
            });

            var txx = Tuple.Create(wellCompletionList, wellCompletionIntervalList);

            ViewBag.Title = "Manage Well Completion Intervals";
            return(View(txx));
        }
コード例 #4
0
        public ActionResult EditWellCompletionInterval(WellCompletionInterval wellCompletionInterval)
        {
            ModelState.Clear();
            ViewBag.LoadStatus = "0";
            try
            {
                if (Session["_wellCompletionInterval"] == null)
                {
                    wellCompletionInterval.Error     = "Session has expired";
                    wellCompletionInterval.ErrorCode = 0;
                    return(Json(wellCompletionInterval, JsonRequestBehavior.AllowGet));
                }

                var oldWellCompletionInterval = Session["_wellCompletionInterval"] as WellCompletionInterval;

                if (oldWellCompletionInterval == null || oldWellCompletionInterval.WellCompletionIntervalId < 1)
                {
                    wellCompletionInterval.Error     = "Session has expired";
                    wellCompletionInterval.ErrorCode = 0;
                    return(Json(wellCompletionInterval, JsonRequestBehavior.AllowGet));
                }

                if (!ModelState.IsValid)
                {
                    wellCompletionInterval.Error     = "Please supply all required entries and try again";
                    wellCompletionInterval.ErrorCode = -1;
                    return(Json(wellCompletionInterval, JsonRequestBehavior.AllowGet));
                }

                var wx = ValidateControl(wellCompletionInterval);

                if (wx.Code < 1)
                {
                    wellCompletionInterval.Error     = wx.Error;
                    wellCompletionInterval.ErrorCode = -1;
                    return(Json(wellCompletionInterval, JsonRequestBehavior.AllowGet));
                }

                oldWellCompletionInterval.WellCompletionId = wellCompletionInterval.WellCompletionId;
                oldWellCompletionInterval.UpperInterval    = wellCompletionInterval.UpperInterval;
                oldWellCompletionInterval.LowerInterval    = wellCompletionInterval.LowerInterval;
                oldWellCompletionInterval.LastUpdatedTime  = DateTime.Now.ToString("hh:mm:ss t ");
                wellCompletionInterval.DateCompleted       = wellCompletionInterval.DateCompleted;

                var k = new WellCompletionIntervalServices().UpdateWellCompletionIntervalCheckDuplicate(oldWellCompletionInterval);
                if (k < 1)
                {
                    if (k == -3)
                    {
                        wellCompletionInterval.Error     = "Well Completion Interval  already exists";
                        wellCompletionInterval.ErrorCode = 0;
                        return(Json(wellCompletionInterval, JsonRequestBehavior.AllowGet));
                    }

                    wellCompletionInterval.Error     = "Process Failed! Please contact the Admin or try again later";
                    wellCompletionInterval.ErrorCode = 0;
                    return(Json(wellCompletionInterval, JsonRequestBehavior.AllowGet));
                }

                wellCompletionInterval.DatecomPletedString = oldWellCompletionInterval.DateCompleted;
                wellCompletionInterval.Error     = "Well Completion Interval  Information was successfully updated";
                wellCompletionInterval.ErrorCode = 1;
                return(Json(wellCompletionInterval, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message);
                wellCompletionInterval.Error     = "An unknown error was encountered. Request could not be serviced. Please try again later.";
                wellCompletionInterval.ErrorCode = 0;
                return(Json(wellCompletionInterval, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #5
0
        private WellCompletion ProcessRecord2(DataRowView dv, ref string msg, int completionTypeId)
        {
            if (dv == null)
            {
                return(null);
            }
            try
            {
                var wellName = dv.Row["wellname"].ToString().Replace(" ", "").Replace(",", "").Trim();

                if (string.IsNullOrEmpty(wellName.Trim()))
                {
                    return(null);
                }

                var mInfo = new WellCompletion
                {
                    WellName = wellName,
                };

                var ttcg = new WellServices().GetWellIdByName(wellName);

                if (ttcg < 1)
                {
                    msg = "Well Information could not be processed";
                    return(null);
                }

                mInfo.WellId = ttcg;

                var year = dv.Row["datecompleted(yyyy/MM/dd)"].ToString().Trim();
                if (string.IsNullOrEmpty(year))
                {
                    msg = "Completion Date is empty.";
                    return(null);
                }
                else
                {
                    DateTime outYear;
                    var      yrResult = DateTime.TryParse(year, out outYear);
                    if (!yrResult)
                    {
                        msg = "Completion Date is empty.";
                        return(null);
                    }
                    else
                    {
                        mInfo.DateCompleted = outYear;
                    }
                }

                var completionStatus = dv.Row["isinitialcompletion(YES/NO)"].ToString().Trim();

                if (string.IsNullOrEmpty(completionStatus))
                {
                    msg = "Please indicate if Well Completion is Initial or ortherwise.";
                    return(null);
                }
                else
                {
                    if (completionStatus.Trim().ToLower().Replace(" ", "") == "yes")
                    {
                        mInfo.IsInitial = true;
                    }
                    if (completionStatus.Trim().ToLower().Replace(" ", "") == "no")
                    {
                        mInfo.IsInitial = false;
                    }
                }
                double l1;
                double up1;
                double l2;
                double up2;
                var    lowerInter1 = dv.Row["lower_interval_1"].ToString().Trim();
                if (string.IsNullOrEmpty(lowerInter1))
                {
                    msg = "Please provide lower Interval 1.";
                    return(null);
                }
                else
                {
                    double outLint;
                    var    dtResult = double.TryParse(lowerInter1, out outLint);
                    if (!dtResult && outLint < 1)
                    {
                        msg = "Please provide a valid lower Interval 1.";
                        return(null);
                    }
                    else
                    {
                        l1 = outLint;
                    }
                }

                var upperInter = dv.Row["upper_interval_1"].ToString().Trim();
                if (string.IsNullOrEmpty(upperInter))
                {
                    msg = "Please provide Upper Interval 1.";
                    return(null);
                }
                else
                {
                    double outUpint;
                    var    dtResult = double.TryParse(upperInter, out outUpint);
                    if (!dtResult && outUpint < 1)
                    {
                        msg = "Please provide a valid Upper Interval 1.";
                        return(null);
                    }
                    else
                    {
                        up1 = outUpint;
                    }
                }

                var lowerInter2 = dv.Row["lower_interval_2"].ToString().Trim();
                if (string.IsNullOrEmpty(lowerInter2))
                {
                    msg = "Please provide lower Interval 2.";
                    return(null);
                }
                else
                {
                    double outLint2;
                    var    dtResult = double.TryParse(lowerInter2, out outLint2);
                    if (!dtResult && outLint2 < 1)
                    {
                        msg = "Please provide a valid lower Interval 2.";
                        return(null);
                    }
                    else
                    {
                        l2 = outLint2;
                    }
                }

                var upperInter2 = dv.Row["upper_interval_2"].ToString().Trim();
                if (string.IsNullOrEmpty(upperInter2))
                {
                    msg = "Please provide Upper Interval 2.";
                    return(null);
                }
                else
                {
                    double outUpint2;
                    var    dtResult = double.TryParse(upperInter2, out outUpint2);
                    if (!dtResult && outUpint2 < 1)
                    {
                        msg = "Please provide a valid Upper Interval 2.";
                        return(null);
                    }
                    else
                    {
                        up2 = outUpint2;
                    }
                }


                if (!string.IsNullOrEmpty(dv.Row["equipmentused"].ToString().Trim()))
                {
                    var dfv         = dv.Row["equipmentused"].ToString().Trim();
                    var equipmentId = new EquipmentServices().GetEquipmentId(dfv);
                    if (equipmentId < 1)
                    {
                        msg = "Equipment Information could not be processed";
                        return(null);
                    }

                    mInfo.EquipmentId = equipmentId;
                }
                else
                {
                    msg = "Equipment used empty.";
                    return(null);
                }

                mInfo.WellCompletionTypeId = completionTypeId;

                var vvz = new WellCompletionServices().AddWellCompletionCheckDuplicate3(mInfo);
                if (vvz < 1)
                {
                    msg = "Well Completion Interval for the same Period, Reason, Completion Type and Equipment already exists for this well.";
                    return(null);
                }

                var wellCompInt = new WellCompletionInterval
                {
                    LowerInterval    = l1,
                    WellCompletionId = vvz,
                    UpperInterval    = up1,
                    DateCompleted    = mInfo.DateCompleted.ToString(),
                    LastUpdatedTime  = DateTime.Now.ToString("G")
                };

                var vvzk = new WellCompletionIntervalServices().AddWellCompletionIntervalCheckDuplicate(wellCompInt);
                if (vvzk < 1)
                {
                    msg = "Well Completion Information could not be processed.";
                    return(null);
                }

                var tdd = new WellCompletionInterval
                {
                    LowerInterval    = l2,
                    WellCompletionId = vvz,
                    UpperInterval    = up2,
                    DateCompleted    = mInfo.DateCompleted.ToString(),
                    LastUpdatedTime  = DateTime.Now.ToString("G")
                };

                var vvzk2 = new WellCompletionIntervalServices().AddWellCompletionIntervalCheckDuplicate(tdd);
                if (vvzk2 < 1)
                {
                    new WellCompletionIntervalServices().DeleteWellCompletionIntervalCheckReferences(vvzk);
                    msg = "Well Completion Information could not be processed.";
                    return(null);
                }

                return(mInfo);
            }
            catch (Exception ex)
            {
                ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message);
                return(null);
            }
        }
コード例 #6
0
        public ActionResult EditWellCompletion(WellCompletion wellCompletion)
        {
            ModelState.Clear();
            ViewBag.LoadStatus = "0";
            try
            {
                if (Session["_wellCompletion"] == null || Session["_wellCompObj"] == null)
                {
                    wellCompletion.Error     = "Session has expired";
                    wellCompletion.ErrorCode = 0;
                    return(Json(wellCompletion, JsonRequestBehavior.AllowGet));
                }

                var oldWellCompletion = Session["_wellCompletion"] as WellCompletion;
                var oldWellCompObj    = Session["_wellCompObj"] as WellCompletionObject;

                if (oldWellCompletion == null || oldWellCompletion.WellCompletionId < 1 || oldWellCompObj == null || oldWellCompObj.WellCompletionId < 1)
                {
                    wellCompletion.Error     = "Session has expired";
                    wellCompletion.ErrorCode = 0;
                    return(Json(wellCompletion, JsonRequestBehavior.AllowGet));
                }

                if (!ModelState.IsValid)
                {
                    wellCompletion.Error     = "Please supply all required entries and try again";
                    wellCompletion.ErrorCode = -1;
                    return(Json(wellCompletion, JsonRequestBehavior.AllowGet));
                }

                var wx = ValidateControl(wellCompletion);

                if (wx.Code < 1)
                {
                    wellCompletion.Error     = wx.Error;
                    wellCompletion.ErrorCode = -1;
                    return(Json(wellCompletion, JsonRequestBehavior.AllowGet));
                }

                oldWellCompletion.EquipmentId          = wellCompletion.EquipmentId;
                oldWellCompletion.WellId               = wellCompletion.WellId;
                oldWellCompletion.WellCompletionTypeId = wellCompletion.WellCompletionTypeId;
                wellCompletion.IsInitial               = wellCompletion.IsInitial;

                if (wellCompletion.WellCompletionTypeId > 1)
                {
                    if (wellCompletion.L2 <= 0)
                    {
                        wellCompletion.Error     = "Please provide a valid Lower Intervalv 2";
                        wellCompletion.ErrorCode = -1;
                        return(Json(wellCompletion, JsonRequestBehavior.AllowGet));
                    }

                    if (wellCompletion.U2 <= 0)
                    {
                        wellCompletion.Error     = "Please provide a valid Upper Interval 2";
                        wellCompletion.ErrorCode = -1;
                        return(Json(wellCompletion, JsonRequestBehavior.AllowGet));
                    }

                    if (wellCompletion.U2 < wellCompletion.L2 || wellCompletion.U2.Equals(wellCompletion.L2))
                    {
                        wellCompletion.Error     = "Please provide a valid Second Upper Interval 2";
                        wellCompletion.ErrorCode = -1;
                        return(Json(wellCompletion, JsonRequestBehavior.AllowGet));
                    }


                    var newCompletionInterval2 = new WellCompletionInterval
                    {
                        LowerInterval    = wellCompletion.L2,
                        UpperInterval    = wellCompletion.U2,
                        DateCompleted    = wellCompletion.DateCompleted.ToString(),
                        LastUpdatedTime  = DateTime.Now.ToString("g"),
                        WellCompletionId = oldWellCompletion.WellCompletionId
                    };

                    if (oldWellCompObj.IntervalId2 > 0)
                    {
                        newCompletionInterval2.WellCompletionIntervalId = oldWellCompObj.IntervalId2;
                        var r = new WellCompletionIntervalServices().UpdateWellCompletionIntervalCheckDuplicate(newCompletionInterval2);
                        if (r < 1)
                        {
                            wellCompletion.Error     = "Well Completion Interval could not be updated";
                            wellCompletion.ErrorCode = 0;
                            return(Json(wellCompletion, JsonRequestBehavior.AllowGet));
                        }
                    }

                    if (oldWellCompObj.IntervalId2 < 1)
                    {
                        var r = new WellCompletionIntervalServices().AddWellCompletionIntervalCheckDuplicate(newCompletionInterval2);
                        if (r < 1)
                        {
                            wellCompletion.Error     = "Well Completion Interval could not be updated";
                            wellCompletion.ErrorCode = 0;
                            return(Json(wellCompletion, JsonRequestBehavior.AllowGet));
                        }
                    }

                    var newCompletionInterval1 = new WellCompletionInterval
                    {
                        LowerInterval    = wellCompletion.L1,
                        UpperInterval    = wellCompletion.U1,
                        DateCompleted    = wellCompletion.DateCompleted.ToString(),
                        LastUpdatedTime  = DateTime.Now.ToString("g"),
                        WellCompletionId = oldWellCompletion.WellCompletionId
                    };

                    if (oldWellCompObj.IntervalId1 > 0)
                    {
                        newCompletionInterval1.WellCompletionIntervalId = oldWellCompObj.IntervalId1;
                        var r = new WellCompletionIntervalServices().UpdateWellCompletionIntervalCheckDuplicate(newCompletionInterval1);
                        if (r < 1)
                        {
                            wellCompletion.Error     = "Well Completion Interval could not be updated";
                            wellCompletion.ErrorCode = 0;
                            return(Json(wellCompletion, JsonRequestBehavior.AllowGet));
                        }
                    }

                    if (oldWellCompObj.IntervalId1 < 1)
                    {
                        var r = new WellCompletionIntervalServices().AddWellCompletionIntervalCheckDuplicate(newCompletionInterval1);
                        if (r < 1)
                        {
                            wellCompletion.Error     = "Well Completion Interval could not be updated";
                            wellCompletion.ErrorCode = 0;
                            return(Json(wellCompletion, JsonRequestBehavior.AllowGet));
                        }
                    }
                }

                if (wellCompletion.WellCompletionTypeId < 2)
                {
                    if (wellCompletion.U1 <= 0)
                    {
                        wellCompletion.Error     = "Please provide a valid Upper Interval";
                        wellCompletion.ErrorCode = -1;
                        return(Json(wellCompletion, JsonRequestBehavior.AllowGet));
                    }

                    if (wellCompletion.U1 < wellCompletion.L1 || wellCompletion.U1.Equals(wellCompletion.L1))
                    {
                        wellCompletion.Error     = "Please provide a valid Upper Interval";
                        wellCompletion.ErrorCode = -1;
                        return(Json(wellCompletion, JsonRequestBehavior.AllowGet));
                    }

                    if (oldWellCompObj.IntervalId2 > 0)
                    {
                        var r = new WellCompletionIntervalServices().DeleteWellCompletionIntervalCheckReferences(oldWellCompObj.IntervalId2);
                        if (!r)
                        {
                            wellCompletion.Error     = "The process could not be completed. The requested item update will cause data loss.";
                            wellCompletion.ErrorCode = 0;
                            return(Json(wellCompletion, JsonRequestBehavior.AllowGet));
                        }
                    }

                    var newCompletionInterval = new WellCompletionInterval
                    {
                        LowerInterval    = wellCompletion.L1,
                        UpperInterval    = wellCompletion.U1,
                        DateCompleted    = wellCompletion.DateCompleted.ToString(),
                        LastUpdatedTime  = DateTime.Now.ToString("g"),
                        WellCompletionId = oldWellCompletion.WellCompletionId
                    };

                    if (oldWellCompObj.IntervalId1 > 0)
                    {
                        newCompletionInterval.WellCompletionIntervalId = oldWellCompObj.IntervalId1;
                        var r = new WellCompletionIntervalServices().UpdateWellCompletionIntervalCheckDuplicate(newCompletionInterval);
                        if (r < 1)
                        {
                            wellCompletion.Error     = "Well Completion Interval could not be updated";
                            wellCompletion.ErrorCode = 0;
                            return(Json(wellCompletion, JsonRequestBehavior.AllowGet));
                        }
                    }

                    if (oldWellCompObj.IntervalId1 < 1)
                    {
                        var r = new WellCompletionIntervalServices().AddWellCompletionIntervalCheckDuplicate(newCompletionInterval);
                        if (r < 1)
                        {
                            wellCompletion.Error     = "Well Completion Interval could not be updated";
                            wellCompletion.ErrorCode = 0;
                            return(Json(wellCompletion, JsonRequestBehavior.AllowGet));
                        }
                    }
                }

                var k = new WellCompletionServices().UpdateWellCompletionCheckDuplicate(oldWellCompletion);
                if (k < 1)
                {
                    wellCompletion.Error     = "Process Failed! Please contact the Admin or try again later";
                    wellCompletion.ErrorCode = 0;
                    return(Json(wellCompletion, JsonRequestBehavior.AllowGet));
                }

                wellCompletion.Error     = "Well Completion  Information was successfully updated";
                wellCompletion.ErrorCode = 1;
                return(Json(wellCompletion, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message);
                wellCompletion.Error     = "An unknown error was encountered. Request could not be serviced. Please try again later.";
                wellCompletion.ErrorCode = 0;
                ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message);
                return(Json(wellCompletion, JsonRequestBehavior.AllowGet));
            }
        }