public List <Oleoducto> GetListOleoductosByNombre(string Nombre) { List <Oleoducto> ductos = new List <Oleoducto>(); try { using (SqlConnection cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["CNPC_Ductos"].ConnectionString)) { SqlCommand cmd = new SqlCommand("uspGetListOleoductosByNombre", cnn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@Nombre", SqlDbType.VarChar).Value = Nombre; cnn.Open(); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { Oleoducto d = new Oleoducto(); d.Id = reader.SafeGetInt32("Id", 0); d.Cliente = reader.SafeGetString("Cliente", ""); d.Codigo = reader.SafeGetString("Codigo", ""); d.Descripcion = reader.SafeGetString("Descripcion", ""); d.Ubicacion = reader.SafeGetString("Ubicacion", ""); d.NoLamina = reader.SafeGetString("NoLamina", ""); d.FechaInspeccion = reader.SafeGetDateTime("FechaInspeccion", new DateTime(1950, 01, 01)); d.Presion = reader.SafeGetDecimal("Presion", 0); d.Temperatura = reader.SafeGetDecimal("Temperatura", 0); d.BLPD = reader.SafeGetInt32("BLPD", 0); d.Schedule1 = reader.SafeGetInt32("Schedule1", 0); d.Schedule2 = reader.SafeGetInt32("Schedule2", 0); d.Schedule3 = reader.SafeGetInt32("Schedule3", 0); d.Material1 = reader.SafeGetString("Material1", ""); d.Material2 = reader.SafeGetString("Material2", ""); d.Material3 = reader.SafeGetString("Material3", ""); d.LongitudTotal = reader.SafeGetDecimal("LongitudTotal", 0); d.BSW = reader.SafeGetString("BSW", ""); d.RowState = reader.SafeGetString("RowState", ""); d.LastUpdate = reader.SafeGetDateTime("LastUpdate", new DateTime(1950, 01, 01)); ductos.Add(d); } cnn.Close(); } //using (SqlConnection cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["CNPC_Ductos"].ConnectionString)) //{ // SqlCommand cmd = new SqlCommand("uspGetCountOleoductos", cnn); // cmd.CommandType = CommandType.StoredProcedure; // cmd.Parameters.Add("@Nombre", SqlDbType.VarChar).Value = Nombre; // cnn.Open(); // SqlDataReader reader = cmd.ExecuteReader(); // cnn.Close(); //} } catch (Exception ex) { throw (new Exception("Error: " + ex.Message)); } return(ductos); }
public static OleoductoViewModel ConvertToViewModel(this Oleoducto request) { var resultado = new OleoductoViewModel { Id = request.Id, Cliente = request.Cliente, Descripcion = request.Descripcion, NoLamina = request.NoLamina, Ubicacion = request.Ubicacion, Material1 = request.Material1, Material2 = request.Material2, Material3 = request.Material3, Schedule1 = request.Schedule1, Schedule2 = request.Schedule2, Schedule3 = request.Schedule3, BLPD = request.BLPD, Presion = request.Presion, Temperatura = request.Temperatura, BSW = request.BSW, FechaInspeccion = request.FechaInspeccion, RowState = request.RowState, LastUpdate = request.LastUpdate }; return(resultado); }
public static Oleoducto ConvertToModel(this OleoductoViewModel model) { Oleoducto resultado = new Oleoducto { Id = model.Id, Cliente = model.Cliente, Descripcion = model.Descripcion, NoLamina = model.NoLamina, Ubicacion = model.Ubicacion, Material1 = model.Material1, Material2 = model.Material2, Material3 = model.Material3, Schedule1 = model.Schedule1, Schedule2 = model.Schedule2, Schedule3 = model.Schedule3, BLPD = model.BLPD, Presion = model.Presion, Temperatura = model.Temperatura, BSW = model.BSW, FechaInspeccion = model.FechaInspeccion, RowState = model.RowState, LastUpdate = model.LastUpdate }; return(resultado); }
public bool Update(Oleoducto ductoToUpdate) { bool Result = false; using (var r = new Repository <Oleoducto>()) { Oleoducto d = r.Retrieve(p => p.Codigo == ductoToUpdate.Codigo & p.Descripcion == ductoToUpdate.Descripcion & p.Codigo == ductoToUpdate.Codigo & p.Cliente == ductoToUpdate.Cliente & p.BLPD == ductoToUpdate.BLPD & p.BSW == ductoToUpdate.BSW & p.FechaInspeccion == ductoToUpdate.FechaInspeccion & p.Material1 == ductoToUpdate.Material1 & p.Material2 == ductoToUpdate.Material2 & p.Material3 == ductoToUpdate.Material3 & p.NoLamina == ductoToUpdate.NoLamina & p.Presion == ductoToUpdate.Presion & p.Schedule1 == ductoToUpdate.Schedule1 & p.Schedule2 == ductoToUpdate.Schedule2 & p.Schedule3 == ductoToUpdate.Schedule3 & p.Temperatura == ductoToUpdate.Temperatura & p.Ubicacion == ductoToUpdate.Ubicacion); if (d == null) { Result = r.Update(ductoToUpdate); } else { throw (new Exception("El Ducto especificado No existe")); } } return(Result); }
public Oleoducto RetrieveByID(int ID) { Oleoducto Result = null; using (var r = new Repository <Oleoducto>()) { Result = r.Retrieve(p => p.Id == ID); } return(Result); }
public RegistroInspeccionVisualResponse FilterByDuctoIdRegistroInspeccionVisual(int ductoId, string Nombre, string Estado) { RegistroInspeccionVisualResponse Result = new RegistroInspeccionVisualResponse(); Oleoducto ducto = null; using (var r = new Repository <RegistroInspeccionVisual>()) { Result.List = r.Filter(p => p.OleoductoID == ductoId && p.CodigoDelTubo.Contains(Nombre) && p.RowState == Estado); } using (var p = new Repository <Oleoducto>()) { ducto = p.Retrieve(q => q.Id == ductoId); ducto.LongitudTotal = p.LongitudOleoducto(ductoId); } Result.oleoducto = ducto; return(Result); }
public Oleoducto Create(Oleoducto newDucto) { Oleoducto Result = null; using (var r = new Repository <Oleoducto>()) { Oleoducto d = r.Retrieve(p => p.Codigo == newDucto.Codigo); if (d == null) { Result = r.Create(newDucto); } else { throw (new Exception("El Ducto especificado ya existe")); } } return(Result); }
public RegistroInspeccionVisualResponse FilterByNameRegistroInspeccionVisual(int OleoductoId, string Nombre, int page, int records) { RegistroInspeccionVisualResponse Result = null; Oleoducto ducto = null; using (var r = new Repository <RegistroInspeccionVisual>()) { Result = r.FilterByNameRegistroInspeccionVisual(OleoductoId, Nombre, page, records); } using (var p = new Repository <Oleoducto>()) { ducto = p.Retrieve(q => q.Id == OleoductoId); ducto.LongitudTotal = p.LongitudOleoducto(OleoductoId); } using (var q = new Repository <TipoSoporte>()) { Result.ListTipoSoporte.List = q.Filter(p => p.Nombre.Contains("")); } Result.oleoducto = ducto; return(Result); }
public OleoductoResponse FilterByNameOleoducto(string Nombre, int page, int records) { OleoductoResponse ductos = new OleoductoResponse(); ductos.List = new List <Oleoducto>(); try { using (SqlConnection cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["CNPC_Ductos"].ConnectionString)) { SqlCommand cmd = new SqlCommand("uspGetListOleoductos", cnn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@Nombre", SqlDbType.VarChar).Value = Nombre; cmd.Parameters.Add("@Records", SqlDbType.Int).Value = records; cmd.Parameters.Add("@Page", SqlDbType.Int).Value = page; cmd.Parameters.Add("@TotalPage", SqlDbType.Int).Direction = ParameterDirection.Output; cnn.Open(); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { Oleoducto d = new Oleoducto(); d.Id = reader.SafeGetInt32("Id", 0); d.Cliente = reader.SafeGetString("Cliente", ""); d.Codigo = reader.SafeGetString("Codigo", ""); d.Descripcion = reader.SafeGetString("Descripcion", ""); d.Ubicacion = reader.SafeGetString("Ubicacion", ""); d.NoLamina = reader.SafeGetString("NoLamina", ""); d.FechaInspeccion = reader.SafeGetDateTime("FechaInspeccion", new DateTime(1950, 01, 01)); d.Presion = reader.SafeGetDecimal("Presion", 0); d.Temperatura = reader.SafeGetDecimal("Temperatura", 0); d.BLPD = reader.SafeGetInt32("BLPD", 0); d.Schedule1 = reader.SafeGetInt32("Schedule1", 0); d.Schedule2 = reader.SafeGetInt32("Schedule2", 0); d.Schedule3 = reader.SafeGetInt32("Schedule3", 0); d.Material1 = reader.SafeGetString("Material1", ""); d.Material2 = reader.SafeGetString("Material2", ""); d.Material3 = reader.SafeGetString("Material3", ""); d.LongitudTotal = reader.SafeGetDecimal("LongitudTotal", 0); d.BSW = reader.SafeGetString("BSW", ""); d.RowState = reader.SafeGetString("RowState", ""); d.LastUpdate = reader.SafeGetDateTime("LastUpdate", new DateTime(1950, 01, 01)); ductos.List.Add(d); } ductos.Page = page; ductos.Records = records; cnn.Close(); } using (SqlConnection cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["CNPC_Ductos"].ConnectionString)) { SqlCommand cmd = new SqlCommand("uspGetCountOleoductos", cnn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@Nombre", SqlDbType.VarChar).Value = Nombre; cmd.Parameters.Add("@Records", SqlDbType.Int).Value = records; cmd.Parameters.Add("@Page", SqlDbType.Int).Value = page; cnn.Open(); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { ductos.TotalPages = reader.SafeGetInt32("TotalPage", 0); ductos.TotalRecords = reader.SafeGetInt32("TotalRecords", 0); } cnn.Close(); } } catch (Exception ex) { ductos.Resultado = false; ductos.MensajeError = "Capa BLL: " + ex.Message; } return(ductos); }