示例#1
0
 private void updateProgress(double received)
 {
     if (received == -1)
     {
         Download_ProgressBar.Value = 100;
         ServerService.MediationServerClient server = new ServerService.MediationServerClient();
         user.loadFiles(uploadPath);
         Files_DataGrid.ItemsSource = user.userFiles;
         server.SignOut(JsonConvert.SerializeObject(user));
         server.SignIn(JsonConvert.SerializeObject(user));
     }
     else
     {
         Download_ProgressBar.Value = (double)(received / downloadFileSize) * 100;
     }
 }
示例#2
0
        private void SignIn_Btn_Click(object sender, RoutedEventArgs e)
        {
            ServerService.MediationServerClient client = new ServerService.MediationServerClient();
            User   user     = new User(configData);
            string userData = JsonConvert.SerializeObject(user, Formatting.Indented);

            if (client.SignIn(userData))
            {
                //MessageBox.Show("Hello " + user.name);
            }
            else
            {
                MessageBox.Show("Error in sign in.");
            }

            FileManagerWindow fileManagerWindow = new FileManagerWindow(user, configData.UploadPath, configData.DownloadPath);

            fileManagerWindow.ShowDialog();
        }
示例#3
0
        private void Search_Btn_Click(object sender, RoutedEventArgs e)
        {
            selectedIndex    = -1;
            downloadFileSize = 0;

            ServerService.MediationServerClient server = new ServerService.MediationServerClient();

            string fileName = Search_TextBox.Text.ToString();
            string listData;

            try
            {
                if (fileName.Length > 0)
                {
                    listData     = server.RequestFiles(fileName);
                    userWithFile = JsonConvert.DeserializeObject <List <User> >(listData);
                    if (userWithFile.Count > 0)
                    {
                        userWithFile.RemoveAll(u => u.ip == this.user.ip);
                        Search_DataGrid.ItemsSource = userWithFile;

                        long size;
                        userWithFile.ElementAt <User>(0).userFiles.TryGetValue(fileName, out size);

                        if (size > 1000)
                        {
                            SizeNum_Lable.Content = size / 1000 + " Kb";
                        }
                        else if (size > 1000000)
                        {
                            SizeNum_Lable.Content = size / 1000000 + " Mb";
                        }
                        else
                        {
                            SizeNum_Lable.Content = size + " b";
                        }
                    }
                }
            }
            catch { }
        }
示例#4
0
 protected override void OnClosed(EventArgs e)
 {
     ServerService.MediationServerClient server = new ServerService.MediationServerClient();
     server.SignOut(JsonConvert.SerializeObject(this.user));
     base.OnClosed(e);
 }