public Response <bool> CrearOrden(OrdenEntity orden) { Response <bool> response = new Response <bool>(); try { using (OrdenRule rule = new OrdenRule()) { var r = rule.CrearOrden(orden); if (r) { response.Data = r; response.Message = $"Orden creada"; response.StatusCode = HttpStatusCode.OK; } else { response.Data = r; response.Message = "No se encontraron registros"; response.StatusCode = HttpStatusCode.NotFound; } } } catch (Exception ex) { response.StatusCode = HttpStatusCode.InternalServerError; response.Message = ex.Message; } return(response); }
public MensajeDto CrearOrden(OrdenEntity orden) { MySqlCommand cmd = GetMySqlCommandInstance("Proc_InsOrdenes"); cmd.Parameters.Add(new MySqlParameter("idFactura", orden.Factura.IdFactura)); cmd.Parameters.Add(new MySqlParameter("FechaMin", orden.FechaEntregaMinima)); cmd.Parameters.Add(new MySqlParameter("FechaMax", orden.FechaEntregaMaxima)); cmd.Parameters.Add(new MySqlParameter("Peso", orden.Peso)); cmd.Parameters.Add(new MySqlParameter("Tamano", orden.tamanio)); cmd.Parameters.Add(new MySqlParameter("Foto", orden.UrlFoto)); cmd.Parameters.Add(new MySqlParameter("idProveedor", orden.Operador.IdOperador)); MensajeDto retorno = null; using (MySqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { retorno = new MensajeDto { MensajeSms = reader.IsDBNull(reader.GetOrdinal("MensajeSms")) ? string.Empty : (string)reader["MensajeSms"], MensajeEmail = reader.IsDBNull(reader.GetOrdinal("MensajeEmail")) ? string.Empty : (string)reader["MensajeEmail"], Telefono = reader.IsDBNull(reader.GetOrdinal("TelefonoCliente")) ? string.Empty : (string)reader["TelefonoCliente"], Correo = reader.IsDBNull(reader.GetOrdinal("EmailCliente")) ? string.Empty : (string)reader["EmailCliente"], }; } } DisposeCommand(cmd); return(retorno); }
public bool ValidarCambiosModificar(OrdenEntity orden) { bool valid = true; //decimal remanente = OrdenHelper.GetRemanentes(orden.IdOrden); //decimal ejecutada = orden.Cantidad - remanente; switch (orden.IdEstado) { case (int)EstadoOrden.Ingresada: case (int)EstadoOrden.Confirmada: //case (int)EstadoOrden.RechazoMercado: valid = !(orden.Cantidad == (Cantidad + orden.Ejecutadas) && orden.PrecioLimite == PrecioLimite && orden.Plazo == PlazoType); // && Cantidad > ejecutada; break; case (int)EstadoOrden.AplicadaParcial: case (int)EstadoOrden.EnMercado: valid = !(orden.Cantidad == (Cantidad + orden.Ejecutadas) && orden.PrecioLimite == PrecioLimite); // && Cantidad > ejecutada; break; default: valid = false; break; } return(valid); }
private string DistribuirPorEstado(Order order) { OrdenEntity orden = null; if (Source == SourceEnum.Api) { orden = OrdenHelper.DesbloquearOrden(order.IdOrden, Source); } if (Source == SourceEnum.ComplementoDMA) { orden = OrdenHelper.ObtenerOrdenbyNumeroOrdenInterno(order.IdOrden); order.NumeroOrdenMercado = orden.NumeroOrdenMercado; order.NumeroOrdenInterno = orden.NumeroOrdenInterno; } else { orden = OrdenHelper.ObtenerOrdenbyID(order.IdOrden); } switch (orden.IdEstado) { case (int)EstadoOrden.Ingresada: return(CancelarOrden(orden, GetUltimaActualizacion(order.Timestamp))); case (int)EstadoOrden.EnMercado: case (int)EstadoOrden.Aplicada: //case (int)EstadoOrden.AplicadaParcial: return(CancelarOrdenMercado(orden, GetUltimaActualizacion(order.Timestamp))); default: throw new M4TraderApplicationException("Estado no Valido para la orden Nro: " + orden.NumeroOrdenInterno); } }
private string ConfimarOrden(Order order) { OrdenEntity orden = OrdenHelper.DesbloquearOrden(order.IdOrden, Source); orden.IdEstado = (int)EstadoOrden.Confirmada; return(OrdenHelper.ConfirmarOrden(orden, Source, GetUltimaActualizacion(order.Timestamp))); }
private string ConfimarOrden(OrdenEntity orden) { OrdenHelper.DesbloquearOrden(orden.IdOrden, Source); orden.IdEstado = (int)EstadoOrden.Confirmada; ordenes.Add(orden); return(OrdenHelper.ConfirmarOrden(orden, Source, orden.Timestamp)); }
public static void AnularConfirmarOrden(OrdenEntity orden) { List <SqlParameter> lista = new List <SqlParameter>(); lista.Add(SqlServerHelper.GetParam("@IdOrden", orden.IdOrden)); lista.Add(SqlServerHelper.GetParam("@IdEstado", orden.IdEstado)); lista.Add(SqlServerHelper.GetParam("@IdMotivoBaja", orden.IdMotivoBaja)); SqlServerHelper.ExecuteNonQuery("orden_owner.ORD_AnularConfirmarOrden", lista); }
public List <OrdenEntity> ConsultaOrdenes(Filtro filtro) { MySqlCommand cmd = GetMySqlCommandInstance("Proc_GetOrdenes"); cmd.Parameters.Add(new MySqlParameter("inu_IdWayBill", filtro.IdOrden)); List <OrdenEntity> retorno = new List <OrdenEntity>(); OrdenEntity orden = null; using (MySqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { orden = new OrdenEntity { IdOrden = (int)reader["IdWayBill"], FechaEntregaMinima = reader.IsDBNull(reader.GetOrdinal("FechaEntregaMinima")) ? new DateTime() : (DateTime)reader["FechaEntregaMinima"], FechaEntregaMaxima = reader.IsDBNull(reader.GetOrdinal("FechaEntregaMaxima")) ? new DateTime() : (DateTime)reader["FechaEntregaMaxima"], FechaCreacion = reader.IsDBNull(reader.GetOrdinal("FechaCreacion")) ? new DateTime() : (DateTime)reader["FechaCreacion"], Peso = reader.IsDBNull(reader.GetOrdinal("PesoProducto")) ? 0 : (int)reader["PesoProducto"], tamanio = reader.IsDBNull(reader.GetOrdinal("TamañoProducto")) ? string.Empty : (string)reader["TamañoProducto"], UrlFoto = reader.IsDBNull(reader.GetOrdinal("FotoProducto")) ? string.Empty : (string)reader["FotoProducto"], Operador = new OperadorLogisticoEntity { IdOperador = reader.IsDBNull(reader.GetOrdinal("idProveedor")) ? 0 : (int)reader["idProveedor"], Nombre = reader.IsDBNull(reader.GetOrdinal("NombreOperador")) ? string.Empty : (string)reader["NombreOperador"], }, Factura = new FacturaEntity { IdFactura = (int)reader["idFactura"], IdentificacionCliente = reader.IsDBNull(reader.GetOrdinal("NumDocCliente")) ? string.Empty : (string)reader["NumDocCliente"], NombreCliente = reader.IsDBNull(reader.GetOrdinal("NomCliente")) ? string.Empty : (string)reader["NomCliente"], TelefonoCliente = reader.IsDBNull(reader.GetOrdinal("TelCliente")) ? string.Empty : (string)reader["TelCliente"], DireccionCliente = reader.IsDBNull(reader.GetOrdinal("DirCliente")) ? string.Empty : (string)reader["DirCliente"], EmailCliente = reader.IsDBNull(reader.GetOrdinal("EmailCliente")) ? string.Empty : (string)reader["EmailCliente"], FechaCompra = reader.IsDBNull(reader.GetOrdinal("FechaCompra")) ? new DateTime() : (DateTime)reader["FechaCompra"], IdentificacionVendedor = reader.IsDBNull(reader.GetOrdinal("NumDocVendedor")) ? string.Empty : (string)reader["NumDocVendedor"], NombreVendedor = reader.IsDBNull(reader.GetOrdinal("NomVendedor")) ? string.Empty : (string)reader["NomVendedor"], TelefonoVendedor = reader.IsDBNull(reader.GetOrdinal("TelVendedor")) ? string.Empty : (string)reader["TelVendedor"], DireccionVendedor = reader.IsDBNull(reader.GetOrdinal("DirVendedor")) ? string.Empty : (string)reader["DirVendedor"], }, FechaUltimaActualizacion = reader.IsDBNull(reader.GetOrdinal("FechaActualizacion")) ? new DateTime() : (DateTime)reader["FechaActualizacion"], Estado = new EstadoOrdenEntity { IdEstado = reader.IsDBNull(reader.GetOrdinal("idEstado")) ? 0 : (int)reader["idEstado"] } }; retorno.Add(orden); } } DisposeCommand(cmd); return(retorno); }
public override ExecutionResult ExecuteCommand(InCourseRequest inCourseRequest) { Response resultado = new Response(); ordenes = new List <OrdenEntity>(); OrdenEntity orden = OrdenHelper.DesbloquearOrden(IdOrden, Source); ordenes.Add(orden); resultado = ProcesamientoGenerica(DistribuirPorEstado, ordenes); LoggingHelper.Instance.AgregarLog(new LogCommandApiEntity("SICancelaOrdenCommand", "CMD-API", inCourseRequest.Id, resultado)); return(ExecutionResult.ReturnInmediatelyAndQueueOthers(resultado)); }
public override ExecutionResult ExecuteCommand(InCourseRequest inCourseRequest) { OrdenEntity ordenEspejo = OrdenHelper.ObtenerOrdenbyID(IdOrden); OrdenEntity orden = CrearOrdenDesdeEspejo(ordenEspejo); orden.IdUsuario = MAEUserSession.InstanciaCargada ? (int?)MAEUserSession.Instancia.IdUsuario : null; Response resultado = new Response(); resultado.Resultado = eResult.Ok; OrdenHelper.AltaOrdenDMA(orden); resultado.Detalle = JsonConvert.SerializeObject(orden); return(ExecutionResult.ReturnInmediatelyAndQueueOthers(resultado)); }
public static FixOrdenEntity FixOrden_AccionIngresar(OrdenEntity orden, FixTipoAccionEnum fixAccion, PartyEntity persona, MercadoEntity mercado, ProductoEntity producto, MonedaEntity moneda, TipoOrdenEntity tipoOrden, PartyEntity personaEnNombreDe) { FixOrdenEntity fixOrden = new FixOrdenEntity(); fixOrden.Accion = fixAccion; fixOrden.NumeroOrdenLocal = orden.IdOrden; fixOrden.Mercado = mercado.Codigo; fixOrden.Moneda = TraducirMoneda(moneda.CodigoISO); fixOrden.Producto = producto.Codigo; fixOrden.TipoOferta = FixTipoEntradaEnum.Offer; fixOrden.Cantidad = orden.Cantidad; fixOrden.CantidadMinima = orden.CantidadMinima; fixOrden.Side = orden.CompraVenta == "C" ? FixSideOrdenEnum.Buy : FixSideOrdenEnum.Sell; fixOrden.FechaVencimientoOrden = orden.FechaVencimiento; fixOrden.Rueda = orden.Rueda; fixOrden.OperoPorTasa = orden.OperoPorTasa; if (orden.PrecioLimite.HasValue) { fixOrden.TipoOrden = FixTipoOrdenEnum.Limit; fixOrden.Precio = orden.PrecioLimite.Value; } else { fixOrden.TipoOrden = FixTipoOrdenEnum.Market; } if (personaEnNombreDe != null) { fixOrden.ClienteId = personaEnNombreDe.TaxIdentificationNumber; fixOrden.ClienteRol = FixRolParticipanteEnum.Cliente; fixOrden.ClienteNro = personaEnNombreDe.MarketCustomerNumber; } if (orden.Plazo.HasValue && orden.Plazo.Value > 0) { fixOrden.TipoPlazoLiquidacionOrden = (PlazoOrdenEnum)orden.Plazo; //if (orden.Plazo.Value > (byte)PlazoOrdenEnum.Hr96) //{ // orden.FechaLiquidacion = CachingManager.Instance.GetFechaLiquidacion(orden.IdProducto,orden.Plazo); //} } fixOrden.TipoDuracionOrden = traducirTipoOrden(tipoOrden); if (OrdenesApplication.Instance.ContextoAplicacion.EnviarAgentCode && !string.IsNullOrEmpty(persona.AgentCode)) { fixOrden.AgenteNegociadorId = persona.AgentCode; } return(fixOrden); }
public OrdenEntity CreateOrder() { bool existeOrden = OrdenHelper.CheckOrdenActivaEnMercadoByIdProducto(IdProducto); if (Tasa != 0 && !existeOrden) { OrdenEntity orden = new OrdenEntity(); ProductoEntity p = CachingManager.Instance.GetProductoById(IdProducto); orden.CompraVenta = "V"; orden.FechaConcertacion = DateTime.Now.ToUniversalTime(); orden.IdMercado = 1; orden.IdProducto = IdProducto; orden.IdMoneda = p.IdMoneda; orden.IdPersona = IdEmpresa; orden.IdEnNombreDe = null; orden.Cantidad = (decimal)PrecioReferencia; orden.IdSourceApplication = (byte)SourceEnum.Web; orden.PrecioLimite = Tasa; orden.IdTipoOrden = 1; orden.Plazo = (byte)PlazoOrdenEnum.ContadoInmediato; orden.IdEstado = (int)EstadoOrden.Ingresada; orden.IdTipoVigencia = TipoVigencia.NoAplica; orden.Rueda = p.Rueda; orden.Tasa = Tasa; orden.IdUsuario = MAEUserSession.InstanciaCargada ? (int?)MAEUserSession.Instancia.IdUsuario : null; if (p.IdTipoProducto == (byte)TiposProducto.FACTURAS) { orden.OperoPorTasa = true; orden.CantidadMinima = orden.Cantidad; } try { OrdenHelper.AltaOrdenDMA(orden); string key = orden.GetProductKey(); OrdenHelper.NotificarAsociacionProductoPortfolio(p, orden.Valorizacion, key, IdPersonas, IdEmpresa, portfolio, orden.IdMercado); } catch (Exception e) { throw new M4TraderApplicationException(e.Message); } return(orden); } return(null); }
public void RecibirOrdenRespuesta(FixOrdenRespuestaEntity ordenMercado) { OrdenEntity ordenInterna = new OrdenEntity(); var inCourseRequest = InCourseRequest.New(); try { CommandLog.Start("RecibirOrdenRespuesta", ordenMercado, inCourseRequest, "ORSInRes"); OrdenHelper.RecibirOrdenRespuesta(ordenMercado, ordenInterna, inCourseRequest.Id); CommandLog.FinishOK("RecibirOrdenRespuesta", ordenInterna, inCourseRequest, "ORSInRes-OK"); } catch (Exception e) { CommandLog.FinishWithError("RecibirOrdenRespuesta", e, inCourseRequest, "ORSInRes-ERROR"); } }
public override ExecutionResult ExecuteCommand(InCourseRequest inCourseRequest) { Response resultado = new Response(); OrdenEntity orden = new OrdenEntity(); ordenes = new List <OrdenEntity>(); ordenes.Add(OrdenHelper.ObtenerOrdenbyID(IdOrden)); resultado = ProcesamientoGenerica <OrdenEntity>(ConfimarOrden, ordenes); LoggingHelper.Instance.AgregarLog(new LogCommandApiEntity("SIConfirmaOrdenCommand", "CMD-API", inCourseRequest.Id, resultado)); return(ExecutionResult.ReturnInmediatelyAndQueueOthers(resultado)); }
public static FixOrdenEntity FixOrden_AccionActualizar(OrdenEntity orden, FixTipoAccionEnum fixAccion, PartyEntity persona, MercadoEntity mercado, ProductoEntity producto, MonedaEntity moneda) { FixOrdenEntity fixOrden = new FixOrdenEntity(); fixOrden.Accion = fixAccion; fixOrden.Cantidad = orden.Cantidad; fixOrden.CantidadMinima = orden.CantidadMinima; fixOrden.Rueda = orden.Rueda; if (orden.PrecioLimite.HasValue) { fixOrden.Precio = orden.PrecioLimite.Value; } fixOrden.Side = orden.CompraVenta == "C" ? FixSideOrdenEnum.Buy : FixSideOrdenEnum.Sell; fixOrden.NumeroOrdenLocal = orden.IdOrden; fixOrden.Mercado = mercado.Codigo; fixOrden.Moneda = TraducirMoneda(moneda.CodigoISO); fixOrden.Producto = producto.Codigo; fixOrden.NumeroOrdenMercado = orden.NumeroOrdenMercado; fixOrden.TipoOferta = FixTipoEntradaEnum.Offer; if (orden.PrecioLimite.HasValue) { fixOrden.TipoOrden = FixTipoOrdenEnum.Limit; fixOrden.Precio = orden.PrecioLimite.Value; } else { fixOrden.TipoOrden = FixTipoOrdenEnum.Market; } if (orden.Plazo.HasValue && orden.Plazo.Value > 0) { fixOrden.TipoPlazoLiquidacionOrden = (PlazoOrdenEnum)orden.Plazo; } if (OrdenesApplication.Instance.ContextoAplicacion.EnviarAgentCode && !string.IsNullOrEmpty(persona.AgentCode)) { fixOrden.AgenteNegociadorId = persona.AgentCode; } fixOrden.TipoDuracionOrden = FixTipoDuracionOrdenEnum.GTC; return(fixOrden); }
private string DistribuirPorEstado(OrdenEntity order) { var orden = OrdenHelper.ObtenerOrdenbyID(order.IdOrden); switch (orden.IdEstado) { case (int)EstadoOrden.Ingresada: return(CancelarOrden(orden, order.Timestamp)); case (int)EstadoOrden.EnMercado: case (int)EstadoOrden.Aplicada: //case (int)EstadoOrden.AplicadaParcial: return(CancelarOrdenMercado(orden, order.Timestamp)); default: return("Estado no Valido para la orden Nro: " + orden.NumeroOrdenInterno); } }
public bool CrearOrden(OrdenEntity orden) { using (OrdenData data = new OrdenData()) { MensajeDto respuesta = data.CrearOrden(orden); //Enviar Correo if (!string.IsNullOrEmpty(respuesta.Correo)) { EnviarEmailCambioEstado(respuesta.Correo, respuesta.MensajeEmail); } //Enviar mensaje if (!string.IsNullOrEmpty(respuesta.Telefono)) { EnviarSmsCambioEstado(respuesta.Telefono, respuesta.MensajeSms); } return(true); } }
public static void ActualizarOrden(OrdenEntity orden) { List <SqlParameter> lista = new List <SqlParameter>(); lista.Add(SqlServerHelper.GetParam("@IdOrden", orden.IdOrden)); lista.Add(SqlServerHelper.GetParam("@PrecioLimite", orden.PrecioLimite)); lista.Add(SqlServerHelper.GetParam("@Plazo", orden.Plazo)); //if (SettlementDate != null) //{ // lista.Add(SqlServerHelper.GetParam("@SettlementDate", orden.FechaLiquidacion)); //} lista.Add(SqlServerHelper.GetParam("@Cantidad", orden.Cantidad)); lista.Add(SqlServerHelper.GetParam("@IdMercado", orden.IdMercado)); SqlServerHelper.ExecuteNonQuery("orden_owner.ORD_ActualizarOrden", lista); }
private OrdenEntity CrearOrdenDesdeEspejo(OrdenEntity ordenEspejo) { OrdenEntity orden = new OrdenEntity(); orden.CompraVenta = ordenEspejo.CompraVenta == "V" ? "C" : "V"; orden.IdMercado = ordenEspejo.IdMercado; orden.FechaConcertacion = DateTime.Now.ToUniversalTime(); orden.IdTipoVigencia = ordenEspejo.IdTipoVigencia; orden.Cantidad = ordenEspejo.Cantidad; orden.PrecioLimite = NuevoPrecioLimite; orden.IdEstado = (int)EstadoOrden.Ingresada; orden.Plazo = ordenEspejo.Plazo; orden.IdSourceApplication = (byte)SourceEnum.DMA; orden.IdProducto = ordenEspejo.IdProducto; orden.IdMoneda = ordenEspejo.IdMoneda; orden.IdTipoOrden = ordenEspejo.IdTipoOrden; orden.IdEnNombreDe = ordenEspejo.IdEnNombreDe; orden.IdPersona = ordenEspejo.IdPersona; orden.IdOrdenDeReferencia = IdOrden; return(orden); }
public static FixOrdenEntity FixOrden_AccionCancelar(OrdenEntity orden, FixTipoAccionEnum fixAccion, PartyEntity persona, MercadoEntity mercado, ProductoEntity producto, MonedaEntity moneda) { FixOrdenEntity fixOrden = new FixOrdenEntity(); fixOrden.Rueda = orden.Rueda; fixOrden.Mercado = mercado.Codigo; fixOrden.Producto = producto.Codigo; fixOrden.NumeroOrdenLocal = orden.IdOrden; fixOrden.NumeroOrdenMercado = orden.NumeroOrdenMercado; fixOrden.Side = orden.CompraVenta == "C" ? FixSideOrdenEnum.Buy : FixSideOrdenEnum.Sell; fixOrden.Cantidad = orden.Cantidad; fixOrden.CantidadMinima = orden.CantidadMinima; fixOrden.FechaTransaccion = DateTime.Now.ToUniversalTime(); if (OrdenesApplication.Instance.ContextoAplicacion.EnviarAgentCode && !string.IsNullOrEmpty(persona.AgentCode)) { fixOrden.AgenteNegociadorId = persona.AgentCode; } return(fixOrden); }
public static void InsertarOrden(OrdenEntity orden) { List <SqlParameter> lista = new List <SqlParameter>(); lista.Add(SqlServerHelper.GetParam("@CompraVenta", orden.CompraVenta)); lista.Add(SqlServerHelper.GetParam("@IdProducto", orden.IdProducto)); lista.Add(SqlServerHelper.GetParam("@IdMoneda", orden.IdMoneda)); lista.Add(SqlServerHelper.GetParam("@IdMercado", orden.IdMercado)); lista.Add(SqlServerHelper.GetParam("@IdPersona", orden.IdPersona)); lista.Add(SqlServerHelper.GetParam("@IdEnNombreDe", orden.IdEnNombreDe)); lista.Add(SqlServerHelper.GetParam("@FechaConcertacion", orden.FechaConcertacion)); lista.Add(SqlServerHelper.GetParam("@Cantidad", orden.Cantidad)); lista.Add(SqlServerHelper.GetParam("@CantidadMinima", orden.CantidadMinima)); if (orden.IdUsuario.HasValue) { lista.Add(SqlServerHelper.GetParam("@IdUsuario", orden.IdUsuario)); } if (orden.PrecioLimite.HasValue) { lista.Add(SqlServerHelper.GetParam("@PrecioLimite", orden.PrecioLimite.Value)); } lista.Add(SqlServerHelper.GetParam("@IdEstado", orden.IdEstado)); if (orden.IdMotivoBaja.HasValue) { lista.Add(SqlServerHelper.GetParam("@IdMotivoBaja", orden.IdMotivoBaja)); } lista.Add(SqlServerHelper.GetParam("@IdTipoVigencia", (int)orden.IdTipoVigencia)); lista.Add(SqlServerHelper.GetParam("@FechaVencimiento", orden.FechaVencimiento)); lista.Add(SqlServerHelper.GetParam("@NumeroOrdenMercado", orden.NumeroOrdenMercado)); if (orden.Plazo.HasValue) { lista.Add(SqlServerHelper.GetParam("@Plazo", orden.Plazo)); } lista.Add(SqlServerHelper.GetParam("@IdTipoOrden", orden.IdTipoOrden)); lista.Add(SqlServerHelper.GetParam("@IdSourceApplication", orden.IdSourceApplication)); if (orden.IdOrdenDeReferencia.HasValue) { lista.Add(SqlServerHelper.GetParam("@IdOrdenDeReferencia", orden.IdOrdenDeReferencia.Value)); } if (orden.EquivalentRate.HasValue) { lista.Add(SqlServerHelper.GetParam("@EquivalentRate", orden.EquivalentRate.Value)); } lista.Add(SqlServerHelper.GetParam("@OperoPorTasa", orden.OperoPorTasa)); if (orden.PrecioVinculado.HasValue) { lista.Add(SqlServerHelper.GetParam("@PrecioVinculado", orden.PrecioVinculado)); } if (orden.Tasa.HasValue) { lista.Add(SqlServerHelper.GetParam("@Tasa", orden.Tasa)); } SqlParameter p1 = SqlServerHelper.GetParamStringOuput("@IdOrden"); lista.Add(p1); SqlParameter p2 = SqlServerHelper.GetParamStringOuput("@NroOrdenInterno"); lista.Add(p2); SqlParameter p3 = SqlServerHelper.GetParamTimeStampOuput("@timestamp"); lista.Add(p3); SqlServerHelper.ExecuteNonQuery("orden_owner.ORD_InsertarOrden", lista); orden.IdOrden = int.Parse(p1.Value.ToString()); orden.NumeroOrdenInterno = int.Parse(p2.Value.ToString()); orden.Timestamp = (byte[])(p3.Value); }
private string ActualizarOrdenMercado(OrdenEntity orden) { return(OrdenHelper.ActualizarOrdenMercado(orden, r_id, SourceEnum.Api, orden.Timestamp)); }
private string CancelarOrdenMercado(OrdenEntity orden, byte[] timeStamp) { orden.IdOrden = IdOrden; return(OrdenHelper.CancelarOrdenMercado(orden, IdMotivo, SourceEnum.Web, timeStamp)); }
public override object ExecuteCommand(InCourseRequest inCourseRequest) { //portfolio = CachingManager.Instance.GetPortfolioDefaultByIdUsuario(IdUsuario); var coleccion = (from d in context.PortfoliosComposicion where d.IdProducto == IdProducto && d.IdMercado == IdMercado && d.IdPortfolio == portfolio.IdPortfolio && d.IdPlazo == (byte)PlazoOrdenEnum.ContadoInmediato select d); if (coleccion.Count() == 0) { var request = new PortfolioComposicionEntity() { IdMercado = IdMercado, IdPortfolio = Convert.ToInt16(portfolio.IdPortfolio), IdProducto = IdProducto, IdPlazo = (byte)PlazoOrdenEnum.ContadoInmediato }; this.AgregarAlContextoParaAlta(request); } List <PartyEntity> parties = new List <PartyEntity>(); if (!IdPersonas.Equals("0")) { var personas = IdPersonas.Split(',').ToList(); parties = (from d in context.Persona where personas.Contains(d.IdParty.ToString()) select d).ToList(); } else { //si IdPersonas solo tiene el 0, se selecciono "Todos" parties = (from d in context.Persona where d.IdParty != IdEmpresa select d).ToList(); } string strParties = string.Empty; foreach (var party in parties) { strParties += party.Name + ","; if (!(from d in context.PermisosProductosEmpresas where d.IdParty == party.IdParty && d.IdProducto == IdProducto select d).Any()) { var requestUser = new PermisosProductosEntity() { IdProducto = IdProducto, IdParty = party.IdParty, PuedeBid = true, PuedeSell = false, Habilitado = false }; this.AgregarAlContextoParaAlta(requestUser); } } strParties = strParties.Remove(strParties.Length - 1); var partyEmpresa = (from d in context.Persona where d.IdParty == IdEmpresa select d).ToList(); foreach (var p in partyEmpresa) { if (!(from d in context.PermisosProductosEmpresas where d.IdParty == IdEmpresa && d.IdProducto == IdProducto select d).Any()) { var requestEmpresa = new PermisosProductosEntity() { IdProducto = IdProducto, IdParty = p.IdParty, PuedeBid = false, PuedeSell = true, Habilitado = false }; this.AgregarAlContextoParaAlta(requestEmpresa); } } OrdenEntity orden = CreateOrder(); return(ExecutionResult.ReturnInmediatelyAndQueueOthers(new { Ok = orden != null, orden, portfolio, strParties })); }
public override ExecutionResult ExecuteCommand(InCourseRequest inCourseRequest) { if (OrdenHelper.ObtenerOrdenOperacionByProducto(IdProducto.Value)) { throw new M4TraderApplicationException("Ya se cerró una orden para este producto"); } OrdenEntity orden = new OrdenEntity(); orden.CompraVenta = CompraOVenta; orden.FechaConcertacion = DateTime.Now.ToUniversalTime(); orden.IdMercado = IdMercado; ProductoEntity producto = new ProductoEntity(); if (CodigoProducto != null) { producto = CachingManager.Instance.GetProductoByCodigoMonedaDefaultAndRueda(CodigoProducto, orden.IdMercado, SegmentMarketId); } else { producto = CachingManager.Instance.GetProductoById(IdProducto.Value); } orden.IdProducto = producto.IdProducto; orden.IdMoneda = IdMoneda.HasValue ? IdMoneda.Value : producto.IdMoneda; orden.Rueda = SegmentMarketId; orden.IdPersona = IdPersona.HasValue ? IdPersona.Value : MAEUserSession.Instancia.IdPersona; orden.IdEnNombreDe = IdEnNombreDe; orden.Cantidad = Cantidad; orden.CantidadMinima = OfertaParcial ? CantidadMinima : Cantidad; orden.IdSourceApplication = (byte)Source; orden.IdEstado = (int)EstadoOrden.Ingresada; orden.OperoPorTasa = OperoPorTasa; orden.Tasa = Tasa; orden.IdUsuario = MAEUserSession.InstanciaCargada ? (int?)MAEUserSession.Instancia.IdUsuario : null; if (!StopType) { orden.PrecioLimite = PrecioLimite; } if (CodigoPlazoType == "") { CodigoPlazoType = "CI"; } orden.Plazo = PlazoType.HasValue ? PlazoType.Value : CachingManager.Instance.GetAllPlazos().Find(x => x.Descripcion == CodigoPlazoType).IdPlazo; //if (orden.Plazo == (byte)PlazoOrdenEnum.Futuro) //{ // orden.FechaLiquidacion = CachingManager.Instance.GetFechaLiquidacionByIdProductoAndPlazo(orden.Plazo, orden.IdProducto).FechaLiquidacion; //} orden.IdTipoVigencia = IdTipoVigencia.HasValue ? (TipoVigencia)IdTipoVigencia.Value : TipoVigencia.NoAplica; if (orden.IdTipoVigencia != TipoVigencia.NoAplica) { orden.FechaVencimiento = FechaVencimiento; } if (OrderType == "") { OrderType = "0"; } if (producto.IdTipoProducto == (byte)TiposProducto.FACTURAS) { OrderType = "3"; orden.OperoPorTasa = true; orden.Tasa = Tasa; orden.CantidadMinima = orden.Cantidad; } TipoOrdenEntity tipoOrden = CachingManager.Instance.GetTipoOrdenByCodigo(OrderType); if (tipoOrden != null) { orden.IdTipoOrden = tipoOrden.IdTipoOrden; } ResponseGenerico resultado = new ResponseGenerico(); ordenes = new List <OrdenEntity>(); ordenes.Add(orden); resultado.Resultado = (byte)eResult.Ok; OrdenHelper.AltaOrdenDMA(orden); orden.TimestampStr = BitConverter.ToString(orden.Timestamp, 0); resultado.Detalle = JsonConvert.SerializeObject(orden); return(ExecutionResult.ReturnInmediatelyAndQueueOthers(resultado)); }
public override ExecutionResult ExecuteCommand(InCourseRequest inCourseRequest) { Response resultado = new Response(); OrdenEntity orden = new OrdenEntity(); ordenes = new List <OrdenEntity>(); //if (Source == 0) // Source = SourceEnum.Mobile; orden = OrdenHelper.ObtenerOrdenbyID(r_id); ProductoEntity p = CachingManager.Instance.GetProductoById(orden.IdProducto); if (ValidarCambiosModificar(orden)) { orden.IdOrden = r_id; orden.Cantidad = Cantidad + orden.Ejecutadas; orden.CantidadMinima = OfertaParcial ? CantidadMinima : Cantidad; orden.Plazo = PlazoType; if (p.IdTipoProducto == (byte)TiposProducto.FACTURAS) { orden.OperoPorTasa = true; } if (PrecioLimite.HasValue) { orden.PrecioLimite = PrecioLimite.Value; } else { orden.PrecioLimite = null; } ordenes.Add(orden); switch (orden.IdEstado) { case (int)EstadoOrden.Ingresada: case (int)EstadoOrden.Confirmada: resultado = ProcesamientoGenerica <OrdenEntity>(ActualizarOrden, ordenes); break; case (int)EstadoOrden.EnMercado: case (int)EstadoOrden.AplicadaParcial: //case (int)EstadoOrden.RechazoMercado: resultado = ProcesamientoGenerica <OrdenEntity>(ActualizarOrdenMercado, ordenes); break; } } else { ConcurrentBag <string> resultadosOk = new ConcurrentBag <string>(); ConcurrentBag <string> resultadosError = new ConcurrentBag <string>(); resultadosError.Add("No se ingresaron modificaciones para la orden Nro: " + orden.NumeroOrdenInterno); resultado.Resultado = eResult.Error; resultado.SetResponse(resultadosOk, resultadosError, "Ordenes"); } return(ExecutionResult.ReturnInmediatelyAndQueueOthers(resultado)); }
private string CancelarOrden(OrdenEntity orden, byte[] timeStamp) { return(OrdenHelper.CancelarOrden(orden, IdMotivo, SourceEnum.Web, timeStamp)); }