protected override void doSpecificWork(BackgroundWorker worker, DoWorkEventArgs args)
        {
            String msg;
            Boolean result = false;

            try
            {
                worker.ReportProgress(10, Constantes.getMessage("MsgUpdateReportFiltersInit"));

                FilterDataResult filteredData = null;

                if (this.allData == null || this.allData.isEmpty())
                {
                    // Primera llamada al cargar los filtros
                    filteredData = new FilterDataResult();
                    filteredData.UsersList = new UserDatos().GetAllUsers();
                    filteredData.CommandsList = new CommandDatos().GetAllCommandsInCommandsUsed();
                    filteredData.CategoriesList = new CategoryDatos().GetAllCategoriesInCommandsUsed();
                }
                else
                {
                    // Resto de llamadas

                    filteredData = new FilterDataResult(this.allData);

                    if (this.filterToApply.User != null)
                    {
                        // Tenemos que calcular los comandos y categorias que tiene sentido mostrar para el usuario seleccionado.
                        List<Int32> commandIds = new UsedCommandDatos().GetDistinctCommandsUsedBy(this.filterToApply.User);
                        filteredData.CommandsList = filteredData.CommandsList.FindAll(c => commandIds.Contains(c.Id_command));

                        List<Int32> categoryIds = new UsedCommandDatos().GetDistinctCategoriesUsedBy(this.filterToApply.User);
                        filteredData.CategoriesList = filteredData.CategoriesList.FindAll(c => categoryIds.Contains(c.Id_category));
                    }

                    if (this.filterToApply.Command != null)
                    {
                        // Tenemos que calcular los usuarios que tiene sentido mostrar para el comando seleccionado.
                        // La categoría se seleccionará automáticamente la correspondiente al comando, de las que haya en el combo.
                        List<Int32> usersIds = new UsedCommandDatos().GetDistinctUsersUsingCmd(this.filterToApply.Command);
                        filteredData.UsersList = filteredData.UsersList.FindAll(u => usersIds.Contains(u.Id_user));
                        filteredData.CategoriesList = filteredData.CategoriesList.FindAll(u => this.filterToApply.Command.Cat.Equals(u));
                    }

                    if (this.filterToApply.Category != null)
                    {
                        // Tenemos que calcular los usuarios que tiene sentido mostrar para la categoría seleccionada.
                        // Los comandos se seleccionarán automáticamente aquellos que pertenezcan a dicha categoría.
                        List<Int32> usersIds = new UsedCommandDatos().GetDistinctUsersUsingCat(this.filterToApply.Category);
                        filteredData.UsersList = filteredData.UsersList.FindAll(u => usersIds.Contains(u.Id_user));
                        filteredData.CommandsList = filteredData.CommandsList.FindAll(c => this.filterToApply.Category.Equals(c.Cat));
                    }
                }

                args.Result = filteredData;
                result = true;
            }
            catch (Exception ex)
            {
                msg = "Error: Problemas actualizando los filtros que se muestran para generar los informes";
                this.modLog.Error(msg + ex.Message);
            }
            finally
            {
                if (result)
                {
                    worker.ReportProgress(100, Constantes.getMessage("MsgUpdateReportFiltersOk"));
                }
                else
                {
                    throw new Exception("MsgUpdateReportFiltersError");
                }
            }
        }
Example #2
0
        /// <summary>
        /// Método para comprobar si categorías almacenadas en la base de Datos
        /// </summary>
        public Boolean hayCommandsUsed()
        {
            UsedCommandDatos uCmd = new UsedCommandDatos();

            return uCmd.hayUsedCommands();
        }
Example #3
0
        /// <summary>
        /// Método para borrar todos los datos de las tablas usuarios y comandos usados antes de cargar un nuevo fichero de logs a analizar de la base de Datos
        /// </summary>
        public Boolean clearDataBase(BackgroundWorker worker)
        {
            Boolean result = true;
            Sequences sec = new Sequences();
            UserDatos usr = new UserDatos();
            UsedCommandDatos used = new UsedCommandDatos();

            try
            {
                worker.ReportProgress(2);
                result = result && usr.DeleteAll();

                worker.ReportProgress(4);
                result = result && used.DeleteAll();

                worker.ReportProgress(6);
                result = result && sec.restartSequences();
            }
            catch (Exception ex)
            {
                result = false;
                this.modLog.Error(ex);
            }
            return result;
        }
Example #4
0
        /// <summary>
        /// Método para dejar las tablas de la base de Datos totalmente limpias
        /// </summary>
        public Boolean clearAllDataBase(BackgroundWorker worker)
        {
            Boolean result = false;
            UserDatos usr = new UserDatos();
            CommandDatos cmd = new CommandDatos();
            CategoryDatos cat = new CategoryDatos();
            UsedCommandDatos used = new UsedCommandDatos();

            result = true;

            try
            {
                worker.ReportProgress(20, Constantes.getMessage("ReportProgress_BU"));
                result = result && usr.DeleteAll();

                worker.ReportProgress(40, Constantes.getMessage("ReportProgress_BCI"));
                result = result && cmd.DeleteAll();

                worker.ReportProgress(60, Constantes.getMessage("ReportProgress_BC"));
                result = result && cat.DeleteAll();

                worker.ReportProgress(80, Constantes.getMessage("ReportProgress_BL"));
                result = result && used.DeleteAll();
            }
            catch (Exception ex)
            {
                result = false;
                this.modLog.Error(ex);
            }
            return result;
        }
Example #5
0
        /// <summary>
        /// Método para almacenar en la base de datos el uso de comandos registrado en el fichero de logs 
        /// </summary>
        /// <param name="usedCommand"></param>
        public Boolean chargeUsedCommand(UsedCommand usedCommand)
        {
            Boolean result = false;

            //Añadimos el registro de comando usado a la lista, junto con su userId y el nombre del comando
            usedCommandsList.Add(usedCommand);

            //Como vamos a hacer carga masiva, vamos rellenando la lista hasta completarla
            if (usedCommandsList.Count >= Constantes.maxCommandsUsed)
            {
                // Cargamos los comandos utilizados en la base de datos
                result = new UsedCommandDatos().InsertUsedCommands(this.usedCommandsList);
                usedCommandsList.Clear();
            }
            else
            {
                result = true;
            }

            return result;
        }
Example #6
0
        /// <summary>
        /// Método para almacenar los últimos registros de comandos utilizados en la base de datos
        /// </summary>
        public Boolean chargeLastUsedCommands()
        {
            UsedCommandDatos usedCommandDatos = new UsedCommandDatos();
            Boolean result = false;

            try
            {
                // Cargamos el comando utilizado en la base de datos
                result = usedCommandDatos.InsertUsedCommands(this.usedCommandsList);
                usedCommandsList.Clear();
            }
            catch (Exception ex)
            {
                result = false;
                this.modLog.Error(ex);
            }

            return result;
        }