/// <summary> /// 添加视频文件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAddVideoFile_Click(object sender, EventArgs e) { if (dgvResult.SelectedRows.Count == 0) { return; } M_MyJob myJob = dgvResult.SelectedRows[0].DataBoundItem as M_MyJob; ofdOpenFile.Title = "视频资源"; ofdOpenFile.FileName = "视频资源"; ofdOpenFile.Filter = "视频资源|*.zip*"; ofdOpenFile.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); DialogResult result = ofdOpenFile.ShowDialog(); if (result == DialogResult.OK) { string filePath = ofdOpenFile.FileName; string fileName = Path.GetFileName(filePath); string fileExt = Path.GetExtension(filePath).ToLower(); string copyPath = string.Format(@"{0}\SowerTestClient\Video\{1}_{2}\", Application.StartupPath, PublicClass.StudentCode, DirFileHelper.GetFileNameNoExtension(filePath)); string videoFileName = string.IsNullOrEmpty(myJob.VideoFileName) == true ? "" : myJob.VideoFileName.ToLower(); if (string.IsNullOrEmpty(videoFileName)) { Msg.ShowInformation(string.Format("作业“{0}”没有添加视频资源,请联系授课教师到作业中心->作业维护发布列表进行添加。", myJob.HWName)); return; } if (fileName.ToLower() != videoFileName) { Msg.ShowInformation(string.Format("您添加的视频资源无效,请添加名字为{0}的视频资源。", videoFileName)); return; } try { if (fileExt != ".zip") { PublicClass.ShowMessageOk("该文件不是有效的视频资源包,请重新添加!"); return; } if (Directory.Exists(copyPath)) { DialogResult dialogResult = PublicClass.ShowMessageOKCancel("该视频资源包已经存在,确定要覆盖吗?"); if (dialogResult == DialogResult.Cancel) { return; } } CommonUtil.ShowProcessing("正在处理中,请稍候...", this, (obj) => { ZipFileTools.UnZipSZL(filePath, copyPath); dgvResult.SelectedRows[0].Cells["VideoDownLoadState"].Value = "已下载"; }, null); } catch (Exception ex) { LogHelper.WriteLog(typeof(frmHomeWork), ex); CommonUtil.WriteLog(ex); } } }
private bool DownLoadFile(string copyPath) { bool downResult = false; bool downMyJobResult = false; string downLoadUrl = string.Empty; string filePath = string.Empty; string fileName = string.Empty; string savePath = string.Empty; string ftpFilePath = "C:\\data\\"; string ftpServerIp = UserConfigSettings.Instance.ReadSetting("题库地址"); string ftpRemotePath = UserConfigSettings.Instance.ReadSetting("题库目录"); string ftpPort = UserConfigSettings.Instance.ReadSetting("端口号"); string ftpUserId = UserConfigSettings.Instance.ReadSetting("ftp用户名"); string ftpPassword = UserConfigSettings.Instance.ReadSetting("ftp密码"); bool anonymous = bool.Parse(UserConfigSettings.Instance.ReadSetting("匿名")); FtpWeb ftpWeb = new FtpWeb(ftpServerIp, ftpRemotePath, ftpUserId, ftpPassword, ftpPort, 10000, false, anonymous); M_Resource resource = dgvResult.SelectedRows[0].DataBoundItem as M_Resource; try { btnDownLoad.Enabled = false; //下载地址 downLoadUrl = fileHost.Replace(@"\", @"/") + resource.RSPath; //文件路径 filePath = resource.RSPath; //文件名 fileName = Path.GetFileName(filePath); //下载文件保存路径 savePath = string.Format("C:\\{0}_{1}", PublicClass.StudentCode, fileName); //下载作业 //downResult = CommonUtil.DownloadFile(downLoadUrl, savePath, tsbBar, tsbMessage, "下载进度:"); ftpWeb.Download(ftpFilePath, resource.RSPath, "", tsbBar, tsbMessage, "下载进度:"); if (downResult) { //解压资源到目录 ZipFileTools.UnZipSZL(savePath, copyPath); //删除下载文件 File.Delete(savePath); //设置已下载状态 dgvResult.SelectedRows[0].Cells["DownLoadState"].Value = "已下载"; downMyJobResult = true; } } catch (Exception ex) { PublicClass.ShowMessageOk(ex.Message); downMyJobResult = false; } finally { btnDownLoad.Enabled = true; } return(downMyJobResult); }
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 = "已下载"; } }
/// <summary> /// 添加视频资源 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAddVideoFile_Click(object sender, EventArgs e) { ofdOpenVideoFile.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); DialogResult result = ofdOpenVideoFile.ShowDialog(); if (result == DialogResult.OK) { string filePath = ofdOpenVideoFile.FileName; string fileName = Path.GetFileNameWithoutExtension(filePath); string fileExt = Path.GetExtension(filePath).ToLower(); string copyPath = string.Format(@"{0}\SowerTestClient\Video\{1}_{2}", Application.StartupPath, PublicClass.StudentCode, fileName); try { if (fileExt != ".zip") { PublicClass.ShowMessageOk("该文件不是有效的视频资源包,请重新添加!"); return; } if (Directory.Exists(copyPath)) { DialogResult dialogResult = PublicClass.ShowMessageOKCancel("该视频资源包已经存在,确定要覆盖吗?"); if (dialogResult == DialogResult.Cancel) { return; } } CommonUtil.ShowProcessing("正在处理中,请稍候...", this, (obj) => { ZipFileTools.UnZipSZL(filePath, copyPath); }, null); } catch (Exception ex) { PublicClass.ShowMessageOk(ex.Message); } finally { LoadVideoFiles(); } } }
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 = "已下载"; } } }
/// <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; } }
/// <summary> /// 还原作业文件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnRestoreJob_Click(object sender, EventArgs e) { var fileName = string.Empty; var fileFullPath = string.Empty; var myJob = new M_MyJob(); var listMyJob = new List <M_MyJob>(); DialogResult dialogResult = ofdOpenFile.ShowDialog(); if (dialogResult == DialogResult.Cancel) { return; } try { fileFullPath = ofdOpenFile.FileName; fileName = Path.GetFileNameWithoutExtension(fileFullPath); InitialStudentDir(fileName); CommonUtil.ShowProcessing("正在处理中,请稍候...", this, (obj) => { ZipFileTools.UnZipSZL(fileFullPath, PublicClass.StudentDir); #region 初始化作业信息 myJob.JobNo = "1"; myJob.RealName = PublicClass.SowerExamPlugn.GetParaValue(PublicClass.StudentDir, "作业信息", "RealName"); myJob.ShowScore = PublicClass.SowerExamPlugn.GetParaValue(PublicClass.StudentDir, "作业信息", "ShowScore"); myJob.ShowAnalysis = PublicClass.SowerExamPlugn.GetParaValue(PublicClass.StudentDir, "作业信息", "ShowAnalysis"); myJob.ExamMode = PublicClass.SowerExamPlugn.GetParaValue(PublicClass.StudentDir, "作业信息", "ExamMode"); myJob.CreateTime = PublicClass.SowerExamPlugn.GetParaValue(PublicClass.StudentDir, "作业信息", "CreateTime"); myJob.IsAllowReSubmitScore = PublicClass.SowerExamPlugn.GetParaValue(PublicClass.StudentDir, "作业信息", "IsAllowReSubmitScore"); myJob.AllowReSubmitScoreCount = publicClass.IntParse(PublicClass.SowerExamPlugn.GetParaValue(PublicClass.StudentDir, "作业信息", "AllowReSubmitScoreCount")); myJob.HWSubmitTimeType = PublicClass.SowerExamPlugn.GetParaValue(PublicClass.StudentDir, "作业信息", "HWSubmitTimeType"); myJob.CourseName = PublicClass.SowerExamPlugn.GetParaValue(PublicClass.StudentDir, "作业信息", "CourseName"); myJob.ChapterName = PublicClass.SowerExamPlugn.GetParaValue(PublicClass.StudentDir, "作业信息", "ChapterName"); myJob.HWName = PublicClass.SowerExamPlugn.GetParaValue(PublicClass.StudentDir, "作业信息", "HWName"); myJob.EnvFileName = PublicClass.SowerExamPlugn.GetParaValue(PublicClass.StudentDir, "作业信息", "EnvFileName"); myJob.FileName = PublicClass.SowerExamPlugn.GetParaValue(PublicClass.StudentDir, "作业信息", "FileName"); myJob.FilePath = PublicClass.SowerExamPlugn.GetParaValue(PublicClass.StudentDir, "作业信息", "FilePath"); myJob.IsEnable = PublicClass.SowerExamPlugn.GetParaValue(PublicClass.StudentDir, "作业信息", "IsEnable"); myJob.IsScoreToCenter = PublicClass.SowerExamPlugn.GetParaValue(PublicClass.StudentDir, "作业信息", "IsScoreToCenter"); myJob.ManagerName = PublicClass.SowerExamPlugn.GetParaValue(PublicClass.StudentDir, "作业信息", "ManagerName"); myJob.IsCaculateTime = PublicClass.SowerExamPlugn.GetParaValue(PublicClass.StudentDir, "作业信息", "IsCaculateTime"); myJob.ClassName = PublicClass.SowerExamPlugn.GetParaValue(PublicClass.StudentDir, "作业信息", "ClassName"); myJob.SpecialtyID = PublicClass.SowerExamPlugn.GetParaValue(PublicClass.StudentDir, "作业信息", "SpecialtyID"); myJob.CityID = PublicClass.SowerExamPlugn.GetParaValue(PublicClass.StudentDir, "作业信息", "CityID"); myJob.PublicUserID = PublicClass.SowerExamPlugn.GetParaValue(PublicClass.StudentDir, "作业信息", "PublicUserID"); myJob.ExamStartDateTime = PublicClass.SowerExamPlugn.GetParaValue(PublicClass.StudentDir, "作业信息", "ExamStartDateTime"); myJob.ExamEndDateTime = PublicClass.SowerExamPlugn.GetParaValue(PublicClass.StudentDir, "作业信息", "ExamEndDateTime"); myJob.IsPay = PublicClass.SowerExamPlugn.GetParaValue(PublicClass.StudentDir, "作业信息", "IsPay"); myJob.IsSingleGrade = PublicClass.SowerExamPlugn.GetParaValue(PublicClass.StudentDir, "作业信息", "IsSingleGrade"); myJob.JobDownLoadState = PublicClass.SowerExamPlugn.GetParaValue(PublicClass.StudentDir, "作业信息", "JobDownLoadState"); myJob.ScoreSubmitted = PublicClass.SowerExamPlugn.GetParaValue(PublicClass.StudentDir, "作业信息", "ScoreSubmitted"); myJob.ClassID = publicClass.IntParse(PublicClass.SowerExamPlugn.GetParaValue(PublicClass.StudentDir, "作业信息", "ClassID")); myJob.AccountDownLoadState = PublicClass.SowerExamPlugn.GetParaValue(PublicClass.StudentDir, "作业信息", "AccountDownLoadState"); myJob.IsUploadAnswerFile = PublicClass.SowerExamPlugn.GetParaValue(PublicClass.StudentDir, "作业信息", "IsUploadAnswerFile"); #endregion listMyJob.Add(myJob); PublicClass.oMyJob = myJob; PublicClass.JobType = JobType.ShiJuan; }, null); dgvResult.AutoGenerateColumns = false; dgvResult.DataSource = listMyJob; btnDoJob.Enabled = true; } catch (Exception ex) { LogHelper.WriteLog(typeof(frmHomeWork), ex); } }
/// <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; } }