Пример #1
0
        private void requestFiles()
        {
            // request file

            string fileName = requestFileTxtBox.Text;

            UserXML.File        file        = new UserXML.File(fileName);
            List <UserXML.File> listOfFiles = new List <UserXML.File>();

            listOfFiles.Add(file);
            UserXML userXML = new UserXML(User.Username, User.Password, listOfFiles);

            MediationServer.WebService ws = new MediationServer.WebService();

            string respond = ws.RequestFiles(userXML.getXMLFormatToString());

            if (respond != null)
            {
                UserXML listOfFilesXML = new UserXML(respond);

                listOfFiles = listOfFilesXML.getFilesListWithNumberOfActiveUsers();

                listView.ItemsSource = listOfFiles;
            }
            else
            {
                MessageBox.Show("File not exists");
                listView.ItemsSource = null;
                listView.Items.Clear();
            }
        }
Пример #2
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            user.Password = txtPassword.Password;

            if (user.checkUserValidation() && !string.IsNullOrEmpty(folderDlg.SelectedPath))
            {
                UserXML userXML = new UserXML(user.Username, user.Password, user.IP, user.PORT, filesList);

                MediationServer.WebService ws = new MediationServer.WebService();

                if (ws.SignIn(userXML.getXMLFormatToString()))
                {
                    Torrent torrentWindow = new Torrent(user);
                    torrentWindow.Show();
                    this.Close();
                }
                else
                {
                    System.Windows.MessageBox.Show(WRONG_SIGNIN);
                }
            }
            else
            {
                System.Windows.MessageBox.Show(EMPTY_FIELDS);
            }
        }
Пример #3
0
        private void signOut(bool isClosed)
        {
            MediationServer.WebService ws = new MediationServer.WebService();

            UserXML userXML = new UserXML(User.Username, User.Password);

            if (ws.SignOut(userXML.getXMLFormatToString()))
            {
                if (!isClosed)
                {
                    Configuration mainWindow = new Configuration();
                    mainWindow.Show();
                    this.Close();
                }
            }
        }
Пример #4
0
        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            // download
            if (listView.HasItems)
            {
                UserXML.File file = (UserXML.File)listView.SelectedItem;

                if (file != null)
                {
                    SocketListener.FileNameToRequest = file.FileName;

                    MediationServer.WebService ws = new MediationServer.WebService();

                    string targetPeerUsername = ws.GetNameByFilename(file.FileName);

                    peer.Channel.BroadcastPeerToConnect(User.Username, targetPeerUsername);
                }
            }
            else
            {
                MessageBox.Show("Please select an item");
            }
        }