Example #1
0
        public ActionResult GetWellWorkovers2(int queryId)
        {
            if (queryId < 1)
            {
                return(Json(new List <WellWorkoverReportObject>(), JsonRequestBehavior.AllowGet));
            }

            var query = new WellWorkoverQueryBuilderServices().GetWellWorkoverQuery(queryId);

            if (query == null || query.WellWorkoverQueryId < 1)
            {
                return(Json(new List <WellWorkoverReportObject>(), JsonRequestBehavior.AllowGet));
            }

            var wellWorkoverList = new WellWorkoverServices().GetOrderedWellWorkoverReportObjects(query) ?? new List <WellWorkoverReportObject>();

            if (!wellWorkoverList.Any())
            {
                return(Json(new List <WellWorkoverReportObject>(), JsonRequestBehavior.AllowGet));
            }

            var jsonResult = Json(wellWorkoverList, JsonRequestBehavior.AllowGet);

            jsonResult.MaxJsonLength = int.MaxValue;
            return(jsonResult);
        }
        public List <WellWorkover> GetWorkoversBySearchDate(int searchMonth, int searchYear)
        {
            try
            {
                var wellWorkOvers = new WellWorkoverServices().GetAllOrderedWellWorkoversByMonth(searchMonth, searchYear);

                if (!wellWorkOvers.Any())
                {
                    return(new List <WellWorkover>());
                }

                wellWorkOvers.ForEach(m =>
                {
                    m.WellName      = m.Well.Name;
                    m.EquipmentName = m.Equipment.Name;
                    m.Reason        = m.WellWorkOverReason.Title;
                    m.MonthStr      = Enum.GetName(typeof(MonthList), m.Month);
                });
                return(wellWorkOvers);
            }
            catch (Exception ex)
            {
                return(new List <WellWorkover>());
            }
        }
        public ActionResult EditWellWorkover(int id)
        {
            var wellWorkover = new WellWorkover();

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

                var myViewObj = new WellWorkoverServices().GetWellWorkover(id);

                if (myViewObj == null || myViewObj.WellWorkOverId < 1)
                {
                    wellWorkover.Error     = "Well Workover information could not be retrieved.";
                    wellWorkover.ErrorCode = -1;
                    return(Json(wellWorkover, JsonRequestBehavior.AllowGet));
                }
                Session["_wellWorkover"] = myViewObj;
                myViewObj.ErrorCode      = myViewObj.WellWorkOverId;
                return(Json(myViewObj, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message);
                wellWorkover.Error     = "An unknown error was encountered. Well Workover  Information could not be retrieved.";
                wellWorkover.ErrorCode = -1;
                return(Json(wellWorkover, JsonRequestBehavior.AllowGet));
            }
        }
        public ActionResult AddWellWorkover(WellWorkover wellWorkover)
        {
            ModelState.Clear();
            ViewBag.LoadStatus = "0";
            try
            {
                if (!ModelState.IsValid)
                {
                    wellWorkover.Error     = "Please supply all required well Completions and try again";
                    wellWorkover.ErrorCode = -1;
                    return(Json(wellWorkover, JsonRequestBehavior.AllowGet));
                }

                var wx = ValidateControl(wellWorkover);

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

                wellWorkover.Year          = wellWorkover.WorkoverDate.Year;
                wellWorkover.Month         = wellWorkover.WorkoverDate.Month;
                wellWorkover.DateCompleted = wellWorkover.WorkoverDate.ToString("yyyy/mm/dd");
                var k = new WellWorkoverServices().AddWellWorkover(wellWorkover);
                if (k < 1)
                {
                    wellWorkover.Error     = "Process Failed! Please contact the Admin or try again later";
                    wellWorkover.ErrorCode = 0;
                    return(Json(wellWorkover, JsonRequestBehavior.AllowGet));
                }

                wellWorkover.Error          = "Record was added successfully";
                wellWorkover.ErrorCode      = 1;
                wellWorkover.WellWorkOverId = k;
                return(Json(wellWorkover, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message);
                wellWorkover.Error     = "An unknown error was encountered. Request could not be serviced. Please try again later.";
                wellWorkover.ErrorCode = 0;
                return(Json(wellWorkover, JsonRequestBehavior.AllowGet));
            }
        }
        private List <WellWorkoverReportObject> GetWorkoverObjects(int pageNumber, int itemsPerPage, GenericSearch search)
        {
            try
            {
                var wellWorkoverObjects = new WellWorkoverServices().GetMoreWellWorkoverReport(itemsPerPage, pageNumber, search.Month, search.Year);

                if (!wellWorkoverObjects.Any())
                {
                    return(new List <WellWorkoverReportObject>());
                }

                return(wellWorkoverObjects);
            }
            catch (Exception ex)
            {
                return(new List <WellWorkoverReportObject>());
            }
        }
        private List <WellWorkover> GetWellWorkoverReports(int itemsPerPage, int pageNumber)
        {
            try
            {
                var wellWorkOvers = new WellWorkoverServices().GetWellWorkoversForReport(itemsPerPage, pageNumber);

                if (!wellWorkOvers.Any())
                {
                    return(new List <WellWorkover>());
                }

                return(wellWorkOvers);
            }
            catch (Exception ex)
            {
                return(new List <WellWorkover>());
            }
        }
        private List <WellWorkoverReportObject> GetWellWorkOverObjects(int itemsPerPage, int pageNumber)
        {
            try
            {
                var wellCompletions = new WellWorkoverServices().GetMoreWellWorkovers(itemsPerPage, pageNumber);

                if (!wellCompletions.Any())
                {
                    return(new List <WellWorkoverReportObject>());
                }

                return(wellCompletions);
            }
            catch (Exception ex)
            {
                return(new List <WellWorkoverReportObject>());
            }
        }
        private List <WellWorkover> GetWellWorkovers(int itemsPerPage, int pageNumber, out int dataCount)
        {
            try
            {
                var wellWorkOvers = new WellWorkoverServices().GetAllOrderedWellWorkovers(itemsPerPage, pageNumber, out dataCount);

                ViewBag.PrDataCount = dataCount.ToString(CultureInfo.InvariantCulture);

                var totalPages = dataCount / itemsPerPage;

                // Counting the last page
                if (dataCount % itemsPerPage != 0)
                {
                    totalPages++;
                }

                ViewBag.PrTotalPages = totalPages;
                ViewBag.PrPage       = pageNumber;
                if (!wellWorkOvers.Any())
                {
                    return(new List <WellWorkover>());
                }

                wellWorkOvers.ForEach(m =>
                {
                    m.WellName       = m.Well.Name;
                    m.EquipmentName  = m.Equipment.Name;
                    m.Reason         = m.WellWorkOverReason.Title;
                    m.MonthStr       = Enum.GetName(typeof(MonthList), m.Month);
                    m.WorkoverPeriod = m.Month + "/" + m.Year;
                });

                return(wellWorkOvers);
            }
            catch (Exception ex)
            {
                ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message);
                dataCount = 0;
                return(new List <WellWorkover>());
            }
        }
Example #9
0
        private List <DocObject> GetYears()
        {
            var jxs = new WellWorkoverServices().GetWellWorkoverYears();

            if (!jxs.Any())
            {
                return(new List <DocObject>());
            }
            var tdv = new List <DocObject>();

            jxs.ForEach(m =>
            {
                var ts = m;

                if (!tdv.Exists(t => t.DocId == ts))
                {
                    tdv.Add(new DocObject {
                        DocName = m.ToString(CultureInfo.InvariantCulture), DocId = ts
                    });
                }
            });
            return(tdv.OrderByDescending(m => m.DocName).ToList());
        }
Example #10
0
        public ActionResult GetWellWorkovers(WellWorkoverQuery queryBuilder)
        {
            if (queryBuilder == null)
            {
                return(Json(new List <WellWorkoverReportObject>(), JsonRequestBehavior.AllowGet));
            }

            if (queryBuilder.EquipmentId < 1 && queryBuilder.WellTypeId < 1 && queryBuilder.CompanyId < 1 && ((queryBuilder.StartDate != null && queryBuilder.StartDate.Value.Year == 0001) || (queryBuilder.StartDate == null)) && ((queryBuilder.EndDate != null && queryBuilder.EndDate.Value.Year == 0001) || (queryBuilder.EndDate == null)) && queryBuilder.WorkoverReasonId < 1 && queryBuilder.WellClassId < 1 && queryBuilder.TerrainId < 1 && queryBuilder.ZoneId < 1)
            {
                return(Json(new List <WellWorkoverReportObject>(), JsonRequestBehavior.AllowGet));
            }

            var wellWorkoverList = new WellWorkoverServices().GetOrderedWellWorkoverReportObjects(queryBuilder) ?? new List <WellWorkoverReportObject>();

            if (!wellWorkoverList.Any())
            {
                return(Json(new List <WellWorkoverReportObject>(), JsonRequestBehavior.AllowGet));
            }
            Session["_successfulWellWorkoverQuery"] = queryBuilder;
            var jsonResult = Json(wellWorkoverList, JsonRequestBehavior.AllowGet);

            jsonResult.MaxJsonLength = int.MaxValue;
            return(jsonResult);
        }
        public ActionResult EditWellWorkover(WellWorkover wellWorkover)
        {
            ModelState.Clear();
            ViewBag.LoadStatus = "0";
            try
            {
                if (Session["_wellWorkover"] == null)
                {
                    wellWorkover.Error     = "Session has expired";
                    wellWorkover.ErrorCode = 0;
                    return(Json(wellWorkover, JsonRequestBehavior.AllowGet));
                }

                var oldWellWorkover = Session["_wellWorkover"] as WellWorkover;

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

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

                var wx = ValidateControl(wellWorkover);

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

                oldWellWorkover.EquipmentId          = wellWorkover.EquipmentId;
                oldWellWorkover.WellId               = wellWorkover.WellId;
                oldWellWorkover.WellWorkOverReasonId = wellWorkover.WellWorkOverReasonId;
                oldWellWorkover.Year          = wellWorkover.WorkoverDate.Year;
                oldWellWorkover.Month         = wellWorkover.WorkoverDate.Month;
                oldWellWorkover.DateCompleted = wellWorkover.WorkoverDate.ToString("yyyy/mm/dd");
                wellWorkover.MonthStr         = Enum.GetName(typeof(MonthList), oldWellWorkover.Month);
                var k = new WellWorkoverServices().UpdateWellWorkover(oldWellWorkover);
                if (k < 1)
                {
                    wellWorkover.Error     = "Process Failed! Please contact the Admin or try again later";
                    wellWorkover.ErrorCode = 0;
                    return(Json(wellWorkover, JsonRequestBehavior.AllowGet));
                }

                wellWorkover.Error     = "Well Workover Reason was successfully updated";
                wellWorkover.ErrorCode = 1;
                return(Json(wellWorkover, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message);
                wellWorkover.Error     = "An unknown error was encountered. Request could not be serviced. Please try again later.";
                wellWorkover.ErrorCode = 0;
                return(Json(wellWorkover, JsonRequestBehavior.AllowGet));
            }
        }
Example #12
0
        private WellWorkover ProcessRecord(DataRowView dv, ref string msg)
        {
            if (dv == null)
            {
                return(null);
            }
            try
            {
                var wellName = dv.Row["well_name"].ToString().Replace(" ", "").Replace(",", "").Trim();

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

                var mInfo = new WellWorkover
                {
                    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["workover_Completion_year(yyyy)"].ToString().Trim();
                long outYear;
                var  yrResult = long.TryParse(year, out outYear);
                if (!yrResult && outYear < 1)
                {
                    msg = "Invalid Workover Completion Year.";
                    return(null);
                }
                else
                {
                    mInfo.Year = outYear;
                }
                //workover_Completion_year(yyyy)

                var month = dv.Row["workover_Completion_month(MM)"].ToString().Trim();
                int outMonth;
                var mnResult = int.TryParse(month, out outMonth);
                if (!mnResult && outMonth < 1)
                {
                    msg = "Invalid Workover Completion Month.";
                    return(null);
                }
                else
                {
                    mInfo.Month = outMonth;
                }


                mInfo.DateCompleted = outYear + "/" + outMonth + "/01";

                if (!string.IsNullOrEmpty(dv.Row["equipment_used"].ToString().Trim()))
                {
                    var dfv         = dv.Row["equipment_used"].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 is empty.";
                    return(null);
                }

                var reason = dv.Row["workover_reason"].ToString().Trim();
                if (!string.IsNullOrEmpty(reason))
                {
                    var dfv      = reason;
                    var reasonId = new WellWorkOverReasonServices().GetWellWorkOverReasonIdByName(dfv);
                    if (reasonId < 1)
                    {
                        msg = "Workover Reason Information could not be processed";
                        return(null);
                    }
                    mInfo.WellWorkOverReasonId = reasonId;
                }
                else
                {
                    msg = "Workover Reason is empty";
                    return(null);
                }
                var status = new WellWorkoverServices().AddWellWorkoverCheckDuplicates(mInfo, mInfo.WellId, mInfo.WellWorkOverReasonId, mInfo.Month, mInfo.Year);
                if (status < 1)
                {
                    if (status == -3)
                    {
                        msg = "Well workover for the same Period, Reason and Equipment already exists for this well.";
                        return(null);
                    }

                    msg = "An error encountered during upload.";
                    return(null);
                }

                mInfo.WellWorkOverId = status;
                return(mInfo);
            }
            catch (Exception ex)
            {
                ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message);
                return(null);
            }
        }