private void GetFiles() { ServicePointManager.ServerCertificateValidationCallback += new RemoteCertificateValidationCallback(ValidateRemoteCertificate); JsonServiceClient client = new JsonServiceClient(CLOUD_SERVICE_ENDPOINT); string GetUrl = string.Format("/getUserFileSystemInfo/{0}/{1}", ConnectedUser.ClientId, ConnectedUser.Password); try { FileList = client.Get <UserFileSystemMetaData>(GetUrl); } catch (Exception ex) { MessageBox.Show(ex.Message); } List <StringValue> List_File = new List <StringValue>(); foreach (FileMetaData file in FileList.fileMDList) { if (file.markedForDeletion == false) { List_File.Add(new StringValue(file.filepath)); string[] F_name = file.filepath.Split('_'); string Val_Param = string.Format(F_name[F_name.Length - 1] + System.Environment.NewLine + "Owner: " + file.owner + " Size: " + file.filesize); TreeNode.AddNodeToTree(File_Node, file.filepath, Val_Param); } else { if (FileList.fileMDList.Contains(file)) { ClientFileSystem.filemap.Remove(file.filepath); string[] F_name = file.filepath.Split('_'); TreeNode.deleteNodeAndGetAllAffected(F_name[F_name.Length - 1], File_Node); } } } Disp_List = TreeNode.fetcAllChildren(this.DirectoryTextBox.Text, File_Node); this.Manage_RecentList(File_Node); FileList_dataGridView.DataSource = Disp_List; if (Disp_List != null) { FileList_dataGridView.Font = new Font("Segoe UI", 10); FileList_dataGridView.Columns["nodekey"].Visible = false; FileList_dataGridView.Columns["nodePath"].Visible = false; } DataGridViewColumn blank = new DataGridViewColumn(); blank.Width = 4000; blank.CellTemplate = new DataGridViewTextBoxCell(); FileList_dataGridView.Columns.Add(blank); DataGridViewImageColumn btnDownload = new DataGridViewImageColumn(); btnDownload.Width = 35; Image downloadImg = Image.FromFile("C:\\Users\\Karthikeya\\Desktop\\file_download.png"); btnDownload.Image = downloadImg; FileList_dataGridView.Columns.Add(btnDownload); DataGridViewImageColumn btnShare = new DataGridViewImageColumn(); btnShare.Width = 35; Image ShareImg = Image.FromFile("C:\\Users\\Karthikeya\\Desktop\\file_share.png"); btnShare.Image = ShareImg; FileList_dataGridView.Columns.Add(btnShare); DataGridViewImageColumn btnDelete = new DataGridViewImageColumn(); btnDelete.Width = 35; Image DeleteImg = Image.FromFile("C:\\Users\\Karthikeya\\Desktop\\del.png"); btnDelete.Image = DeleteImg; FileList_dataGridView.Columns.Add(btnDelete); // for share with you list foreach (SharedFile file in FileList.sharedFileList) { string[] F = file.filename.Split('_'); string ShareVal = string.Format(F[F.Length - 1] + System.Environment.NewLine + "Owner: " + file.owner); Share_List.Add(new TreeNode(file.filename, ShareVal, file.filename)); // shared with me } SharedWithDataList.DataSource = Share_List; if (Share_List != null) { SharedWithDataList.Font = new Font("Segoe UI", 10); SharedWithDataList.Columns["nodekey"].Visible = false; SharedWithDataList.Columns["nodePath"].Visible = false; } DataGridViewImageColumn btnSDownload = new DataGridViewImageColumn(); btnSDownload.Width = 35; btnSDownload.Image = downloadImg; SharedWithDataList.Columns.Add(btnSDownload); // for shared by you list foreach (FileMetaData file in FileList.fileMDList) { if (file.sharedwithclients.Count() > 0) { string[] F = file.filepath.Split('_'); string ShareVal = string.Format(F[F.Length - 1] + System.Environment.NewLine + "You shared with: "); foreach (string id in file.sharedwithclients) { ShareVal = string.Format(ShareVal + id + " "); } SharedBy_List.Add(new TreeNode(file.filepath, ShareVal, file.filepath)); } } SharedByDataList.DataSource = SharedBy_List; if (SharedBy_List != null) { SharedByDataList.Font = new Font("Segoe UI", 10); SharedByDataList.Columns["nodekey"].Visible = false; SharedByDataList.Columns["nodePath"].Visible = false; } DataGridViewImageColumn btnBDownload = new DataGridViewImageColumn(); btnBDownload.Width = 35; btnBDownload.Image = downloadImg; SharedByDataList.Columns.Add(btnBDownload); DataGridViewImageColumn btnUnBShare = new DataGridViewImageColumn(); btnUnBShare.Width = 35; Image UnShareImg = Image.FromFile("C:\\Users\\Karthikeya\\Desktop\\file_Unshare.png"); btnUnBShare.Image = UnShareImg; SharedByDataList.Columns.Add(btnUnBShare); SharedByDataList.AutoResizeColumns(); FileList_dataGridView.AutoResizeColumns(); SharedWithDataList.AutoResizeColumns(); SharedByDataList.AutoResizeRows(); FileList_dataGridView.AutoResizeRows(); SharedWithDataList.AutoResizeRows(); this.UsageProgressBar.Value = (int)FileList.userMetaData.totalFileSystemSizeBytes; int per = this.UsageProgressBar.Value / 100000000; this.UsageTextBox.Text = string.Format(per + " of 10 GB"); }
private void UpdateFileList() { ServicePointManager.ServerCertificateValidationCallback += new RemoteCertificateValidationCallback(ValidateRemoteCertificate); JsonServiceClient client = new JsonServiceClient(CLOUD_SERVICE_ENDPOINT); List <TreeNode> newShared = new List <TreeNode>(); List <TreeNode> newSharedBy = new List <TreeNode>(); string GetUrl = string.Format("/getUserFileSystemInfo/{0}/{1}", ConnectedUser.ClientId, ConnectedUser.Password); try { FileList = client.Get <UserFileSystemMetaData>(GetUrl); } catch (Exception ex) { MessageBox.Show(ex.Message); } List <StringValue> List_File = new List <StringValue>(); foreach (FileMetaData file in FileList.fileMDList) { if (file.markedForDeletion == false) { List_File.Add(new StringValue(file.filepath)); string[] F_name = file.filepath.Split('_'); string Val_Param = string.Format(F_name[F_name.Length - 1] + System.Environment.NewLine + "Owner: " + file.owner + " Size: " + file.filesize); TreeNode.AddNodeToTree(File_Node, file.filepath, Val_Param); } else { if (FileList.fileMDList.Contains(file)) { ClientFileSystem.filemap.Remove(file.filepath); string[] F_name = file.filepath.Split('_'); TreeNode.deleteNodeAndGetAllAffected(F_name[F_name.Length - 1], File_Node); } } } Disp_List = TreeNode.fetcAllChildren(this.DirectoryTextBox.Text, File_Node); this.Manage_RecentList(File_Node); foreach (SharedFile file in FileList.sharedFileList) { string[] F = file.filename.Split('_'); string ShareVal = string.Format(F[F.Length - 1] + System.Environment.NewLine + "Owner: " + file.owner); newShared.Add(new TreeNode(file.filename, ShareVal, file.filename)); // shared with me } Share_List = newShared; foreach (FileMetaData file in FileList.fileMDList) { if (file.sharedwithclients.Count() > 0) { string[] F = file.filepath.Split('_'); string ShareVal = string.Format(F[F.Length - 1] + System.Environment.NewLine + "You shared with: "); foreach (string id in file.sharedwithclients) { ShareVal = string.Format(ShareVal + id + " "); } newSharedBy.Add(new TreeNode(file.filepath, ShareVal, file.filepath)); } } SharedBy_List = newSharedBy; SharedByDataList.DataSource = SharedBy_List; FileList_dataGridView.DataSource = Disp_List; SharedWithDataList.DataSource = Share_List; SharedByDataList.AutoResizeColumns(); FileList_dataGridView.AutoResizeColumns(); SharedWithDataList.AutoResizeColumns(); SharedByDataList.AutoResizeRows(); FileList_dataGridView.AutoResizeRows(); SharedWithDataList.AutoResizeRows(); this.UsageProgressBar.Value = (int)FileList.userMetaData.totalFileSystemSizeBytes; int per = this.UsageProgressBar.Value / 100000000; this.UsageTextBox.Text = string.Format(per + " of 10 GB"); }