Пример #1
0
        public void DoWork(object state)
        {
            var optionsBuild = new DbContextOptionsBuilder <GTTContext>();

            optionsBuild.UseNpgsql("Host=192.168.99.100;Port=5432;Username=postgres;Password=example;Database=ApiGtt;");// Host =ec2-54-247-113-90.eu-west-1.compute.amazonaws.com;Port=5432;Username=dxrfnsywqjvdeq;Password=d0dc61b17af9ffe0b1cc18e87089fa07898d66123b92b6514afdea0281c2fe83;Database=dcm55dbn35qm7c;");

            using (var context = new GTTContext(optionsBuild.Options))
            {
                context.Certificates.Load();
                foreach (var cert in context.Certificates.Local)
                {
                    DateTime today   = DateTime.Today;
                    DateTime maxdate = DateTime.Today.AddMonths(1);
                    //DateTime maxdateAux = new DateTime(2018, 01, 29);
                    // Primero los que ya han caducado (los eliminados ya no cuentan)
                    // Puede pasar a Caducado un correcto, un alertado o un jira
                    if (!cert.eliminado && cert.caducidad < today && cert.estado != Estado.caducado)
                    {
                        Certificate c2 = context.Certificates.Find(cert.id);
                        c2.estado = Estado.caducado;
                        context.SaveChanges();
                        _logger.LogInformation("El certificado " + c2.alias + " ha pasado a Caducado.");
                    }
                    // Luego los que van a caducar en 1 mes (los eliminados ya no cuentan)
                    else if (!cert.eliminado && cert.caducidad < maxdate && cert.estado == Estado.correcto)
                    {
                        Certificate c2 = context.Certificates.Find(cert.id);
                        c2.estado = Estado.alertado;
                        context.SaveChanges();
                        _logger.LogInformation("El certificado " + c2.alias + " ha pasado a Alertado.");
                    }
                }
            }
        }
Пример #2
0
 public UserController(GTTContext context)
 {
     this._context = context;
     if (this._context.Users.Count() == 0)
     {
         Console.WriteLine("No existe ningun usuario");
         User newUser = new User();
         newUser.username = "******";
         newUser.password = Encrypt.Hash("1234");
         newUser.role     = Role.admin;
         User newUser2 = new User();
         newUser2.username = "******";
         newUser2.password = Encrypt.Hash("1234");
         newUser2.role     = Role.user;
         this._context.Users.Add(newUser);
         this._context.Users.Add(newUser2);
         this._context.SaveChanges();
     }
     if (this._context.Jiras.Count() == 0)
     {
         Console.WriteLine("No existe ningun usuario Jira");
         Jira newJira = new Jira();
         newJira.username  = "******";
         newJira.password  = "******";
         newJira.component = "Arquitectura...";
         newJira.url       = "https://edunavarro13.atlassian.net";
         newJira.proyect   = "SIT";
         newJira.idUser    = 1;
         this._context.Jiras.Add(newJira);
         this._context.SaveChanges();
     }
 }
Пример #3
0
 public CertificateController(GTTContext context)
 {
     this._context = context;
 }
Пример #4
0
 public ValuesController(GTTContext context)
 {
     this._context = context;
 }
Пример #5
0
 public AuthController(GTTContext context)
 {
     this._context = context;
 }
Пример #6
0
 public JiraController(GTTContext context)
 {
     this._context = context;
 }
Пример #7
0
 public void setContext(GTTContext _context)
 {
     _logger.LogInformation("Ejecutando tarea");
 }