Esempio n. 1
0
        internal static void ProcessAsync(AppJson appJson)
        {
            if (UtilSession.Request(appJson, CommandEnum.BulmaNavbarItemIsClick, out CommandJson commandJson, out BulmaNavbar navbar))
            {
                var  navbarItem = navbar.ItemListAll().Single(item => item.Id == commandJson.BulmaNavbarItemId);
                Grid grid       = navbarItem.Grid;

                // User clicked navbar button
                if (navbarItem.ItemEnum == BulmaNavbarItemEnum.Text)
                {
                    appJson.RequestJson.CommandAdd(new CommandJson {
                        CommandEnum = CommandEnum.GridIsClickRow, ComponentId = grid.Id, RowStateId = navbarItem.RowStateId
                    });
                }

                // User changed navbar filter text
                if (navbarItem.ItemEnum == BulmaNavbarItemEnum.Filter)
                {
                    string filterText = commandJson.BulmaFilterText;
                    int    rowStateId = navbarItem.RowStateId;

                    var column = grid.ColumnList.Single(item => item.FieldNameCSharp == navbarItem.FilterFieldNameCSharp);
                    var cell   = grid.CellList.Single(item => item.RowStateId == rowStateId && item.ColumnId == column.Id && item.CellEnum == GridCellEnum.Filter);

                    appJson.RequestJson.CommandAdd(new CommandJson {
                        CommandEnum = CommandEnum.GridCellIsModify, ComponentId = grid.Id, RowStateId = navbarItem.RowStateId, GridCellId = cell.Id, GridCellText = filterText
                    });
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Returns JsonClient. Create AppJson and process request.
        /// </summary>
        internal async Task <string> ProcessAsync(HttpContext context, AppJson appJson)
        {
            if (appJson == null)
            {
                // Create AppJson with session data.
                appJson = await CreateAppJsonSession(context);
            }

            // Process
            try
            {
                await appJson.ProcessInternalAsync(appJson);
            }
            catch (Exception exception)
            {
                appJson.BootstrapAlert(UtilFramework.ExceptionToString(exception), BootstrapAlertEnum.Error);
                appJson.IsReload = true;
            }

            // Version tag
            RenderVersion(appJson);

            // RequestCount
            appJson.RequestCount = appJson.RequestJson.RequestCount;

            // ResponseCount
            appJson.ResponseCount += 1;

            // SerializeSession, SerializeClient
            UtilSession.Serialize(appJson, out string jsonClientResponse);

            return(jsonClientResponse);
        }
Esempio n. 3
0
        /// <summary>
        /// User clicked home button for example on navbar.
        /// </summary>
        public static Task ProcessHomeIsClickAsync(AppJson appJson)
        {
            if (UtilSession.Request(appJson, CommandEnum.HomeIsClick, out _, out ComponentJson _))
            {
                // User clicked home button
            }

            return(Task.FromResult(0));
        }
Esempio n. 4
0
 /// <summary>
 /// User clicked internal link or clicked backward, forward navigation history. Instead of GET and download Angular again a POST command is sent.
 /// </summary>
 public static async Task ProcessNavigateLinkAsync(AppJson appJson)
 {
     // User clicked internal link.
     if (UtilSession.Request(appJson, RequestCommand.NavigateLink, out CommandJson commandJson, out ComponentJson _))
     {
         await appJson.NavigateSessionInternalAsync(commandJson.NavigateLinkPath, commandJson.NavigateLinkPathIsAddHistory);
     }
     // User clicked backward, forward navigation button.
     if (UtilSession.Request(appJson, RequestCommand.NavigateLinkBackwardForward, out commandJson, out ComponentJson _))
     {
         await appJson.NavigateSessionInternalAsync(commandJson.NavigateLinkPath, commandJson.NavigateLinkPathIsAddHistory);
     }
 }
Esempio n. 5
0
        /// <summary>
        /// User clicked internal link or user clicked backward or forward button in browser. Instead of GET and download Angular again a POST command is sent.
        /// </summary>
        public static async Task ProcessNavigatePostAsync(AppJson appJson)
        {
            // User clicked internal link.
            if (UtilSession.Request(appJson, CommandEnum.NavigatePost, out CommandJson commandJson, out ComponentJson _))
            {
                await appJson.NavigateSessionInternalAsync(commandJson.NavigatePath, commandJson.NavigatePathIsAddHistory);
            }

            // User clicked backward or forward button in browser.
            if (UtilSession.Request(appJson, CommandEnum.NavigateBackwardForward, out commandJson, out ComponentJson _))
            {
                await appJson.NavigateSessionInternalAsync(commandJson.NavigatePath, commandJson.NavigatePathIsAddHistory);
            }
        }
Esempio n. 6
0
 /// <summary>
 /// Process navbar button click.
 /// </summary>
 public static async Task ProcessBootstrapNavbarAsync(AppJson appJson)
 {
     if (UtilSession.Request(appJson, CommandEnum.BootstrapNavbarButtonIsClick, out CommandJson commandJson, out BootstrapNavbar navbar))
     {
         if (navbar.ButtonList != null)
         {
             var buttonList = new List <BootstrapNavbarButton>();
             ProcessBootstrapNavbarButtonListAll(navbar.ButtonList, buttonList);
             foreach (BootstrapNavbarButton button in buttonList)
             {
                 if (commandJson.BootstrapNavbarButtonId == button.Id)
                 {
                     GridRowState rowState = button.Grid.RowStateList[button.RowStateId - 1];
                     await UtilGrid.RowSelectAsync(button.Grid, rowState, isRender : true);
                 }
             }
         }
     }
 }
Esempio n. 7
0
        /// <summary>
        /// Create AppJson with session data.
        /// </summary>
        internal async Task <AppJson> CreateAppJsonSession(HttpContext context)
        {
            // Deserialize RequestJson
            RequestJson requestJson;
            string      requestJsonText = await UtilServer.StreamToString(context.Request.Body);

            if (requestJsonText != null)
            {
                requestJson        = JsonSerializer.Deserialize <RequestJson>(requestJsonText);
                requestJson.Origin = RequestOrigin.Browser;
                foreach (var command in requestJson.CommandList)
                {
                    command.Origin       = RequestOrigin.Browser;
                    command.GridCellText = UtilFramework.StringNull(command.GridCellText); // Sanitize incomming request.
                }
            }
            else
            {
                requestJson = new RequestJson(null)
                {
                    RequestCount = 1
                };
            }

            // Deserialize AppJson (Session) or init
            var appJson = UtilSession.Deserialize();

            // IsExpired
            bool isSessionExpired   = appJson == null && requestJson.RequestCount > 1;
            bool isBrowserRefresh   = appJson != null && requestJson.RequestCount != appJson.RequestCount + 1; // Or BrowserTabSwitch.
            bool isBrowserTabSwitch = appJson != null && requestJson.ResponseCount != appJson.ResponseCount;

            // New session
            if (appJson == null || isBrowserRefresh || isBrowserTabSwitch)
            {
                // New AppJson (Session)
                bool isInit = false;
                if (appJson == null || UtilServer.Context.Request.Method == "GET")
                {
                    appJson = CreateAppJson();
                    isInit  = true;
                }
                appJson.RequestUrl       = UtilServer.RequestUrl();
                appJson.IsSessionExpired = isSessionExpired;

                // New RequestJson
                string browserPath = requestJson.BrowserPath;
                requestJson = new RequestJson(null)
                {
                    RequestCount = requestJson.RequestCount, BrowserUrl = requestJson.BrowserUrl
                };                                                                                                                    // Reset RequestJson.
                appJson.RequestJson = requestJson;

                // Add navigate command to queue
                if (UtilServer.Context.Request.Method == "POST" || browserPath == "/")
                {
                    appJson.Navigate(browserPath, false); // User clicked backward, forward navigation history.
                }

                // New session init
                if (isInit)
                {
                    await appJson.InitInternalAsync();
                }
            }
            else
            {
                appJson.IsSessionExpired = false;
            }

            // Set RequestJson
            appJson.RequestJson = requestJson;

            return(appJson);
        }
Esempio n. 8
0
        public void procesar(TipoProceso tipoProceso)
        {
            logger.info(string.Format("Ejecutando proceso: {0} ", tipoProceso));
            var          utilSession = new UtilSession();
            classSession session     = null;
            string       cuerpoSMS   = "";

            try
            {
                var fecha = getFechaPorTipoProceso(tipoProceso);

                // Crea una instancia de Service Boleto con la configuración según el proceso
                var service = new ServiceBoleto(tipoProceso, fecha);

                // Obtener todos los boletos Emitidos en el DQB
                var boletosEmitidosDQB = service.ObtenerListaBoletosDQB(tipoProceso);

                // Filtra los boletos que no se encuentren VOID
                var boletosAProcesar = boletosEmitidosDQB.Where(boleto => !boleto.Estado.Equals("VOID")).ToList();

                // Obtener todos los boletos Registrados en el PTA
                var boletosRegistradosPTA = service.obtenerBoletoRegistradosPTA(Configuracion.EsquemaDB.Actual);

                // Consolida los boletos en DQB Activos con los boletos en PTA
                var boletosConsolidados = service.consolidarBoletos(boletosAProcesar, boletosRegistradosPTA);

                session = utilSession.getSession();

                // Crea una instancia del Gestor e inyectar session
                GestorProceso gestorProceso = new GestorProceso(session);

                if (boletosConsolidados.Any())
                {
                    if (tipoProceso == TipoProceso.AVISO_NO_FACTURADOS || tipoProceso == TipoProceso.AVISO_NO_FACTURADOS_AYER)
                    {
                        gestorProceso.ejecutarProceso(new ProcesoAvisoNoFacturado(), boletosConsolidados, fecha);
                        gestorProceso.ejecutarProceso(new ProcesoAvisoNoEnPTA(), boletosConsolidados, fecha);
                    }
                    else if (tipoProceso == TipoProceso.AVISO_ANULACION)
                    {
                        gestorProceso.ejecutarProceso(new ProcesoAvisoAnulacion(), boletosConsolidados);
                    }
                    else if (tipoProceso == TipoProceso.ANULACION && "NM".Equals(Configuracion.empresa))
                    {
                        gestorProceso.ejecutarProceso(new ProcesoAnulacion(), boletosConsolidados);
                    }
                    else if (tipoProceso == TipoProceso.AVISO_VOID_DQB_NO_EN_PTA)
                    {
                        boletosAProcesar = boletosEmitidosDQB.Where(boleto => boleto.Estado.Equals("VOID")).ToList();
                        if (boletosAProcesar.Any())
                        {
                        }
                    }
                }
                cuerpoSMS = string.Format("{0} - {1} - Se ejecuto correctamente el proceso {2} del Robot de Anulaciones", Configuracion.Gds, Configuracion.empresa, tipoProceso);
            }
            catch (Exception ex)
            {
                cuerpoSMS = string.Format("{0} - {1} - Ocurrió un error en el proceso {2} del Robot de Anulaciones, Por favor revisar su mail para más detalles.", Configuracion.Gds, Configuracion.empresa, tipoProceso);
                MailUtils.getInstance().sendMailError(ex, tipoProceso);
                logger.info(string.Format("Ocurrió un error inesperado: {0}", ex.ToString()));
            }
            finally
            {
                utilSession.closeSession(session);
                if (tipoProceso == TipoProceso.AVISO_ANULACION || tipoProceso == TipoProceso.ANULACION)
                {
                    new Utilitario().envioSMS(cuerpoSMS, "ROBOT_AVISO_SABRE", Configuracion.contactosEnvioSMS);
                }
            }
        }