Ejemplo n.º 1
0
        private void load_search_treeView(string tenFileCanTim)
        {
            string   mindTypeQ = "name contains " + "'" + tenFileCanTim + "'";
            TreeNode root;

            try
            {
                api.GoogleDriveAPI gg_api = new api.GoogleDriveAPI();
                IList <Google.Apis.Drive.v3.Data.File> contents = gg_api.Search_Somethings(name_token, mindTypeQ);

                trvFolder.Nodes.Clear();

                root = new TreeNode("Kết Quả Cho \"" + tenFileCanTim + "\"");

                if (contents != null && contents.Count > 0)
                {
                    foreach (var content in contents)
                    {
                        TreeNode tn = new TreeNode(content.Name);
                        tn.Tag = content.Id;

                        root.Nodes.Add(tn);
                    }
                }
            }
            catch
            {
                MessageBox.Show("File Not Found", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            trvFolder.Nodes.Add(root);
            trvFolder.ExpandAll();
        }
Ejemplo n.º 2
0
        private void load_files()
        {
            api.GoogleDriveAPI gg_api = new api.GoogleDriveAPI();
            string             mindType_GetAllFiles      = "mimeType != 'application/vnd.google-apps.folder'";
            IList <Google.Apis.Drive.v3.Data.File> files = gg_api.Search_Somethings(name_token, mindType_GetAllFiles);

            TreeNode rootFile = new TreeNode("Tất Cả File");

            rootFile.NodeFont = new Font(new FontFamily("Consolas"), 10f, FontStyle.Bold);

            if (files != null && files.Count > 0)
            {
                foreach (var folder in files)
                {
                    TreeNode tn = new TreeNode(folder.Name);
                    tn.Tag = folder.Id;
                    rootFile.Nodes.Add(tn);
                }
            }

            trvFolder.Invoke(new MethodInvoker(delegate()
            {
                trvFolder.Nodes.Add(rootFile);
                trvFolder.ExpandAll();
            }));
        }
Ejemplo n.º 3
0
        private void btnUpload_Click(object sender, EventArgs e)
        {
            if (txtPathUpload.Text.Trim().Equals(""))
            {
                MessageBox.Show("BẠN CHƯA CHỌN FILE", "FILE NOT FOUND", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            string File_Name = Get_FileName_FromPath(txtPathUpload.Text);

            DialogResult dr = MessageBox.Show("BẠN CÓ MUỐN UPDATE VỚI TÊN: " + File_Name, "CẢNH BÁO", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (dr == DialogResult.No)
            {
                return;
            }

            api.GoogleDriveAPI gg_api = new api.GoogleDriveAPI();

            Thread thread_lazy = new Thread(new ThreadStart(Open_WaitingFrm));

            thread_lazy.Start();

            gg_api.Upload_to_Root(File_Name, txtPathUpload.Text, name_token);

            load_TreeView();

            frmWait.Invoke(new MethodInvoker(delegate()
            {
                frmWait.Close();
            }));

            MessageBox.Show("UPLOAD THÀNH CÔNG", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Ejemplo n.º 4
0
        private void setPathSave()
        {
            api.GoogleDriveAPI gg_api         = new api.GoogleDriveAPI();
            SaveFileDialog     saveFileDialog = new SaveFileDialog();

            saveFileDialog.FileName += gg_api.getFileName_ID(IdFile, name_token);

            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                txtPathDownload.Text = saveFileDialog.FileName;
            }
        }
Ejemplo n.º 5
0
        private void load_folders()
        {
            api.GoogleDriveAPI gg_api = new api.GoogleDriveAPI();
            string             mindType_GetAllFolders      = "mimeType = 'application/vnd.google-apps.folder'";
            IList <Google.Apis.Drive.v3.Data.File> folders = gg_api.Search_Somethings(name_token, mindType_GetAllFolders);

            TreeNode rootFolder = new TreeNode("Tất Cả Thư Mục");

            rootFolder.NodeFont = new Font(new FontFamily("Consolas"), 10f, FontStyle.Bold);

            if (folders != null && folders.Count > 0)
            {
                foreach (var folder in folders)
                {
                    TreeNode tn = new TreeNode(folder.Name);
                    tn.Tag = folder.Id;
                    rootFolder.Nodes.Add(tn);
                }
            }

            trvFolder.Nodes.Add(rootFolder);
        }
Ejemplo n.º 6
0
        private void trvFolder_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if (trvFolder.SelectedNode.Level > 0)
            {
                try
                {
                    api.GoogleDriveAPI gg_api     = new api.GoogleDriveAPI();
                    string             mindType_Q = "'" + trvFolder.SelectedNode.Tag + "'" + " in parents";

                    txtFileID_Down.Text   = trvFolder.SelectedNode.Tag.ToString();
                    txtFileID_Delete.Text = trvFolder.SelectedNode.Tag.ToString();

                    IList <Google.Apis.Drive.v3.Data.File> contents = gg_api.Search_Somethings(name_token, mindType_Q);

                    trvFolder.SelectedNode.Nodes.Clear();

                    if (contents != null && contents.Count > 0)
                    {
                        foreach (var content in contents)
                        {
                            TreeNode tn = new TreeNode(content.Name);
                            tn.Tag = content.Id;

                            trvFolder.SelectedNode.Nodes.Add(tn);
                        }
                    }
                }
                catch
                {
                    MessageBox.Show("File Not Found", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                trvFolder.ExpandAll();
            }
        }
Ejemplo n.º 7
0
 private int download_File()
 {
     api.GoogleDriveAPI gg_api = new api.GoogleDriveAPI();
     return(gg_api.DownloadGoogleFile(IdFile, getPathSave(txtPathDownload.Text), name_token));
 }