Example #1
0
 public static void CerrarElDia(int idUsuario)
 {
     using (ReadCommittedTransactionScope scope = new ReadCommittedTransactionScope(TransactionScopeOption.Required))
     {
         RechazarOrdenesPorCierreDia();
         using (OrdenesContext context = new OrdenesContext())
         {
             int idEstadoSistema = context.EstadoSistema.Where(p1 => p1.IdEstadoSistema != 0).Max(r => r.IdEstadoSistema);
             var entidad         = context.EstadoSistema.Where(p => p.IdEstadoSistema == idEstadoSistema).FirstOrDefault();
             if (entidad != null)
             {
                 EstadoSistemaEntity request = entidad;
                 request.EjecucionValidacion = true;
                 request.EstadoAbierto       = false;
                 request.FechaCierre         = DateTime.Now;
                 request.IdUsuarioCierre     = idUsuario;
             }
             if (!entidad.EstadoAbierto)
             {
                 //Si el Dia ya estaba cerrado, no lo vuelvo a cerrar
                 context.SaveChanges();
             }
         }
         OrdenHelper.InformarMercadoEstado((byte)TipoEstadoSistema.ULTIMO_CERRADO, "CerrarSistemaCommand");
         PortfolioHelper.DesAsociarPortfoliosProductosFCE();
         scope.Complete();
     }
 }
Example #2
0
        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)));
        }
Example #3
0
        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(OrdenEntity orden)
        {
            OrdenHelper.DesbloquearOrden(orden.IdOrden, Source);
            orden.IdEstado = (int)EstadoOrden.Confirmada;
            ordenes.Add(orden);

            return(OrdenHelper.ConfirmarOrden(orden, Source, orden.Timestamp));
        }
Example #5
0
        public ActionResult Create(NovedadModel model)
        {
            var helper = new OrdenHelper();

            helper.Save(model, CurrentUserId);
            InitializeViewBag();

            return(RedirectToAction("Details", "Ticket", new { id = model.NroOrden }));
        }
Example #6
0
 private string DeleteRejectedOrder(Order order)
 {
     try
     {
         return(OrdenHelper.DeleteRejectedOrder(order.IdOrden));
     }
     catch (Exception e)
     {
         throw new M4TraderApplicationException(e.Message + " No se pudo eliminar la orden: " + order.IdOrden);
     }
 }
Example #7
0
        public static void AbrirElDia(int idUsuario)
        {
            bool cerrarAntes = false;
            //TODO: se lo deshabilito temporalmente porque requiere tener habilitado el servicio MS MSDTC (Distributed Transaction Server)
            //using (ReadCommittedTransactionScope scope = new ReadCommittedTransactionScope(TransactionScopeOption.Required))
            //{
            EstadoSistemaEntity estadoSistema;

            using (OrdenesContext context = new OrdenesContext())
            {
                int idEstadoSistema = context.EstadoSistema.Where(p1 => p1.IdEstadoSistema != 0).Max(r => r.IdEstadoSistema);
                estadoSistema = context.EstadoSistema.Where(p => p.IdEstadoSistema == idEstadoSistema).FirstOrDefault();
                if (estadoSistema.EstadoAbierto)
                {
                    cerrarAntes = true;
                }
                if (!cerrarAntes)
                {
                    CleanOfertas_Precios();
                    CleanLimitesDiarios();
                    //context.OpenConnection();
                    EstadoSistemaEntity request = new EstadoSistemaEntity()
                    {
                        EjecucionValidacion = false,
                        EstadoAbierto       = true,
                        FechaCierre         = null,
                        IdUsuarioCierre     = null,
                        FechaApertura       = DateTime.Now,
                        FechaSistema        = DateTime.Now,
                        BajaLogica          = false,
                        IdUsuarioApertura   = idUsuario
                    };
                    context.Add(request);
                    context.SaveChanges();
                    estadoSistema = request;
                }
                else
                {
                    OrdenHelper.ActualizarOrdenes();
                }
            }
            if (!cerrarAntes)
            {
                OrdenHelper.InformarMercadoEstado((byte)TipoEstadoSistema.ULTIMO_ABIERTO, "AbrirSistemaCommand");
                //    scope.Complete();
                //}
            }
            //TODO validar
            else if (estadoSistema.FechaSistema.Date != DateTime.Now.Date)
            {
                CerrarElDiaYAbrirlo(idUsuario);
            }
        }
Example #8
0
        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));
        }
Example #9
0
        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));
        }
        // GET: Reporte
        public ActionResult Recibo(int id)
        {
            var ticket = new OrdenHelper().GetReparacionReciboData(id);

            if (ticket != null)
            {
                return(View(ticket));
            }
            else
            {
                return(View("Error"));
            }
        }
Example #11
0
        public ActionResult KanbanColumn(int id, DateTime?desde, DateTime?hasta, int?tecnicoid, int?comercioid, int?responsableid)
        {
            var model = new ListaOrdenesModel();

            switch (id)
            {
            case 1:
                model.Ordenes = new OrdenHelper().GetOrdenesByEstado(ReparacionEstado.INGRESADO, desde, hasta, tecnicoid, comercioid, responsableid);
                ViewBag.Title = ReparacionEstado.INGRESADO.ToString();
                break;

            case 2:
                model.Ordenes = new OrdenHelper().GetOrdenesByEstado(ReparacionEstado.PRESUPUESTADO, desde, hasta, tecnicoid, comercioid, responsableid);
                ViewBag.Title = ReparacionEstado.PRESUPUESTADO.ToString();
                break;

            case 3:
                model.Ordenes = new OrdenHelper().GetOrdenesByEstado(ReparacionEstado.ESPREPUESTO, desde, hasta, tecnicoid, comercioid, responsableid);
                ViewBag.Title = ReparacionEstado.ESPREPUESTO.ToString();
                break;

            case 4:
                var helper = new OrdenHelper();
                model.Ordenes = helper.GetOrdenesByEstado(ReparacionEstado.AREPARAR, desde, hasta, tecnicoid, comercioid, responsableid);
                model.Ordenes.AddRange(helper.GetOrdenesByEstado(ReparacionEstado.REINGRESADO, desde, hasta, tecnicoid, comercioid, responsableid));
                ViewBag.Title = ReparacionEstado.AREPARAR.ToString();
                break;

            case 5:
                model.Ordenes = new OrdenHelper().GetOrdenesByEstado(ReparacionEstado.REPARADO, desde, hasta, tecnicoid, comercioid, responsableid);
                ViewBag.Title = ReparacionEstado.REPARADO.ToString();
                break;

            case 6:
                model.Ordenes = new OrdenHelper().GetOrdenesByEstado(ReparacionEstado.RECHAZADO, desde, hasta, tecnicoid, comercioid, responsableid);
                ViewBag.Title = ReparacionEstado.RECHAZADO.ToString();
                break;

            case 7:
                model.Ordenes = new OrdenHelper().GetOrdenesByEstado(ReparacionEstado.PARAENTREGAR, desde, hasta, tecnicoid, comercioid, responsableid);
                ViewBag.Title = ReparacionEstado.PARAENTREGAR.ToString();
                break;

            default:
                break;
            }

            ViewBag.ColumnId = $"column-{id}";
            return(PartialView(model));
        }
Example #12
0
        public override object ExecuteCommand(InCourseRequest inCourseRequest)
        {
            var request = (from d in context.PortfoliosComposicion where IdPortfoliosComposiciones.Contains(d.IdPortfoliosComposicion) select d).ToList();

            Productos = request.Select(y => y.IdProducto).Distinct().ToList();
            foreach (int IdProducto in Productos)
            {
                PortfolioHelper.DesHabilitarPortfoliosProductosFCE(IdProducto);
                //TODO poner la key que corresponda.
                string key = string.Empty;
                OrdenHelper.NotificarDesAsociacionProductoPortfolio(IdProducto, "EliminaPortfolioComposicionEmpresasCommand", key);
            }
            return(null);
        }
Example #13
0
        // GET: Novedad/Edit/5
        public ActionResult Edit(int ticketid, int id)
        {
            var ticket = new OrdenHelper().GetOrden(ticketid);
            var model  = ticket.Novedades.Where(x => x.Id == id).FirstOrDefault();

            model.NroOrden = ticketid;
            var tipo = model.TipoNovedadId;

            InitializeViewBag();

            var view = SetNovedadModal(tipo);

            return(PartialView(view, model));
        }
Example #14
0
        public void RecibirGarantiasRespuesta(FixGarantiasEntity garantia)
        {
            var inCourseRequest = InCourseRequest.New();

            try
            {
                CommandLog.Start("RecibirGarantiasRespuesta", garantia, inCourseRequest, "ORSGInRes");
                OrdenHelper.RecibirGarantiasRespuesta(garantia, inCourseRequest.Id);
                CommandLog.FinishOK("RecibirGarantiasRespuesta", garantia, inCourseRequest, "ORSGInRes-OK");
            }
            catch (Exception e)
            {
                CommandLog.FinishWithError("RecibirGarantiasRespuesta", e, inCourseRequest, "ORSGInRes-ERROR");
            }
        }
Example #15
0
        public void RecibirTradeCaptureReportRespuesta(FixTradeCaptureReportInfo tradeCaptureReport)
        {
            var inCourseRequest = InCourseRequest.New();

            try
            {
                CommandLog.Start("RecibirTradeCaptureReportRespuesta", tradeCaptureReport, inCourseRequest, "ORSGInRes");
                OrdenHelper.RecibirTradeCaptureReportRespuesta(tradeCaptureReport, inCourseRequest.Id);
                CommandLog.FinishOK("RecibirTradeCaptureReportRespuesta", tradeCaptureReport, inCourseRequest, "ORSGInRes-OK");
            }
            catch (Exception e)
            {
                CommandLog.FinishWithError("RecibirTradeCaptureReportRespuesta", e, inCourseRequest, "ORSGInRes-ERROR");
            }
        }
Example #16
0
        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 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));
        }
Example #18
0
        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");
            }
        }
Example #19
0
        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);
            }
        }
Example #20
0
        public ActionResult Create(int tipo, int nroOrden)
        {
            var orden = new OrdenHelper().GetOrden(nroOrden);
            var model = new NovedadModel();

            model.NroOrden          = orden.NroOrden;
            model.ResponsableId     = orden.ResponsableId;
            model.ResponsableNombre = orden.ResponsableNombre;
            model.TecnicoId         = orden.TecnicoId;
            model.TecnicoNombre     = orden.TecnicoNombre;
            model.Monto             = orden.Presupuesto;
            model.TipoNovedadId     = tipo;
            model.FechaEntrega      = DateTime.Now;

            InitializeViewBag();

            var view = SetNovedadModal(tipo);

            return(PartialView(view, model));
        }
Example #21
0
 private string CancelarOrdenMercado(OrdenEntity orden, byte[] timeStamp)
 {
     orden.IdOrden = IdOrden;
     return(OrdenHelper.CancelarOrdenMercado(orden, IdMotivo, SourceEnum.Web, timeStamp));
 }
Example #22
0
 public ReparacionController()
 {
     _db          = new FastServiceEntities();
     _OrdenHelper = new OrdenHelper();
 }
        // GET: Domicilio

        public DomicilioController()
        {
            _ordenHelper = new OrdenHelper();
            Origen       = "-34.784654,-58.315066"; //FastService
            Destino      = "-34.784654,-58.315066"; //FastService
        }
        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));
        }
Example #25
0
 private string CancelarOrden(OrdenEntity orden, byte[] timeStamp)
 {
     return(OrdenHelper.CancelarOrden(orden, IdMotivo, SourceEnum.Web, timeStamp));
 }
        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 ActualizarOrdenMercado(OrdenEntity orden)
 {
     return(OrdenHelper.ActualizarOrdenMercado(orden, r_id, SourceEnum.Api, orden.Timestamp));
 }
Example #28
0
 private string ReRegistrarse(string mercado)
 {
     return(OrdenHelper.ReRegistrarse(mercado));
 }
Example #29
0
 public void RecibirHeartBeat()
 {
     OrdenHelper.RecibirHeartBeat();
 }