예제 #1
0
        public ActionResult GetWells(WellQuery queryBuilder)
        {
            if (queryBuilder == null)
            {
                return(Json(new List <WellReportObject>(), JsonRequestBehavior.AllowGet));
            }


            if (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.BlockId < 1 && queryBuilder.WellClassId < 1 && queryBuilder.FieldId < 1 && queryBuilder.TerrainId < 1 && queryBuilder.ZoneId < 1)
            {
                return(Json(new List <WellReportObject>(), JsonRequestBehavior.AllowGet));
            }

            var wellList = new WellServices().GetOrderedWellReportObjects(queryBuilder) ?? new List <WellReportObject>();

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

            jsonResult.MaxJsonLength = int.MaxValue;
            return(jsonResult);
        }
예제 #2
0
        public ActionResult GetMoreWells()
        {
            int pageNumber = 1;

            var o = Session["_workOverWellpageNumber"];

            if (o != null)
            {
                var tfd = (int)o;
                if (tfd < 1)
                {
                    pageNumber = PageNumber;
                }
                else
                {
                    pageNumber += tfd;
                }
            }

            var dfg = new WellServices().GetWells(400, pageNumber);

            if (!dfg.Any())
            {
                return(Json(new List <WellObject>(), JsonRequestBehavior.AllowGet));
            }
            Session["_workOverWellpageNumber"] = pageNumber;
            return(Json(dfg, JsonRequestBehavior.AllowGet));
        }
예제 #3
0
        public ActionResult GetWells2(int queryId)
        {
            if (queryId < 1)
            {
                return(Json(new List <WellReportObject>(), JsonRequestBehavior.AllowGet));
            }

            var query = new WellQueryBuilderServices().GetWellQuery(queryId);

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

            var wellList = new WellServices().GetOrderedWellReportObjects(query) ?? new List <WellReportObject>();

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

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

            jsonResult.MaxJsonLength = int.MaxValue;
            return(jsonResult);
        }
예제 #4
0
        private List <Well> GetWells(int itemsPerPage, int pageNumber, out int dataCount)
        {
            try
            {
                var fxs = new WellServices().GetAllOrderedWells(itemsPerPage, pageNumber, out dataCount) ?? new List <Well>();
                if (!fxs.Any())
                {
                    return(new List <Well>());
                }
                dataCount         = dataCount - 1;
                ViewBag.DataCount = dataCount.ToString(CultureInfo.InvariantCulture);

                var totalPages = dataCount / itemsPerPage;

                // Counting the last page
                if (dataCount % itemsPerPage != 0)
                {
                    totalPages++;
                }
                fxs.Remove(fxs.Find(m => m.WellId == (int)OtherNotAvailable.Not_Available));
                //ViewBag.ItemCount = (pageNumber * itemsPerPage) - 150;

                ViewBag.TotalPages = totalPages;
                ViewBag.Page       = pageNumber;
                return(fxs);
            }
            catch (Exception ex)
            {
                dataCount = 0;
                ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message);
                return(new List <Well>());
            }
        }
예제 #5
0
        private List <DocObject> GetYears()
        {
            var jxs = new WellServices().GetSpudYears();

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

            jxs.ForEach(m =>
            {
                var gt = 0;
                var ds = int.TryParse(m, out gt);
                if (ds && gt > 0)
                {
                    tdv.Add(new DocObject
                    {
                        DocName = m,
                        DocId   = int.Parse(m)
                    });
                }
            });
            return(tdv.OrderByDescending(m => m.DocName).ToList());
        }
예제 #6
0
        private List <WellObject> GetWells()
        {
            var ttg = new WellServices().GetWells(200, PageNumber);

            if (!ttg.Any())
            {
                return(new List <WellObject>());
            }
            Session["_workOverWellpageNumber"] = 1;
            return(ttg);
        }
예제 #7
0
        private ActionResult GetSelect2Wells()
        {
            try
            {
                var fxs = new WellServices().GetWells() ?? new List <Well>();
                if (!fxs.Any())
                {
                    return(Json(new List <Well>(), JsonRequestBehavior.AllowGet));
                }

                return(Json(fxs, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message);
                return(Json(new List <Well>(), JsonRequestBehavior.AllowGet));
            }
        }
예제 #8
0
        private List <WellReportObject> GetWellObjects(int itemsPerPage, int pageNumber, long companyId)
        {
            try
            {
                var wellList = new WellServices().GetWellObjects(itemsPerPage, pageNumber, companyId) ?? new List <WellReportObject>();

                if (!wellList.Any())
                {
                    return(new List <WellReportObject>());
                }

                return(wellList);
            }
            catch (Exception ex)
            {
                ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message);
                return(new List <WellReportObject>());
            }
        }
예제 #9
0
        public ActionResult EditWell(int id)
        {
            var well = new Well();

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

                var myViewObj = new WellServices().GetWell(id);

                if (myViewObj == null || myViewObj.WellId < 1)
                {
                    well.Error     = "Well  Information could not be retrieved.";
                    well.ErrorCode = -1;
                    return(Json(well, JsonRequestBehavior.AllowGet));
                }
                Session["_well"]    = myViewObj;
                myViewObj.ErrorCode = myViewObj.WellId;
                if (well.SpudDate != null)
                {
                    well.Date = ((DateTime)well.SpudDate).ToString("yyyy/MM/dd");
                }

                return(Json(myViewObj, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message);
                well.Error     = "An unknown error was Well  Information could not be retrieved.";
                well.ErrorCode = -1;
                return(Json(well, JsonRequestBehavior.AllowGet));
            }
        }
        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);
            }
        }
예제 #11
0
        private Well ProcessRecord(DataRowView dv, ref string msg)
        {
            if (dv == null)
            {
                return(null);
            }
            try
            {
                var mInfo = new Well
                {
                    Name = dv.Row["Well_Name"].ToString().Trim(),
                };

                var      spuDate = dv.Row["SPud_Date"].ToString().Trim();
                DateTime d1;
                if (!string.IsNullOrEmpty(spuDate))
                {
                    var realDate = DateTime.TryParse(spuDate, out d1);
                    if (!realDate)
                    {
                        mInfo.SpudDate = DateTime.Now;
                    }
                    mInfo.SpudDate = d1;
                }

                else
                {
                    mInfo.SpudDate = DateTime.Now;
                }


                double dept = 0;
                if (!string.IsNullOrEmpty(dv.Row["Total_Dept"].ToString().Trim()))
                {
                    var totalDeptStr = dv.Row["Total_Dept"].ToString().Trim();

                    var deptResult = double.TryParse(totalDeptStr, out dept);
                    if (!deptResult || dept < 1)
                    {
                        dept = 0;
                    }
                }

                mInfo.TotalDept = dept;

                var remarks = dv.Row["Remarks"].ToString().Trim();

                if (!string.IsNullOrEmpty(remarks))
                {
                    mInfo.Remarks = remarks.Trim();
                }

                var wellTypeName = dv.Row["WellType_Name"].ToString().Trim();

                if (!string.IsNullOrEmpty(wellTypeName))
                {
                    var wellTypeId = new WellTypeServices().GetWellTypeId(wellTypeName);
                    mInfo.WellTypeId = wellTypeId;
                }
                else
                {
                    mInfo.WellTypeId = (int)OtherNotAvailable.Not_Available;
                }

                var techAllowed = dv.Row["Technical_Allowed"].ToString().Trim();
                if (!string.IsNullOrEmpty(techAllowed))
                {
                    double outRes;
                    var    techAllowedResult = double.TryParse(techAllowed, out outRes);
                    if (techAllowedResult && outRes > 0)
                    {
                        mInfo.TechnicalAllowable = outRes;
                    }
                }


                //var blockName = dv.Row["Field_Name"].ToString().Trim();

                //if (!string.IsNullOrEmpty(blockName))
                //{
                //    var blockId = new WellTypeServices().GetWellTypeId(wellTypeName);
                //    if (blockId < 1)
                //    {
                //        mInfo.WellTypeId = (int)OtherNotAvailable.Not_Available;
                //    }
                //    else
                //    {
                //        mInfo.BlockId = blockId;
                //    }

                //}
                //else
                //{
                //    mInfo.WellTypeId = (int)OtherNotAvailable.Not_Available;
                //}

                var wellId = new WellServices().AddWellCheckDuplicate2(mInfo);

                if (wellId > 0)
                {
                    var wellClassName = dv.Row["WellClass_Name"].ToString().Trim();

                    if (!string.IsNullOrEmpty(wellClassName))
                    {
                        var status = new WellClasServices().CreateWellClassAddClassification(wellClassName, wellId);
                        if (status < 1)
                        {
                            msg = "Well could not be classified";
                            return(null);
                        }
                    }
                }
                mInfo.WellId = wellId;
                return(mInfo);
            }
            catch (Exception ex)
            {
                ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message);
                return(null);
            }
        }
예제 #12
0
        public ActionResult WellUpload(HttpPostedFileBase file)
        {
            try
            {
                if (file.ContentLength > 0)
                {
                    const string folderPath = "~/BulkUploadTemplate";

                    var fileName = file.FileName;
                    var path     = folderPath + "/" + fileName;
                    if (System.IO.File.Exists(Server.MapPath(path)))
                    {
                        System.IO.File.Delete(Server.MapPath(path));
                    }
                    file.SaveAs(Server.MapPath(folderPath + "/" + fileName));

                    var mList = new List <Well>();
                    var msg   = string.Empty;
                    if (!new WellUploadManager().Import(Server.MapPath(path), "well", ref mList, ref msg))
                    {
                        ViewBag.ErrorCode    = -1;
                        ViewBag.ErrorMessage = msg;
                        return(View());
                    }

                    if (!mList.Any())
                    {
                        ViewBag.ErrorCode    = -1;
                        ViewBag.ErrorMessage = msg;
                        return(View());
                    }

                    var errorList  = new List <Well>();
                    var succesList = new List <Well>();
                    foreach (var wellInfo in mList)
                    {
                        var wellId = new WellServices().AddWellCheckDuplicate2(wellInfo);

                        if (wellId < 1)
                        {
                            errorList.Add(wellInfo);
                        }
                        else
                        {
                            succesList.Add(wellInfo);

                            if (wellId > 0)
                            {
                                if (!string.IsNullOrEmpty(wellInfo.WellClassName))
                                {
                                    new WellClasServices().CreateWellClassAddClassification(wellInfo.WellClassName, wellId);
                                }
                            }
                        }
                    }
                    if (errorList.Any() && succesList.Any())
                    {
                        var ts = succesList.Count + " records were successfully uploaded." +
                                 "\n" + errorList.Count + " record(s) could not be uploaded due to duplicates/unknown errors encountered.";
                        ViewBag.ErrorCode = -1;

                        if (msg.Length > 0)
                        {
                            ts += "<br/>" + msg;
                        }
                        ViewBag.ErrorMessage = ts;
                        return(View());
                    }

                    if (errorList.Any() && !succesList.Any())
                    {
                        var ts = errorList.Count + " records could not be uploaded due to duplicates/unknown errors encountered.";
                        ViewBag.ErrorCode = -1;

                        if (msg.Length > 0)
                        {
                            ts += "<br/>" + msg;
                        }
                        ViewBag.ErrorMessage = ts;
                        return(View());
                    }

                    if (!errorList.Any() && succesList.Any())
                    {
                        ViewBag.ErrorCode = 5;
                        //ViewBag.ErrorMessage = mList.Count + " records were successfully uploaded.";

                        var tsx = succesList.Count + " records were successfully uploaded.";

                        if (msg.Length > 0)
                        {
                            tsx += "<br/>" + msg;
                        }
                        ViewBag.ErrorMessage = tsx;
                        return(View());
                    }


                    //return View("Wells", new WellViewModel { WellTypes = GetWellTypes(), Companies = GetCompanies(), Blocks = GetBlocks(), Wells = GetWells(ItemsPerPage, PageNumber, out dataCount), WellClasses = GetWellClasses() });
                }
                ViewBag.ErrorCode    = -1;
                ViewBag.ErrorMessage = "The selected file is invalid";
                return(View());
            }
            catch (Exception ex)
            {
                ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message);
                ViewBag.ErrorCode    = -1;
                ViewBag.ErrorMessage = "The selected file is invalid";
                return(View());
            }
        }
예제 #13
0
        public ActionResult EditWell(Well well)
        {
            ModelState.Clear();
            ViewBag.LoadStatus = "0";
            try
            {
                if (Session["_well"] == null)
                {
                    well.Error     = "Session has expired";
                    well.ErrorCode = 0;
                    return(Json(well, JsonRequestBehavior.AllowGet));
                }

                var oldWell = Session["_well"] as Well;

                if (oldWell == null || oldWell.WellId < 1)
                {
                    well.Error     = "Session has expired";
                    well.ErrorCode = -1;
                    return(Json(well, JsonRequestBehavior.AllowGet));
                }

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

                var wx = ValidateControl(well);

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

                oldWell.SpudDate           = well.SpudDate;
                oldWell.Name               = well.Name;
                oldWell.TechnicalAllowable = well.TechnicalAllowable;
                oldWell.WellTypeId         = well.WellTypeId;
                oldWell.TotalDept          = well.TotalDept;
                oldWell.Remarks            = well.Remarks;
                if (well.SpudDate != null)
                {
                    well.Date = ((DateTime)well.SpudDate).ToString("yyyy/MM/dd");
                }

                var k = new WellServices().UpdateWellCheckDuplicate(oldWell);
                if (k < 1)
                {
                    if (k == -3)
                    {
                        well.Error     = "Well  already exists";
                        well.ErrorCode = 0;
                        return(Json(well, JsonRequestBehavior.AllowGet));
                    }

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

                well.Error     = "Well  Information was successfully updated";
                well.ErrorCode = 1;
                return(Json(well, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message);
                well.Error     = "An unknown error was encountered. Request could not be serviced. Please try again later.";
                well.ErrorCode = 0;
                return(Json(well, JsonRequestBehavior.AllowGet));
            }
        }
예제 #14
0
        public ActionResult AddWell(Well well)
        {
            ModelState.Clear();
            ViewBag.LoadStatus = "0";
            try
            {
                if (!ModelState.IsValid)
                {
                    well.Error     = "Please supply all required fields and try again";
                    well.ErrorCode = -1;
                    return(Json(well, JsonRequestBehavior.AllowGet));
                }

                var wx = ValidateControl(well);

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

                var k = new WellServices().AddWellCheckDuplicate(well);
                if (k < 1)
                {
                    if (k == -3)
                    {
                        well.Error     = "Well  already exists";
                        well.ErrorCode = -3;
                        return(Json(well, JsonRequestBehavior.AllowGet));
                    }

                    if (k == -4)
                    {
                        well.Error     = "Well has already been classified";
                        well.ErrorCode = -3;
                        return(Json(well, JsonRequestBehavior.AllowGet));
                    }

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

                if (well.SpudDate != null)
                {
                    well.Date = ((DateTime)well.SpudDate).ToString("yyyy/MM/dd");
                }

                well.Error     = "Record was added successfully";
                well.ErrorCode = 1;
                well.WellId    = k;
                return(Json(well, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message);
                well.Error     = "An unknown error was encountered. Request could not be serviced. Please try again later.";
                well.ErrorCode = 0;
                return(Json(well, JsonRequestBehavior.AllowGet));
            }
        }
예제 #15
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);
            }
        }