コード例 #1
0
        private void FtpDownload(M_MyJob myJob)
        {
            //文件路径
            string filePath = Path.GetDirectoryName(myJob.FilePath).Replace("\\", "//");
            //文件名
            string fileName = Path.GetFileName(myJob.FilePath);
            //复制文件到系统路径
            string copyPath = string.Format(@"{0}\SowerTestClient\Paper\Download\{1}_{2}", Application.StartupPath, PublicClass.StudentCode, fileName);
            //下载文件保存路径
            string savePath = string.Format("{0}\\{1}", Globals.DownLoadDir, fileName);

            FtpWeb ftpWeb = CommonUtil.GetFtpWeb();

            if (ftpWeb != null)
            {
                ftpWeb.Download(Globals.DownLoadDir, fileName, filePath, tsbBar, tsbMessage, "作业下载进度:");
            }

            //复制作业到系统目录
            File.Copy(savePath, copyPath, true);
            //删除下载文件
            File.Delete(savePath);
            //设置已下载状态
            dgvResult.SelectedRows[0].Cells["JobDownLoadState"].Value = "已下载";
            tsbMessage.Text = "作业下载进度:";
            tsbBar.Value    = 0;
            //下载账套文件
            if (ftpWeb != null && myJob.RequireEnvFile.ToLower() == "true" && myJob.IsUpload.ToLower() == "true" && cbIsDownAccount.Checked == true)
            {
                filePath = Path.GetDirectoryName(myJob.EnvFilePath).Replace("\\", "//");
                fileName = myJob.EnvFileName;
                copyPath = string.Format(@"{0}\SowerTestClient\Paper\Account\{1}", Application.StartupPath, fileName);
                savePath = string.Format("{0}\\{1}", Globals.DownLoadDir, fileName);
                ftpWeb.Download(Globals.DownLoadDir, fileName, filePath, tsbBar, tsbMessage, "帐套下载进度:");
                //复制作业到系统目录
                DirFileHelper.Copy(savePath, copyPath);
                //删除临时下载文件
                DirFileHelper.DeleteFile(savePath);
                tsbMessage.Text = "帐套下载进度:";
                tsbBar.Value    = 0;
                dgvResult.SelectedRows[0].Cells["AccountDownLoadState"].Value = "已下载";
            }
            //下载视频文件
            if (ftpWeb != null && myJob.IsUploadVideoFile == true && string.IsNullOrEmpty(myJob.VideoFilePath) == false && cbIsDownVideo.Checked == true)
            {
                filePath = Path.GetDirectoryName(myJob.VideoFilePath).Replace("\\", "//");
                fileName = myJob.VideoFileName;
                copyPath = string.Format(@"{0}\SowerTestClient\Video\{1}_{2}\", Application.StartupPath, PublicClass.StudentCode, DirFileHelper.GetFileNameNoExtension(myJob.VideoFilePath));
                savePath = string.Format("{0}\\{1}", Globals.DownLoadDir, fileName);
                ftpWeb.Download(Globals.DownLoadDir, fileName, filePath, tsbBar, tsbMessage, "视频下载进度:");
                //复制作业到系统目录
                ZipFileTools.UnZipSZL(savePath, copyPath);
                //删除临时下载文件
                DirFileHelper.DeleteFile(savePath);
                tsbMessage.Text = "视频下载进度:";
                tsbBar.Value    = 0;
                dgvResult.SelectedRows[0].Cells["VideoDownLoadState"].Value = "已下载";
            }
        }
コード例 #2
0
        /// <summary>
        /// 删除数据
        /// </summary>
        /// <param name="keyValue">主键</param>
        public void RemoveForm(string keyValue)
        {
            //删除老照片
            TelphoneCertificationEntity oldEntity = this.BaseRepository().FindEntity(keyValue);

            DirFileHelper.DeleteFile(oldEntity.photo_z);
            DirFileHelper.DeleteFile(oldEntity.photo_b);
            DirFileHelper.DeleteFile(oldEntity.photo_s);
            this.BaseRepository().Delete(keyValue);
        }
コード例 #3
0
ファイル: AppController.cs プロジェクト: paddy235/ERCHTMS
        public ActionResult RemoveForm(string keyValue)
        {
            var Entity = weChatAppBLL.GetEntity(keyValue);

            if (Entity != null)
            {
                weChatAppBLL.RemoveForm(keyValue);
                DirFileHelper.DeleteFile(Entity.AppLogo);
            }
            return(Success("删除成功。"));
        }
コード例 #4
0
        /// <summary>删除单一文件,并删除数据库记录</summary>
        /// <param name="picPath">/upload/1.jpg</param>
        /// <returns></returns>
        public void Upload_OneDel(string picPath)
        {
            if (string.IsNullOrEmpty(picPath))
            {
                return;
            }
            if (picPath.Length < 4)
            {
                return;
            }

            DirFileHelper.DeleteFile(picPath);
            Upload_DelRs(picPath);
        }
コード例 #5
0
 /// <summary>比较_oldFile 同 _newFile,删除旧文件</summary>
 /// <param name="oldFile">旧文件</param>
 /// <param name="newFile">新文件</param>
 /// <param name="isPic">是图片文件,同时删除小图片</param>
 public void Upload_DiffFile(string oldFile, string newFile, bool isPic)
 {
     //删除旧的文件
     if (oldFile.Length > 4 && string.Compare(oldFile, newFile, true) != 0)
     {
         if (isPic)
         {
             DirFileHelper.DelPicFile(oldFile);
         }
         else
         {
             DirFileHelper.DeleteFile(oldFile);
         }
         Upload_DelRs(oldFile);
     }
 }
コード例 #6
0
 public IHttpActionResult RemoveFile(FileItemModel obj)
 {
     if (obj != null && obj.Id == 0)
     {
         string webPath = HttpContext.Current.Server.MapPath("~");
         bool   re      = DirFileHelper.DeleteFile(webPath + obj.Url);
         if (!re)
         {
             return(NotFound());
         }
         return(Ok());
     }
     else
     {
         return(BadRequest());
     }
 }
コード例 #7
0
        public object UpLoadPic()
        {
            //try
            //{
            //string minPicPath = Config.MinPicPath;
            string             webPath    = HttpContext.Current.Server.MapPath("~") + Config.GetSampleConfig().SampleFilePath;
            string             picPath    = webPath + @"pic\";
            string             minPicPath = webPath + @"pic\MinPic\";
            HttpFileCollection files      = HttpContext.Current.Request.Files;
            string             filename   = "";
            string             styleid    = SessionManage.CurrentSample.StyleId;

            foreach (string key in files.AllKeys)
            {
                HttpPostedFile file = files[key];    //file.ContentLength文件长度
                if (string.IsNullOrEmpty(file.FileName) == false)
                {
                    string fname = DirFileHelper.GetFileName(file.FileName);
                    fname    = fname.Replace("(", string.Empty).Replace(")", string.Empty).Replace(" ", string.Empty);
                    filename = SessionManage.CurrentSample.StyleId + "_" + fname;
                    string filepath = picPath + fname;

                    UploadHelper.FileUpload(file, picPath, fname);
                    //原始文件压缩
                    ImageHelper.MakeSmallImg(filepath, picPath + filename, 1500, 1500);

                    //压缩文件再压缩
                    ImageHelper.MakeSmallImg(filepath, minPicPath + filename, 300, 300);
                    DirFileHelper.DeleteFile(filepath);

                    SessionManage.CurrentSample.AddFile(filename, "", fname, FileType.Pic);
                }
            }
            return(Ok(new { name = filename }));
            //}
            //catch (Exception e)
            //{
            //    return BadRequest(e.Message);
            //}
        }
コード例 #8
0
        /// <summary>
        /// 删除题库文件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDeleteTopicDB_Click(object sender, EventArgs e)
        {
            string sdbFile  = "";
            string sdbtFile = "";

            if (dgvTopicDB.SelectedRows.Count <= 0)
            {
                return;
            }

            DialogResult dialogResult = PublicClass.ShowMessageOKCancel("您确定要删除吗?");

            if (dialogResult == DialogResult.OK)
            {
                try
                {
                    M_ExerciseSubjectDetail subject = dgvTopicDB.SelectedRows[0].DataBoundItem as M_ExerciseSubjectDetail;
                    sdbFile  = subject.TopicFilePath;
                    sdbtFile = subject.TopicFilePath.Substring(0, subject.TopicFilePath.Length - 1);
                    DirFileHelper.DeleteFile(sdbFile);
                    DirFileHelper.DeleteFile(sdbtFile);
                }
                catch (IOException)
                {
                    string errorMessage = string.Format("无法删除该文件,文件正在被另一个人或程序使用。\n关闭任何可能使用这个文件的程序,重新试一次。");
                    PublicClass.ShowErrorMessageOk(errorMessage);
                }
                catch (Exception ex)
                {
                    PublicClass.ShowMessageOk(ex.Message);
                }
                finally
                {
                    //刷新列表
                    LoadTopicDB();
                }
            }
        }
コード例 #9
0
        /// <summary>
        /// 删除账套文件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDeleteFile_Click(object sender, EventArgs e)
        {
            string casfFile = "";

            if (dgvFiles.SelectedRows.Count == 0)
            {
                return;
            }
            DialogResult dialogResult = PublicClass.ShowMessageOKCancel("您确定要删除吗?");

            if (dialogResult == DialogResult.OK)
            {
                try
                {
                    M_ExerciseFile files = dgvFiles.SelectedRows[0].DataBoundItem as M_ExerciseFile;
                    casfFile = files.FilePath;
                    listFile.Remove(files);
                    //删除.sdb文件
                    DirFileHelper.DeleteFile(casfFile);
                }
                catch (IOException)
                {
                    string errorMessage = string.Format("无法删除该文件,文件正在被另一个人或程序使用。\n关闭任何可能使用这个文件的程序,重新试一次。");
                    PublicClass.ShowErrorMessageOk(errorMessage);
                }
                catch (Exception ex)
                {
                    PublicClass.ShowMessageOk(ex.Message);
                }
                finally
                {
                    //刷新列表
                    LoadFiles();
                }
            }
        }
コード例 #10
0
        /// <summary>
        /// 添加题库文件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAddTopicDB_Click(object sender, EventArgs e)
        {
            DialogResult result = ofdOpenTopicDB.ShowDialog();

            if (result == DialogResult.OK)
            {
                string        existsResult = string.Empty;
                string        filePath     = ofdOpenTopicDB.FileName;
                string        fileTPath    = ofdOpenTopicDB.FileName + "t";
                string        fileName     = Path.GetFileName(filePath);
                string        fileExt      = Path.GetExtension(filePath).ToLower();
                string        copyPath     = string.Format(@"{0}\data\{1}_{2}", Application.StartupPath, PublicClass.StudentCode, fileName.Replace(".srk", ".sdb"));
                string        copyTPath    = string.Format(@"{0}\data\{1}_{2}t", Application.StartupPath, PublicClass.StudentCode, fileName.Replace(".srk", ".sdb"));
                string        connection   = string.Format(@"data source={0};password={1};polling=false;failifmissing=true", filePath, PublicClass.PasswordTopicDB);
                string        connectionT  = string.Format(@"data source={0};polling=false;failifmissing=true", fileTPath);
                M_SubjectProp mSubjectProp = new M_SubjectProp();
                try
                {
                    if (fileExt != ".sdb" && fileExt != ".srk")
                    {
                        PublicClass.ShowMessageOk("该文件不是有效的题库文件,请重新添加!");
                        return;
                    }
                    if (File.Exists(copyPath) && File.Exists(copyTPath))
                    {
                        DialogResult dialogResult = PublicClass.ShowMessageOKCancel("该题库文件已经存在,确定要覆盖吗?");
                        if (dialogResult == DialogResult.Cancel)
                        {
                            return;
                        }
                    }
                    CommonUtil.ShowProcessing("正在验证题库,请稍候...", this, (obj) =>
                    {
                        //复制一个.sdbt文件
                        DirFileHelper.CopyFile(filePath, fileTPath);
                        //修改.sdbt文件密码
                        bool updateResult = key3.ChangePassWordByGB2312(fileTPath, PublicClass.PassWordTopicDB_SDB, "");
                        if (updateResult)
                        {
                            SQLiteConnection conn = new SQLiteConnection(connectionT);
                            conn.Open();
                            if (ConnectionState.Open == conn.State)
                            {
                                conn.ChangePassword(PublicClass.PasswordTopicDB);
                                conn.Close();
                                DirFileHelper.CopyFile(filePath, copyPath);
                                DirFileHelper.CopyFile(fileTPath, copyTPath);
                                mSubjectProp = bSubjectProp.GetSubjectProp(Path.GetFileName(copyTPath));
                                existsResult = bService.ExistsTopicDB(mSubjectProp.TopicDBCode, mSubjectProp.TopicDBVersion);
                                if (existsResult == "-1")
                                {
                                    DirFileHelper.DeleteFile(copyPath);
                                    DirFileHelper.DeleteFile(copyTPath);
                                }
                            }
                            conn.Dispose();
                            conn = null;
                            DirFileHelper.DeleteFile(fileTPath);
                        }
                        else
                        {
                            PublicClass.ShowMessageOk("无法打开题库文件,该题库不是有效的题库文件!");
                        }
                        key3.Dispose();
                    }, null);
                    if (existsResult == "-1")
                    {
                        Msg.ShowInformation("在作业中心->练习题库列表中没有添加该文件,请联系授课老师进行添加。");
                    }
                }
                catch (SQLiteException)
                {
                    PublicClass.ShowMessageOk("无法打开题库文件,该题库不是有效的题库文件!");
                    DirFileHelper.DeleteFile(copyPath);
                    DirFileHelper.DeleteFile(copyTPath);
                }
                catch (AggregateException)
                {
                    PublicClass.ShowMessageOk("无法打开题库文件,该题库不是有效的题库文件!");
                    DirFileHelper.DeleteFile(copyPath);
                    DirFileHelper.DeleteFile(copyTPath);
                }
                catch (Exception ex)
                {
                    PublicClass.ShowMessageOk(ex.Message);
                    DirFileHelper.DeleteFile(copyPath);
                    DirFileHelper.DeleteFile(copyTPath);
                }
                finally
                {
                    LoadTopicDB();
                }
            }
        }
コード例 #11
0
        /// <summary>
        /// 保存表单(新增、修改)
        /// </summary>
        /// <param name="keyValue">主键值</param>
        /// <param name="entity">实体对象</param>
        /// <returns></returns>
        public string SaveForm(string keyValue, TelphoneCertificationEntity entity)
        {
            IRepository           db = new RepositoryFactory().BaseRepository().BeginTrans();
            SmsSingleSenderResult singleResult;
            SmsSingleSender       singleSender = new SmsSingleSender(1400040861, "a92c87d0d291698777a9b5f323c0388a");

            TelphonePuEntity    puData    = db.FindEntity <TelphonePuEntity>(t => t.Telphone == entity.mobileNumber);
            TelphoneLiangEntity liangData = db.FindEntity <TelphoneLiangEntity>(t => t.Telphone == entity.mobileNumber);

            if (puData == null && liangData == null)
            {
                return("Error!认证的手机号码不存在!");
            }
            if (!string.IsNullOrEmpty(keyValue))
            {
                //发送短信
                if (entity.sendMessage == 1)
                {
                    TelphoneCertificationEntity oldEntity = this.BaseRepository().FindEntity(keyValue);
                    if (oldEntity.loadMark == 0 && entity.loadMark == 2)
                    {
                        List <string> templParams = new List <string>();
                        templParams.Add(entity.mobileNumber);
                        //成功
                        singleResult = singleSender.SendWithParam("86", entity.custTelphone, 172611, templParams, "", "", "");
                        //微信提醒模板:审核通过
                        WechatHelper.SendToOK(oldEntity.createId);
                    }
                    else if (oldEntity.loadMark == 0 && entity.loadMark == 1)
                    {
                        List <string> templParams = new List <string>();
                        templParams.Add(entity.mobileNumber);
                        templParams.Add(entity.description);
                        //失败
                        singleResult = singleSender.SendWithParam("86", entity.custTelphone, 172613, templParams, "", "", "");
                        //微信提醒模板:审核不通过
                        WechatHelper.SendToFail(oldEntity.createId, entity.description);
                    }
                }
                entity.Modify(keyValue);
                this.BaseRepository().Update(entity);
                return("OK!操作成功");
            }
            else
            {
                //已经提交过的号码,覆盖
                var CertificationData = db.FindEntity <TelphoneCertificationEntity>(t => t.mobileNumber == entity.mobileNumber);
                if (CertificationData != null)
                {
                    if (CertificationData.loadMark == 2)
                    {
                        return("Error!该号码已经激活,无需再次提交。");
                    }
                    else if (CertificationData.loadMark == 0)
                    {
                        return("Error!正在认证中,请先耐心等待认证结果,不要重复提交!");
                    }
                    else
                    {
                        //失败的再处理
                        entity.loadCount   = CertificationData.loadCount + 1;//提交次数加1
                        entity.loadMark    = 0;
                        entity.description = "";
                        entity.Modify(CertificationData.ID);
                        this.BaseRepository().Update(entity);
                        //删除老照片
                        DirFileHelper.DeleteFile(CertificationData.photo_z);
                        DirFileHelper.DeleteFile(CertificationData.photo_b);
                        DirFileHelper.DeleteFile(CertificationData.photo_s);
                        return("OK!再次上传成功!请耐心等待审核结果……");
                    }
                }
                else
                {
                    entity.Create();
                    this.BaseRepository().Insert(entity);
                    return("OK!提交成功!请耐心等待审核结果……");
                }
            }
        }
コード例 #12
0
        /// <summary>根据UploadConfig的单一缩放</summary>
        /// <param name="picImg">图片地址(没有任何扩展后缀,比如后台没有:"b","m","s","b")</param>
        /// <param name="mC">根据vid查得的 UploadConfig配置</param>
        public static void OneMakeThumbImage(string picImg, UploadConfig mC)
        {
            string bigImg = DirFileHelper.GetFilePathPostfix(picImg, "b");
            string midImg = DirFileHelper.GetFilePathPostfix(picImg, "m");
            string minImg = DirFileHelper.GetFilePathPostfix(picImg, "s");
            string hotImg = DirFileHelper.GetFilePathPostfix(picImg, "h");
            string orgImg = DirFileHelper.GetFilePathPostfix(picImg, "o");

            //--------------------------------------------------
            //big
            DirFileHelper.DeleteFile(bigImg);
            if (mC.IsBigPic == 1)
            {
                if (mC.BigWidth > 0 && mC.BigHeight > 0)
                {
                    Uploader.MakeThumbImage(orgImg, bigImg,
                                            ConvertHelper.Cint0(mC.BigWidth),
                                            ConvertHelper.Cint0(mC.BigHeight),
                                            ConvertHelper.Cint0(mC.BigQuality),
                                            ConvertHelper.Cint0(mC.CutType));
                }
                else//因为不限制宽高,所以直接复制出来就行了
                {
                    DirFileHelper.CopyFile(orgImg, bigImg);
                }

                //添加水印
                if (mC.IsWaterPic == 1)
                {
                    Uploader.MakeWaterPic(bigImg);
                }
            }


            //--------------------------------------------------
            //mid
            DirFileHelper.DeleteFile(midImg);
            if (mC.IsMidPic == 1)
            {
                if (mC.MidWidth > 0 && mC.MidHeight > 0)
                {
                    Uploader.MakeThumbImage(orgImg, midImg,
                                            ConvertHelper.Cint0(mC.MidWidth),
                                            ConvertHelper.Cint0(mC.MidHeight),
                                            ConvertHelper.Cint0(mC.MidQuality),
                                            ConvertHelper.Cint0(mC.CutType));
                }
                else//因为不限制宽高,所以直接复制出来就行了
                {
                    DirFileHelper.CopyFile(orgImg, midImg);
                }

                //添加水印
                if (mC.IsWaterPic == 1)
                {
                    Uploader.MakeWaterPic(midImg);
                }
            }

            //--------------------------------------------------
            //hot
            DirFileHelper.DeleteFile(hotImg);
            if (mC.IsHotPic == 1)
            {
                if (mC.HotWidth > 0 && mC.HotHeight > 0)
                {
                    Uploader.MakeThumbImage(orgImg, hotImg,
                                            ConvertHelper.Cint0(mC.HotWidth),
                                            ConvertHelper.Cint0(mC.HotHeight),
                                            ConvertHelper.Cint0(mC.HotQuality),
                                            ConvertHelper.Cint0(mC.CutType));
                }
                else//因为不限制宽高,所以直接复制出来就行了
                {
                    DirFileHelper.CopyFile(orgImg, hotImg);
                }

                //添加水印
                if (mC.IsWaterPic == 1)
                {
                    Uploader.MakeWaterPic(hotImg);
                }
            }

            //--------------------------------------------------
            //min
            DirFileHelper.DeleteFile(minImg);
            if (mC.IsMinPic == 1)
            {
                if (mC.IsMinPic > 0 && mC.MinHeight > 0)
                {
                    Uploader.MakeThumbImage(orgImg, minImg,
                                            ConvertHelper.Cint0(mC.MinWidth),
                                            ConvertHelper.Cint0(mC.MinHeight),
                                            ConvertHelper.Cint0(mC.MinQuality),
                                            ConvertHelper.Cint0(mC.CutType));
                }
                else//因为不限制宽高,所以直接复制出来就行了
                {
                    DirFileHelper.CopyFile(orgImg, minImg);
                }

                //微型图不用加水印
            }


            //--------------------------------------------------
            //pic
            DirFileHelper.DeleteFile(picImg);
            if (mC.IsFixPic == 1)
            {
                if (mC.PicWidth > 0 && mC.PicHeight > 0)
                {
                    Uploader.MakeThumbImage(orgImg, picImg,
                                            ConvertHelper.Cint0(mC.PicWidth),
                                            ConvertHelper.Cint0(mC.PicHeight),
                                            ConvertHelper.Cint0(mC.PicQuality),
                                            ConvertHelper.Cint0(mC.CutType));
                }
                else//因为不限制宽高,所以直接复制出来就行了
                {
                    DirFileHelper.CopyFile(orgImg, picImg);
                }

                //添加水印
                if (mC.IsWaterPic == 1)
                {
                    Uploader.MakeWaterPic(picImg);
                }
            }
        }
コード例 #13
0
        /// <returns>上传成功返回"",并填充 Model.UploadFile</returns>
        /// <param name="vid">上传配置模块id,即UploadConfig_Id</param>
        /// <param name="key">随机key</param>
        /// <param name="userId">上传者id</param>
        /// <param name="userName">上传者UserName</param>
        /// <param name="remotePicUrl">远程图片的url地址</param>
        /// <param name="m_r">Model.UploadFile</param>
        /// <returns>上传成功返回"",并填充 Model.UploadFile</returns>
        public string Upload_RemotePic(int vid, string key, int userId, string userName, string remotePicUrl, UploadFile m_r)
        {
            #region 检查参数
            //---------------------------------------------------
            if (vid < 1 || key.Length < 10)
            {
                return("缺少参数:key或sid");
            }
            //---------------------------------------------------

            #region 检查登陆
            m_r.UserId   = userId;
            m_r.UserName = userName;

            if (m_r.UserId == 0)
            {
                return("您的权限不足!");
            }
            #endregion

            //---------------------------------------------------
            UploadConfig mC = Read_UploadConfig(vid);
            if (mC.Id != vid)
            {
                return("缺少参数:UploadConfig_Id!");
            }

            if (mC.IsPost != 1)
            {
                return("系统暂时禁止上传文件2!");
            }

            if (mC.IsEditor != 1)
            {
                return("非编辑器类别!");
            }

            mC.UploadType_TypeKey = "image";
            #endregion


            //----------------------------------------------
            #region 生成暂时目录
            string sCfgSavePath = new Uploader().SavePath;
            string sSavePath    = DirFileHelper.FixDirPath(sCfgSavePath + mC.SaveDir) + DateTime.Now.ToString("yyMM") + "/";
            if (!DirFileHelper.CheckSaveDir(sSavePath))
            {
                return("SavePath设置不当:" + sSavePath + ", 或权限不足!");
            }

            string sServerDir = sCfgSavePath + "remote/";
            if (!DirFileHelper.CheckSaveDir(sServerDir))
            {
                return("ServerDir设置不当:" + sServerDir + ", 或权限不足!");
            }
            //----------------------------------------------
            string sSrcName = StringHelper.Left(DirFileHelper.GetFileName(remotePicUrl), 90);
            string sFileExt = DirFileHelper.GetFileExtension(sSrcName);

            //因部部分网站不是标准的jpg、gif扩展名,所以修改下面代码
            if (sFileExt.Length > 0)
            {
                string sAllowed = ",jpg,gif,png,bmp,";
                string sExt     = "," + sFileExt.ToLower() + ",";
                if (sAllowed.IndexOf(sExt) == -1)
                {
                    sFileExt = "jpg";
                }
            }
            else
            {
                sFileExt = "jpg";
            }
            //----------------------------------------------

            string sNewFile = DirFileHelper.GetRndFileName("." + sFileExt);

            if (sServerDir.IndexOf(":") < 0)
            {
                sServerDir = DirFileHelper.FixDirPath(DirFileHelper.GetMapPath(sServerDir));
            }
            string sNewRoot = System.IO.Path.Combine(sServerDir, sNewFile);
            #endregion

            //----------------------------------------------
            #region   到暂时目录
            try
            {
                var wc = new System.Net.WebClient();
                wc.DownloadFile(remotePicUrl, sNewRoot);
            }
            catch (Exception ex)
            {
                //throw ex;
                return(ex.Message.ToLower());
            }

            if (!DirFileHelper.IsExistFile(sNewRoot))
            {
                return("上传失败");
            }
            #endregion

            //----------------------------------------------
            #region 判断是否真实图片格式,并取得图片宽高
            int ww = 0, hh = 0;
            if (!Uploader.Get_Pic_WW_HH(sNewRoot, out ww, out hh))
            {
                DirFileHelper.DeleteFile(sNewRoot);
                return("非法格式!不是图片文件。");
            }

            int  iMaxSize  = mC.PicSize;
            long iFileSize = DirFileHelper.GetFileSize(sNewRoot);

            /*
             * if (iFileSize > iMaxSize)
             * {
             *  return "上传文件大小超过了限制.最多上传(" + DirFileHelper.FmtFileSize2(iMaxSize) + ").";
             * }
             */
            #endregion


            #region 把上传的暂时文件复制到相关模块目录中
            string sNewPath = sSavePath + sNewFile;
            string orgImg   = DirFileHelper.GetFilePathPostfix(sNewPath, "o");

            //复制到原始图
            DirFileHelper.CopyFile(sNewRoot, orgImg);

            //删除暂时上传的图片
            DirFileHelper.DeleteFile(sNewRoot);

            //生成相关缩略图
            OneMakeThumbImage(sNewPath, mC);

            #endregion


            //----------------------------------------------
            #region 保存入数据库
            m_r.UploadConfig_Id = mC.Id;
            m_r.JoinName        = mC.JoinName;
            m_r.JoinId          = 0;

            m_r.UserType = mC.UserType;
            m_r.UserIp   = IpHelper.GetUserIp();
            m_r.AddDate  = DateTime.Now;
            m_r.InfoText = "";
            m_r.RndKey   = key;

            m_r.Name = sNewFile;
            m_r.Path = sNewPath;
            m_r.Src  = sSrcName;
            m_r.Ext  = sFileExt;

            m_r.Size      = ConvertHelper.Cint0(iFileSize);
            m_r.PicWidth  = ww;
            m_r.PicHeight = hh;

            //保存入数据库
            Add_UploadFile(m_r);
            #endregion

            //------------------------------------
            //上传成功,输出结果
            return("");
        }
コード例 #14
0
        private void HttpDownload(M_MyJob myJob)
        {
            //下载地址
            string downLoadUrl = string.Format("{0}/{1}", fileHost, myJob.FilePath.Replace(@"\", @"/"));
            //文件路径
            string filePath = myJob.FilePath;
            //文件名
            string fileName = Path.GetFileName(filePath);
            //复制文件到系统路径
            string copyPath = string.Format(@"{0}\SowerTestClient\Paper\Download\{1}_{2}", Application.StartupPath, PublicClass.StudentCode, fileName);
            //下载文件保存路径
            string savePath = string.Format("{0}\\{1}_{2}", Globals.DownLoadDir, PublicClass.StudentCode, fileName);
            //下载作业
            bool downResult = CommonUtil.DownloadFile(downLoadUrl, savePath, tsbBar, tsbMessage, "作业下载进度:");

            if (downResult)
            {
                //复制作业到系统目录
                File.Copy(savePath, copyPath, true);
                //删除下载文件
                File.Delete(savePath);
                //设置已下载状态
                dgvResult.SelectedRows[0].Cells["JobDownLoadState"].Value = "已下载";
                tsbMessage.Text = "作业下载进度:";
                tsbBar.Value    = 0;
            }
            if (myJob.RequireEnvFile.ToLower() == "true" && myJob.IsUpload.ToLower() == "true" && cbIsDownAccount.Checked == true)
            {
                downLoadUrl = string.Format("{0}/{1}", fileHost, myJob.EnvFilePath.Replace(@"\", @"/"));
                filePath    = myJob.FilePath;
                fileName    = myJob.EnvFileName;
                copyPath    = string.Format(@"{0}\SowerTestClient\Paper\Account\{1}", Application.StartupPath, fileName);
                savePath    = string.Format("{0}\\{1}", Globals.DownLoadDir, fileName);
                downResult  = CommonUtil.DownloadFile(downLoadUrl, savePath, tsbBar, tsbMessage, "帐套下载进度:");
                if (downResult)
                {
                    //复制作业到系统目录
                    DirFileHelper.Copy(savePath, copyPath);
                    //删除临时下载文件
                    DirFileHelper.DeleteFile(savePath);
                    tsbMessage.Text = "账套下载进度:";
                    tsbBar.Value    = 0;
                    dgvResult.SelectedRows[0].Cells["AccountDownLoadState"].Value = "已下载";
                }
            }
            //下载视频文件
            if (string.IsNullOrEmpty(myJob.VideoFilePath) == false && myJob.IsUploadVideoFile == true && cbIsDownVideo.Checked == true)
            {
                downLoadUrl = string.Format("{0}/{1}", fileHost, myJob.VideoFilePath.Replace(@"\", @"/"));
                filePath    = myJob.VideoFilePath;
                fileName    = myJob.VideoFileName;
                copyPath    = string.Format(@"{0}\SowerTestClient\Video\{1}_{2}", Application.StartupPath, PublicClass.StudentCode, Path.GetFileNameWithoutExtension(fileName));
                savePath    = string.Format("{0}\\{1}", Globals.DownLoadDir, fileName);
                downResult  = CommonUtil.DownloadFile(downLoadUrl, savePath, tsbBar, tsbMessage, "视频下载进度:");
                if (downResult)
                {
                    //复制作业到系统目录
                    ZipFileTools.UnZipSZL(savePath, copyPath);
                    //删除临时下载文件
                    DirFileHelper.DeleteFile(savePath);
                    tsbMessage.Text = "视频下载进度:";
                    tsbBar.Value    = 0;
                    dgvResult.SelectedRows[0].Cells["VideoDownLoadState"].Value = "已下载";
                }
            }
        }
コード例 #15
0
        /// <summary>
        /// 下载资源文件
        /// </summary>
        /// <param name="copyPath"></param>
        /// <returns></returns>
        private void DownLoad(string copyPath)
        {
            bool   downResult  = false;
            string downLoadUrl = string.Empty;
            string filePath    = string.Empty;
            string fileName    = string.Empty;
            string savePath    = string.Empty;
            string downPath    = Globals.DownLoadDir;

            try
            {
                if (dgvResult.SelectedRows.Count == 0)
                {
                    return;
                }
                M_Resource resource = dgvResult.SelectedRows[0].DataBoundItem as M_Resource;
                btnDownLoad.Enabled = false;
                //下载地址
                downLoadUrl = string.Format("{0}/{1}", fileHost, resource.RSPath.Replace(@"\", @"/"));
                //文件路径
                filePath = resource.RSPath;
                //文件名
                fileName = Path.GetFileName(filePath);
                //下载文件保存路径
                savePath = string.Format("{0}{1}", downPath, fileName);
                //下载作业
                downResult = CommonUtil.DownloadFile(downLoadUrl, savePath, tsbBar, tsbMessage, "下载进度:");
                if (downResult)
                {
                    switch (resource.RSType)
                    {
                    case MyResourceType.ZhangTao:
                        //解压资源到目录
                        ZipFileTools.UnZipSZL(savePath, copyPath);
                        break;

                    case MyResourceType.TiKU:
                        downPath = string.Format(@"{0}\{1}", downPath, Path.GetFileNameWithoutExtension(fileName));
                        //解压资源到目录
                        ZipFileTools.UnZipSZL(savePath, downPath);
                        DirectoryInfo directoryInfo = new DirectoryInfo(downPath);
                        FileInfo[]    fileInfo      = directoryInfo.GetFiles(); //只取.srk文件
                        if (fileInfo.Length > 0)
                        {
                            DownLoadTopicDB(fileInfo[0].FullName);
                        }
                        DirFileHelper.DeleteDirectory(downPath);
                        break;

                    case MyResourceType.ZiLiao:
                        //解压资源到目录
                        ZipFileTools.UnZipSZL(savePath, copyPath);
                        break;

                    default:
                        //解压资源到目录
                        ZipFileTools.UnZipSZL(savePath, copyPath);
                        break;
                    }
                    //删除下载文件
                    DirFileHelper.DeleteFile(savePath);
                    //设置已下载状态
                    dgvResult.SelectedRows[0].Cells["DownLoadState"].Value = "已下载";
                }
            }
            catch (Exception ex)
            {
                Msg.ShowError("资源下载失败,详情请参考系统错误日志。");
                LogHelper.WriteLog(typeof(frmResource), ex);
                CommonUtil.WriteLog(ex);
            }
            finally
            {
                btnDownLoad.Enabled = true;
            }
        }
コード例 #16
0
 /// <summary>
 /// 下载题库
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnDown_Click(object sender, EventArgs e)
 {
     #region 局部变量
     string topicFileName      = string.Empty;
     string topicFilePath      = string.Empty;
     string topicEnvFilePath   = string.Empty;
     string topicVideoFilePath = string.Empty;
     string requireEnvFile     = string.Empty;
     string envFileName        = string.Empty;
     string envFilePath        = string.Empty;
     string videoFileName      = string.Empty;
     string videoFilePath      = string.Empty;
     string envFileExt         = string.Empty;
     string copyEnvPath        = string.Empty;
     string copyVideoPath      = string.Empty;
     string filePath           = string.Empty;
     string fileTPath          = string.Empty;
     string fileExt            = string.Empty;
     string fileName           = string.Empty;
     string copyPath           = string.Empty;
     string copyTPath          = string.Empty;
     string connection         = string.Empty;
     string connectionT        = string.Empty;
     string errorMessage       = string.Empty;
     FtpWeb ftpWeb             = null;
     #endregion
     try
     {
         btnDown.Enabled = false;
         if (dgvDownTopicDB.SelectedRows.Count == 0)
         {
             return;
         }
         M_TopicDB topicDB = dgvDownTopicDB.SelectedRows[0].DataBoundItem as M_TopicDB;
         #region 检测本地是否存在题库文件
         string path = string.Format(@"{0}\data\{1}_{2}.sdbt", Application.StartupPath, PublicClass.StudentCode, topicDB.TopicDBName);
         if (File.Exists(path))
         {
             M_SubjectProp subject = bSubjectProp.GetSubjectProp(string.Format("{0}_{1}.sdbt", PublicClass.StudentCode, topicDB.TopicDBName));
             if (subject.TopicDBVersion == topicDB.TopicDBVersion && subject.TopicDBCode == topicDB.TopicDBCode)
             {
                 PublicClass.ShowErrorMessageOk("您已经下载过这个题库文件,不能重复下载。");
                 return;
             }
         }
         #endregion
         #region 初始化变量
         topicFileName  = Path.GetFileName(topicDB.TopicDBPath);
         topicFilePath  = Path.GetDirectoryName(topicDB.TopicDBPath).Replace("\\", "//");
         requireEnvFile = string.IsNullOrEmpty(topicDB.RequireEnvFile) == true ? "false" : topicDB.RequireEnvFile.ToLower();
         filePath       = string.Format("{0}\\{1}", Globals.DownLoadDir, topicFileName);
         fileTPath      = string.Format("{0}\\{1}t", Globals.DownLoadDir, topicFileName);
         fileExt        = string.IsNullOrEmpty(topicDB.TopicDBPath) == true ? "" : Path.GetExtension(topicDB.TopicDBPath).ToLower();
         fileName       = string.Format("{0}{1}", topicDB.TopicDBName, fileExt);
         copyPath       = string.Format(@"{0}\data\{1}_{2}", Application.StartupPath, PublicClass.StudentCode, fileName.Replace(".srk", ".sdb"));
         copyTPath      = string.Format(@"{0}\data\{1}_{2}t", Application.StartupPath, PublicClass.StudentCode, fileName.Replace(".srk", ".sdb"));
         connection     = string.Format(@"data source={0};password={1};polling=false;failifmissing=true", filePath, PublicClass.PasswordTopicDB);
         connectionT    = string.Format(@"data source={0};polling=false;failifmissing=true", fileTPath);
         #endregion
         //下载题库文件
         ftpWeb = CommonUtil.GetFtpWeb();
         if (ftpWeb != null)
         {
             ftpWeb.Download(Globals.DownLoadDir, topicFileName, topicFilePath, proDown, lblDown, "题库下载进度:");
         }
         else
         {
             Msg.ShowInformation("FTP地址不可用,请返回登陆界面进行配置。");
             return;
         }
         //下载账套文件
         if (ftpWeb != null && requireEnvFile == "true" && topicDB.IsUploadEnvFile == true && !string.IsNullOrEmpty(topicDB.EnvFilePath))
         {
             envFileName      = Path.GetFileName(topicDB.EnvFilePath);
             envFilePath      = string.Format("{0}\\{1}", Globals.DownLoadDir, envFileName);
             copyEnvPath      = string.Format(@"{0}\SowerTestClient\Paper\Account\{1}", Application.StartupPath, envFileName);
             topicEnvFilePath = Path.GetDirectoryName(topicDB.EnvFilePath).Replace("\\", "//");
             ftpWeb.Download(Globals.DownLoadDir, envFileName, topicEnvFilePath, proDown, lblDown, "账套下载进度:");
         }
         //下载视频文件
         if (ftpWeb != null && topicDB.IsUploadVideoFile == true && !string.IsNullOrEmpty(topicDB.VideoFilePath))
         {
             videoFileName      = Path.GetFileName(topicDB.VideoFilePath);
             videoFilePath      = string.Format("{0}\\{1}", Globals.DownLoadDir, videoFileName);
             copyVideoPath      = string.Format(@"{0}\SowerTestClient\Video\{1}_{2}\", Application.StartupPath, PublicClass.StudentCode, DirFileHelper.GetFileNameNoExtension(videoFileName));
             topicVideoFilePath = Path.GetDirectoryName(topicDB.VideoFilePath).Replace("\\", "//");
             ftpWeb.Download(Globals.DownLoadDir, videoFileName, topicVideoFilePath, proDown, lblDown, "视频下载进度:");
         }
         #region 验证题库文件
         if (fileExt != ".sdb" && fileExt != ".srk")
         {
             Msg.ShowError("该文件不是有效的题库文件,请重新添加!");
             return;
         }
         if (File.Exists(copyTPath) && File.Exists(copyPath))
         {
             if (!Msg.AskQuestion("该题库文件已经存在,确定要覆盖吗?"))
             {
                 return;
             }
         }
         if (File.Exists(filePath))
         {
             CommonUtil.ShowProcessing("正在验证题库,请稍候...", this, (obj) =>
             {
                 //复制一个.sdbt文件
                 DirFileHelper.CopyFile(filePath, fileTPath);
                 //修改.sdbt文件密码
                 bool updateResult = key3.ChangePassWordByGB2312(fileTPath, PublicClass.PassWordTopicDB_SDB, "");
                 if (updateResult)
                 {
                     SQLiteConnection conn = new SQLiteConnection(connectionT);
                     conn.Open();
                     if (ConnectionState.Open == conn.State)
                     {
                         //更改题库密码
                         conn.ChangePassword(PublicClass.PasswordTopicDB);
                         //复制题库到系统目录
                         DirFileHelper.CopyFile(filePath, copyPath);
                         DirFileHelper.CopyFile(fileTPath, copyTPath);
                         //复制账套到系统目录
                         if (requireEnvFile == "true" && topicDB.IsUploadEnvFile == true && !string.IsNullOrEmpty(topicDB.EnvFilePath))
                         {
                             DirFileHelper.CopyFile(envFilePath, copyEnvPath);
                         }
                         //复制视频到系统目录
                         if (topicDB.IsUploadVideoFile == true && !string.IsNullOrEmpty(topicDB.VideoFilePath))
                         {
                             ZipFileTools.UnZipSZL(videoFilePath, copyVideoPath);
                         }
                         conn.Close();
                     }
                     conn.Dispose();
                     conn = null;
                     DirFileHelper.DeleteFile(filePath);
                     DirFileHelper.DeleteFile(fileTPath);
                     DirFileHelper.DeleteFile(envFilePath);
                     DirFileHelper.DeleteFile(videoFilePath);
                 }
                 else
                 {
                     Msg.ShowError("该题库不是有效的题库文件!");
                 }
                 key3.Dispose();
             }, null);
         }
         #endregion
     }
     catch (SQLiteException se)
     {
         Msg.ShowError("无法打开题库文件,该题库不是有效的题库文件!");
         LogHelper.WriteLog(typeof(frmDownTopicDB), se);
         CommonUtil.WriteLog(se);
     }
     catch (WebException we)
     {
         Msg.ShowError("该题库文件不存在,请联系管理员重新上传。");
         LogHelper.WriteLog(typeof(frmDownTopicDB), we);
         CommonUtil.WriteLog(we);
     }
     catch (AggregateException ae)
     {
         Msg.ShowError("无法打开题库文件,该题库不是有效的题库文件!");
         LogHelper.WriteLog(typeof(frmDownTopicDB), ae);
         CommonUtil.WriteLog(ae);
     }
     catch (Exception ex)
     {
         PublicClass.ShowErrorMessageOk(ex.Message);
         LogHelper.WriteLog(typeof(frmDownTopicDB), ex);
         CommonUtil.WriteLog(ex);
     }
     finally
     {
         btnDown.Enabled = true;
     }
 }
コード例 #17
0
        /// <summary>上传文件,并按设置生成缩略图,水印</summary>
        /// <returns></returns>
        public bool UploadFile(HttpPostedFile oFile = null)
        {
            #region 检查设置
            if (!this.IsEnabled)
            {
                SendResponse(500, "");
                return(false);
            }

            if (this.IsChkSrcPost)
            {
                if (!RequestHelper.ChkSrcPost())
                {
                    SendResponse(501, "");
                    return(false);
                }
            }

            if (this._savePath.Length < 1)
            {
                SendResponse(101, "SavePath未设置");
                return(false);
            }

            if (oFile == null)
            {
                if (this.FilePostName.Length < 1)
                {
                    SendResponse(101, "filePostName未设置");
                    return(false);
                }
            }

            this._savePath = DirFileHelper.FixDirPath(_savePath) + DateTime.Now.ToString("yyMM") + "/";
            bool isOk = DirFileHelper.CheckSaveDir(this._savePath);

            if (!isOk)
            {
                SendResponse(101, "SavePath设置不当:" + this._savePath + ", 或权限不足!");
                return(false);
            }
            #endregion

            //------------------------------------------------
            #region 获取文件对象
            //获取文件对象
            if (oFile == null)
            {
                oFile = HttpContext.Current.Request.Files[FilePostName];
            }
            if (oFile == null)
            {
                SendResponse(201, "");
                return(false);
            }
            //------------------------------------------------
            //原始文件名;
            this.SrcName = Path.GetFileName(oFile.FileName);
            #endregion

            //------------------------------------------------
            #region 检查文件大小
            this._fileSize = oFile.ContentLength;

            //不能上传小于10字节的内容
            if (this.SrcName.Length < 3 || this._fileSize < 10)
            {
                SendResponse(201, "");
                return(false);
            }

            //检测文件大小是否超过限制
            if (this._fileSize > (this._maxSize * 1024))
            {
                SendResponse(301, "");
                return(false);
            }

            #endregion

            //------------------------------------------------
            #region 检查文件类型
            this.FileExt = Path.GetExtension(this.SrcName).ToLower().TrimStart('.');

            if (!checkAllowedExt(this.FileExt))
            {
                SendResponse(202, "");
                return(false);
            }
            #endregion


            #region   文件
            //上传
            string sServerDir = _savePath;
            if (sServerDir.IndexOf(":") < 0)
            {
                sServerDir = DirFileHelper.FixDirPath(DirFileHelper.GetMapPath(sServerDir));
            }

            string sNewFile = "";   //新文件名(系统生成)
            string sNewRoot = "";   //新文件路径(绝对路径)

            while (true)
            {
                sNewFile = DirFileHelper.GetRndFileName("." + this.FileExt);
                sNewRoot = System.IO.Path.Combine(sServerDir, sNewFile);

                if (!DirFileHelper.IsExistFile(sNewRoot))
                {
                    try
                    {
                        oFile.SaveAs(sNewRoot);
                    }
                    catch
                    {
                        SendResponse(204, "");
                        return(false);
                    }
                    break;
                }
            }

            this.NewFile = sNewFile;
            this.NewPath = _savePath + sNewFile;
            #endregion

            //------------------------------------------------
            #region 生成缩略图 + 水印
            if (this.FileExt == "jpg" || this.FileExt == "png" || this.FileExt == "gif" || this.FileExt == "jpeg" || this.FileExt == "bmp")
            {
                #region 取得原始尺寸
                try//能取得图片宽高,是真实的图片
                {
                    System.Drawing.Image testImage1 = System.Drawing.Image.FromFile(sNewRoot);
                    this.SrcWidth  = testImage1.Width;
                    this.SrcHeight = testImage1.Height;
                    testImage1.Dispose();

                    this.NewWidth  = this.SrcWidth;
                    this.NewHeight = this.SrcHeight;
                }
                catch
                {
                    //非法格式,不是真正的图片
                    DirFileHelper.DeleteFile(sNewRoot);
                    SendResponse(202, "");
                    return(false);
                }

                //------------------------------------------------
                //先备份原始图
                var tmpPath = "";
                tmpPath = System.IO.Path.Combine(sServerDir, DirFileHelper.GetFileNamePostfix(sNewFile, "o"));
                DirFileHelper.CopyFile(sNewRoot, tmpPath);
                #endregion


                if (this._isFixPic || this._isBigPic || this._isMidPic || this._isMinPic)
                {
                    #region 创建大图
                    if (this._isBigPic)
                    {
                        tmpPath = System.IO.Path.Combine(sServerDir, DirFileHelper.GetFileNamePostfix(sNewFile, "b"));

                        if (this._bigWidth > 0 && this._bigHeight > 0)
                        {
                            //缩略
                            MakeThumbImage(sNewRoot, tmpPath, this._bigWidth, this._bigHeight, this._bigQuality, this.CutType);
                        }
                        else//因为不限制宽高,所以直接复制出来就行了
                        {
                            DirFileHelper.CopyFile(sNewRoot, tmpPath);
                        }

                        //添加水印
                        if (this.IsWaterPic)
                        {
                            MakeWaterPic(tmpPath);
                        }
                    }
                    #endregion

                    //------------------------------------------------
                    #region 创建中图
                    if (this._isMidPic)
                    {
                        tmpPath = System.IO.Path.Combine(sServerDir, DirFileHelper.GetFileNamePostfix(sNewFile, "m"));

                        if (this._midWidth > 0 && this._midHeight > 0)
                        {
                            //缩略图
                            MakeThumbImage(sNewRoot, tmpPath, this._midWidth, this._midHeight, this._midQuality, this.CutType);
                        }
                        else//因为不限制宽高,所以直接复制出来就行了
                        {
                            DirFileHelper.CopyFile(sNewRoot, tmpPath);
                        }

                        //添加水印
                        if (this.IsWaterPic)
                        {
                            MakeWaterPic(tmpPath);
                        }
                    }
                    #endregion

                    //------------------------------------------------
                    #region 创建小图
                    if (this._isMinPic)
                    {
                        tmpPath = System.IO.Path.Combine(sServerDir, DirFileHelper.GetFileNamePostfix(sNewFile, "s"));

                        if (this._minWidth > 0 && this._minHeight > 0)
                        {
                            //缩略图
                            MakeThumbImage(sNewRoot, tmpPath, this._minWidth, this._minHeight, this._minQuality, this.CutType);
                        }
                        else//因为不限制宽高,所以直接复制出来就行了
                        {
                            DirFileHelper.CopyFile(sNewRoot, tmpPath);
                        }

                        //微型图不用加水印
                    }
                    #endregion

                    //------------------------------------------------
                    #region 创建推荐图
                    if (this._isHotPic)
                    {
                        tmpPath = System.IO.Path.Combine(sServerDir, DirFileHelper.GetFileNamePostfix(sNewFile, "h"));

                        if (this._hotWidth > 0 && this._hotHeight > 0)
                        {
                            //缩略图
                            MakeThumbImage(sNewRoot, tmpPath, this._hotWidth, this._hotHeight, this._hotQuality, this.CutType);
                        }
                        else//因为不限制宽高,所以直接复制出来就行了
                        {
                            DirFileHelper.CopyFile(sNewRoot, tmpPath);
                        }


                        //添加水印
                        if (this.IsWaterPic)
                        {
                            MakeWaterPic(tmpPath);
                        }
                    }
                    #endregion

                    //------------------------------------------------
                    #region 限制列表图
                    if (this._isFixPic && this._picWidth > 0 && this._picHeight > 0)
                    {
                        MakeThumbImage(sNewRoot, sNewRoot, this._picWidth, this._picHeight, this._picQuality, this.CutType);
                    }
                    #endregion


                    #region 取得缩放后的图片宽高
                    try
                    {
                        System.Drawing.Image testImage2 = System.Drawing.Image.FromFile(sNewRoot);
                        this.NewWidth  = testImage2.Width;
                        this.NewHeight = testImage2.Height;
                        testImage2.Dispose();
                    }
                    catch
                    {
                        DirFileHelper.DelPicFile(this.NewPath);
                        SendResponse(202, "");
                        return(false);
                    }
                    #endregion
                }

                //列表图是否加水印
                if (DirFileHelper.IsExistFile(sNewRoot) && this.IsWaterPic)
                {
                    MakeWaterPic(sNewRoot);
                }
            }
            #endregion

            //上传成功!!
            return(true);
        }