Example #1
0
        protected void btnFind_Click_1(object sender, System.EventArgs e)
        {
            Cursor = Cursors.WaitCursor;
            Pinger ping = new Pinger();

            if (txtSearch.Text != "")
            {
                lstResults.ListItems.Clear();
                P2PService    p  = new P2PService();
                OptionsLoader ol = new OptionsLoader();
                p.Url = ol.ServiceUrl;
                PeerFile[] FoundFiles = p.FindPeersWithFiles(txtSearch.Text);
                this.LogOnToService();                 // Update the file info
                int    PingTime  = 0;
                string pingEntry = null;
                if (null != FoundFiles)
                {
                    foreach (PeerFile file in FoundFiles)
                    {
                        PingTime = ping.GetPingTime(file.IpAddress);
                        if (PingTime <= 10)
                        {
                            pingEntry = "< 10 ms";
                        }
                        else
                        {
                            pingEntry = Convert.ToString(PingTime) + " ms";
                        }
                        string[] Entry = new string[5];
                        Entry[0] = file.Path;
                        Entry[1] = file.Size;
                        Entry[2] = file.Connection;
                        Entry[3] = file.IpAddress;
                        Entry[4] = pingEntry;
                        lstResults.InsertItem(0, file.Name, 0, Entry);
                    }
                }
                else                 //prepare default entry
                {
                    string[] Entry = new string[5];
                    Entry[0] = "n/a";
                    Entry[1] = "n/a";
                    Entry[2] = "n/a";
                    Entry[3] = "n/a";
                    Entry[4] = "n/a";
                    lstResults.InsertItem(0, "No Results Found", 0, Entry);
                }
            }
            Cursor = Cursors.Default;
        }
Example #2
0
        protected void btnFind_Click_1(object sender, System.EventArgs e)
        {
            Cursor = Cursors.WaitCursor;
            Pinger ping = new Pinger();

            if( txtSearch.Text != "")
            {
                lstResults.ListItems.Clear();
                P2PService p = new P2PService();
                OptionsLoader ol = new OptionsLoader();
                p.Url = ol.ServiceUrl;
                PeerFile[] FoundFiles = p.FindPeersWithFiles(txtSearch.Text);
                this.LogOnToService(); // Update the file info
                int PingTime = 0;
                string pingEntry = null;
                if (null != FoundFiles)
                {
                    foreach (PeerFile file in FoundFiles)
                    {
                        PingTime = ping.GetPingTime(file.IpAddress);
                        if(PingTime <=10)
                        {
                            pingEntry = "< 10 ms";
                        }
                        else
                        {
                            pingEntry = Convert.ToString(PingTime) + " ms";
                        }
                        string[] Entry = new string[5];
                        Entry[0] = file.Path;
                        Entry[1] = file.Size;
                        Entry[2] = file.Connection;
                        Entry[3] = file.IpAddress;
                        Entry[4] = pingEntry;
                        lstResults.InsertItem(0,file.Name,0,Entry);
                    }
                }
                else //prepare default entry
                {
                    string[] Entry = new string[5];
                    Entry[0] = "n/a";
                    Entry[1] = "n/a";
                    Entry[2] = "n/a";
                    Entry[3] = "n/a";
                    Entry[4] = "n/a";
                    lstResults.InsertItem(0,"No Results Found",0,Entry);
                }
            }
            Cursor = Cursors.Default;
        }