Exemplo n.º 1
0
        bool Connect()
        {
            car = new TcpClient();
            IPAddress Adresse;

            if (!IPAddress.TryParse(textBox1.Text, out Adresse))
            {
                MessageBox.Show("Keine gültige IP-Adresse!");
                return(false);
            }
            String URL = "http://" + Adresse.ToString() + ":8090/test.mjpg";

            try { car.Connect(Adresse, 9001); }
            catch (Exception e) { MessageBox.Show("Verbindungsfehler Oo" + e.Message); return(false); }
            Stream clst = car.GetStream();

            biRea = new BinaryReader(clst);
            biWri = new BinaryWriter(clst);
            int Wert = biRea.ReadInt16();

            biWri.Write((Int16)Math.Floor((decimal)Wert / 2 + 2));
            if (biRea.ReadBoolean())
            {
                //Annehmen der Verbindung. Bei Verdacht (whyever XD) ein false senden!
                biWri.Write(true);
                lbStatus.Text         = "Verbindung hergestellt. Viel Spaß! :D";
                ImgGetter             = new MjpegProcessor.MjpegDecoder();
                ImgGetter.FrameReady += mjpeg_FrameReady;
                ImgGetter.ParseStream(new Uri("http://" + textBox1.Text + ":8090/test.mjpg"));
                return(true);
            }
            return(false);
        }
Exemplo n.º 2
0
        private void AfficherCoordonneClient()
        {
            //vérifier si l'Id saisie existe
            int  id         = 0;
            bool idClientOk = false;

            while (!idClientOk)
            {
                AfficherListeClient();
                id         = Input.Read <int>("Id du client :");
                idClientOk = _listeClient.Where(a => a.Id == id).Any();
            }

            //recuperer le client selon Id saisie et ses coordonnées
            var coordonneesClient = AppGrandHotel.Instance.Contexte.GetCoordonneesClient().Where(p => p.Id == id).FirstOrDefault();

            _adresse = coordonneesClient.Adresse;
            var telephones = coordonneesClient.Telephones;
            var emails     = coordonneesClient.Emails;

            Console.WriteLine("Adresse: {0}", _adresse.ToString());
            ConsoleTable.From(telephones, "Telephones").Display("Telephones");
            ConsoleTable.From(emails, "Emails").Display("Emails");
        }
Exemplo n.º 3
0
 public static void Insert(Adresse e, ParkingContext context)
 {
     using (WebClient wc = new WebClient())
     {
         try
         {
             string           querypark = "https://maps.googleapis.com/maps/api/geocode/json?address=" + e.ToString() + "&key=AIzaSyCyoqbqJVd_MtZRT_0DmYmznxxJWRfMjQI";
             var              json2     = wc.DownloadString(querypark);
             RootObjectGoogle item      = JsonConvert.DeserializeObject <RootObjectGoogle>(json2);
             if (item.results.Count != 0)
             {
                 e.lat = item.results.FirstOrDefault().geometry.location.lat;
                 e.lng = item.results.FirstOrDefault().geometry.location.lng;
             }
         }
         catch (Exception)
         {
             context.Adresses.Add(e); //meme si il y a une erreur on ajoute l'adresse sans latitude ni longitude
             throw;
         }
         context.Adresses.Add(e);
     }
 }