Beispiel #1
0
        /**
         * - Istanzio i servizi,
         * - li aggiungo in una lista interna che mi tengo io per gestire i servizi.
         * - Avvio i servizi appena creati
         */
        private void avviaServizi()
        {
            // Creo la mappa dei servizi
            _serviziAvviati = new Dictionary <string, IServizio>();

            // Creo i servizi

            foreach (String key in this.configurazione.nomiServizi.Keys)
            {
                Type interfaccia = null;

                int posIniz = key.IndexOf("<");
                if (posIniz > 0)
                {
                    // Devo gestire i generic type
                    int posFine = key.IndexOf(">", posIniz + 1);
                    if (posFine > 0)
                    {
                        String genericStr = key.Substring(posIniz + 1, posFine - posIniz - 1);
                        Type   generic    = Type.GetType(genericStr);
                        if (generic == null)
                        {
                            generic = Type.GetType(genericStr + ",Digiphoto.Lumen.Core");
                        }
                        if (generic == null)
                        {
                            generic = Type.GetType(genericStr + ",Digiphoto.Lumen.Model");
                        }

                        String interfaceName = key.Substring(0, posIniz);

                        String tutto = interfaceName + "`1";

                        interfaccia = Type.GetType(tutto);
                        if (interfaccia == null)
                        {
                            interfaccia = Type.GetType(tutto + ",Digiphoto.Lumen.Core");
                        }
                        if (interfaccia == null)
                        {
                            interfaccia = Type.GetType(tutto + ",Digiphoto.Lumen.Model");
                        }

                        interfaccia = interfaccia.MakeGenericType(generic);
                    }
                }
                else
                {
                    interfaccia = Type.GetType(key);
                }


                creaAggiungiAvviaServizio(interfaccia);
            }

            // Questo servizio nasce
            IVolumeCambiatoSrv vcs = getServizioAvviato <IVolumeCambiatoSrv>();

            if (vcs != null)
            {
                // TODO forse si può sporstare dentro la IMPL
                vcs.attesaBloccante = false;
                vcs.attesaEventi();
            }

            // IL servizio dei barcodes lo tengo spento. Lo accendo solo alla necessità
            IBarCodeSrv bcs = getServizioAvviato <IBarCodeSrv>();

            if (bcs != null)
            {
                bcs.stop();
            }
            IDbRebuilderSrv dbr = getServizioAvviato <IDbRebuilderSrv>();

            if (dbr != null)
            {
                dbr.stop();
            }

            // Anche il servizio di lettura scanner impronte digitali lo tengo spento. lo accendo solo alla necessità
            IImpronteSrv imp = getServizioAvviato <IImpronteSrv>();

            if (imp != null && imp.statoRun == StatoRun.Running)
            {
                if (Configurazione.UserConfigLumen.scannerImpronteGestito == false)
                {
                    imp.stop();
                }
            }
        }