コード例 #1
0
ファイル: kurier.cs プロジェクト: herbalrp/TSST-NCC
        public kurier(String IP, int port, Menadzer menadzer)
        {
            this.IP = IP;
            this.port = port;
            this.menadzer = menadzer;
            try
            {
                client = new TcpClient();
                client.Connect(IPAddress.Parse(IP), port);


                NetworkStream stream = client.GetStream();
                writer = new StreamWriter(stream);
                reader = new StreamReader(stream);

                writer.WriteLine("JESTEM#"+menadzer.id+"#"+getIPAdress());
                writer.Flush();
                ThreadStart r = new ThreadStart(run);
                Thread newThread = new Thread(r);
                newThread.Start();
            }catch(Exception)
            {
                string data = DateTime.Now.ToString();
                menadzer.dodaj_informacje_o_bledzie("błąd#" + data + "#nie można połączyć się z kablami");
            }

        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: herbalrp/TSST-NCC
        private void button5_Click(object sender, EventArgs e)
        {
            string path = comboBox2.SelectedItem + ".txt";
            
            string[] lines = System.IO.File.ReadAllLines(@path);
            int port = int.Parse(lines[1]);
            string id = lines[3];
            string id_CC = lines[5];
            string domena = lines[7];
            Dictionary<string, string> slownik = new Dictionary<string, string>();
            for(int i=9; i<lines.Length;i++)
            {
                string[] split = lines[i].Split(new char[] { '#' });
                slownik.Add(split[0], split[1]);
            }

             path = comboBox2.SelectedItem + "_elementy.txt";

            lines = System.IO.File.ReadAllLines(@path);
            List<String> elementy = new List<string>();
            foreach(string s in lines)
            {
                elementy.Add(s);
            }
            menadzer = new Menadzer(port, id, domena, id_CC, comboBox2.SelectedItem.ToString(), slownik, this, elementy);
           
        }