Beispiel #1
0
        /*
         * Método que realiza la misma función que el método OnTreeviewNeighboursRowActivated. BOTON CONEXIÓN
         * */
        protected void OnConnectionPngAction1Activated(object sender, EventArgs e)
        {
            TreeIter t;
            TreePath p = treeviewNeighbours.Selection.GetSelectedRows()[0];

            this._infoNeighboursView.GetIter(out t, p);

            string vecino = (string)this._infoNeighboursView.GetValue(t, 0);

            //Comprobamos que está el usuario y si la tupla que tiene es del mismo (tipoBBDD,nombreBBDD)
            if (!this._messages.ContainsKey(vecino))
            {
                this._connectionDialog = new ConnectionDialog(this._user.Nombre, vecino, null, null, this._claves);

                this._connectionDialog.Run();


                switch (this._connectionDialog.TypeOutPut)
                {
                case Constants.CANCEL:

                    break;

                case Constants.MENSAJE_CONEXION:
                    Dictionary <string, PipeMessage> messageC = new Dictionary <string, PipeMessage>();
                    messageC.Add(Constants.CONNECTION, this._connectionDialog.Connection);
                    Tuple <string, string, Dictionary <string, PipeMessage> > tupl =
                        new Tuple <string, string, Dictionary <string, PipeMessage> >(null, null, messageC);

                    if (!this._messages.ContainsKey(vecino))
                    {
                        List <Tuple <string, string, Dictionary <string, PipeMessage> > > lista = new List <Tuple <string, string, Dictionary <string, PipeMessage> > >();
                        lista.Add(tupl);

                        this._messages.Add(vecino, lista);
                    }
                    else
                    {
                        this._messages[vecino].Add(tupl);
                    }

                    if (!this._keyPairClients.ContainsKey(vecino))
                    {
                        Tuple <RsaKeyParameters, SymmetricAlgorithm> tup = new Tuple <RsaKeyParameters, SymmetricAlgorithm>(this._connectionDialog.Connection.PublicKey, this._connectionDialog.Connection.SymmetricKey);
                        this._keyPairClients.Add(vecino, tup);
                    }

                    this._neighbours.SaveNeighbourDatabases(this._connectionDialog.Connection.MessageResponse);

                    AddValuesDatabasesNeighbours();

                    MostrarSolicitudConexion(this._connectionDialog.Connection.MessageRequest);
                    MostrarConexion(this._connectionDialog.Connection.MessageResponse);
                    IncrementarConexionesActivas();

                    break;

                case Constants.ERROR_CONNECTION:
                    MostrarError(this._connectionDialog.TypeOutPut);
                    break;
                }
            }
        }
Beispiel #2
0
        /*
         * Método evento para solicitar esquema BBDD. BOTON ESQUEMA
         * */
        protected void OnSchemaPngActionActivated(object sender, EventArgs e)
        {
            TreeIter t;
            TreePath p = treeviewDatabases.Selection.GetSelectedRows()[0];

            this._infoBBDDView.GetIter(out t, p);

            string usuarioDestino = (string)this._infoBBDDView.GetValue(t, 0);
            string tipoBBDD       = (string)this._infoBBDDView.GetValue(t, 1);
            string nombreBBDD     = (string)this._infoBBDDView.GetValue(t, 2);

            //Comprobamos que está el usuario y si la tupla que tiene es del mismo (tipoBBDD,nombreBBDD)
            if (this._messages.ContainsKey(usuarioDestino))
            {
                Tuple <string, string, Dictionary <string, PipeMessage> > tupla = DevuelveTupla(usuarioDestino, tipoBBDD, nombreBBDD);

                if (tupla == null)
                {
                    Tuple <string, string, Dictionary <string, PipeMessage> > firstTupla = DevuelvePrimeraTupla(usuarioDestino);
                    int index = this._messages[usuarioDestino].IndexOf(firstTupla);

                    PipeMessage pipeConexion = this._messages[usuarioDestino][index].Item3[Constants.CONNECTION];

                    this._connectionDialog = new ConnectionDialog(this._user.Nombre, usuarioDestino, tipoBBDD, nombreBBDD, pipeConexion, this._claves);
                }
                else
                {
                    int index = this._messages[usuarioDestino].IndexOf(tupla);

                    if (!ComprobarTuplaConSchema(usuarioDestino, tipoBBDD, nombreBBDD))
                    {
                        PipeMessage pipeConexion = this._messages[usuarioDestino][index].Item3[Constants.CONNECTION];

                        this._connectionDialog = new ConnectionDialog(this._user.Nombre, usuarioDestino, tipoBBDD, nombreBBDD, pipeConexion, this._claves);
                    }
                }
            }

            this._connectionDialog.Run();

            switch (this._connectionDialog.TypeOutPut)
            {
            case Constants.CANCEL:

                break;

            case Constants.MENSAJE_ESQUEMA:

                if (!ComprobarTuplaConSchema(usuarioDestino, tipoBBDD, nombreBBDD))
                {
                    Tuple <string, string, Dictionary <string, PipeMessage> > tuplaa = DevuelveTupla(usuarioDestino, tipoBBDD, nombreBBDD);

                    if (tuplaa != null)
                    {
                        //Añadimos un nuevo pipeMessage a la tupla existente
                        int indexx = this._messages[usuarioDestino].IndexOf(tuplaa);
                        this._messages[usuarioDestino][indexx].Item3.Add(Constants.SCHEMA, this._connectionDialog.Schema);
                    }
                    else
                    {
                        Tuple <string, string, Dictionary <string, PipeMessage> > tuplaDiferente = DevuelvePrimeraTupla(usuarioDestino);

                        //Añadimos una nueva tupla
                        Dictionary <string, PipeMessage> diccionarioNuevo = new Dictionary <string, PipeMessage>();
                        //diccionarioNuevo.Add(Constants.CONNECTION, tuplaDiferente.Item3[Constants.CONNECTION]);
                        diccionarioNuevo.Add(Constants.SCHEMA, this._connectionDialog.Schema);
                        Tuple <string, string, Dictionary <string, PipeMessage> > tuplaNueva = new Tuple <string, string, Dictionary <string, PipeMessage> >(tipoBBDD, nombreBBDD, diccionarioNuevo);
                        this._messages[usuarioDestino].Add(tuplaNueva);
                    }
                }

                MostrarSolicitudEsquema(this._connectionDialog.Schema.MessageRequest);
                MostrarEsquema(this._connectionDialog.Schema.MessageResponse);
                break;

            case Constants.ERROR_CONNECTION:
                MostrarError(this._connectionDialog.TypeOutPut);
                break;
            }
        }
Beispiel #3
0
        /*
         * Método evento para solicitar consulta BBDD. BOTON SELECT
         * */
        protected void OnSelectPngActionActivated(object sender, EventArgs e)
        {
            TreeIter t;
            TreePath p = treeviewDatabases.Selection.GetSelectedRows()[0];

            this._infoBBDDView.GetIter(out t, p);


            string usuarioDestino = (string)this._infoBBDDView.GetValue(t, 0);
            string tipoBBDD       = (string)this._infoBBDDView.GetValue(t, 1);
            string nombreBBDD     = (string)this._infoBBDDView.GetValue(t, 2);

            //Comprobamos que está el usuario y si la tupla que tiene es del mismo (tipoBBDD,nombreBBDD)
            if (this._messages.ContainsKey(usuarioDestino))
            {
                Tuple <string, string, Dictionary <string, PipeMessage> > tupla = DevuelveTupla(usuarioDestino, tipoBBDD, nombreBBDD);

                if (tupla != null)
                {
                    int index = this._messages[usuarioDestino].IndexOf(tupla);

                    if (ComprobarTuplaConSchema(usuarioDestino, tipoBBDD, nombreBBDD))
                    {
                        PipeMessage pipeConexion = null;
                        if (this._messages[usuarioDestino][index].Item3.ContainsKey(Constants.CONNECTION))
                        {
                            pipeConexion = this._messages[usuarioDestino][index].Item3[Constants.CONNECTION];
                        }
                        else
                        {
                            Tuple <string, string, Dictionary <string, PipeMessage> > tuplaAuxiliar = DevuelveTupla(usuarioDestino, null, null);

                            int indexAuxiliar = this._messages[usuarioDestino].IndexOf(tuplaAuxiliar);
                            pipeConexion = this._messages[usuarioDestino][indexAuxiliar].Item3[Constants.CONNECTION];
                        }
                        PipeMessage pipeSchema = this._messages[usuarioDestino][index].Item3[Constants.SCHEMA];

                        this._connectionDialog = new ConnectionDialog(this._user.Nombre,
                                                                      usuarioDestino, tipoBBDD, nombreBBDD, pipeConexion, pipeSchema, this._claves);
                    }
                }
            }

            this._connectionDialog.Run();

            switch (this._connectionDialog.TypeOutPut)
            {
            case Constants.CANCEL:

                break;

            case Constants.MENSAJE_CONSULTA:
                Tuple <string, string, Dictionary <string, PipeMessage> > tupla = DevuelveTupla(usuarioDestino, tipoBBDD, nombreBBDD);

                int index = this._messages[usuarioDestino].IndexOf(tupla);
                if (this._messages[usuarioDestino][index].Item3.ContainsKey(Constants.SELECT))
                {
                    this._messages[usuarioDestino][index].Item3[Constants.SELECT] = this._connectionDialog.Select;
                }
                else
                {
                    this._messages[usuarioDestino][index].Item3.Add(Constants.SELECT, this._connectionDialog.Select);
                }

                MostrarSolicitudConsulta(this._connectionDialog.Select.MessageRequest);
                MostrarResultadoConsulta(this._connectionDialog.Select.MessageRequest, this._connectionDialog.Select.MessageResponse);

                break;

            case Constants.ERROR_CONNECTION:
                MostrarError(this._connectionDialog.TypeOutPut);
                break;
            }
        }