public List <CurrentOperationModel> GetOperationsHistory(int RigId) { List <CurrentOperationModel> model = new List <CurrentOperationModel>(); try { string query = String.Format(@"select WellOpId, ROW_NUMBER()OVER(ORDER BY WellOpId Desc)ROWNUM, WellName, LocName, WellTypeName, SectionName, B.WellDepth, A.CurrentDepth, OperationsName, Datediff(dd, getdate(),WellPlannedDate)DaysOnWell, StartTime, EndTime from WellOperations A inner join Well B on A.WellId = B.WellId inner join WellType C on B.WellTypeId = C.WellTypeId inner join Location D on D.LocId = B.LocationId inner join SectionalDetails E on E.SecId = A.SecId inner join Operations F on F.OperationsId = A.OperationsId where B.RigId = {0} order by WellOpId desc", RigId); fun.OpenConnection(); if (fun.getConnection().State == ConnectionState.Open) { DataSet ds = fun.fillComboDataset(query); if (ds.Tables.Count > 0) { foreach (DataRow item in ds.Tables[0].Rows) { CurrentOperationModel cOpr = new CurrentOperationModel(); cOpr.WellName = item["WellName"].ToString(); cOpr.LocName = item["LocName"].ToString(); cOpr.WellTypeName = item["WellTypeName"].ToString(); cOpr.SectionName = item["SectionName"].ToString(); cOpr.WellDepth = Convert.ToDecimal(item["WellDepth"].ToString()); cOpr.CurrentDepth = Convert.ToDecimal(item["CurrentDepth"].ToString()); cOpr.OperationsName = item["OperationsName"].ToString(); cOpr.DaysOnWell = Convert.ToInt32(item["DaysOnWell"].ToString()); cOpr.ROWNUM = Convert.ToInt32(item["ROWNUM"].ToString()); cOpr.StartTime = Convert.ToDateTime(item["StartTime"].ToString()); if (item["EndTime"].ToString() != "") { cOpr.EndTime = Convert.ToDateTime(item["EndTime"].ToString()); } cOpr.WellOpId = Convert.ToInt32(item["WellOpId"].ToString()); model.Add(cOpr); } } } } catch (Exception ex) { throw ex; } return(model); }
public CurrentOperationModel GetCurrentOperation(int RigId) { CurrentOperationModel model = new CurrentOperationModel(); try { string query = String.Format(@"select top 1 WellName, LocName, WellTypeName, SectionName, B.WellDepth, A.CurrentDepth, OperationsName, Datediff(dd, getdate(),WellPlannedDate)DaysOnWell from WellOperations A inner join Well B on A.WellId = B.WellId inner join WellType C on B.WellTypeId = C.WellTypeId inner join Location D on D.LocId = B.LocationId inner join SectionalDetails E on E.SecId = A.SecId inner join Operations F on F.OperationsId = A.OperationsId where B.RigId = {0} order by WellOpId desc", RigId); fun.OpenConnection(); if (fun.getConnection().State == ConnectionState.Open) { DataSet ds = fun.fillComboDataset(query); if (ds.Tables.Count > 0) { foreach (DataRow item in ds.Tables[0].Rows) { model.WellName = item["WellName"].ToString(); model.LocName = item["LocName"].ToString(); model.WellTypeName = item["WellTypeName"].ToString(); model.SectionName = item["SectionName"].ToString(); model.WellDepth = Convert.ToDecimal(item["WellDepth"].ToString()); model.CurrentDepth = Convert.ToDecimal(item["CurrentDepth"].ToString()); model.OperationsName = item["OperationsName"].ToString(); model.DaysOnWell = Convert.ToInt32(item["DaysOnWell"].ToString()); } } } } catch (Exception ex) { throw ex; } return(model); }