/// <summary> /// 更新科目参数 /// </summary> private void UpdateSubjectProp() { M_SubjectProp updateSubject = new M_SubjectProp(); //if (PublicClass.oSubjectProp.PaperType == "1") //{ // PublicClass.oSubjectProp.PresetPaperID = Convert.ToInt32(PublicClass.SowerExamPlugn.GetParaValue(PublicClass.StudentDir, "试卷参数", "FixPaperID")); //} updateSubject.PresetPaperID = PublicClass.oSubjectProp.PresetPaperID; updateSubject.ExamMode = PublicClass.oSubjectProp.ExamMode; updateSubject.PaperType = PublicClass.oSubjectProp.PaperType; bSubjectProp.UpdateSubjectProp(updateSubject); }
public void UpdateSubjectProp(M_SubjectProp subjectProp) { string sql = "UPDATE 考试信息 SET 套卷ID = @套卷ID , 考试模式 = @考试模式 , 组卷类型 = @组卷类型"; //string sql = "UPDATE 考试信息 SET 套卷ID = 2 , 考试模式 = 2 , 组卷类型 = 2"; SQLiteHelper.InitialConnection(PublicClass.TopicDBFileName_SDBT); SQLiteParameter[] param = { new SQLiteParameter("@套卷ID", subjectProp.PresetPaperID), new SQLiteParameter("@考试模式", subjectProp.ExamMode), new SQLiteParameter("@组卷类型", subjectProp.PaperType), }; int result = SQLiteHelper.ExecuteNonQuery(sql, param); }
/// <summary> /// 加载题库文件 /// </summary> private void LoadTopicDB() { try { listSubject.Clear(); DirectoryInfo directoryInfo = new DirectoryInfo(Application.StartupPath + @"\data"); FileInfo[] fileInfo = directoryInfo.GetFiles("*.sdbt"); //只取.sdbt文件 foreach (FileInfo item in fileInfo) { if (item.Extension.ToLower() == ".sdbt") { string subjectId = Path.GetFileNameWithoutExtension(item.Name); string[] temp = subjectId.Split('_'); if (temp.Length == 0) { continue; } if (temp[0] != PublicClass.StudentCode) { continue; } M_SubjectProp mSubjectProp = bSubjectProp.GetSubjectProp(Path.GetFileName(item.Name)); M_ExerciseSubjectDetail subject = new M_ExerciseSubjectDetail(); subject.TopicDBCode = mSubjectProp.TopicDBCode; subject.SubjectName = mSubjectProp.SubjectName; subject.TopicDBVersion = mSubjectProp.TopicDBVersion; subject.FileName = mSubjectProp.EnvFileName; subject.TopicFilePath = item.FullName; subject.VideoFileName = Path.GetFileNameWithoutExtension(mSubjectProp.MediaPackageFileName); listSubject.Add(subject); } } DataBindTopicDB(); } catch (Exception ex) { LogHelper.WriteLog(typeof(frmExercise), ex); CommonUtil.WriteLog(ex); } }
private void cboSubject_SelectedIndexChanged(object sender, EventArgs e) { if (cboSubject.SelectedIndex == 0) { lbTaoJuan.DataBindings.Clear(); return; } try { string TopicDBFileName_SDBT = string.Format(@"{0}.sdbt", cboSubject.SelectedValue); M_SubjectProp subjectProp = bSubjectProp.GetSubjectProp(TopicDBFileName_SDBT); if (subjectProp.PaperType == "0") { lblPaperType.Text = "随机组卷:随机抽取试题组成一套试卷"; grpPaperInfo.Visible = false; } else { lblPaperType.Text = "固定套卷:按固定模式组成一套试卷"; grpPaperInfo.Visible = true; TaoJuan = bTaoJuanXinXi.GetTaoJuanXinXi(TopicDBFileName_SDBT); if (TaoJuan.Count > 0) { lbTaoJuan.DataSource = TaoJuan; lbTaoJuan.DisplayMember = "TaoJuanMingCheng"; lbTaoJuan.ValueMember = "TaoJuanID"; lbTaoJuan.SelectedIndex = 0; } } } catch (Exception ex) { LogHelper.WriteLog(typeof(frmExercise), ex); CommonUtil.WriteLog(ex); } }
public M_SubjectProp GetSubjectProp(string topicDBFilePath) { M_SubjectProp entity = new M_SubjectProp(); string CONNECTION_STRING = string.Format(@"data source={0}\data\{1};password={2};polling=false;failifmissing=true", Application.StartupPath, topicDBFilePath, PublicClass.PasswordTopicDB); string sql = "select * from 考试信息"; SQLiteConnection connection = new SQLiteConnection(CONNECTION_STRING); SQLiteCommand command = new SQLiteCommand(sql, connection); connection.Open(); SQLiteDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection); if (reader.Read()) { #region 初始化 entity.ExamNumber = "6515999999010001"; entity.StudentName = "模拟考生"; //题库代码 entity.TopicDBCode = reader["题库代码"].ToString(); //试卷名称 entity.PaperName = string.Format("{0}_{1}.dat", entity.TopicDBCode, entity.ExamNumber); //课程名称 entity.SubjectName = reader["课程名称"].ToString(); //考试时间 entity.TotalExamTime = Convert.ToInt32(reader["考试时间"]); //显示成绩 entity.ShowScore = Convert.ToBoolean(reader["显示成绩"]); //抽题参数 //是否套卷 //套卷ID entity.PresetPaperID = Convert.ToInt32(reader["套卷ID"]); //显示题型标题 //XML版约定格式 //显示评析 entity.ShowAnalysis = Convert.ToBoolean(reader["显示评析"]); //上机题目录按小题分配 //检查office版本 //检查office安装 //Updating //版本 entity.TopicDBVersion = reader["版本"].ToString(); //相关帐套 //帐套初始日期 entity.UFAccountInitDate = reader["账套初始日期"].ToString(); //使用帐套初始日期 entity.UseUFAccountInitDate = Convert.ToBoolean(reader["使用账套初始日期"]); //使用回车分割填空 //组卷类型 entity.PaperType = reader["组卷类型"].ToString(); //方案ID //应急题库 //使用统计分类 //EnvFileName entity.EnvFileName = reader["EnvFileName"].ToString(); //EnvFileVersion entity.EnvFileVersion = reader["EnvFileVersion"].ToString(); //CreatePaperMode entity.CreatePaperMode = Convert.ToInt32(reader["CreatePaperMode"]); //考试模式 entity.ExamMode = reader["考试模式"].ToString(); entity.MediaPackageFileName = reader["MediaPackageFileName"].ToString(); //UserLockerIDs //EnableMondifyExamMode //发布类型 //分阶段考试 //套卷是否乱序 //entity.RequireEnvFile = true; //entity.CreateTopicSubDir = false; //entity.UFTopicTypeExists = false; //entity.ShowReadme = false; //entity.ReadmeInOfficialExam = ""; //entity.ReadmeInSimulativelExam = ""; //entity.TimeMode = 0; //entity.AllowHideNavBar = false; //entity.IgnoreTopicTypeUseNavButton = false; //entity.AutoSaveInterval = 0; #endregion if (reader != null) { reader.Close(); reader.Dispose(); } } if (command != null) { command.Cancel(); command.Dispose(); command = null; } if (connection != null) { if (connection.State == ConnectionState.Open) { connection.Close(); } connection.Dispose(); connection = null; } return(entity); }
/// <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; } }
public void UpdateSubjectProp(M_SubjectProp subjectProp) { dal.UpdateSubjectProp(subjectProp); }
/// <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(); } } }