diff --git a/.gitignore b/.gitignore index 4594cc9..8a0fb8f 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ obj/ Debug/ test/ packages/ +Migrations/ .vs *.ide-shm *.cache diff --git a/ShockQuiz/DAL/EntityFramework/Mapping/PreguntaMap.cs b/ShockQuiz/DAL/EntityFramework/Mapping/PreguntaMap.cs index 4a0c857..cf6da34 100644 --- a/ShockQuiz/DAL/EntityFramework/Mapping/PreguntaMap.cs +++ b/ShockQuiz/DAL/EntityFramework/Mapping/PreguntaMap.cs @@ -29,6 +29,16 @@ public PreguntaMap() this.HasRequired(x => x.Conjunto) .WithMany(x => x.Preguntas) .HasForeignKey(x => x.ConjuntoId); + + /*this.HasRequired(x => x.SesionActual) + .WithMany(x => x.Preguntas) + .HasForeignKey(x => x.SesionActualId);*/ + + this.Property(x => x.SesionActualId) + .IsRequired() + .HasColumnName("idSesionActual"); + + this.Ignore(x => x.ConjuntoNombre); } } } diff --git a/ShockQuiz/DAL/EntityFramework/Mapping/SesionMap.cs b/ShockQuiz/DAL/EntityFramework/Mapping/SesionMap.cs index 8bb4b7c..18c95a7 100644 --- a/ShockQuiz/DAL/EntityFramework/Mapping/SesionMap.cs +++ b/ShockQuiz/DAL/EntityFramework/Mapping/SesionMap.cs @@ -14,7 +14,7 @@ public SesionMap() .HasDatabaseGeneratedOption(System.ComponentModel.DataAnnotations.Schema.DatabaseGeneratedOption.Identity) .HasColumnName("id"); - this.Property(x => x.CantidadPreguntas) + this.Property(x => x.PreguntasRestantes) .HasColumnName("cantidadPreguntas") .IsRequired(); @@ -31,8 +31,7 @@ public SesionMap() .IsRequired(); this.Property(x => x.FechaFin) - .HasColumnName("fechaInicio") - .IsRequired(); + .HasColumnName("fechaInicio"); this.Property(x => x.FechaFin) .HasColumnName("fechaFin") @@ -46,8 +45,8 @@ public SesionMap() .WithMany(x => x.Sesiones) .HasForeignKey(x => x.ConjuntoId); - this.Ignore(x => x.Preguntas); - this.Ignore(x => x.RespuestasCorrectas); + this.Property(x => x.RespuestasCorrectas); + this.Property(x => x.CantidadTotalPreguntas); } } } diff --git a/ShockQuiz/DAL/EntityFramework/RepositorioPregunta.cs b/ShockQuiz/DAL/EntityFramework/RepositorioPregunta.cs index 808ac8f..5baab71 100644 --- a/ShockQuiz/DAL/EntityFramework/RepositorioPregunta.cs +++ b/ShockQuiz/DAL/EntityFramework/RepositorioPregunta.cs @@ -44,7 +44,7 @@ public IEnumerable ObtenerTodas() /// Conjunto /// Cantidad de Preguntas /// - public IEnumerable ObtenerPreguntas(Categoria pCategoria, Dificultad pDificultad, Conjunto pConjunto, int pCantidad = 10) + public IEnumerable ObtenerPreguntas(int pCategoria, int pDificultad, int pConjunto, int pCantidad = 10) { var list = from t in iDbContext.Preguntas @@ -52,13 +52,13 @@ public IEnumerable ObtenerPreguntas(Categoria pCategoria, Dificultad p .Include(x => x.Categoria) .Include(x => x.Dificultad) .Include(x => x.Conjunto) - where t.Categoria.Nombre == pCategoria.Nombre - && t.Dificultad.Nombre == pDificultad.Nombre - && t.Conjunto.Nombre == pConjunto.Nombre + where t.Categoria.Id == pCategoria + && t.Dificultad.Id == pDificultad + && t.Conjunto.ConjuntoId == pConjunto select t; if (list.Count() >= pCantidad) { - return list.ToList().OrderBy(x => rnd.Next()).Take(pCantidad); + return list; } else { @@ -70,7 +70,8 @@ public string GetOrCreate(string pNombre, string pConjunto) { var manager = ((IObjectContextAdapter)iDbContext).ObjectContext; - var dbPregunta = iDbContext.Preguntas.ToList().Where(x => x.Nombre == pNombre && x.Conjunto.Nombre == pConjunto).Any(); + var dbPregunta = iDbContext.Preguntas.Include(x => x.Conjunto).ToList() + .Where(x => x.Nombre == pNombre && x.Conjunto.Nombre == pConjunto).Any(); @@ -110,5 +111,34 @@ public IEnumerable ObtenerCategorias(int pConjunto) } return listaCategorias; } + + /// + /// Este método se utiliza para obtener todas las instancias de la clase Pregunta + /// las cuales poseen una sesión activa, a partir de su ID. + /// + /// El ID de la sesión activa + /// + public IEnumerable ObtenerPreguntasPorSesion(int pIdSesion) + { + var preguntasFiltradas = (from p in iDbContext.Preguntas.Include(x => x.Respuestas) + where p.SesionActualId == pIdSesion + select p); + return preguntasFiltradas; + } + + /// + /// Este método se utiliza para obtener una pregunta y sus respuestas + /// a partir de si ID. + /// + /// El ID de la pregunta a traer + /// + public Pregunta ObtenerPreguntaPorId(int pIdPregunta) + { + var pregunta = (from p in iDbContext.Preguntas.Include(x => x.Respuestas) + where p.PreguntaId == pIdPregunta + select p + ); + return pregunta.First(); + } } } diff --git a/ShockQuiz/DAL/EntityFramework/RepositorioSesion.cs b/ShockQuiz/DAL/EntityFramework/RepositorioSesion.cs index da339bd..08ca165 100644 --- a/ShockQuiz/DAL/EntityFramework/RepositorioSesion.cs +++ b/ShockQuiz/DAL/EntityFramework/RepositorioSesion.cs @@ -1,6 +1,7 @@ using ShockQuiz.Dominio; using System.Collections.Generic; using System.Linq; +using System; namespace ShockQuiz.DAL.EntityFramework { @@ -36,5 +37,49 @@ public IEnumerable ObtenerTodas(string pUsuario) { return this.iDbContext.Set().Where(x => x.Usuario.Nombre == pUsuario); } + + /// + /// Devuelve la sesion que se encuentre activa en la base de datos. + /// + /// + public IEnumerable ObtenerSesionActiva() + { + var sesionActiva = from s in iDbContext.Sesiones + .Include("Conjunto") + .Include("Categoria") + .Include("Dificultad") + where !s.SesionFinalizada + select s; + return sesionActiva; + } + + /// + /// Este método se utiliza para obtener la última sesión que se ha + /// subido a la base de datos. + /// + /// + public Sesion ObtenerUltimaSesion() + { + var ultimaSesion = from s in iDbContext.Sesiones + .Include("Conjunto") + select s; + return ultimaSesion.OrderByDescending(x => x.SesionId).First(); + } + + /// + /// Este método se utiliza para obtener una sesión de la base de datos + /// a partir de su ID, así como su conjunto y dificultad. + /// + /// El ID de la sesión a traer + /// + public Sesion ObtenerSesionId(int pIdSesion) + { + var sesionActiva = from s in iDbContext.Sesiones + .Include("Conjunto") + .Include("Dificultad") + where s.SesionId == pIdSesion + select s; + return sesionActiva.First(); + } } } diff --git a/ShockQuiz/DAL/EntityFramework/RepositorioUsuario.cs b/ShockQuiz/DAL/EntityFramework/RepositorioUsuario.cs index bc8c4ba..9a623bb 100644 --- a/ShockQuiz/DAL/EntityFramework/RepositorioUsuario.cs +++ b/ShockQuiz/DAL/EntityFramework/RepositorioUsuario.cs @@ -35,7 +35,10 @@ public IEnumerable ObtenerTodos() /// public Usuario ObtenerPorNombre(string pNombre) { - return this.iDbContext.Set().First(x => x.Nombre == pNombre); + var usuarios = (from u in iDbContext.Usuarios + where u.Nombre == pNombre + select u); + return usuarios.First(); } } } diff --git a/ShockQuiz/DAL/EntityFramework/ShockQuizDbContext.cs b/ShockQuiz/DAL/EntityFramework/ShockQuizDbContext.cs index d437e3a..96de4cd 100644 --- a/ShockQuiz/DAL/EntityFramework/ShockQuizDbContext.cs +++ b/ShockQuiz/DAL/EntityFramework/ShockQuizDbContext.cs @@ -8,7 +8,7 @@ public class ShockQuizDbContext : DbContext { public ShockQuizDbContext() : base("ShockQuiz") { - Database.SetInitializer(new MigrateDatabaseToLatestVersion()); + //Database.SetInitializer(new MigrateDatabaseToLatestVersion()); } public DbSet Preguntas { get; set; } diff --git a/ShockQuiz/DAL/IRepositorioPregunta.cs b/ShockQuiz/DAL/IRepositorioPregunta.cs index 88c736c..6b9975c 100644 --- a/ShockQuiz/DAL/IRepositorioPregunta.cs +++ b/ShockQuiz/DAL/IRepositorioPregunta.cs @@ -7,9 +7,11 @@ public interface IRepositorioPregunta : IRepositorio { void AgregarPreguntas(IEnumerable pPreguntas); - IEnumerable ObtenerPreguntas(Categoria pCategoria, Dificultad pDificultad, Conjunto pConjunto, int pCantidad); + IEnumerable ObtenerPreguntas(int pCategoria, int pDificultad, int pConjunto, int pCantidad); IEnumerable ObtenerTodas(); string GetOrCreate(string pNombre, string pConjunto); IEnumerable ObtenerCategorias(int pConjunto); + IEnumerable ObtenerPreguntasPorSesion(int pIdSesion); + Pregunta ObtenerPreguntaPorId(int pIdPregunta); } } diff --git a/ShockQuiz/DAL/IRepositorioSesion.cs b/ShockQuiz/DAL/IRepositorioSesion.cs index d1eb0e7..462600c 100644 --- a/ShockQuiz/DAL/IRepositorioSesion.cs +++ b/ShockQuiz/DAL/IRepositorioSesion.cs @@ -7,5 +7,8 @@ public interface IRepositorioSesion : IRepositorio { IEnumerable ObtenerTodas(string pUsuario); IEnumerable ObtenerRanking(int pTop); + IEnumerable ObtenerSesionActiva(); + Sesion ObtenerUltimaSesion(); + Sesion ObtenerSesionId(int pIdSesion); } } diff --git a/ShockQuiz/DAL/OpenTriviaDB/JsonMapper.cs b/ShockQuiz/DAL/OpenTriviaDB/JsonMapper.cs index 226e41f..0ff72ee 100644 --- a/ShockQuiz/DAL/OpenTriviaDB/JsonMapper.cs +++ b/ShockQuiz/DAL/OpenTriviaDB/JsonMapper.cs @@ -1,6 +1,7 @@ using Newtonsoft.Json; using ShockQuiz.DAL.EntityFramework; using ShockQuiz.Dominio; +using ShockQuiz.IO; using System; using System.Collections.Generic; using System.IO; @@ -55,7 +56,7 @@ public static string ObtenerToken() /// API Token /// Cantidad de Preguntas /// - public static List AlmacenarPreguntas(string pToken = null, int pNumber = 10) + public static List GetPreguntas(string pToken = null, int pNumber = 10) { List listaPreguntas = new List(); string CONJUNTO = "OpenTDB"; @@ -82,56 +83,46 @@ public static List AlmacenarPreguntas(string pToken = null, int pNumbe // Se parsea la respuesta y se serializa a JSON a un objeto dynamic dynamic mResponseJSON = JsonConvert.DeserializeObject(reader.ReadToEnd()); - using (var bDbContext = new ShockQuizDbContext()) + // Se iteran cada uno de los resultados. + foreach (var bResponseItem in mResponseJSON.results) { - using (UnitOfWork bUoW = new UnitOfWork(bDbContext)) - { - // Se iteran cada uno de los resultados. - foreach (var bResponseItem in mResponseJSON.results) - { - - string preguntaDesc = HttpUtility.HtmlDecode(bResponseItem.question.ToString()); - string categoria = HttpUtility.HtmlDecode(bResponseItem.category.ToString()); - string dificultad = HttpUtility.HtmlDecode(bResponseItem.difficulty.ToString()); + string preguntaDesc = HttpUtility.HtmlDecode(bResponseItem.question.ToString()); + string categoria = HttpUtility.HtmlDecode(bResponseItem.category.ToString()); + string dificultad = HttpUtility.HtmlDecode(bResponseItem.difficulty.ToString()); - List respuestas = new List(); - Respuesta respuestaCorrecta = new Respuesta() - { - EsCorrecta = true, - DefRespuesta = HttpUtility.HtmlDecode(bResponseItem.correct_answer.ToString()) - }; - respuestas.Add(respuestaCorrecta); + List respuestas = new List(); + Respuesta respuestaCorrecta = new Respuesta() + { + EsCorrecta = true, + DefRespuesta = HttpUtility.HtmlDecode(bResponseItem.correct_answer.ToString()) + }; + respuestas.Add(respuestaCorrecta); - for (int i = 0; i < 3; i++) - { - Respuesta res = new Respuesta() - { - DefRespuesta = HttpUtility.HtmlDecode(bResponseItem.incorrect_answers[i].ToString()), - EsCorrecta = false - }; - respuestas.Add(res); - } + for (int i = 0; i < 3; i++) + { + Respuesta res = new Respuesta() + { + DefRespuesta = HttpUtility.HtmlDecode(bResponseItem.incorrect_answers[i].ToString()), + EsCorrecta = false + }; + respuestas.Add(res); + } - Pregunta pregunta = new Pregunta() - { - Nombre = bUoW.RepositorioPregunta.GetOrCreate(preguntaDesc, CONJUNTO), - Categoria = bUoW.RepositorioCategoria.GetOrCreate(categoria), - Dificultad = bUoW.RepositorioDificultad.GetOrCreate(dificultad), - Conjunto = bUoW.RepositorioConjunto.Get(CONJUNTO), - Respuestas = respuestas - }; - if (pregunta.Nombre != string.Empty) - { - bUoW.RepositorioPregunta.Agregar(pregunta); - } - } - bUoW.GuardarCambios(); + Pregunta pregunta = new Pregunta() + { + Nombre = preguntaDesc, + Categoria = new Categoria() { Nombre = categoria }, + Dificultad = new Dificultad() { Nombre = dificultad }, + ConjuntoNombre = CONJUNTO, + Respuestas = respuestas + }; + if (pregunta.Nombre != string.Empty) + { + listaPreguntas.Add(pregunta); } } } } - - catch (WebException ex) { WebResponse mErrorResponse = ex.Response; diff --git a/ShockQuiz/Dominio/Categoria.cs b/ShockQuiz/Dominio/Categoria.cs index b31f341..65a6f34 100644 --- a/ShockQuiz/Dominio/Categoria.cs +++ b/ShockQuiz/Dominio/Categoria.cs @@ -6,7 +6,6 @@ public class Categoria { public int Id { get; set; } public string Nombre { get; set; } - public ICollection Sesiones { get; set; } public ICollection Preguntas { get; set; } } diff --git a/ShockQuiz/Dominio/ConjuntoOTDB.cs b/ShockQuiz/Dominio/ConjuntoOTDB.cs index b21b427..b31fe1b 100644 --- a/ShockQuiz/Dominio/ConjuntoOTDB.cs +++ b/ShockQuiz/Dominio/ConjuntoOTDB.cs @@ -1,10 +1,14 @@ using ShockQuiz.DAL.OpenTriviaDB; +using ShockQuiz.Forms; using System; +using System.Collections.Generic; namespace ShockQuiz.Dominio { public class ConjuntoOTDB : Conjunto { + FachadaConfiguracionAdmin fachada = new FachadaConfiguracionAdmin(); + public override double CalcularPuntaje(Sesion pSesion) { int TIEMPO_LIMITE_1 = 5; @@ -25,7 +29,7 @@ public override double CalcularPuntaje(Sesion pSesion) break; } double FACTOR_TIEMPO = 1; - double tiempoPorPregunta = pSesion.Duracion().TotalSeconds / pSesion.CantidadPreguntas; + double tiempoPorPregunta = pSesion.SegundosTranscurridos / pSesion.CantidadTotalPreguntas; if (tiempoPorPregunta < TIEMPO_LIMITE_1) { FACTOR_TIEMPO = 5; @@ -38,7 +42,7 @@ public override double CalcularPuntaje(Sesion pSesion) { FACTOR_TIEMPO = 3; } - double puntaje = ((double)pSesion.RespuestasCorrectas / (double)pSesion.CantidadPreguntas) * FACTOR_DIFICULTAD * FACTOR_TIEMPO; + double puntaje = ((double)pSesion.RespuestasCorrectas / (double)pSesion.CantidadTotalPreguntas) * FACTOR_DIFICULTAD * FACTOR_TIEMPO; return Math.Round(puntaje, 2); } @@ -50,13 +54,15 @@ public override void AgregarPreguntas(int pCantidad, string pToken = null) int aux = pCantidad; while (aux > 0) { - JsonMapper.AlmacenarPreguntas(pToken, aux); + List preguntas = JsonMapper.GetPreguntas(pToken, aux); + fachada.AlmacenarPreguntas(preguntas); aux -= 50; } } else { - JsonMapper.AlmacenarPreguntas(pToken, pCantidad); + List preguntas = JsonMapper.GetPreguntas(pToken, pCantidad); + fachada.AlmacenarPreguntas(preguntas); } } } diff --git a/ShockQuiz/Dominio/Pregunta.cs b/ShockQuiz/Dominio/Pregunta.cs index 3df0b0f..c515322 100644 --- a/ShockQuiz/Dominio/Pregunta.cs +++ b/ShockQuiz/Dominio/Pregunta.cs @@ -18,12 +18,18 @@ public class Pregunta public Dificultad Dificultad { get; set; } public int ConjuntoId { get; set; } public Conjunto Conjunto { get; set; } + public string ConjuntoNombre { get; set; } public ICollection Respuestas { get; set; } + public int SesionActualId { get; set; } + /// + /// Este método se utiliza para comprobar si una respuesta dada a + /// la pregunta es correcta. + /// + /// La respuesta seleccionada + /// public ResultadoRespuesta Responder(string pRespuesta) { - //Este método se encarga de comprobar si la respuesta ingresada es correcta, devolviendo - //true si es así y false en caso contrario. ResultadoRespuesta resultado = new ResultadoRespuesta(); foreach (var item in Respuestas.ToList()) { @@ -44,10 +50,12 @@ public ResultadoRespuesta Responder(string pRespuesta) return resultado; } + /// + /// Este método se utiliza para obtener las posibles respuestas a la pregunta. + /// + /// public List ObtenerRespuestas() { - //Este método se encarga de devolver las respuestas asociadas a la pregunta, - //ordenadas aleatoriamente. Random random = new Random(); string temp; List lista = new List(); diff --git a/ShockQuiz/Dominio/Respuesta.cs b/ShockQuiz/Dominio/Respuesta.cs index 024f07e..a586581 100644 --- a/ShockQuiz/Dominio/Respuesta.cs +++ b/ShockQuiz/Dominio/Respuesta.cs @@ -5,9 +5,7 @@ public class Respuesta public int RespuestaId { get; set; } public string DefRespuesta { get; set; } public bool EsCorrecta { get; set; } - public int PreguntaId { get; set; } public Pregunta Pregunta { get; set; } - } } diff --git a/ShockQuiz/Dominio/Sesion.cs b/ShockQuiz/Dominio/Sesion.cs index a07b929..3736549 100644 --- a/ShockQuiz/Dominio/Sesion.cs +++ b/ShockQuiz/Dominio/Sesion.cs @@ -8,7 +8,8 @@ namespace ShockQuiz.Dominio public class Sesion { public int SesionId { get; set; } - public int CantidadPreguntas { get; set; } + public int PreguntasRestantes { get; set; } + public int CantidadTotalPreguntas { get; set; } public int CategoriaId { get; set; } public Categoria Categoria { get; set; } public int DificultadId { get; set; } @@ -20,46 +21,41 @@ public class Sesion public int UsuarioId { get; set; } public Conjunto Conjunto { get; set; } public int ConjuntoId { get; set; } - public List Preguntas { get; set; } public int RespuestasCorrectas { get; set; } = 0; + public double SegundosTranscurridos { get; set; } + public bool SesionFinalizada { get; set; } - public List ObtenerRespuestas() + /// + /// Este método se utiliza para modificar los datos de la sesión + /// según se haya respondido correctamente o no. + /// + /// Si la respuesta dada a la pregunta fue correcta + /// + public bool Responder(bool pEsCorrecta) { - return Preguntas.First().ObtenerRespuestas(); - } - - public string ObtenerPregunta() - { - return Preguntas.First().Nombre; - } - - public ResultadoRespuesta Responder(string pRespuesta) - { - Pregunta pregunta = Preguntas.First(); - ResultadoRespuesta resultado = pregunta.Responder(pRespuesta); - if (resultado.EsCorrecta) + bool finSesion = false; + PreguntasRestantes--; + if (pEsCorrecta) { RespuestasCorrectas++; } - - Preguntas.Remove(pregunta); - if (Preguntas.Count() == 0) + if (PreguntasRestantes <= 0) { - resultado.FinSesion = true; + finSesion = true; this.FechaFin = DateTime.Now; this.Puntaje = Conjunto.CalcularPuntaje(this); } - return resultado; - } - - public TimeSpan Duracion() - { - return FechaFin - FechaInicio; + this.SesionFinalizada = finSesion; + return finSesion; } + /// + /// Este método se utiliza para obtener el tiempo límite de la sesión + /// + /// public double TiempoLimite() { - return CantidadPreguntas * Conjunto.TiempoEsperadoPorPregunta; + return CantidadTotalPreguntas * Conjunto.TiempoEsperadoPorPregunta; } } } diff --git a/ShockQuiz/Dominio/Usuario.cs b/ShockQuiz/Dominio/Usuario.cs index d04755e..020268d 100644 --- a/ShockQuiz/Dominio/Usuario.cs +++ b/ShockQuiz/Dominio/Usuario.cs @@ -10,6 +10,12 @@ public class Usuario public bool Admin { get; set; } public ICollection Sesiones { get; set; } + /// + /// Este método se utiliza para comprobar si la contraseña escrita + /// es la correcta para este usuario. + /// + /// La contraseña escrita + /// public bool ContraseñaCorrecta(string pPass) { if (pPass == this.Contraseña) diff --git a/ShockQuiz/Forms/AyudanteTimer.cs b/ShockQuiz/Forms/AyudanteTimer.cs new file mode 100644 index 0000000..f359426 --- /dev/null +++ b/ShockQuiz/Forms/AyudanteTimer.cs @@ -0,0 +1,81 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +using System.ComponentModel; +using System.Timers; +using System.Windows.Forms; + +namespace ShockQuiz.Forms +{ + public class AyudanteTimer + { + public static int TiempoLimite { get; set; } + public double TiempoTranscurrido { get; set; } + public BackgroundWorker bgWorker = new BackgroundWorker(); + private Action OnTimerFinished; + public Action OnTickTimer; + + public AyudanteTimer(int pTiempoLimite, Action pOnTimeFinishedHandler, Action pOnTickTimer) + { + this.OnTimerFinished = pOnTimeFinishedHandler; + this.OnTickTimer = pOnTickTimer; + + this.bgWorker.WorkerReportsProgress = true; + this.bgWorker.WorkerSupportsCancellation = true; + this.bgWorker.DoWork += new DoWorkEventHandler(this.bgWorker_DoWork); + this.bgWorker.ProgressChanged += new ProgressChangedEventHandler(this.bgWorker_ProgressChanged); + this.bgWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(this.bgWorker_RunWorkerCompleted); + + TiempoLimite = pTiempoLimite; + bgWorker.RunWorkerAsync(); + } + + /// + /// Este método se utiliza para notificar que debe actualizarse la cantidad de segundos + /// transcurridos a medida que avanza el tiempo. + /// + /// + /// + private void bgWorker_DoWork(object sender, DoWorkEventArgs e) + { + for (int i = TiempoLimite; i > 0; i--) + { + if (bgWorker.CancellationPending) + { + e.Cancel = true; + break; + } + + Thread.Sleep(1000); + bgWorker.ReportProgress(i); + } + } + + /// + /// Este método se utiliza para actualizar la cantidad de segundos transcurridos de la sesión + /// + /// + /// + private void bgWorker_ProgressChanged(object sender, ProgressChangedEventArgs e) + { + TiempoTranscurrido += 1; + OnTickTimer?.Invoke(e.ProgressPercentage); + } + + /// + /// Este método se activa cuando finaliza el trabajo del background worker + /// + /// + /// + private void bgWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) + { + if (!e.Cancelled) + { + bgWorker.CancelAsync(); + OnTimerFinished?.Invoke(); + } + } + } +} diff --git a/ShockQuiz/Forms/ConfiguracionAdminForm.cs b/ShockQuiz/Forms/ConfiguracionAdminForm.cs index 49e37d8..cac1d07 100644 --- a/ShockQuiz/Forms/ConfiguracionAdminForm.cs +++ b/ShockQuiz/Forms/ConfiguracionAdminForm.cs @@ -56,11 +56,15 @@ private void BtnAgregar_Click(object sender, EventArgs e) { if (nudCantidad.Value > 0) { - Conjunto conjunto = (Conjunto)cbConjunto.SelectedItem; try { - conjunto.AgregarPreguntas(Decimal.ToInt32(nudCantidad.Value), conjunto.Token); - MessageBox.Show(Decimal.ToInt32(nudCantidad.Value) + " preguntas añadidas correctamente!", "Éxito", MessageBoxButtons.OK, MessageBoxIcon.Information); + if (cbConjunto.Text == "OpenTDB") + { + ConjuntoOTDB conjunto = new ConjuntoOTDB(); + conjunto.AgregarPreguntas(Decimal.ToInt32(nudCantidad.Value), conjunto.Token); + MessageBox.Show(Decimal.ToInt32(nudCantidad.Value) + " preguntas añadidas correctamente al conjunto OpenTDB!", "Éxito", MessageBoxButtons.OK, MessageBoxIcon.Information); + + } } catch (Exception) { @@ -92,7 +96,7 @@ private void btnAddConjunto_Click(object sender, EventArgs e) private void btnDispose_Click(object sender, EventArgs e) { - DialogResult dr = MessageBox.Show("¿Estas seguro de borar toda la información?", "Confirmar limpieza de DB", MessageBoxButtons.YesNo); + DialogResult dr = MessageBox.Show("¿Estas seguro de borrar toda la información?", "Confirmar limpieza de DB", MessageBoxButtons.YesNo); if (dr == DialogResult.Yes) { try @@ -100,10 +104,9 @@ private void btnDispose_Click(object sender, EventArgs e) fachada.LimpiarDB(); MessageBox.Show("Operación realiazada correctamente!", "Éxito", MessageBoxButtons.OK, MessageBoxIcon.Information); } - catch (Exception) + catch (Exception ex ) { - MessageBox.Show("Error?!"); - throw; + MessageBox.Show(ex.Message); } } } diff --git a/ShockQuiz/Forms/ConfigurarSesionForm.cs b/ShockQuiz/Forms/ConfigurarSesionForm.cs index d1ee0c6..9757542 100644 --- a/ShockQuiz/Forms/ConfigurarSesionForm.cs +++ b/ShockQuiz/Forms/ConfigurarSesionForm.cs @@ -41,21 +41,22 @@ private void BtnIniciar_Click(object sender, EventArgs e) { try { - SesionForm sesionForm = new SesionForm(fachada.IniciarSesion(idUsuario, (Categoria)cbCategoria.SelectedItem, (Dificultad)cbDificultad.SelectedItem, Decimal.ToInt32(nudCantidad.Value), (Conjunto)cbConjunto.SelectedItem), (Categoria)cbCategoria.SelectedItem, (Dificultad)cbDificultad.SelectedItem, Decimal.ToInt32(nudCantidad.Value)); + var categoria = (Categoria)cbCategoria.SelectedItem ?? new Categoria { }; + var dificultad = (Dificultad)cbDificultad.SelectedItem ?? new Dificultad { }; + var sesion = fachada.IniciarSesion(idUsuario, categoria.Id, dificultad.Id, Decimal.ToInt32(nudCantidad.Value), ((Conjunto)cbConjunto.SelectedItem).ConjuntoId); + SesionForm sesionForm = new SesionForm(sesion.SesionId, categoria.Nombre, dificultad.Nombre, Decimal.ToInt32(nudCantidad.Value)); sesionForm.FormClosed += new FormClosedEventHandler(SesionForm_FormClosed); sesionForm.Show(); this.Hide(); } - catch(InvalidOperationException) + catch (PreguntasInsuficientesException) { - MessageBox.Show("Seleccione una dificultad y categoría.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); - + MessageBox.Show("No hay preguntas suficientes para la selección", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } - catch (PreguntasInsuficientesException) + catch (Exception) { - MessageBox.Show("No hay preguntas suficientes para la selección", "Error",MessageBoxButtons.OK,MessageBoxIcon.Error); + MessageBox.Show("Seleccione una dificultad y categoría.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } - } private void BtnCancelar_Click(object sender, EventArgs e) diff --git a/ShockQuiz/Forms/Controladores/FachadaConfiguracionAdmin.cs b/ShockQuiz/Forms/Controladores/FachadaConfiguracionAdmin.cs index f7d382e..58c6edc 100644 --- a/ShockQuiz/Forms/Controladores/FachadaConfiguracionAdmin.cs +++ b/ShockQuiz/Forms/Controladores/FachadaConfiguracionAdmin.cs @@ -7,7 +7,7 @@ namespace ShockQuiz.Forms { - class FachadaConfiguracionAdmin + public class FachadaConfiguracionAdmin { /// /// Incrementa la autoridad de un usuario a administrador @@ -72,6 +72,10 @@ public void AñadirConjunto(string pNombre, int pTEPP, bool token) } } + /// + /// Este método se utiliza para eliminar los datos almacenados actualmente + /// en la base de datos. + /// public void LimpiarDB() { using (var bDbContext = new ShockQuizDbContext()) @@ -95,5 +99,35 @@ public void LimpiarDB() } } } + + public void AlmacenarPreguntas(List pPreguntas) + { + using (var bDbContext = new ShockQuizDbContext()) + { + using (UnitOfWork bUoW = new UnitOfWork(bDbContext)) + { + foreach (var pregunta in pPreguntas) + { + string preguntaDesc = pregunta.Nombre; + string CONJUNTO = pregunta.ConjuntoNombre; + pregunta.Nombre = bUoW.RepositorioPregunta.GetOrCreate(preguntaDesc, CONJUNTO); + + string categoria = pregunta.Categoria.Nombre; + pregunta.Categoria = bUoW.RepositorioCategoria.GetOrCreate(categoria); + + string dificultad = pregunta.Dificultad.Nombre; + pregunta.Dificultad = bUoW.RepositorioDificultad.GetOrCreate(dificultad); + + pregunta.Conjunto = bUoW.RepositorioConjunto.Get(CONJUNTO); + + if (pregunta.Nombre != string.Empty) + { + bUoW.RepositorioPregunta.Agregar(pregunta); + } + } + bUoW.GuardarCambios(); + } + } + } } } diff --git a/ShockQuiz/Forms/Controladores/FachadaConfigurarSesion.cs b/ShockQuiz/Forms/Controladores/FachadaConfigurarSesion.cs index 3cc9153..fc57074 100644 --- a/ShockQuiz/Forms/Controladores/FachadaConfigurarSesion.cs +++ b/ShockQuiz/Forms/Controladores/FachadaConfigurarSesion.cs @@ -60,33 +60,46 @@ public IEnumerable ObtenerDificultades() /// obteniendo sus instancias de la base de datos. /// /// Id del usuario de la sesión - /// La categoría de las preguntas - /// La dificultad + /// Id de la categoría de las preguntas + /// Id de la dificultad /// Cantidad de preguntas de la sesión - /// Conjunto del que se obtienen las preguntas de la sesión + /// Id del conjunto del que se obtienen las preguntas de la sesión /// - public Sesion IniciarSesion(int pUsuario, Categoria pCategoria, Dificultad pDificultad, int pCantidad, Conjunto pConjunto) + public Sesion IniciarSesion(int pUsuario, int pCategoria, int pDificultad, int pCantidad, int pConjunto) { Sesion sesion = new Sesion(); - Usuario usuario; + sesion.FechaInicio = DateTime.Now; + sesion.CategoriaId = pCategoria; + sesion.DificultadId = pDificultad; + sesion.ConjuntoId = pConjunto; + sesion.PreguntasRestantes = pCantidad; + sesion.CantidadTotalPreguntas = pCantidad; + sesion.UsuarioId = pUsuario; + sesion.FechaFin = DateTime.Parse("01-01-2399"); + sesion.SesionFinalizada = false; + sesion.SegundosTranscurridos = 0; + using (var bDbContext = new ShockQuizDbContext()) { using (UnitOfWork bUoW = new UnitOfWork(bDbContext)) { - usuario = bUoW.RepositorioUsuario.Obtener(pUsuario); - sesion.Usuario = usuario; - sesion.UsuarioId = usuario.UsuarioId; - sesion.Preguntas = bUoW.RepositorioPregunta.ObtenerPreguntas(pCategoria, pDificultad, pConjunto, pCantidad).ToList(); + sesion.Usuario = bUoW.RepositorioUsuario.Obtener(pUsuario); + sesion.Conjunto = bUoW.RepositorioConjunto.Obtener(pConjunto); + sesion.Categoria = bUoW.RepositorioCategoria.Obtener(pCategoria); + sesion.Dificultad = bUoW.RepositorioDificultad.Obtener(pDificultad); + + bUoW.RepositorioSesion.Agregar(sesion); + bUoW.GuardarCambios(); + + int idSesion = bUoW.RepositorioSesion.ObtenerUltimaSesion().SesionId; + IEnumerable listaDePreguntas = bUoW.RepositorioPregunta.ObtenerPreguntas(pCategoria, pDificultad, pConjunto, pCantidad); + foreach (Pregunta pregunta in listaDePreguntas) + { + pregunta.SesionActualId = idSesion; + } + bUoW.GuardarCambios(); } } - sesion.FechaInicio = DateTime.Now; - sesion.Categoria = pCategoria; - sesion.CategoriaId = pCategoria.Id; - sesion.Dificultad = pDificultad; - sesion.DificultadId = pDificultad.Id; - sesion.Conjunto = pConjunto; - sesion.ConjuntoId = pConjunto.ConjuntoId; - sesion.CantidadPreguntas = pCantidad; return sesion; } } diff --git a/ShockQuiz/Forms/Controladores/FachadaLogin.cs b/ShockQuiz/Forms/Controladores/FachadaLogin.cs index ada3706..93c9544 100644 --- a/ShockQuiz/Forms/Controladores/FachadaLogin.cs +++ b/ShockQuiz/Forms/Controladores/FachadaLogin.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using ShockQuiz.Excepciones; +using System; namespace ShockQuiz.Forms { @@ -34,6 +35,29 @@ public int CheckLogin(string pUser, string pPass) } } + /// + /// Este método se utiliza para obtener una sesión aún activa presente + /// en la base de datos. + /// + /// + public Sesion ObtenerSesionNoFinalizada() + { + Sesion res = null; + using (var bDbContext = new ShockQuizDbContext()) + { + using (UnitOfWork bUoW = new UnitOfWork(bDbContext)) + { + IEnumerable sesionesActivas = bUoW.RepositorioSesion.ObtenerSesionActiva(); + if (sesionesActivas.Count() > 0) + { + res = sesionesActivas.First(); + } + } + } + return res; + } + + /// /// Registra a un usuario en la base de datos de la aplicación /// @@ -88,5 +112,27 @@ public bool EsAdmin(string pUsuario) } } } + + /// + /// Este método se encarga de cancelar una sesión que se encuentre activa + /// + public void CancelarSesionActiva() + { + using (var bDbContext = new ShockQuizDbContext()) + { + using (UnitOfWork bUoW = new UnitOfWork(bDbContext)) + { + Sesion sesionActiva = bUoW.RepositorioSesion.ObtenerSesionActiva().First(); + sesionActiva.FechaFin = DateTime.Now; + foreach (Pregunta pregunta in bUoW.RepositorioPregunta.ObtenerPreguntasPorSesion(sesionActiva.SesionId)) + { + pregunta.Responder(""); + sesionActiva.Responder(false); + } + sesionActiva.SesionFinalizada = true; + bUoW.GuardarCambios(); + } + } + } } } diff --git a/ShockQuiz/Forms/Controladores/FachadaSesion.cs b/ShockQuiz/Forms/Controladores/FachadaSesion.cs index 27a2753..eebc5e8 100644 --- a/ShockQuiz/Forms/Controladores/FachadaSesion.cs +++ b/ShockQuiz/Forms/Controladores/FachadaSesion.cs @@ -1,28 +1,42 @@ using ShockQuiz.DAL.EntityFramework; using ShockQuiz.Dominio; using ShockQuiz.IO; +using ShockQuiz.Forms; +using System.Linq; using System; +using System.Collections.Generic; namespace ShockQuiz { + /// + /// El objetivo de esta clase es funcionar como intermediario entre la interfaz gráfica + /// correspondiente a la sesión de preguntas, y las clases con las que se interactúa. + /// public class FachadaSesion { - /// - /// El objetivo de esta clase es funcionar como intermediario entre la interfaz gráfica - /// correspondiente a la sesión de preguntas, y las clases con las que se interactúa. - /// - public Sesion iSesionActual { get; set; } + public int idSesionActual { get; set; } + public int idPreguntaActual { get; set; } + public AyudanteTimer ayudanteTimer { get; set; } /// /// Devuelve un PreguntaDTO correspondiente a la siguiente de la sesión /// /// public PreguntaDTO ObtenerPreguntaYRespuestas() - { - PreguntaDTO preguntaYRespuestas = new PreguntaDTO(); - preguntaYRespuestas.Pregunta = iSesionActual.ObtenerPregunta(); - preguntaYRespuestas.Respuestas = iSesionActual.ObtenerRespuestas(); - return preguntaYRespuestas; + { + using (var bDbContext = new ShockQuizDbContext()) + { + using (UnitOfWork bUoW = new UnitOfWork(bDbContext)) + { + Random random = new Random(); + PreguntaDTO preguntaYRespuestas = new PreguntaDTO(); + Pregunta pregunta = bUoW.RepositorioPregunta.ObtenerPreguntasPorSesion(idSesionActual).OrderBy(x => random.Next()).First(); + preguntaYRespuestas.Pregunta = pregunta.Nombre; + preguntaYRespuestas.Respuestas = pregunta.ObtenerRespuestas(); + idPreguntaActual = pregunta.PreguntaId; + return preguntaYRespuestas; + } + } } /// @@ -32,28 +46,44 @@ public PreguntaDTO ObtenerPreguntaYRespuestas() /// public ResultadoRespuesta Responder(string pRespuesta) { - ResultadoRespuesta resultado = iSesionActual.Responder(pRespuesta); - return resultado; + using (var bDbContext = new ShockQuizDbContext()) + { + using (UnitOfWork bUoW = new UnitOfWork(bDbContext)) + { + ResultadoRespuesta resultado; + Sesion sesionActual = bUoW.RepositorioSesion.ObtenerSesionId(idSesionActual); + Pregunta pregunta = bUoW.RepositorioPregunta.ObtenerPreguntaPorId(idPreguntaActual); + pregunta.SesionActualId = 0; + resultado = pregunta.Responder(pRespuesta); + resultado.FinSesion = sesionActual.Responder(resultado.EsCorrecta); + sesionActual.SegundosTranscurridos = ayudanteTimer.TiempoTranscurrido; + bUoW.GuardarCambios(); + return resultado; + } + } } /// /// Devuelve un resultado al verificar que la sesión actual no se exceda del tiempo límite /// /// - public ResultadoRespuesta RevisarTiempoLimite() + public void FinTiempoLimite() { - double tiempo = iSesionActual.TiempoLimite(); - ResultadoRespuesta resultado = new ResultadoRespuesta(); - resultado.FinSesion = false; - if ((DateTime.Now - iSesionActual.FechaInicio).TotalSeconds > tiempo) + using (var bDbContext = new ShockQuizDbContext()) { - for (int i = iSesionActual.Preguntas.Count; i > 0; i--) + using (UnitOfWork bUoW = new UnitOfWork(bDbContext)) { - resultado = iSesionActual.Responder(""); + Sesion sesionActual = bUoW.RepositorioSesion.Obtener(idSesionActual); + sesionActual.SesionFinalizada = true; + IEnumerable preguntasRestantes = bUoW.RepositorioPregunta.ObtenerPreguntasPorSesion(idSesionActual); + foreach (Pregunta pregunta in preguntasRestantes) + { + idPreguntaActual = pregunta.PreguntaId; + Responder(""); + } + bUoW.GuardarCambios(); } - resultado.TiempoLimiteFinalizado = true; } - return resultado; } /// @@ -62,26 +92,42 @@ public ResultadoRespuesta RevisarTiempoLimite() /// public double ObtenerPuntaje() { - return iSesionActual.Puntaje; + using (var bDbContext = new ShockQuizDbContext()) + { + using (UnitOfWork bUoW = new UnitOfWork(bDbContext)) + { + Sesion sesionActual = bUoW.RepositorioSesion.Obtener(idSesionActual); + return sesionActual.Puntaje; + } + } } - + /// - /// Guarda la sesión actual en la base datos + /// Este método se utiliza para iniciar el timer que verifica el tiempo límite de + /// la sesión. /// - public void GuardarSesion() + /// La acción a realizar cuando se agota el tiempo límite + /// La acción a realizar por cada tick + public void IniciarTimer(Action pOnTimeFinishedHandler, Action pOnTickTimer) { using (var bDbContext = new ShockQuizDbContext()) { using (UnitOfWork bUoW = new UnitOfWork(bDbContext)) { - this.iSesionActual.Categoria = null; - this.iSesionActual.Conjunto = null; - this.iSesionActual.Dificultad = null; - this.iSesionActual.Usuario = null; - bUoW.RepositorioSesion.Agregar(this.iSesionActual); - bUoW.GuardarCambios(); + Sesion sesionActual = bUoW.RepositorioSesion.Obtener(idSesionActual); + sesionActual.Conjunto = bUoW.RepositorioConjunto.Obtener(sesionActual.ConjuntoId); + int tiempoRestante = Convert.ToInt32(sesionActual.TiempoLimite() - sesionActual.SegundosTranscurridos); + ayudanteTimer = new AyudanteTimer(tiempoRestante, pOnTimeFinishedHandler, pOnTickTimer); } } } + + /// + /// Este método se utiliza para detener el timer activo + /// + public void DetenerTimer() + { + ayudanteTimer.bgWorker.CancelAsync(); + } } } diff --git a/ShockQuiz/Forms/LoginForm.cs b/ShockQuiz/Forms/LoginForm.cs index d8f169e..022f49c 100644 --- a/ShockQuiz/Forms/LoginForm.cs +++ b/ShockQuiz/Forms/LoginForm.cs @@ -1,6 +1,7 @@ using System; using System.Windows.Forms; using ShockQuiz.Excepciones; +using ShockQuiz.Dominio; namespace ShockQuiz.Forms { @@ -22,11 +23,34 @@ private void btnLogin_Click(object sender, EventArgs e) try { int usuario = facha.CheckLogin(txtUsuario.Text, txtContraseña.Text); - MessageBox.Show("Bienvenido " + txtUsuario.Text + "!", "Iniciar sesión", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); bool esAdmin = facha.EsAdmin(txtUsuario.Text); MenuForm menuForm = new MenuForm(usuario, esAdmin); menuForm.FormClosed += new FormClosedEventHandler(LoginForm_FormClosed); - menuForm.Show(); + var sesionActiva = facha.ObtenerSesionNoFinalizada(); + if (sesionActiva != null) + { + DialogResult dialogResult = MessageBox.Show("Existe una sesión sin finalizar, ¿desea continuarla?", "Sesión activa", MessageBoxButtons.YesNo); + if (dialogResult == DialogResult.Yes) + { + menuForm.Show(); + SesionForm sesionForm = new SesionForm(sesionActiva.SesionId, sesionActiva.Categoria.Nombre, sesionActiva.Dificultad.Nombre, sesionActiva.PreguntasRestantes); + //sesionForm.FormClosed += new FormClosedEventHandler(LoginForm_FormClosed); + sesionForm.Show(); + this.Hide(); + } + else if (dialogResult == DialogResult.No) + { + facha.CancelarSesionActiva(); + menuForm.Show(); + this.Hide(); + } + } + else + { + menuForm.Show(); + } + + this.Hide(); } catch (InvalidOperationException) diff --git a/ShockQuiz/Forms/RankingForm.Designer.cs b/ShockQuiz/Forms/RankingForm.Designer.cs index a0a5fbd..2e1cb18 100644 --- a/ShockQuiz/Forms/RankingForm.Designer.cs +++ b/ShockQuiz/Forms/RankingForm.Designer.cs @@ -35,6 +35,10 @@ private void InitializeComponent() this.btnActualizar = new System.Windows.Forms.Button(); this.nudTop = new System.Windows.Forms.NumericUpDown(); this.label1 = new System.Windows.Forms.Label(); + this.nombre = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.puntaje = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.fecha = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.duracion = new System.Windows.Forms.DataGridViewTextBoxColumn(); ((System.ComponentModel.ISupportInitialize)(this.dgvRanking)).BeginInit(); this.Ranking.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.nudTop)).BeginInit(); @@ -43,6 +47,11 @@ private void InitializeComponent() // dgvRanking // this.dgvRanking.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dgvRanking.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.nombre, + this.puntaje, + this.fecha, + this.duracion}); this.dgvRanking.Location = new System.Drawing.Point(6, 19); this.dgvRanking.Name = "dgvRanking"; this.dgvRanking.Size = new System.Drawing.Size(454, 263); @@ -115,6 +124,33 @@ private void InitializeComponent() this.label1.TabIndex = 2; this.label1.Text = "Top número:"; // + // nombre + // + this.nombre.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.nombre.HeaderText = "Nickname"; + this.nombre.Name = "nombre"; + // + // puntaje + // + this.puntaje.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells; + this.puntaje.HeaderText = "Puntaje"; + this.puntaje.Name = "puntaje"; + this.puntaje.Width = 68; + // + // fecha + // + this.fecha.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells; + this.fecha.HeaderText = "Fecha"; + this.fecha.Name = "fecha"; + this.fecha.Width = 62; + // + // duracion + // + this.duracion.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells; + this.duracion.HeaderText = "Duración (s)"; + this.duracion.Name = "duracion"; + this.duracion.Width = 89; + // // RankingForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -142,5 +178,9 @@ private void InitializeComponent() private System.Windows.Forms.Button btnActualizar; private System.Windows.Forms.NumericUpDown nudTop; private System.Windows.Forms.Label label1; + private System.Windows.Forms.DataGridViewTextBoxColumn nombre; + private System.Windows.Forms.DataGridViewTextBoxColumn puntaje; + private System.Windows.Forms.DataGridViewTextBoxColumn fecha; + private System.Windows.Forms.DataGridViewTextBoxColumn duracion; } } \ No newline at end of file diff --git a/ShockQuiz/Forms/RankingForm.cs b/ShockQuiz/Forms/RankingForm.cs index 912279e..e0dbfa4 100644 --- a/ShockQuiz/Forms/RankingForm.cs +++ b/ShockQuiz/Forms/RankingForm.cs @@ -14,14 +14,11 @@ public RankingForm() { InitializeComponent(); List ranking = facha.ObtenerTop(); - dgvRanking.DataSource = ranking.Select(x => new + foreach (var item in ranking) { - x.Usuario.Nombre, - x.Puntaje, - Fecha = x.FechaInicio, - Duración = x.Duracion() - }) - .ToList(); + dgvRanking.Rows.Add(item.Usuario.Nombre, item.Puntaje, item.FechaInicio, item.SegundosTranscurridos); + + } } private void btnSalir_Click(object sender, EventArgs e) @@ -32,13 +29,11 @@ private void btnSalir_Click(object sender, EventArgs e) private void btnActualizar_Click(object sender, EventArgs e) { List ranking = facha.ObtenerTop(Decimal.ToInt32(nudTop.Value)); - dgvRanking.DataSource = ranking.Select(x => new + foreach (var item in ranking) { - x.Usuario.Nombre, - x.Puntaje, - Fecha = x.FechaInicio, - Duración = x.Duracion() - }).ToList(); + dgvRanking.Rows.Add(item.Usuario.Nombre, item.Puntaje, item.FechaInicio, item.SegundosTranscurridos); + + } } } } diff --git a/ShockQuiz/Forms/RankingForm.resx b/ShockQuiz/Forms/RankingForm.resx index 12ad234..889509f 100644 --- a/ShockQuiz/Forms/RankingForm.resx +++ b/ShockQuiz/Forms/RankingForm.resx @@ -117,6 +117,18 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + True + + + True + + + True + + + True + diff --git a/ShockQuiz/Forms/SesionForm.Designer.cs b/ShockQuiz/Forms/SesionForm.Designer.cs index f622daf..46f3eb5 100644 --- a/ShockQuiz/Forms/SesionForm.Designer.cs +++ b/ShockQuiz/Forms/SesionForm.Designer.cs @@ -20,6 +20,8 @@ protected override void Dispose(bool disposing) base.Dispose(disposing); } + + #region Código generado por el Diseñador de Windows Forms /// @@ -43,10 +45,9 @@ private void InitializeComponent() this.label9 = new System.Windows.Forms.Label(); this.lblCategoria = new System.Windows.Forms.Label(); this.lblDificultad = new System.Windows.Forms.Label(); - this.btnSiguiente = new System.Windows.Forms.Button(); this.lblTimer = new System.Windows.Forms.Label(); - this.progressBar = new System.Windows.Forms.ProgressBar(); - this.backgroundWorker = new System.ComponentModel.BackgroundWorker(); + this.backgroundWorker1 = new System.ComponentModel.BackgroundWorker(); + this.btnSiguiente = new System.Windows.Forms.Button(); this.SuspendLayout(); // // lblPregunta @@ -61,7 +62,7 @@ private void InitializeComponent() // label2 // this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(594, 9); + this.label2.Location = new System.Drawing.Point(539, 33); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(50, 13); this.label2.TabIndex = 5; @@ -117,7 +118,7 @@ private void InitializeComponent() // lblRespuestasActuales // this.lblRespuestasActuales.AutoSize = true; - this.lblRespuestasActuales.Location = new System.Drawing.Point(651, 9); + this.lblRespuestasActuales.Location = new System.Drawing.Point(618, 33); this.lblRespuestasActuales.Name = "lblRespuestasActuales"; this.lblRespuestasActuales.Size = new System.Drawing.Size(14, 13); this.lblRespuestasActuales.TabIndex = 10; @@ -126,16 +127,16 @@ private void InitializeComponent() // label4 // this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(602, 33); + this.label4.Location = new System.Drawing.Point(514, 9); this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(42, 13); + this.label4.Size = new System.Drawing.Size(86, 13); this.label4.TabIndex = 11; - this.label4.Text = "Tiempo"; + this.label4.Text = "Tiempo restante:"; // // label6 // this.label6.AutoSize = true; - this.label6.Location = new System.Drawing.Point(672, 9); + this.label6.Location = new System.Drawing.Point(644, 33); this.label6.Name = "label6"; this.label6.Size = new System.Drawing.Size(12, 13); this.label6.TabIndex = 13; @@ -144,7 +145,7 @@ private void InitializeComponent() // lblRespuestasTotales // this.lblRespuestasTotales.AutoSize = true; - this.lblRespuestasTotales.Location = new System.Drawing.Point(689, 9); + this.lblRespuestasTotales.Location = new System.Drawing.Point(660, 33); this.lblRespuestasTotales.Name = "lblRespuestasTotales"; this.lblRespuestasTotales.Size = new System.Drawing.Size(14, 13); this.lblRespuestasTotales.TabIndex = 14; @@ -155,23 +156,23 @@ private void InitializeComponent() this.label8.AutoSize = true; this.label8.Location = new System.Drawing.Point(9, 9); this.label8.Name = "label8"; - this.label8.Size = new System.Drawing.Size(54, 13); + this.label8.Size = new System.Drawing.Size(57, 13); this.label8.TabIndex = 15; - this.label8.Text = "Categoría"; + this.label8.Text = "Categoría:"; // // label9 // this.label9.AutoSize = true; - this.label9.Location = new System.Drawing.Point(12, 33); + this.label9.Location = new System.Drawing.Point(9, 33); this.label9.Name = "label9"; - this.label9.Size = new System.Drawing.Size(51, 13); + this.label9.Size = new System.Drawing.Size(54, 13); this.label9.TabIndex = 16; - this.label9.Text = "Dificultad"; + this.label9.Text = "Dificultad:"; // // lblCategoria // this.lblCategoria.AutoSize = true; - this.lblCategoria.Location = new System.Drawing.Point(69, 9); + this.lblCategoria.Location = new System.Drawing.Point(101, 9); this.lblCategoria.Name = "lblCategoria"; this.lblCategoria.Size = new System.Drawing.Size(16, 13); this.lblCategoria.TabIndex = 17; @@ -180,12 +181,21 @@ private void InitializeComponent() // lblDificultad // this.lblDificultad.AutoSize = true; - this.lblDificultad.Location = new System.Drawing.Point(69, 33); + this.lblDificultad.Location = new System.Drawing.Point(101, 33); this.lblDificultad.Name = "lblDificultad"; this.lblDificultad.Size = new System.Drawing.Size(13, 13); this.lblDificultad.TabIndex = 18; this.lblDificultad.Text = "‼"; // + // lblTimer + // + this.lblTimer.AutoSize = true; + this.lblTimer.Location = new System.Drawing.Point(653, 9); + this.lblTimer.Name = "lblTimer"; + this.lblTimer.Size = new System.Drawing.Size(21, 13); + this.lblTimer.TabIndex = 20; + this.lblTimer.Text = "0 s"; + // // btnSiguiente // this.btnSiguiente.BackgroundImage = global::ShockQuiz.Properties.Resources.next; @@ -198,32 +208,6 @@ private void InitializeComponent() this.btnSiguiente.UseVisualStyleBackColor = true; this.btnSiguiente.Click += new System.EventHandler(this.BtnSiguiente_Click); // - // lblTimer - // - this.lblTimer.AutoSize = true; - this.lblTimer.Location = new System.Drawing.Point(651, 33); - this.lblTimer.Name = "lblTimer"; - this.lblTimer.Size = new System.Drawing.Size(21, 13); - this.lblTimer.TabIndex = 20; - this.lblTimer.Text = "0 s"; - // - // progressBar - // - this.progressBar.Location = new System.Drawing.Point(605, 49); - this.progressBar.Name = "progressBar"; - this.progressBar.Size = new System.Drawing.Size(98, 10); - this.progressBar.Style = System.Windows.Forms.ProgressBarStyle.Continuous; - this.progressBar.TabIndex = 21; - this.progressBar.Value = 100; - // - // backgroundWorker - // - this.backgroundWorker.WorkerReportsProgress = true; - this.backgroundWorker.WorkerSupportsCancellation = true; - this.backgroundWorker.DoWork += new System.ComponentModel.DoWorkEventHandler(this.backgroundWorker_DoWork); - this.backgroundWorker.ProgressChanged += new System.ComponentModel.ProgressChangedEventHandler(this.backgroundWorker_ProgressChanged); - this.backgroundWorker.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.backgroundWorker_RunWorkerCompleted); - // // SesionForm // this.AcceptButton = this.btnSiguiente; @@ -252,7 +236,7 @@ private void InitializeComponent() this.Name = "SesionForm"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Partida"; - this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.SesionForm_FormClosed); + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.SesionForm_FormClosing); this.ResumeLayout(false); this.PerformLayout(); @@ -276,8 +260,7 @@ private void InitializeComponent() private System.Windows.Forms.Label lblDificultad; private System.Windows.Forms.Button btnSiguiente; private System.Windows.Forms.Label lblTimer; - private System.Windows.Forms.ProgressBar progressBar; - private System.ComponentModel.BackgroundWorker backgroundWorker; + private System.ComponentModel.BackgroundWorker backgroundWorker1; } } diff --git a/ShockQuiz/Forms/SesionForm.cs b/ShockQuiz/Forms/SesionForm.cs index 46669ce..4acff68 100644 --- a/ShockQuiz/Forms/SesionForm.cs +++ b/ShockQuiz/Forms/SesionForm.cs @@ -1,86 +1,45 @@ using ShockQuiz.Dominio; using ShockQuiz.IO; using System; -using System.Threading; +using System.IO; +using System.Reflection; +using System.Runtime.InteropServices; using System.Windows.Forms; - +using System.Drawing.Text; +using System.Drawing; namespace ShockQuiz { public partial class SesionForm : Form { FachadaSesion fachada = new FachadaSesion(); - int segTimer; - int limitTime; - public SesionForm(Sesion pSesion, Categoria pCategoria, Dificultad pDificultad, int pCantidad) + public SesionForm(int pSesionId, string pCategoria, string pDificultad, int pCantidad) { InitializeComponent(); - lblCategoria.Text = pCategoria.Nombre; - lblDificultad.Text = pDificultad.Nombre; - fachada.iSesionActual = pSesion; - lblRespuestasTotales.Text = pCantidad.ToString(); + lblCategoria.Text = pCategoria; + lblDificultad.Text = pDificultad; + fachada.idSesionActual = pSesionId; lblRespuestasActuales.Text = "0"; - - //Timer - limitTime = (int)fachada.iSesionActual.TiempoLimite(); - progressBar.Maximum = limitTime; - progressBar.Value = segTimer = limitTime; - lblTimer.Text = segTimer + " seg."; - backgroundWorker.RunWorkerAsync(); - + LoadFont(); SiguientePregunta(); - } - - private void backgroundWorker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e) - { - for (int i = limitTime; i > 0; i--) - { - if (backgroundWorker.CancellationPending) - { - e.Cancel = true; - break; - } - - Thread.Sleep(1000); - backgroundWorker.ReportProgress(i); - } - } - - private void backgroundWorker_ProgressChanged(object sender, System.ComponentModel.ProgressChangedEventArgs e) - { - progressBar.Value = e.ProgressPercentage; - if (segTimer > 0) - { - segTimer -= 1; - } - lblTimer.Text = segTimer + " seg"; - } + lblRespuestasTotales.Text = pCantidad.ToString(); - private void backgroundWorker_RunWorkerCompleted(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e) - { - if (!e.Cancelled) - { - ResultadoRespuesta resultado = fachada.RevisarTiempoLimite(); - Finalizar(resultado); - } + fachada.IniciarTimer(FinTiempoLimite,ActualizarTimer); } private void Finalizar(ResultadoRespuesta pResultado) { if (pResultado.TiempoLimiteFinalizado) { - backgroundWorker.CancelAsync(); btnSiguiente.Enabled = false; - fachada.GuardarSesion(); MessageBox.Show("¡Tiempo agotado! Puntaje: " + fachada.ObtenerPuntaje(), "Fin de la partida", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.Close(); } else if (pResultado.FinSesion) { - backgroundWorker.CancelAsync(); + fachada.DetenerTimer(); btnSiguiente.Enabled = false; - fachada.GuardarSesion(); MessageBox.Show("Puntaje: " + fachada.ObtenerPuntaje(), "Fin de la partida", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); ; this.Close(); } @@ -148,20 +107,26 @@ private void BtnRespuesta4_Click(object sender, EventArgs e) private void SiguientePregunta() { + PreguntaDTO actual = fachada.ObtenerPreguntaYRespuestas(); lblPregunta.Text = actual.Pregunta; + btnRespuesta1.Text = actual.Respuestas[0]; btnRespuesta1.Enabled = true; btnRespuesta1.BackColor = System.Drawing.SystemColors.Control; + btnRespuesta2.Text = actual.Respuestas[1]; btnRespuesta2.Enabled = true; btnRespuesta2.BackColor = System.Drawing.SystemColors.Control; + btnRespuesta3.Text = actual.Respuestas[2]; btnRespuesta3.Enabled = true; btnRespuesta3.BackColor = System.Drawing.SystemColors.Control; + btnRespuesta4.Text = actual.Respuestas[3]; btnRespuesta4.Enabled = true; btnRespuesta4.BackColor = System.Drawing.SystemColors.Control; + lblRespuestasActuales.Text = (int.Parse(lblRespuestasActuales.Text) + 1).ToString(); btnSiguiente.Enabled = false; } @@ -171,6 +136,58 @@ private void BtnSiguiente_Click(object sender, EventArgs e) SiguientePregunta(); } + private void FinTiempoLimite() + { + btnSiguiente.Enabled = false; + fachada.FinTiempoLimite(); + MessageBox.Show("¡Tiempo agotado! Puntaje: " + fachada.ObtenerPuntaje(), "Fin de la partida", MessageBoxButtons.OK, MessageBoxIcon.Warning); + this.Close(); + } + + private void SesionForm_FormClosing(object sender, FormClosingEventArgs e) + { + fachada.DetenerTimer(); + } + + private void ActualizarTimer(int pTiempoRestante) + { + lblTimer.Text = pTiempoRestante.ToString()+ " s"; + } + + PrivateFontCollection fonts = new PrivateFontCollection(); + + [DllImport("gdi32.dll")] + private static extern IntPtr AddFontMemResourceEx(IntPtr pbFont, uint cbFont, + IntPtr pdv, [In] ref uint pcFonts); + private void LoadFont() + { + byte[] fontData = Properties.Resources.Adobe_Garamond_Pro_Regular; + IntPtr fontPtr = Marshal.AllocCoTaskMem(fontData.Length); + Marshal.Copy(fontData, 0, fontPtr, fontData.Length); + uint dummy = 0; + fonts.AddMemoryFont(fontPtr, Properties.Resources.Adobe_Garamond_Pro_Regular.Length); + AddFontMemResourceEx(fontPtr, (uint)Properties.Resources.Adobe_Garamond_Pro_Regular.Length, IntPtr.Zero, ref dummy); + Marshal.FreeCoTaskMem(fontPtr); + + Font preguntaFont = new Font(fonts.Families[0], 21.0F); + lblPregunta.Font = preguntaFont; + + Font otrosFont = new Font(fonts.Families[0], 15.0F); + lblCategoria.Font = otrosFont; + lblDificultad.Font = otrosFont; + lblRespuestasActuales.Font = otrosFont; + lblRespuestasTotales.Font = otrosFont; + lblTimer.Font = otrosFont; + label2.Font = otrosFont; + label4.Font = otrosFont; + label6.Font = otrosFont; + label8.Font = otrosFont; + label9.Font = otrosFont; + btnRespuesta1.Font = otrosFont; + btnRespuesta2.Font = otrosFont; + btnRespuesta3.Font = otrosFont; + btnRespuesta4.Font = otrosFont; + private void ColorBotonCorrecto(string pRespuesta) { if (btnRespuesta1.Text == pRespuesta) @@ -195,10 +212,5 @@ private void ColorBotonCorrecto(string pRespuesta) btnRespuesta4.Enabled = false; btnSiguiente.Enabled = true; } - - private void SesionForm_FormClosed(object sender, FormClosedEventArgs e) - { - backgroundWorker.CancelAsync(); - } } } diff --git a/ShockQuiz/Forms/SesionForm.resx b/ShockQuiz/Forms/SesionForm.resx index d3946b4..bd3c3af 100644 --- a/ShockQuiz/Forms/SesionForm.resx +++ b/ShockQuiz/Forms/SesionForm.resx @@ -117,8 +117,8 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 112, 5 + + 17, 17 True diff --git a/ShockQuiz/Migrations/201912091454053_test.Designer.cs b/ShockQuiz/Migrations/201912091454053_test.Designer.cs deleted file mode 100644 index b120560..0000000 --- a/ShockQuiz/Migrations/201912091454053_test.Designer.cs +++ /dev/null @@ -1,29 +0,0 @@ -// -namespace ShockQuiz.Migrations -{ - using System.CodeDom.Compiler; - using System.Data.Entity.Migrations; - using System.Data.Entity.Migrations.Infrastructure; - using System.Resources; - - [GeneratedCode("EntityFramework.Migrations", "6.4.0")] - public sealed partial class test : IMigrationMetadata - { - private readonly ResourceManager Resources = new ResourceManager(typeof(test)); - - string IMigrationMetadata.Id - { - get { return "201912091454053_test"; } - } - - string IMigrationMetadata.Source - { - get { return null; } - } - - string IMigrationMetadata.Target - { - get { return Resources.GetString("Target"); } - } - } -} diff --git a/ShockQuiz/Migrations/201912091454053_test.cs b/ShockQuiz/Migrations/201912091454053_test.cs deleted file mode 100644 index 336a733..0000000 --- a/ShockQuiz/Migrations/201912091454053_test.cs +++ /dev/null @@ -1,136 +0,0 @@ -namespace ShockQuiz.Migrations -{ - using System; - using System.Data.Entity.Migrations; - - public partial class test : DbMigration - { - public override void Up() - { - CreateTable( - "dbo.Categorias", - c => new - { - id = c.Int(nullable: false, identity: true), - nombre = c.String(nullable: false, maxLength: 150), - }) - .PrimaryKey(t => t.id); - - CreateTable( - "dbo.Preguntas", - c => new - { - id = c.Int(nullable: false, identity: true), - nombre = c.String(nullable: false), - CategoriaId = c.Int(nullable: false), - DificultadId = c.Int(nullable: false), - ConjuntoId = c.Int(nullable: false), - }) - .PrimaryKey(t => t.id) - .ForeignKey("dbo.Categorias", t => t.CategoriaId, cascadeDelete: true) - .ForeignKey("dbo.Conjuntos", t => t.ConjuntoId, cascadeDelete: true) - .ForeignKey("dbo.Dificultades", t => t.DificultadId, cascadeDelete: true) - .Index(t => t.CategoriaId) - .Index(t => t.DificultadId) - .Index(t => t.ConjuntoId); - - CreateTable( - "dbo.Conjuntos", - c => new - { - id = c.Int(nullable: false, identity: true), - nombre = c.String(nullable: false, maxLength: 100), - TiempoEsperadoPorPregunta = c.Double(nullable: false), - tokenAPI = c.String(), - }) - .PrimaryKey(t => t.id); - - CreateTable( - "dbo.Sesiones", - c => new - { - id = c.Int(nullable: false, identity: true), - cantidadPreguntas = c.Int(nullable: false), - CategoriaId = c.Int(nullable: false), - DificultadId = c.Int(nullable: false), - puntaje = c.Double(nullable: false), - FechaInicio = c.DateTime(nullable: false), - fechaFin = c.DateTime(nullable: false), - UsuarioId = c.Int(nullable: false), - ConjuntoId = c.Int(nullable: false), - }) - .PrimaryKey(t => t.id) - .ForeignKey("dbo.Categorias", t => t.CategoriaId, cascadeDelete: true) - .ForeignKey("dbo.Conjuntos", t => t.ConjuntoId, cascadeDelete: true) - .ForeignKey("dbo.Dificultades", t => t.DificultadId, cascadeDelete: true) - .ForeignKey("dbo.Usuarios", t => t.UsuarioId, cascadeDelete: true) - .Index(t => t.CategoriaId) - .Index(t => t.DificultadId) - .Index(t => t.UsuarioId) - .Index(t => t.ConjuntoId); - - CreateTable( - "dbo.Dificultades", - c => new - { - id = c.Int(nullable: false, identity: true), - nombre = c.String(nullable: false, maxLength: 100), - }) - .PrimaryKey(t => t.id); - - CreateTable( - "dbo.Usuarios", - c => new - { - id = c.Int(nullable: false, identity: true), - user = c.String(nullable: false, maxLength: 20), - password = c.String(nullable: false, maxLength: 20), - Admin = c.Boolean(nullable: false), - }) - .PrimaryKey(t => t.id) - .Index(t => t.user, unique: true); - - CreateTable( - "dbo.Respuestas", - c => new - { - id = c.Int(nullable: false, identity: true), - respuesta = c.String(nullable: false), - EsCorrecta = c.Boolean(nullable: false), - PreguntaId = c.Int(nullable: false), - }) - .PrimaryKey(t => t.id) - .ForeignKey("dbo.Preguntas", t => t.PreguntaId, cascadeDelete: true) - .Index(t => t.PreguntaId); - - } - - public override void Down() - { - DropForeignKey("dbo.Respuestas", "PreguntaId", "dbo.Preguntas"); - DropForeignKey("dbo.Preguntas", "DificultadId", "dbo.Dificultades"); - DropForeignKey("dbo.Preguntas", "ConjuntoId", "dbo.Conjuntos"); - DropForeignKey("dbo.Sesiones", "UsuarioId", "dbo.Usuarios"); - DropForeignKey("dbo.Sesiones", "DificultadId", "dbo.Dificultades"); - DropForeignKey("dbo.Sesiones", "ConjuntoId", "dbo.Conjuntos"); - DropForeignKey("dbo.Sesiones", "CategoriaId", "dbo.Categorias"); - DropForeignKey("dbo.Preguntas", "CategoriaId", "dbo.Categorias"); - DropIndex("dbo.Respuestas", new[] { "PreguntaId" }); - DropIndex("dbo.Usuarios", new[] { "user" }); - DropIndex("dbo.Sesiones", new[] { "ConjuntoId" }); - DropIndex("dbo.Sesiones", new[] { "UsuarioId" }); - DropIndex("dbo.Sesiones", new[] { "DificultadId" }); - DropIndex("dbo.Sesiones", new[] { "CategoriaId" }); - DropIndex("dbo.Preguntas", new[] { "ConjuntoId" }); - DropIndex("dbo.Preguntas", new[] { "DificultadId" }); - DropIndex("dbo.Preguntas", new[] { "CategoriaId" }); - DropTable("dbo.Respuestas"); - DropTable("dbo.Usuarios"); - DropTable("dbo.Dificultades"); - DropTable("dbo.Sesiones"); - DropTable("dbo.Conjuntos"); - DropTable("dbo.Preguntas"); - DropTable("dbo.Categorias"); - } - } -} diff --git a/ShockQuiz/Migrations/201912091454053_test.resx b/ShockQuiz/Migrations/201912091454053_test.resx deleted file mode 100644 index cdedb9c..0000000 --- a/ShockQuiz/Migrations/201912091454053_test.resx +++ /dev/null @@ -1,126 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 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 - - - dbo - - \ No newline at end of file diff --git a/ShockQuiz/Program.cs b/ShockQuiz/Program.cs index 2e512a7..e71afc9 100644 --- a/ShockQuiz/Program.cs +++ b/ShockQuiz/Program.cs @@ -12,10 +12,7 @@ static class Program [STAThread] static void Main() { - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); - Application.Run(new LoginForm()); - /*try + try { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false);; @@ -24,10 +21,8 @@ static void Main() catch (Exception ex) { Logger.LogError(ex); - throw; - + MessageBox.Show("Ha ocurrido una excepción, dirijase a ErrorLog.txt para más información", "Error"); } - */ } } } diff --git a/ShockQuiz/Properties/Resources.Designer.cs b/ShockQuiz/Properties/Resources.Designer.cs index f49693c..2cdb870 100644 --- a/ShockQuiz/Properties/Resources.Designer.cs +++ b/ShockQuiz/Properties/Resources.Designer.cs @@ -60,6 +60,16 @@ internal Resources() { } } + /// + /// Busca un recurso adaptado de tipo System.Byte[]. + /// + internal static byte[] Adobe_Garamond_Pro_Regular { + get { + object obj = ResourceManager.GetObject("Adobe_Garamond_Pro_Regular", resourceCulture); + return ((byte[])(obj)); + } + } + /// /// Busca un recurso adaptado de tipo System.Drawing.Bitmap. /// diff --git a/ShockQuiz/Properties/Resources.resx b/ShockQuiz/Properties/Resources.resx index 3402a7c..5891925 100644 --- a/ShockQuiz/Properties/Resources.resx +++ b/ShockQuiz/Properties/Resources.resx @@ -118,6 +118,9 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + ..\Resources\Adobe Garamond Pro Regular.ttf;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + ..\Resources\next.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a diff --git a/ShockQuiz/Resources/Adobe Garamond Pro Regular.ttf b/ShockQuiz/Resources/Adobe Garamond Pro Regular.ttf new file mode 100644 index 0000000..5974106 Binary files /dev/null and b/ShockQuiz/Resources/Adobe Garamond Pro Regular.ttf differ diff --git a/ShockQuiz/ShockQuiz.csproj b/ShockQuiz/ShockQuiz.csproj index 0236101..905127e 100644 --- a/ShockQuiz/ShockQuiz.csproj +++ b/ShockQuiz/ShockQuiz.csproj @@ -1,6 +1,6 @@  - + Debug @@ -57,8 +57,8 @@ etc_wit_symbol_i01.ico - - ..\packages\BouncyCastle.1.8.6.1\lib\BouncyCastle.Crypto.dll + + ..\packages\BouncyCastle.1.8.3.1\lib\BouncyCastle.Crypto.dll ..\packages\EntityFramework.6.4.4\lib\net45\EntityFramework.dll @@ -124,6 +124,7 @@ + Form @@ -190,9 +191,9 @@ - - - 201912091454053_test.cs + + + 202011241913037_init.cs @@ -218,8 +219,8 @@ LoginForm.cs - - 201912091454053_test.cs + + 202011241913037_init.cs ResXFileCodeGenerator @@ -246,6 +247,7 @@ + @@ -264,6 +266,14 @@ + + + Este proyecto hace referencia a los paquetes NuGet que faltan en este equipo. Use la restauración de paquetes NuGet para descargarlos. Para obtener más información, consulte http://go.microsoft.com/fwlink/?LinkID=322105. El archivo que falta es {0}. + + + + + if not exist "$(TargetDir)x86" md "$(TargetDir)x86" @@ -271,12 +281,4 @@ if not exist "$(TargetDir)amd64" md "$(TargetDir)amd64" xcopy /s /y "$(SolutionDir)packages\Microsoft.SqlServer.Compact.4.0.8876.1\NativeBinaries\amd64\*.*" "$(TargetDir)amd64" - - - Este proyecto hace referencia a los paquetes NuGet que faltan en este equipo. Use la restauración de paquetes NuGet para descargarlos. Para obtener más información, consulte http://go.microsoft.com/fwlink/?LinkID=322105. El archivo que falta es {0}. - - - - - \ No newline at end of file diff --git a/ShockQuiz/packages.config b/ShockQuiz/packages.config index a08a82e..eab741e 100644 --- a/ShockQuiz/packages.config +++ b/ShockQuiz/packages.config @@ -1,9 +1,9 @@  - - - - + + + +