Example #1
0
 public void TearDown()
 {
     // Elimino il controller ed il database
     gestioneUtentiController.Dispose();
     gestioneUtentiController = null;
     File.Delete(@"test_database.db");
 }
Example #2
0
        public ServerStazione(ISensore sensore, IGestioneUtentiController gestioneUtentiController, byte[] certBytes, string password)
        {
            _sensore = sensore;
            _gestioneUtentiController = gestioneUtentiController;

            // Carica il certificato
            _certificato = new X509Certificate2(certBytes, password, X509KeyStorageFlags.UserKeySet);
        }
Example #3
0
        public void SetUp()
        {
            // Se il database esiste, lo elimino
            if (File.Exists(@"test_database.db"))
            {
                File.Delete(@"test_database.db");
            }

            // Creo un nuovo controller
            gestioneUtentiController = new GestioneUtentiController("test_database.db");
        }
Example #4
0
        public RegistraUtenteForm(IGestioneUtentiController gestioneUtentiController)
        {
            InitializeComponent();

            var materialSkinManager = MaterialSkinManager.Instance;

            materialSkinManager.AddFormToManage(this);
            materialSkinManager.Theme       = MaterialSkinManager.Themes.LIGHT;
            materialSkinManager.ColorScheme = SismioColor.Scheme;

            this.registraUtente1.Controller = gestioneUtentiController;
        }
Example #5
0
        public ServerStazione(ISensore sensore, IGestioneUtentiController gestioneUtentiController, string certFile, string password)
        {
            _sensore = sensore;
            _gestioneUtentiController = gestioneUtentiController;

            // Assicurati che il certificato esista
            if (!File.Exists(certFile))
            {
                throw new CertificatoNonTrovatoEccezione("The specified certificate cannot be found.");
            }

            // Carica il certificato
            _certificato = new X509Certificate2(certFile, password, X509KeyStorageFlags.UserKeySet);
        }
Example #6
0
        public Login(AutenticazioneController controller, IGestioneUtentiController gestioneUtentiController,
                     IGestioneStazioniController stazioniController, IStoricoController storicoController,
                     SorgenteFactory factory, GestoreEventi gestoreEventi)
        {
            InitializeComponent();
            _controller = controller;
            _gestioneUtentiController = gestioneUtentiController;
            _stazioniController       = stazioniController;
            _storicoController        = storicoController;
            _factory       = factory;
            _gestoreEventi = gestoreEventi;

            var materialSkinManager = MaterialSkinManager.Instance;

            materialSkinManager.AddFormToManage(this);
            materialSkinManager.Theme       = MaterialSkinManager.Themes.LIGHT;
            materialSkinManager.ColorScheme = SismioColor.Scheme;
            this.background.BackColor       = SismioColor.Scheme.DarkPrimaryColor;
            //
            // Load Font
            //
            byte[] fontData = Properties.Resources.RobotoMono_Bold;
            IntPtr fontPtr  = System.Runtime.InteropServices.Marshal.AllocCoTaskMem(fontData.Length);

            System.Runtime.InteropServices.Marshal.Copy(fontData, 0, fontPtr, fontData.Length);
            uint dummy = 0;

            fonts.AddMemoryFont(fontPtr, Properties.Resources.RobotoMono_Bold.Length);
            AddFontMemResourceEx(fontPtr, (uint)Properties.Resources.RobotoMono_Bold.Length, IntPtr.Zero, ref dummy);
            System.Runtime.InteropServices.Marshal.FreeCoTaskMem(fontPtr);

            robotoMono = new Font(fonts.Families[0], 14.0F);

            this.textUsername.Font = robotoMono;
            this.title.Font        = new Font(fonts.Families[0], 56.0F);

            // Focus at the startup
            this.ActiveControl = this.textUsername;

            // Precompilo il form
            this.textUsername.Text = "admin";
            this.textPassword.Text = "admin";

            // Carico la combo box
            CaricaSorgenti();
        }
Example #7
0
        public MainForm(IGestioneUtentiController gestioneUtentiController,
                        IGestioneStazioniController gestioneStazioniController,
                        IStoricoController storico,
                        ISorgente sorgente, GestoreEventi gestoreEventi,
                        AutenticazioneController autenticazioneController)
        {
            InitializeComponent();

            this.homeDashboard1.Sorgente      = sorgente;
            this.homeDashboard1.GestoreEventi = gestoreEventi;
            this.homeDashboard1.GestioneStazioniController = gestioneStazioniController;

            this.storico1.StoricoController               = storico;
            this.homeGestioneUtenti1.UtentiController     = gestioneUtentiController;
            this.homeGestioneStazioni1.StazioniController = gestioneStazioniController;

            var materialSkinManager = MaterialSkinManager.Instance;

            materialSkinManager.AddFormToManage(this);
            materialSkinManager.Theme       = MaterialSkinManager.Themes.LIGHT;
            materialSkinManager.ColorScheme = SismioColor.Scheme;
            this.navbar.BackColor           = SismioColor.Scheme.DarkPrimaryColor;
            //this.BackColor = SismioColor.BackColor;

            this.tabControl.SelectedTab = this.tabDashboard;

            this.tabDashboard.BackColor        = SismioColor.BackColor;
            this.tabGestioneStazioni.BackColor = SismioColor.BackColor;
            this.tabGestioneUtenti.BackColor   = SismioColor.BackColor;
            this.tabStorico.BackColor          = SismioColor.BackColor;

            // Nascondo i pulsanti in base ai permessi
            IUtente utenteCorrente = autenticazioneController.UtenteAttivo;

            if (utenteCorrente == null)
            {
                this.navGestioneStazioni.Visible = false;
                this.navGestioneUtenti.Visible   = false;
            }
            else
            {
                this.navGestioneStazioni.Visible = utenteCorrente.PuoModificareStazioni();
                this.navGestioneUtenti.Visible   = utenteCorrente.PuoModificareUtenti();
            }
        }
Example #8
0
        public TrasmissioneDatiWorker(IGestioneUtentiController gestioneUtentiController, ISensore sensore, SslStream sslStream)
        {
            _gestioneUtentiController = gestioneUtentiController;

            _sensore   = sensore;
            _sslStream = sslStream;

            // Crea i lettori e scrittori binari
            _binaryWriter = new BinaryWriter(sslStream);
            _binaryReader = new BinaryReader(sslStream);

            // Ottengo le credenziali utente
            string user = _binaryReader.ReadString();
            string pass = _binaryReader.ReadString();

            Console.WriteLine("Richiesta connessione per utente :{0}", user);

            // Verifico le credenziali
            // TODO Log della connessione remota
            IUtente utenteRemoto = gestioneUtentiController.ValidaCredenziali(user, pass);

            if (utenteRemoto != null)  // Credenziali accettate
            {
                // Invio la risposta
                _binaryWriter.Write("ACCEPT");

                Console.WriteLine("Connessione accettata");

                // Creo il thread di networking
                _threadNetwork = new Thread(new ThreadStart(Run));

                // Registra il worker come ricevitore del sensore per ricevere i dati
                // in tempo reale
                sensore.RicevitoriDatiSensore += OnRisultatiGrezziDisponibili;
            }
            else  // Credenziali non accettate
            {
                // Invio la risposta
                _binaryWriter.Write("INVALID");

                Console.WriteLine("Connessione non accettata");

                throw new CredenzialiInvalideEccezione("Le credenziali non sono valide");
            }
        }
Example #9
0
 public AutenticazioneController(IGestioneUtentiController gestioneUtentiController)
 {
     this._gestioneUtentiController = gestioneUtentiController;
 }