Пример #1
0
        private void UploadingResults(TreeNode rootNode)
        {
            if (rootNode == null)
            {
                return;
            }
            if (!Directory.Exists((rootNode.Tag as Dictionary <string, string>)["Path"].ToString().Trim()))
            {
                return;
            }
            System.Windows.Forms.FolderBrowserDialog sOpenFileD = new System.Windows.Forms.FolderBrowserDialog();
            sOpenFileD.RootFolder = Environment.SpecialFolder.Desktop;
            if (sOpenFileD.ShowDialog() == DialogResult.OK)
            {
                if (!sOpenFileD.SelectedPath.ToLower().EndsWith("gdb"))
                {
                    MessageBox.Show("请选择gdb数据库文件夹", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                string strPathName               = sOpenFileD.SelectedPath;
                string strDirtoryName            = strPathName.Substring(strPathName.LastIndexOf("\\") + 1);
                Dictionary <string, string> pDic = new Dictionary <string, string>();
                if (Directory.Exists(strPathName.ToString()))
                {
                    string strPath = (rootNode.Tag as Dictionary <string, string>)["Path"].ToString().Trim() + "\\" + strDirtoryName;
                    if (!ModStringpro.IsSameTreeNode(rootNode, strDirtoryName, strPath))
                    {
                        SysCommon.CProgress vProgress = new SysCommon.CProgress();
                        vProgress.ShowDescription    = true;
                        vProgress.ShowProgressNumber = true;
                        vProgress.TopMost            = true;
                        vProgress.EnableCancel       = true;
                        vProgress.EnableUserCancel(true);
                        vProgress.ShowProgress();
                        Application.DoEvents();
                        vProgress.SetProgress("正在上传GDB数据.....");
                        try
                        {
                            ModStringpro.CopyDirectory(strPathName, (rootNode.Tag as Dictionary <string, string>)["Path"].ToString(), vProgress);
                            vProgress.Close();
                        }
                        catch
                        {
                            pDic.Add(strDirtoryName, "文件上传失败");
                            vProgress.Close();
                            return;
                        }
                        DirectoryInfo fi = new DirectoryInfo(strPath);
                        if (fi.Attributes.ToString().IndexOf("ReadOnly") != -1)
                        {
                            fi.Attributes = FileAttributes.Normal;
                        }
                        TreeNode ResultsNode = new TreeNode(strDirtoryName);  //创建文件类型新节点
                        Dictionary <string, string> pDicTag = new Dictionary <string, string>();
                        pDicTag.Add("Path", strPath);
                        pDicTag.Add("Type", "GDB");
                        ResultsNode.Tag              = pDicTag;
                        ResultsNode.ImageKey         = "PDB";
                        ResultsNode.SelectedImageKey = "PDB";

                        rootNode.Nodes.Add(ResultsNode);
                        rootNode.Expand();
                        pDic.Add(strDirtoryName, "数据上传成功");
                    }
                    else
                    {
                        pDic.Add(strDirtoryName, "目录中已经存在");
                    }
                }

                frmUploadingList pfrmUploadingList = new frmUploadingList(pDic);
                pfrmUploadingList.ShowDialog();
            }
        }
Пример #2
0
        private void UploadingResults(TreeNode rootNode)
        {
            if (rootNode == null)
            {
                return;
            }
            if (!Directory.Exists((rootNode.Tag as Dictionary <string, string>)["Path"].ToString().Trim()))
            {
                return;
            }
            System.Windows.Forms.OpenFileDialog sOpenFileD = new System.Windows.Forms.OpenFileDialog();
            sOpenFileD.CheckFileExists = true;
            sOpenFileD.CheckPathExists = true;
            sOpenFileD.Multiselect     = true;
            sOpenFileD.Title           = "选择文件";
            sOpenFileD.Filter          = "制图文件(*.mxd)|*.mxd|Excel工作薄 (*.xls;*.xlsx)|*.xls;*.xlsx|Word(*.doc;*.docx)|*.doc;*.docx|Text 文档(*.txt)|*.txt|PDF 文档(*.pdf)|*.pdf|图片文件 (*.jpg;*.png;*.bmp)|*.jpg;*.png;*.bmp";
            if (sOpenFileD.ShowDialog() == DialogResult.OK)
            {
                Dictionary <string, string> pDic = new Dictionary <string, string>();
                string[]            strFileName  = sOpenFileD.FileNames;
                SysCommon.CProgress vProgress    = new SysCommon.CProgress();
                vProgress.ShowDescription    = true;
                vProgress.ShowProgressNumber = true;
                vProgress.TopMost            = true;
                vProgress.EnableCancel       = true;
                vProgress.EnableUserCancel(true);
                vProgress.MaxValue       = strFileName.Length;
                vProgress.ProgresssValue = 0;
                vProgress.Step           = 1;
                vProgress.ShowProgress();
                vProgress.SetProgress("正在上传.....");
                for (int j = 0; j < strFileName.Length; j++)
                {
                    vProgress.SetProgress("正在上传:" + Path.GetFileName(strFileName[j].ToString()) + "成果......");
                    vProgress.ProgresssValue = vProgress.ProgresssValue + 1;
                    if (vProgress.UserAskCancel)
                    {
                        vProgress.Close();
                        break;
                    }
                    if (File.Exists(strFileName[j].ToString()))
                    {
                        string strPath = (rootNode.Tag as Dictionary <string, string>)["Path"].ToString().Trim() + "\\" + Path.GetFileName(strFileName[j].ToString());
                        if (!ModStringpro.IsSameTreeNode(rootNode, Path.GetFileName(strPath), strPath))
                        {
                            if (!ModStringpro.copyDirectory(strFileName[j].ToString(), strPath))
                            {
                                pDic.Add(Path.GetFileName(strFileName[j].ToString()), "文件上传失败");
                                continue;
                            }
                            FileInfo fi = new FileInfo(strPath);
                            if (fi.Attributes.ToString().IndexOf("ReadOnly") != -1)
                            {
                                fi.Attributes = FileAttributes.Normal;
                            }
                            TreeNode ResultsNode = new TreeNode(Path.GetFileName(strPath));   //创建文件类型新节点
                            Dictionary <string, string> pDicTag = new Dictionary <string, string>();
                            pDicTag.Add("Path", strPath);
                            pDicTag.Add("Type", "File");
                            ResultsNode.Tag = pDicTag;
                            switch (Path.GetExtension(strPath).ToLower())
                            {
                            case ".mxd":
                                ResultsNode.ImageKey         = "ArcMap";
                                ResultsNode.SelectedImageKey = "ArcMap";
                                break;

                            case ".doc":
                            case ".docx":
                                ResultsNode.ImageKey         = "word";
                                ResultsNode.SelectedImageKey = "word";
                                break;

                            case ".xls":
                            case ".xlsx":
                                ResultsNode.ImageKey         = "excel";
                                ResultsNode.SelectedImageKey = "excel";
                                break;

                            case ".jpg":
                            case ".bmp":
                            case ".png":
                            case ".img":
                            case ".jpeg":
                            case ".gif":
                                ResultsNode.ImageKey         = "images";
                                ResultsNode.SelectedImageKey = "images";
                                break;

                            case ".txt":
                                ResultsNode.ImageKey         = "text";
                                ResultsNode.SelectedImageKey = "text";
                                break;

                            case ".pdf":
                                ResultsNode.ImageKey         = "pdf";
                                ResultsNode.SelectedImageKey = "pdf";
                                break;
                            }

                            rootNode.Nodes.Add(ResultsNode);
                            rootNode.Expand();
                            pDic.Add(Path.GetFileName(strFileName[j].ToString()), "文件上传成功");
                        }
                        else
                        {
                            pDic.Add(Path.GetFileName(strFileName[j].ToString()), "目录中已经存在");
                        }
                    }
                }
                vProgress.Close();
                Application.DoEvents();
                frmUploadingList pfrmUploadingList = new frmUploadingList(pDic);
                pfrmUploadingList.ShowDialog();
            }
        }