示例#1
0
        //重命名
        private void listView1_AfterLabelEdit(object sender, LabelEditEventArgs e)
        {
            if (!string.IsNullOrEmpty(e.Label))
            {
                ListViewItem myItem = lvFiles.Items[e.Item];
                if (myItem != null)
                {
                    ListViewItem existItem = FindItemByName(e.Label);
                    if (existItem != null)
                    {
                        MessageBox.Show("该文件夹名已存在!");
                        e.CancelEdit = true;
                    }
                    else
                    {
                        FSClient   client = new FSClient();
                        FileStatus myFile = myItem.Tag as FileStatus;

                        bool result = client.ReName(myFile.Path, ConfigHelper.HdfsRoot + "/" + CurrentPath + e.Label);
                        if (!result)
                        {
                            e.CancelEdit = true;
                            MessageBox.Show("文件夹重命名失败!");
                        }
                        else
                        {
                            LoadFileStatus(CurrentPath);
                        }
                    }
                }
            }
        }
示例#2
0
        //新建文件夹
        private void btMkdir_Click(object sender, EventArgs e)
        {
            string newName = MakeNewName("新建文件夹");

            ListViewItem li = new ListViewItem();

            li.ImageIndex       = 1;
            li.SubItems[0].Text = newName;
            li.SubItems.Add(DateTime.Now.ToString("yyyy-MM-dd HH:mm"));
            li.SubItems.Add("文件夹");
            li.SubItems.Add("");

            FSClient client = new FSClient();
            bool     result = client.MakeDir(ConfigHelper.HdfsRoot + CurrentPath + newName);

            if (result)
            {
                lvFiles.Items.Add(li);
                SelectItemEidt(newName);
            }
            else
            {
                MessageBox.Show("新建文件夹失败!");
            }
        }
示例#3
0
        //加载列表
        private void LoadFileStatus(string path)
        {
            if (string.IsNullOrEmpty(path))
            {
                path = "/";
            }

            FSClient          client = new FSClient();
            List <FileStatus> myList = client.GetFlolderList(ConfigHelper.HdfsRoot + path);

            if (myList != null)
            {
                //向上按钮
                btUp.Enabled = !(path == "/");

                //下拉选择过的路径
                if (!tbAddress.Items.Contains(path))
                {
                    tbAddress.Items.Add(path);
                }
                //更改显示,触发tbAddress_SelectedIndexChanged
                CurrentPath    = path;
                tbAddress.Text = path;
                //显示数据
                ShowInListView(myList);
            }
        }
示例#4
0
        //上传动作
        private void DoUploadWork(object sender, DoWorkEventArgs e)
        {
            UploadArg fileNames = e.Argument as UploadArg;

            FSClient fs = new FSClient();

            fs.MutUpload(worker, fileNames.FilePathList, ConfigHelper.HdfsRoot + CurrentPath, fileNames.LocalFileRoot);
        }
示例#5
0
        private void DoDownLoadWork(object sender, DoWorkEventArgs e)
        {
            DownloadArg da = e.Argument as DownloadArg;

            FSClient fs = new FSClient();

            fs.MutDownLoad(worker, da.SavePath, da.FileList, da.OutFileType);
            e.Result = "'" + da.SavePath + "',共找到" + da.FileList.Count + "个文件";
        }
示例#6
0
        //根据导入列表下载
        public void DownLoadFile(List <string> pathList, string outFamate)
        {
            FolderBrowserDialog fbd = new FolderBrowserDialog();

            fbd.ShowNewFolderButton = true;
            fbd.Description         = "请选择一个文件夹存放导出的视频文件。";

            //选择保存文件夹
            if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                worker.DoWork             += new DoWorkEventHandler(DoDownLoadWork);
                worker.ProgressChanged    += new ProgressChangedEventHandler(ProgessChanged);
                worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(CompleteDownLoadWork);

                List <FileStatus> fileList = new List <FileStatus>();

                FSClient      fs      = new FSClient();
                List <string> noFound = new List <string>();

                foreach (string filePath in pathList)
                {
                    FileStatus myfile = fs.GetFileStatus(ConfigHelper.HdfsRoot + "/" + CurrentPath + "/" + filePath + outFamate);
                    if (myfile != null)
                    {
                        fileList.Add(myfile);
                    }
                    else
                    {
                        noFound.Add(filePath);
                    }
                }
                string nofoundTitle = string.Format("以下{0}个文件没有找到,请核实:\r\n{1}\r\n===结束===", noFound.Count, string.Join("\r\n", noFound.ToArray()));
                File.WriteAllText(fbd.SelectedPath + "/NoFound.txt", nofoundTitle);

                worker.RunWorkerAsync(new DownloadArg()
                {
                    FileList = fileList, SavePath = fbd.SelectedPath, OutFileType = 0
                });
            }
        }
示例#7
0
 //粘贴
 private void MenuItemPaste_Click(object sender, EventArgs e)
 {
     if (pasterTemp.Count > 0)
     {
         FSClient      client  = new FSClient();
         List <string> noPaste = client.MoveFile(pasterTemp.ToArray(), ConfigHelper.HdfsRoot + CurrentPath);
         if (noPaste.Count > 0)
         {
             try
             {
                 File.WriteAllText("c:/NoPaste.txt", string.Join("\r\n", pasterTemp.ToArray()));
             }
             catch (Exception ee)
             {
                 logger.Error("粘贴错误", ee);
             }
             MessageBox.Show("有" + pasterTemp.Count + "个文件或文件夹没有粘贴成功!请查看c:/NoPaste.txt详细!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         //清除剪切板
         pasterTemp.Clear();
         //重新加载
         LoadFileStatus(CurrentPath);
     }
 }
示例#8
0
 //删除选中
 private void btDelete_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("确定删除选中的文件或文件夹?", "确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
         == System.Windows.Forms.DialogResult.Yes)
     {
         if (lvFiles.SelectedItems.Count > 0)
         {
             foreach (ListViewItem item in lvFiles.SelectedItems)
             {
                 FileStatus myfile = item.Tag as FileStatus;
                 if (myfile != null)
                 {
                     FSClient client = new FSClient();
                     bool     result = client.Delete(myfile.Path, true);
                     string   msg    = string.Format("{2}:{0} 删除{1}", Path.GetFileName(myfile.Path), result ? "成功" : "失败", myfile.Isdir ? "文件夹" : "文件");
                     lbProgressTxt.Text = msg;
                 }
                 Application.DoEvents();
             }
             //重新加载
             LoadFileStatus(CurrentPath);
         }
     }
 }
示例#9
0
        /// <summary>
        /// 根据订单 或右键下载
        /// </summary>
        /// <param name="pathList">key:文件名,value:主题名</param>
        /// <param name="outFamate">导出格式</param>
        /// <param name="fileType">以什么为文件名,0文件名,1主题名,2主题文件夹</param>
        public void DownLoadFile(Dictionary<string, string> pathList, string outFamate, int fileType)
        {
            FolderBrowserDialog fbd = new FolderBrowserDialog();
            fbd.ShowNewFolderButton = true;
            fbd.Description = "请选择一个文件夹存放导出的视频文件。";

            //选择保存文件夹
            if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                worker.DoWork += new DoWorkEventHandler(DoDownLoadWork);
                worker.ProgressChanged += new ProgressChangedEventHandler(ProgessChanged);
                worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(CompleteDownLoadWork);

                List<FileStatus> fileList = new List<FileStatus>();

                FSClient fs = new FSClient();
                List<string> noFound = new List<string>();
                foreach (string filePath in pathList.Keys)
                {
                    FileStatus myfile = fs.GetFileStatus(ConfigHelper.HdfsRoot + "/" + CurrentPath + "/" + filePath + outFamate);
                    if (myfile != null)
                    {
                        myfile.FileName = pathList[filePath] + outFamate;
                        fileList.Add(myfile);
                    }
                    else
                    {
                        noFound.Add(filePath);
                    }
                }
                string nofoundTitle = string.Format("以下{0}个文件没有找到,请核实:\r\n{1}\r\n===结束===", noFound.Count, string.Join("\r\n", noFound.ToArray()));
                File.WriteAllText(fbd.SelectedPath + "/NoFound.txt", nofoundTitle);

                worker.RunWorkerAsync(new DownloadArg() { FileList = fileList, SavePath = fbd.SelectedPath, OutFileType = fileType });
            }
        }
示例#10
0
        //加载列表
        private void LoadFileStatus(string path)
        {
            if (string.IsNullOrEmpty(path))
                path = "/";

            FSClient client=new FSClient();
            List<FileStatus> myList = client.GetFlolderList(ConfigHelper.HdfsRoot + path);
            if (myList != null)
            {
                //向上按钮
                btUp.Enabled = !(path == "/");

                //下拉选择过的路径
                if (!tbAddress.Items.Contains(path))
                {
                    tbAddress.Items.Add(path);
                }
                //更改显示,触发tbAddress_SelectedIndexChanged
                CurrentPath = path;
                tbAddress.Text = path;
                //显示数据
                ShowInListView(myList);
            }
        }
示例#11
0
 //粘贴
 private void MenuItemPaste_Click(object sender, EventArgs e)
 {
     if (pasterTemp.Count > 0)
     {
         FSClient client = new FSClient();
         List<string> noPaste = client.MoveFile(pasterTemp.ToArray(), ConfigHelper.HdfsRoot + CurrentPath);
         if (noPaste.Count > 0)
         {
             try
             {
                 File.WriteAllText("c:/NoPaste.txt", string.Join("\r\n", pasterTemp.ToArray()));
             }
             catch (Exception ee)
             {
                 logger.Error("粘贴错误", ee);
             }
             MessageBox.Show("有" + pasterTemp.Count + "个文件或文件夹没有粘贴成功!请查看c:/NoPaste.txt详细!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         //清除剪切板
         pasterTemp.Clear();
         //重新加载
         LoadFileStatus(CurrentPath);
     }
 }
示例#12
0
        //重命名
        private void listView1_AfterLabelEdit(object sender, LabelEditEventArgs e)
        {
            if (!string.IsNullOrEmpty(e.Label))
            {
                ListViewItem myItem = lvFiles.Items[e.Item];
                if (myItem != null)
                {
                    ListViewItem existItem = FindItemByName(e.Label);
                    if (existItem != null)
                    {
                        MessageBox.Show("该文件夹名已存在!");
                        e.CancelEdit = true;
                    }
                    else
                    {
                        FSClient client = new FSClient();
                        FileStatus myFile=myItem.Tag as FileStatus;

                        bool result = client.ReName(myFile.Path, ConfigHelper.HdfsRoot + "/" + CurrentPath + e.Label);
                        if (!result)
                        {
                            e.CancelEdit = true;
                            MessageBox.Show("文件夹重命名失败!");
                        }
                        else
                        {
                            LoadFileStatus(CurrentPath);
                        }
                    }
                }
            }
        }
示例#13
0
        //上传动作
        private void DoUploadWork(object sender, DoWorkEventArgs e)
        {
            UploadArg fileNames = e.Argument as UploadArg;

            FSClient fs = new FSClient();

            fs.MutUpload(worker, fileNames.FilePathList, ConfigHelper.HdfsRoot + CurrentPath, fileNames.LocalFileRoot);
        }
示例#14
0
        private void DoDownLoadWork(object sender, DoWorkEventArgs e)
        {
            DownloadArg da = e.Argument as DownloadArg;

            FSClient fs = new FSClient();

            fs.MutDownLoad(worker, da.SavePath, da.FileList, da.OutFileType);
            e.Result = "'" + da.SavePath + "',共找到" + da.FileList.Count + "个文件";
        }
示例#15
0
        //新建文件夹
        private void btMkdir_Click(object sender, EventArgs e)
        {
            string newName = MakeNewName("新建文件夹");

            ListViewItem li = new ListViewItem();
            li.ImageIndex = 1;
            li.SubItems[0].Text = newName;
            li.SubItems.Add(DateTime.Now.ToString("yyyy-MM-dd HH:mm"));
            li.SubItems.Add("文件夹");
            li.SubItems.Add("");

            FSClient client = new FSClient();
            bool result = client.MakeDir(ConfigHelper.HdfsRoot + CurrentPath + newName);
            if (result)
            {
                lvFiles.Items.Add(li);
                SelectItemEidt(newName);
            }
            else
            {
                MessageBox.Show("新建文件夹失败!");
            }
        }
示例#16
0
 //删除选中
 private void btDelete_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("确定删除选中的文件或文件夹?", "确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
         == System.Windows.Forms.DialogResult.Yes)
     {
         if (lvFiles.SelectedItems.Count > 0)
         {
             foreach (ListViewItem item in lvFiles.SelectedItems)
             {
                 FileStatus myfile = item.Tag as FileStatus;
                 if (myfile != null)
                 {
                     FSClient client = new FSClient();
                     bool result = client.Delete(myfile.Path, true);
                     string msg = string.Format("{2}:{0} 删除{1}", Path.GetFileName(myfile.Path), result ? "成功" : "失败", myfile.Isdir ? "文件夹" : "文件");
                     lbProgressTxt.Text = msg;
                 }
                 Application.DoEvents();
             }
             //重新加载
             LoadFileStatus(CurrentPath);
         }
     }
 }