示例#1
0
        /// <summary>
        /// 异步拷贝到本地sourcefile目录下
        /// </summary>
        public void AsnycCopy()
        {
            DriveInfo[] drives = DriveInfo.GetDrives();
            string      hd     = sourcePath.Substring(0, 1);
            string      hdtype = "";

            foreach (DriveInfo dri in drives)
            {
                string _name = dri.Name.Substring(0, 1);
                if (_name == hd)
                {
                    hdtype = dri.DriveType.ToString();
                    break;
                }
            }
            string dir      = Application.StartupPath + "\\sourcefile\\";
            string filename = sourceFilename;

            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }
            string pathSrc = sourcePath + "\\" + sourceFilename;
            string ext     = Path.GetExtension(pathSrc);

            //if (ext == ".ppt" || ext == ".pptx" || ext == ".doc" || ext == ".docx" || ext == ".jpg" || ext == ".jpeg" || ext == ".bmp" || ext == ".png" || ext == ".gif")
            //{
            //    FileOper.CopyFile(pathSrc, dir + filename, true);
            //}
            EService.selectFile(sourceFilename, pathSrc, false);

            if (filename.IndexOf("ppt") > 0 || filename.IndexOf("PPT") > 0)
            {
                bExporting = true;
                MyPPT.exportImg(sourcePath + "\\" + sourceFilename);


                bExporting = false;
            }
        }
示例#2
0
        private void ReadFilePath(string diskPath, int field, bool bNotify = false)
        {
            currentdir = diskPath;
            if (diskPath.LastIndexOf("\\") == diskPath.Length - 1)
            {
                diskPath = diskPath.Substring(0, diskPath.Length - 1);
            }
            ArrayList autoAddedFileList = new ArrayList();
            ArrayList al = Disk.MergrObj(diskPath.Replace("\r\n", ""));

            btnList = new ArrayList();
            if (field == 1)
            {
                Button backBtn = CreateBackBtn();
                btnList.Add(backBtn);
            }

            bool bAutoSync = false;

            string[]  szType    = { "ppt", "pptx", "doc", "docx", "pdf", "mp3", "wma", "wmv", "mp4", "swf" };
            ArrayList filelist0 = Disk.getFilelist(diskPath.Replace("\r\n", ""), szType);

            if (filelist0.Count <= 5)
            {
                bAutoSync = true;
            }
            else
            {
                Httpd.pushFilelistTips("U盘课件文件超过5个!\r\n请手动选择课件文件,并使用鼠标\"右键\"选择\"添加到如e小助手\"");
            }
            bAutoSync = false;

            for (int k = 0; k < al.Count; k++)
            {
                string value = al[k].ToString();
                Button btn   = new Button();
                btn.Size      = new System.Drawing.Size(70, 70);
                btn.BackColor = System.Drawing.Color.FromArgb(255, 255, 255);
                btn.FlatStyle = FlatStyle.Flat;
                btn.FlatAppearance.BorderColor        = System.Drawing.Color.FromArgb(153, 209, 255);
                btn.FlatAppearance.BorderSize         = 0;
                btn.FlatAppearance.MouseDownBackColor = System.Drawing.Color.FromArgb(204, 232, 255);
                btn.FlatAppearance.MouseOverBackColor = System.Drawing.Color.FromArgb(229, 243, 255);
                btn.TextAlign  = ContentAlignment.BottomCenter;
                btn.MouseMove += new System.Windows.Forms.MouseEventHandler(btn_MouseMove);
                btn.MouseDown += new System.Windows.Forms.MouseEventHandler(btn_MouseDown);
                btn.AllowDrop  = true;
                if (value.Split('|')[0].ToString() == "0")
                {
                    btn.BackgroundImage = global::RueHelper.Properties.Resources.wenjianjia;
                    btn.Name            = "0|" + diskPath + "|" + value.Split('|')[2].ToString();
                }
                else
                {
                    string filename = value.Split('|')[2].ToString();
                    string extName  = filename.Substring(filename.LastIndexOf(".") + 1, (filename.Length - filename.LastIndexOf(".") - 1));
                    btn.BackgroundImage = FileICON(extName);//load
                    if (btn.BackgroundImage == null)
                    {
                        continue;
                    }
                    btn.Name = "1|" + diskPath + "|" + value.Split('|')[2].ToString();

                    if (filename.StartsWith("~$"))
                    {
                        continue;
                    }

                    if (field == 0 && bAutoSync)
                    {
                        //仅仅在插上U盘时自动加载
                        string _filepath = diskPath + "\\" + filename;
                        autoAddedFileList.Add(_filepath);
                        continue;
                    }
                }
                this.label6.Text = diskPath + "\\" + value.Split('|')[2].ToString();
                btn.Text         = value.Split('|')[1].ToString();
                string tooltipStr = value.Split('|')[2].ToString() + "\r\n类型:" + value.Split('|')[3].ToString() + "\r\n修改日期:" + value.Split('|')[5].ToString() + "\r\n大小:" + value.Split('|')[4].ToString() + "";
                this.toolTip1.SetToolTip(btn, tooltipStr);
                addButtonlist_Left(btn);
            }

            try
            {
                for (int i = 0; i < autoAddedFileList.Count; i++)
                {
                    string _path = (string)autoAddedFileList.ToArray()[i];
                    string _name = Path.GetFileName(_path);
                    EService.selectFile(_name, _path);
                    this.AddFile(_path, false);
                }
            }catch (Exception e1) {
                ;//
            }

            Thread thread = new Thread(delegate()
            {
                if (autoAddedFileList.Count == 0)
                {
                    return;
                }

                bExporting = true;

                try
                {
                    string title = Global.getSchoolname() + " - " + Global.getClassname() + "";
                    if (bNotify)
                    {
                        if (fNotify == null)
                        {
                            fNotify = new FormNotify(title, "\r\n 课件导入中,请稍后!", 30);
                        }
                        this.Invoke(new System.EventHandler(this.showForm), new object[] { fNotify, null });
                        fNotify.InvokeUpdate(title, "\r\n 课件导入中,请稍后!");
                    }

                    for (int i = 0; i < autoAddedFileList.Count; i++)
                    {
                        string filepathSrc = (string)autoAddedFileList.ToArray()[i];
                        Log.Info("copy ppt......0:" + filepathSrc);
                        string _fname = Path.GetFileName(filepathSrc);
                        if (_fname.IndexOf("ppt") > 0 || _fname.IndexOf("PPT") > 0)
                        {
                            Log.Info("copy ppt......3");
                            MyPPT.exportImg(filepathSrc);
                            Log.Info("copy ppt......4");
                        }
                        Log.Info("copy ppt......5");
                    }
                    bExporting = false;
                    if (bNotify && fNotify != null)
                    {
                        fNotify.InvokeUpdate(title, "\r\n 课件导入完毕!");
                        Thread.Sleep(5000);
                        fNotify.InvokeClose();
                        fNotify = null;
                    }
                }catch (Exception e1) {
                    Log.Error("Err!!! " + e1.Message);
                    bExporting = false;
                    try
                    {
                        if (fNotify != null)
                        {
                            fNotify.InvokeClose();
                            fNotify = null;
                        }
                    }
                    catch (Exception e2)
                    {
                        Log.Error("Err!!! " + e2.Message);
                    }
                }
            });

            thread.Start();

            RefreshControls();
        }