/// <summary> /// Método para almacenar todos los comandos nuevos que aparecen en el fichero de logs /// </summary> /// <param name="commandsList"></param> public Boolean chargeCommands(List<Command> commandsList) { Boolean result = false; CommandDatos cmd = new CommandDatos(); //Cargamos los comandos nuevos del fichero de logs en la base de datos result = cmd.InsertCommands(commandsList); this.modLog.Info("Hemos insertado " + commandsList.Count + " comandos en la base de datos"); return result; }
/// <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 chargeInitialCommands(List<Command> cmdList, BackgroundWorker w) { int j = 0; Boolean end = false; Boolean result = true; int wTimer = 85; CommandDatos cmdDatos = new CommandDatos(); List<Command> listCommandsAux = new List<Command>(); try { do { wTimer++; w.ReportProgress(wTimer); for(int i = 1; i<Constantes.maxInitialCommands && !end; i++) { if (j < cmdList.Count) { listCommandsAux.Add(cmdList[j]); j++; } else { end = true; } } if (!end) { result = result && cmdDatos.InsertInicialCommands(listCommandsAux); listCommandsAux.Clear(); } }while(!end && result); result = result && cmdDatos.InsertInicialCommands(listCommandsAux); } catch (Exception ex) { this.modLog.Error(ex); } return result; }
/// <summary> /// Método para obtener todos los comandos almacenados en la base de Datos /// </summary> public List<Command> getAllCommands() { List<Command> allCommands = new List<Command>(); CommandDatos cmdData = new CommandDatos(); allCommands = cmdData.GetAllCommands(); return allCommands; }
/// <summary> /// Método para borrar todos los datos de todas las tablas de la base de Datos /// </summary> public Boolean restartDataBase(BackgroundWorker worker) { Boolean result = true; Sequences sec = new Sequences(); CommandDatos cmd = new CommandDatos(); CategoryDatos cat = new CategoryDatos(); try { worker.ReportProgress(4); result = result && cmd.DeleteAll(); worker.ReportProgress(6); result = result && cat.DeleteAll(); worker.ReportProgress(10); result = result && sec.restartBothSequences(); } catch (Exception ex) { result = false; this.modLog.Error(ex); } return result; }
/// <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; }