Ejemplo n.º 1
0
        private void SendPortInformationsToServer(int partNumber, int sellerId, double price, string info)
        {
            PartInformations partInformations = new PartInformations(partNumber, info, price, sellerId);

            //Send it to Server... :-)
            NetworkComms.SendObject("MessagePartInformations", _Model.ServerIpAddresse, Convert.ToInt32(_Model.ServerPort), partInformations);
        }
Ejemplo n.º 2
0
        private static void IncomingMessagePartInformations(PacketHeader packetHeader, Connection connection, PartInformations incomingObject)
        {
            Console.WriteLine("\nA message was received from " + connection.ToString() + " which said '" + incomingObject.PartDescription + "'.");

            IPEndPoint               remoteIpEndPoint         = connection.ConnectionInfo.RemoteEndPoint as IPEndPoint;
            string                   addresse                 = remoteIpEndPoint.Address.ToString();
            SellerDataBase           sellerDataBase           = new SellerDataBase();
            PartInformationsDataBase partInformationsDataBase = new PartInformationsDataBase();
            StatistikDataBase        statistikDataBase        = new StatistikDataBase();

            //Seller foundedSeller = sellerDataBase.FindOne(x => x.SellerId == incomingObject.SellerId);
            Seller foundedSeller = sellerDataBase.FindOne(x => x.SaleNumbers.Contains(incomingObject.SellerId));


            switch (packetHeader.PacketType)
            {
            case "MessagePartInformations":
                if (foundedSeller != null)
                {
                    NetworkComms.SendObject("MessageSellerIsFound", addresse, remoteIpEndPoint.Port, incomingObject);
                }
                else
                {
                    //TODO Send to Seller Client --> the seller id is not found in die Seller DataBase
                    NetworkComms.SendObject("MessageSellerIdFromPartNotFound", addresse, remoteIpEndPoint.Port, "Die Verkäufernummer wurde nicht gefunden...");
                }
                break;

            case "MessagePartInformationsConfirmed":
                //added only date and the ip address from the sender
                Statistik statistik = new Statistik(DateTime.Now, remoteIpEndPoint.ToString());
                statistikDataBase.Upsert(statistik);

                //added part to the database
                partInformationsDataBase.Upsert(incomingObject);
                break;
            }
        }
Ejemplo n.º 3
0
        private void IncomingMessagePartInformations(PacketHeader packetHeader, Connection connection, PartInformations incomingObject)
        {
            switch (packetHeader.PacketType)
            {
            case "MessageSellerIsFound":
                Invoke(new Action(() =>
                {
                    DialogResult result = MessageBox.Show("Betrag: " + incomingObject.PartPrice.ToString(), "Bitte bestätigen", MessageBoxButtons.OKCancel);

                    if (result == DialogResult.OK)
                    {
                        ListViewItem item = new ListViewItem(incomingObject.PartDescription);
                        item.SubItems.Add(incomingObject.PartNumber.ToString());
                        item.SubItems.Add(incomingObject.PartPrice.ToString() + "€");

                        listView1.Items.Add(item);
                        labelPartPrice.Text = incomingObject.PartPrice.ToString() + "€";
                        _TotalPrice        += incomingObject.PartPrice;

                        labelTotalPrice.Text = _TotalPrice.ToString() + "€";
                        textBox1.Focus();
                        NetworkComms.SendObject("MessagePartInformationsConfirmed", _Model.ServerIpAddresse, Convert.ToInt32(_Model.ServerPort), incomingObject);
                    }
                }));

                break;
            }
        }