@@ -72,10 +72,14 @@ internal class ControladorRefrescoCache : ControladorServicioGnoss
7272
7373 private Dictionary < Guid , string > mListaUrlPorProyecto = new Dictionary < Guid , string > ( ) ;
7474
75+ private List < string > mListaProyectos = new List < string > ( ) ;
76+
7577 private int mNumeroMaxPeticionesWebSimultaneas = 5 ;
7678
7779 private List < BusquedaRefrescoCaducidad > mListaBusquedaRefrescoCaducidad = new List < BusquedaRefrescoCaducidad > ( ) ;
7880
81+ RabbitMQClient mRabbitMQClient ;
82+
7983
8084 #endregion
8185
@@ -101,9 +105,10 @@ protected override ControladorServicioGnoss ClonarControlador()
101105 #region Métodos generales
102106
103107 Dictionary < string , DateTime > peticionesProcesadas = new Dictionary < string , DateTime > ( ) ;
104-
108+
105109 private bool ProcesarItem ( string pFila )
106110 {
111+
107112 using ( var scope = ScopedFactory . CreateScope ( ) )
108113 {
109114 EntityContext entityContext = scope . ServiceProvider . GetRequiredService < EntityContext > ( ) ;
@@ -144,7 +149,14 @@ private bool ProcesarItem(string pFila)
144149 peticionesProcesadas [ item ] = DateTime . Now ;
145150 }
146151
147- ProcesarFilaColaRefrescoCache ( filaCola , entityContext , loggingService , redisCacheWrapper , virtuosoAD , servicesUtilVirtuosoAndReplication ) ;
152+ if ( ! filaCola . TipoEvento . Equals ( ( short ) TiposEventosRefrescoCache . BusquedaVirtuoso ) || ( filaCola . TipoEvento . Equals ( ( short ) TiposEventosRefrescoCache . BusquedaVirtuoso ) && ! mListaProyectos . Contains ( filaCola . ProyectoID . ToString ( ) ) ) )
153+ {
154+ ProcesarFilaColaRefrescoCache ( filaCola , entityContext , loggingService , redisCacheWrapper , virtuosoAD , servicesUtilVirtuosoAndReplication ) ;
155+ if ( filaCola . TipoEvento . Equals ( ( short ) TiposEventosRefrescoCache . BusquedaVirtuoso ) )
156+ {
157+ mListaProyectos . Add ( filaCola . ProyectoID . ToString ( ) ) ;
158+ }
159+ }
148160
149161 filaCola = null ;
150162
@@ -180,15 +192,15 @@ private void ProcesarFilaColaRefrescoCache(BaseComunidadDS.ColaRefrescoCacheRow
180192 catch ( Exception ex )
181193 {
182194 pFilaColaRefrescoCache . Estado = 1 ;
183- EnviarCorreoErrorYGuardarLog ( ex , "Error Refresco caché (ProcesarFilaModificarCaducidadCache)" , entityContext , loggingService ) ;
195+ EnviarCorreoErrorYGuardarLog ( ex , "Error Refresco caché (ProcesarFilaModificarCaducidadCache)" , entityContext , loggingService ) ;
184196 }
185197 }
186198 else
187199 {
188200 var busquedaRefrescoCaducidad = mListaBusquedaRefrescoCaducidad . FirstOrDefault ( item => item . ProyectoID . Equals ( pFilaColaRefrescoCache . ProyectoID ) && item . TipoBusqueda . Equals ( pFilaColaRefrescoCache . TipoBusqueda ) ) ;
189201 if ( busquedaRefrescoCaducidad == null || busquedaRefrescoCaducidad . Caducidad . AddMinutes ( 1 ) < DateTime . Now )
190202 {
191- if ( busquedaRefrescoCaducidad != null )
203+ if ( busquedaRefrescoCaducidad != null )
192204 {
193205 mListaBusquedaRefrescoCaducidad . Remove ( busquedaRefrescoCaducidad ) ;
194206 }
@@ -216,12 +228,12 @@ protected void RealizarMantenimientoRabbitMQ(LoggingService loggingService, bool
216228 {
217229 RabbitMQClient . ReceivedDelegate funcionProcesarItem = new RabbitMQClient . ReceivedDelegate ( ProcesarItem ) ;
218230 RabbitMQClient . ShutDownDelegate funcionShutDown = new RabbitMQClient . ShutDownDelegate ( OnShutDown ) ;
219-
220- RabbitMQClient rabbitMQClient = new RabbitMQClient ( RabbitMQClient . BD_SERVICIOS_WIN , NOMBRE_COLA , loggingService , mConfigService , EXCHANGE , NOMBRE_COLA ) ;
221231
232+ mRabbitMQClient = new RabbitMQClient ( RabbitMQClient . BD_SERVICIOS_WIN , NOMBRE_COLA , loggingService , mConfigService , EXCHANGE , NOMBRE_COLA ) ;
233+ mListaProyectos = new List < string > ( ) ;
222234 try
223235 {
224- rabbitMQClient . ObtenerElementosDeCola ( funcionProcesarItem , funcionShutDown ) ;
236+ mRabbitMQClient . ObtenerElementosDeCola ( funcionProcesarItem , funcionShutDown ) ;
225237 mReiniciarLecturaRabbit = false ;
226238 }
227239 catch ( Exception ex )
@@ -349,16 +361,34 @@ public override void RealizarMantenimiento(EntityContext entityContext, EntityCo
349361 parametroAplicacionGBD . ObtenerConfiguracionGnoss ( GestorParametroAplicacionDS ) ;
350362 mUrlIntragnoss = GestorParametroAplicacionDS . ParametroAplicacion . Where ( parametroApp => parametroApp . Parametro . Equals ( "UrlIntragnoss" ) ) . FirstOrDefault ( ) . Valor ;
351363
352- mDominio = GestorParametroAplicacionDS . ParametroAplicacion . Where ( parametroApp=> parametroApp . Parametro . Equals ( "UrlIntragnoss" ) ) . FirstOrDefault ( ) . Valor ;
364+ mDominio = GestorParametroAplicacionDS . ParametroAplicacion . Where ( parametroApp => parametroApp . Parametro . Equals ( "UrlIntragnoss" ) ) . FirstOrDefault ( ) . Valor ;
353365 mDominio = mDominio . Replace ( "http://" , "" ) . Replace ( "www." , "" ) ;
354366
355367 if ( mDominio [ mDominio . Length - 1 ] == '/' )
356368 {
357369 mDominio = mDominio . Substring ( 0 , mDominio . Length - 1 ) ;
358370 }
371+ if ( mConfigService . UsarCacheRefreshActiva ( ) )
372+ {
373+ while ( true )
374+ {
375+ Task tarea = Task . Factory . StartNew ( ( ) => RealizarMantenimientoRabbitMQ ( loggingService ) ) ;
376+
377+ Thread . Sleep ( 60000 ) ; // 1 minuto
359378
360- RealizarMantenimientoRabbitMQ ( loggingService ) ;
361- RealizarMantenimientoBaseDatosColas ( ) ;
379+ if ( mRabbitMQClient != null )
380+ {
381+ mRabbitMQClient . CerrarConexionLectura ( ) ;
382+ mRabbitMQClient . Dispose ( ) ;
383+ }
384+
385+ Thread . Sleep ( 300000 ) ; // 5 minutos
386+ }
387+ }
388+ else
389+ {
390+ RealizarMantenimientoRabbitMQ ( loggingService ) ;
391+ }
362392 }
363393
364394 private void ProcesarFila ( BaseComunidadDS . ColaRefrescoCacheRow pFilaCola , EntityContext entityContext , LoggingService loggingService , RedisCacheWrapper redisCacheWrapper , VirtuosoAD virtuosoAD , IServicesUtilVirtuosoAndReplication servicesUtilVirtuosoAndReplication )
@@ -582,10 +612,10 @@ private void ProcesarFilaDeBusqueda(BaseComunidadDS.ColaRefrescoCacheRow pFilaCo
582612 facetadoCL . InvalidarResultadosYFacetasDeBusquedaEnProyecto ( pFilaCola . ProyectoID , FacetadoAD . TipoBusquedaToString ( ( TipoBusqueda ) pFilaCola . TipoBusqueda ) , true ) ;
583613 facetadoCL . BorrarRSSDeComunidad ( pFilaCola . ProyectoID ) ;
584614
585- if ( ! pFilaCola . IsInfoExtraNull ( ) && pFilaCola . InfoExtra . StartsWith ( "rdf:type=" ) )
615+ /* if (!pFilaCola.IsInfoExtraNull() && pFilaCola.InfoExtra.StartsWith("rdf:type="))
586616 {
587617 facetadoCL.InvalidarResultadosYFacetasDeBusquedaEnProyecto(pFilaCola.ProyectoID, pFilaCola.InfoExtra, true);
588- }
618+ }*/
589619
590620 //Si contiene el tipo de búsqueda que se está pidiendo se necesitan limpiar todas las pestanyas que contengan esa búsqueda.
591621 ProyectoCN proyCN = new ProyectoCN ( entityContext , loggingService , mConfigService , servicesUtilVirtuosoAndReplication ) ;
@@ -843,7 +873,7 @@ private ParametroGeneral ObtenerFilaParametroGeneral(Guid pProyectoID, EntityCon
843873 GestorParametroGeneral gestorParametroGeneral = new GestorParametroGeneral ( ) ;
844874 //ParametroAplicacionGBD parametroAplicacionGBD = new ParametroAplicacionGBD();
845875 //gestorParametroGeneral= parametroAplicacionGBD.ObtenerParametrosGeneralesDeProyecto(gestorParametroGeneral,pProyectoID);
846- gestorParametroGeneral = paramCL . ObtenerParametrosGeneralesDeProyecto ( pProyectoID ) ;
876+ gestorParametroGeneral = paramCL . ObtenerParametrosGeneralesDeProyecto ( pProyectoID ) ;
847877 //paramCL.Dispose();
848878
849879 ParametroGeneral parametroGeneralBusqueda = gestorParametroGeneral . ListaParametroGeneral . Where ( parametroGeneral => parametroGeneral . ProyectoID . Equals ( pProyectoID ) ) . FirstOrDefault ( ) ;
@@ -876,7 +906,7 @@ private void RefrescarCacheComponente(Guid pComponenteID, Guid pProyectoID, Enti
876906
877907 private void RefrescarCacheComponente ( CMSComponente filaComponente , EntityContext entityContext , LoggingService loggingService , RedisCacheWrapper redisCacheWrapper , IServicesUtilVirtuosoAndReplication servicesUtilVirtuosoAndReplication )
878908 {
879- RealizarPeticionWebRefrescoCache ( filaComponente , entityContext , loggingService , redisCacheWrapper , servicesUtilVirtuosoAndReplication ) ;
909+ RealizarPeticionWebRefrescoCache ( filaComponente , entityContext , loggingService , redisCacheWrapper , servicesUtilVirtuosoAndReplication ) ;
880910 }
881911
882912 private void ActualizarFechaProximaActualizacionComponente ( CMSComponente pFilaComponente , DateTime pFechaActualizacion , bool pActualizarBD , EntityContext entityContext , LoggingService loggingService , IServicesUtilVirtuosoAndReplication servicesUtilVirtuosoAndReplication )
@@ -987,7 +1017,7 @@ private List<CMSComponente> CargarComponentesCaducados(EntityContext entityConte
9871017 // CMSCN cmsCN = new CMSCN(mFicheroConfiguracionBD);
9881018 // mCmsDS = cmsCN.ObtenerComponentesCMSDeProyecto(pProyectoID);
9891019
990-
1020+
9911021 // foreach (CMSDS.CMSComponenteRow filaComponente in mCmsDS.CMSComponente)
9921022 // {
9931023 // TipoCaducidadComponenteCMS tipoCaducidad = (TipoCaducidadComponenteCMS)filaComponente.TipoCaducidadComponente;
0 commit comments