Example #1
0
    private void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else if (instance != this)
        {
            Destroy(gameObject);
        }
        DontDestroyOnLoad(gameObject);

        sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
        var ep = new IPEndPoint(IPAddress.Parse("211.46.116.181"), 9190);

        sock.Connect(ep);

        readThread = new Thread(ReciveToServer);
        readThread.Start();

        sendThread = new Thread(SendToServer);
        sendThread.Start();

        postBox = PostBox.GetInstance;
        StartCoroutine(CheckQueue());
    }
Example #2
0
        /*
         * Método privado para solicitar esquema
         * */
        private bool solicitarEsquema()
        {
            string msg, response;

            //Proceso el envio
            PostBox post = new PostBox(this._source, this._destination, Constants.MENSAJE_ESQUEMA, this._db_name, this._db_type, this._body, this._connection.SymmetricKey, this._keyPair);

            msg = post.ProcesarEnvio();

            //Creo el cliente y le envio el mensaje
            Client c        = new Client();
            bool   conexion = c.comprobarConexion(Constants.GATEKEEPER);

            if (conexion)
            {
                response = c.StartClient(msg, Constants.GATEKEEPER);

                //Proceso la respuesta
                post.ProcesarRespuesta(response);

                this._schema.MessageRequest  = post.MessageRequest;
                this._schema.MessageResponse = post.MessageResponse;
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #3
0
        private bool conexionSegunda()
        {
            string msg, response;

            PostBox post = new PostBox(this._source, this._destination, Constants.MENSAJE_CONEXION_B, this._keyPair, this._publicKeyClient, this._symmetricKey);

            msg = post.ProcesarEnvioConexion();

            //Creo el cliente y le envio el mensaje
            Client c        = new Client();
            bool   conexion = c.comprobarConexion(Constants.GATEKEEPER);

            if (conexion)
            {
                response = c.StartClient(msg, Constants.GATEKEEPER);

                //Proceso la respuesta
                post.ProcesarRespuestaConexion(response);

                this._connection = new PipeMessage(this._auxiliarConexion.MessageRequest, this._auxiliarConexion.MessageResponse, post.MessageRequest, post.MessageResponse, post.PublicKeyClient, this._symmetricKey);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #4
0
        private bool conexionPrimera()
        {
            string msg, response;

            this._auxiliarConexion = new PostBox(this._source, this._destination, Constants.MENSAJE_CONEXION_A, this._keyPair);
            msg = this._auxiliarConexion.ProcesarEnvioConexion();

            //Creo el cliente y le envio el mensaje
            Client c        = new Client();
            bool   conexion = c.comprobarConexion(Constants.GATEKEEPER);

            if (conexion)
            {
                response = c.StartClient(msg, Constants.GATEKEEPER);

                //Proceso la respuesta
                this._auxiliarConexion.ProcesarRespuestaConexion(response);

                this._publicKeyClient = this._auxiliarConexion.PublicKeyClient;
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #5
0
        public void ReadCallback(IAsyncResult ar)
        {
            String content = String.Empty;

            // Retrieve the state object and the handler socket
            // from the asynchronous state object.
            StateObject state   = (StateObject)ar.AsyncState;
            Socket      handler = state.workSocket;

            // Read data from the client socket.
            int bytesRead = handler.EndReceive(ar);

            if (bytesRead > 0)
            {
                // There  might be more data, so store the data received so far.
                state.sb.Append(Encoding.ASCII.GetString(
                                    state.buffer, 0, bytesRead));

                // Check for end-of-file tag. If it is not there, read
                // more data.
                content = state.sb.ToString();
                if (content.IndexOf("</root>") > -1)
                {
                    // client. Display it on the console.
                    log.Info("Read " + content.Length + " bytes from socket. \n");
                }
                else
                {
                    // Not all data received. Get more.
                    handler.BeginReceive(state.buffer, 0, StateObject.BufferSize, 0,
                                         new AsyncCallback(ReadCallback), state);
                }
                log.Debug("Recieved:" + content);

                PostBox post = new PostBox(_keyPair);

                string respuesta = post.procesar(content, _keyPairClients);

                if (!this._keyPairClients.ContainsKey(post.MessageRecieve.Source))
                {
                    Tuple <RsaKeyParameters, SymmetricAlgorithm> tupla = new Tuple <RsaKeyParameters, SymmetricAlgorithm>(post.PublicKeyClient, post.SymmetricKey);
                    _keyPairClients.Add(post.MessageRecieve.Source, tupla);
                }
                else if (this._keyPairClients[post.MessageRecieve.Source].Item2 == null)
                {
                    Tuple <RsaKeyParameters, SymmetricAlgorithm> tupla = new Tuple <RsaKeyParameters, SymmetricAlgorithm>(post.PublicKeyClient, post.SymmetricKey);
                    _keyPairClients[post.MessageRecieve.Source] = tupla;
                }

                Send(handler, respuesta);
            }
        }
Example #6
0
        public static EventStoreConfiguration <TEventStoreConnectionStringName> ConfigurePushNotifications <TEventStoreConnectionStringName>(
            this EventStoreConfiguration <TEventStoreConnectionStringName> config)
            where TEventStoreConnectionStringName : class
        {
            EventStore <AdoNetTransactionUowProvider <TEventStoreConnectionStringName> > .Publish = domainEvents =>
            {
                PostBox <AdoNetTransactionScopeUowProvider> .Drop
                    (() => Request <Subscription> .By(new RegisteredSubscriptions()))
                    (domainEvents.Select(x => new Event {
                    Notification = x, EventId = new NoEventId()
                }));
            };

            return(config);
        }
        private void UpdateTeacherClick(object sender, RoutedEventArgs e)
        {
            string ConnectionString = @"Data Source=DESKTOP-15P21ID;Initial Catalog=kursovoi;Integrated Security=True";
            string sqlExpression    = $"SELECT id,name From facylties where name='{faculty}'";

            using (SqlConnection connection = new SqlConnection(ConnectionString))
            {
                connection.Open();
                SqlCommand    command = new SqlCommand(sqlExpression, connection);
                SqlDataReader reader  = command.ExecuteReader();
                SqlCommand    cm1     = connection.CreateCommand();
                try
                {
                    while (reader.Read())
                    {
                        object s = reader.GetValue(0);
                        fakk_id = Convert.ToInt32(s);
                    }
                    reader.Close();
                    if (fakk_id == 0)
                    {
                        MessageBox.Show("Такого факультета не существует");
                    }
                    else
                    {
                        cm1.CommandText = "update users set first_name='" + SurnameBox.Text + "',middle_name='" + NameBox.Text + "',login='******',email='" + PostBox.Text + "',faculty_id='" + fakk_id + "' where id='" + id_admin_panel + "'";
                        cm1.ExecuteNonQuery();
                        MessageBox.Show("Данные успешно обновлены!");
                    }
                }

                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    SurnameBox.Clear();
                    NameBox.Clear();
                    LoginBox.Clear();
                    PostBox.Clear();
                    FacultyBox.Clear();
                    connection.Close();
                    reader.Close();
                }
            }
        }
        private void fetchPosts()
        {
            int postIndex = 0;

            foreach (Post post in m_LoggedInUser.Posts)
            {
                PostBox postBox = new PostBox(post);
                (m_CurrentChildForm as FormNewsFeed).flowLayoutPanelNewsFeed.Controls.Add(postBox);
                postIndex++;
                if (postIndex == AppSettings.Instance.MaxPostsShown)
                {
                    break;
                }
            }

            if (m_LoggedInUser.Posts.Count == 0)
            {
                MessageBox.Show("No posts to retrieve!");
            }
        }
Example #9
0
 public static void Handler(IReadOnlyCollection <Subscription> subscriptions)
 {
     Functions.Handle
     (
         CommitState,
         CommitStream,
         LastSeenFunction,
         RecentNotificationsFunction,
         subscriptions.Select(x => x.NotificationContract),
         notifications => PostBox <AdoNetTransactionScopeUowProvider> .Post
         (
             notifications.SelectMany(notification =>
                                      new Event
     {
         EventId      = new NoEventId(),
         Notification = notification
     }.SubscriberMessages(subscriptions))
         ),
         RecordLastSeenFunction
     );
 }
Example #10
0
 /// <summary>   Converts this object to a row. </summary>
 /// <returns>   This object as a string. </returns>
 public string ToRow()
 {
     return
         ($"{AccountNumber.ToDatev()};{Name_Enterprise.ToDatev()};{NameExtension1.ToDatev()};{Name_Person.ToDatev()};{FirstName_Person.ToDatev()};{Name.ToDatev()};{AddressType.ToString().ToDatev()};" +
          $"{ShortName.ToDatev()};\"\";\"\";{Salutation.ToDatev()};\"\";\"\";\"\";{PostalAddressType.ToDatev()};{Street.ToDatev()};{PostBox.ToDatev()};{ZipCode.ToDatev()};{City.ToDatev()};\"\";{TransportAddition.ToDatev()};{AddressAddition.ToDatev()};\"\";\"\";\"\";1;;;\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"1\";;;\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";;;\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";;;\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";;;\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";;;\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";;;\"\";;;;;;;;;;;;;;;;;;;;;;;;;;\"\";\"\";;\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";;;\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";;;\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";;;\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";;;\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";;;\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";;;\"\";;\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";;;;;;;;;;;;");
 }
Example #11
0
        /*
         * Método para realizar consulta SELECT
         */
        protected void OnButtonSelectClicked(object sender, EventArgs e)
        {
            string msg, response;

            this.Hide();
            if (this._db_type == Constants.MYSQL)
            {
                BodyRespuesta002MySQL schema = new BodyRespuesta002MySQL(this._schema.MessageResponse.Body.InnerXml);

                this.Hide();
                this._selectDialog = new SelectDialog(this._destination, this._db_name, schema);
                this._selectDialog.Run();

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

                    break;

                case Constants.MENSAJE_CONSULTA:
                    XmlNode bodyMessage = (XmlNode)this._selectDialog.Body;
                    PostBox post        = new PostBox(this._source, this._destination, Constants.MENSAJE_CONSULTA, this._db_name, this._db_type, bodyMessage, this._connection.SymmetricKey, this._keyPair);
                    msg = post.ProcesarEnvio();

                    //Creo el cliente y le envio el mensaje
                    Client c        = new Client();
                    bool   conexion = c.comprobarConexion(Constants.GATEKEEPER);
                    if (conexion)
                    {
                        response = c.StartClient(msg, Constants.GATEKEEPER);

                        //Proceso la respuesta

                        post.ProcesarRespuesta(response);

                        this._select.MessageRequest  = post.MessageRequest;
                        this._select.MessageResponse = post.MessageResponse;

                        this._typeOutPut = Constants.MENSAJE_CONSULTA;
                    }
                    else
                    {
                        this._typeOutPut = Constants.ERROR_CONNECTION;
                    }

                    break;

                case Constants.ERROR_CONNECTION:

                    this._typeOutPut = Constants.ERROR_CONNECTION;

                    break;
                }
            }   //Caso MongoDB
            else if (this._db_type == Constants.MONGODB)
            {
                BodyRespuesta002MongoDB schema = new BodyRespuesta002MongoDB(this._schema.MessageResponse.Body.InnerXml);
                this.Hide();
                this._findDialog = new FindDialog(this._destination, this._db_name, schema);
                this._findDialog.Run();

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

                    break;

                case Constants.MENSAJE_CONSULTA:
                    XmlNode bodyMessage = (XmlNode)this._findDialog.Body;
                    PostBox post        = new PostBox(this._source, this._destination, Constants.MENSAJE_CONSULTA, this._db_name, this._db_type, bodyMessage, this._connection.SymmetricKey, this._keyPair);
                    msg = post.ProcesarEnvio();

                    //Creo el cliente y le envio el mensaje
                    Client c        = new Client();
                    bool   conexion = c.comprobarConexion(Constants.GATEKEEPER);
                    if (conexion)
                    {
                        response = c.StartClient(msg, Constants.GATEKEEPER);

                        //Proceso la respuesta

                        post.ProcesarRespuesta(response);

                        this._select.MessageRequest  = post.MessageRequest;
                        this._select.MessageResponse = post.MessageResponse;

                        this._typeOutPut = Constants.MENSAJE_CONSULTA;
                    }
                    else
                    {
                        this._typeOutPut = Constants.ERROR_CONNECTION;
                    }
                    break;

                case Constants.ERROR_CONNECTION:

                    this._typeOutPut = Constants.ERROR_CONNECTION;

                    break;
                }
            }

            this.Destroy();
        }