Exemplo n.º 1
0
        private void Search_Click(object sender, RoutedEventArgs e)
        {
            string fileName = Search_TextBox.Text.ToString();
            string listData;

            this.index    = -1;
            this.fileSize = 0;
            try
            {
                if (fileName != null || fileName != "")
                {
                    files     = JsonConvert.DeserializeObject <List <DAL.File> >(server.getFiles());
                    listData  = server.fileRequest(userData, fileName);
                    fileUsers = JsonConvert.DeserializeObject <List <DAL.User> >(listData);
                    if (fileUsers.Count == 0)
                    {
                        MessageBox.Show("No such file.");
                    }
                    else
                    {
                        DAL.User temp = new DAL.User();
                        foreach (var u in fileUsers)
                        {
                            if (config.name == u.name)
                            {
                                temp = u;
                            }
                        }
                        fileUsers.Remove(temp);
                        Search_DataGrid.ItemsSource = fileUsers;
                        foreach (var file in this.files)
                        {
                            if (file != null)
                            {
                                if (file.name == fileName)
                                {
                                    fileSize = file.size;
                                }
                            }
                        }
                        this.calculateSize(fileSize);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                MessageBox.Show("File not found.");
            }
        }