示例#1
0
 public OCSuscripcionesController()
 {
     _entityRepo = new OCSuscripcionesRepository();
 }
示例#2
0
                                                     public async Task <IHttpActionResult> NotificationStart()
                                                     {
                                                         try { log.Info(new MDCSet(this.ControllerContext.RouteData));
                                                               var NuevosOcs = await _entityRepo.GetAllNewsWithOCs(); //.Where(x=>x.nuevo==true)

                                                               var listOcs = new List <NuevoOC>(NuevosOcs);
                                                               for (int i = 0; i < 1; i++)
                                                               {
                                                                   if (NuevosOcs == null || NuevosOcs.Count() == 0)
                                                                   {
                                                                       break;
                                                                   }


                                                                   OCSuscripcionesRepository susc = new OCSuscripcionesRepository();
                                                                   var oCSuscripciones            = await susc.GetAllEmpleadosANDsuscritoWithOc();

                                                                   if (oCSuscripciones == null || oCSuscripciones.Count() == 0)
                                                                   {
                                                                       break;
                                                                   }

                                                                   HashSet <String> clavesEmpleado = new HashSet <string>(
                                                                       oCSuscripciones.Select(x => x.ClaveEmpleado));

                                                                   var personas = await susc.PersonasGetAllCollectionMAX(clavesEmpleado);

                                                                   await _entityRepo.UpdateSetFalseInNuevo();

                                                                   List <PersonaSuscripciones> lista = new List <PersonaSuscripciones>();

                                                                   getCorreoConfig        conf          = new getCorreoConfig();
                                                                   SendCorreo             send          = new SendCorreo();
                                                                   Correo                 correo        = new Correo();
                                                                   List <OCSuscripciones> OCSuscripcion = new List <OCSuscripciones>();


                                                                   if (NuevosOcs == null ||
                                                                       listOcs == null || listOcs.Count < 1 || NuevosOcs.Count() == 0)
                                                                   {
                                                                       break;
                                                                   }
                                                                   try { log.Info(new MDCSet(this.ControllerContext.RouteData));
                                                                         string servidorWeb = ConfigurationManager.AppSettings["servidorWeb"];
                                                                         List <OCSuscripciones> oCSuscripcionesList = new List <OCSuscripciones>(oCSuscripciones);
                                                                         foreach (var p in personas)
                                                                         {
                                                                             var porEmpleado = oCSuscripcionesList.FindAll(x => x.ClaveEmpleado == p.ClavePersona);
                                                                             if (porEmpleado != null)
                                                                             {
                                                                                 OCSuscripcion = new List <OCSuscripciones>(porEmpleado);
                                                                                 var email = getCorreo(OCSuscripcion, listOcs, servidorWeb);
                                                                                 if (email.goSend)
                                                                                 {
                                                                                     await send.Send(p, getCorreo(OCSuscripcion, listOcs, servidorWeb), conf);
                                                                                 }
                                                                             }
                                                                             //lista.Add(new PersonaSuscripciones(p, OCSuscripcion));
                                                                         }
                                                                   }
                                                                   catch (Exception e) { log.Error(new MDCSet(this.ControllerContext.RouteData), e); }
                                                               }
                                                               return(Ok("pendiente")); }
                                                         catch (Exception e) { log.Error(new MDCSet(this.ControllerContext.RouteData), e);

                                                                               return(InternalServerError(e)); }
                                                     }