public bool Agregar(ref ALQUILER oALQUILER) { try { return new AlquilerDao().Agregar(ref oALQUILER); } catch (Exception ex) { throw new FaultException(ex.Message); } }
public bool Agregar(ALQUILER oALQUILER) { try { if (!MessageQueue.Exists(rutaCola)) MessageQueue.Create(rutaCola); MessageQueue cola = new MessageQueue(rutaCola); Message mensaje = new Message(); AlquilerCola oAlquilerCola = new AlquilerCola() { Direccion = oALQUILER.Direccion, Distrito = oALQUILER.Distrito, Estado = oALQUILER.Estado, Fecha = oALQUILER.Fecha, fechaFin = oALQUILER.fechaFin, FechaInicio = oALQUILER.FechaInicio, IdAlquiler = oALQUILER.IdAlquiler, IdPersona = oALQUILER.IdPersona, IdVehiculo = oALQUILER.IdVehiculo }; //cola.Formatter = new XmlMessageFormatter(new Type[] { typeof(ALQUILER) }); mensaje.Label = "Nuevo Alquiler"; //mensaje.Body = oALQUILER; mensaje.Body = oAlquilerCola; cola.Send(mensaje); return true; } catch (Exception ex) { throw new FaultException(ex.Message); } }
public List<ALQUILER> RegistrarAlquilerCola() { try { if (!MessageQueue.Exists(rutaCola)) MessageQueue.Create(rutaCola); MessageQueue cola = new MessageQueue(rutaCola); var Colas = cola.GetAllMessages(); List<AlquilerCola> ListaAlquilerCola = new List<AlquilerCola>(); foreach (Message item in Colas) { cola.Formatter = new XmlMessageFormatter(new Type[] { typeof(AlquilerCola) }); Message mensaje = cola.Receive(); AlquilerCola oAlquilerCola = (AlquilerCola)mensaje.Body; ListaAlquilerCola.Add(oAlquilerCola); } List<ALQUILER> ListaAlquilerError = new List<ALQUILER>(); List<ALQUILER> ListaAlquiler = new List<ALQUILER>(); foreach (var item in ListaAlquilerCola) { var oAlquiler = new ALQUILER() { Direccion = item.Direccion, Distrito = item.Distrito, Estado = item.Estado, Fecha = item.Fecha, fechaFin = item.fechaFin, FechaInicio = item.FechaInicio, IdAlquiler = item.IdAlquiler, IdPersona = item.IdPersona, IdVehiculo = item.IdVehiculo }; try { var vResult = new AlquilerDao().Agregar(ref oAlquiler); if (!vResult) throw new Exception("Error en guardar el alquiler"); ListaAlquiler.Add(oAlquiler); } catch (Exception ex) { ListaAlquilerError.Add(oAlquiler); } } return ListaAlquiler; } catch (FaultException ex) { throw new FaultException(ex.Message); } }