/// <summary> /// 修改Spoken试卷包xml /// </summary> /// <param name="kjsForder"></param> private void editSpokenPaper(string kjsForder, string sqmm, PaperEntity pe) { //修改paper.xml FileInfo[] filePaperXmlList = new DirectoryInfo(kjsForder).GetFiles("paper.xml"); FileInfo filePaperXml = filePaperXmlList[0]; //修改试卷代码 XmlHelper.Update(filePaperXml.FullName, "/Paper/PaperInfo/PaperNO", "", pe.paperNo); //修改试卷小题代码 try { XmlDocument doc = new XmlDocument(); doc.Load(filePaperXml.FullName); XmlElement xe = doc.SelectSingleNode("/Paper/QuestionList") as XmlElement; XmlNodeList xnl = xe.ChildNodes; int i = 0; foreach (XmlNode xn in xnl) { XmlNode xnQuestionNO = xn.SelectSingleNode("QuestionNO"); XmlElement xe01 = (XmlElement)xnQuestionNO; xe01.InnerText = pe.questionNo[i]; doc.Save(filePaperXml.FullName); i++; } //压缩加密spoken试卷包 DirectoryInfo di = new DirectoryInfo(kjsForder); string saveFile = txt_save.Text.Trim() + "\\" + di.Name + ".ksj"; //压缩ksj FileCompress.CompressFiles(kjsForder, saveFile, SPOKENPWD, null, true); //固定密码加密kjs int result3 = SecModule.FileVerify(SPOKENPWD, saveFile); //第二次压缩成zip string saveFile1 = saveFile.Replace(".ksj", ".zip"); FileCompress.CompressFiles(saveFile, saveFile1, SPOKENPWD, null, true); //授权码加密zip int result2 = SecModule.FileVerify(sqmm, saveFile1); //第三压缩成zip string saveFile2 = saveFile.Replace(".ksj", ".zip"); FileCompress.CompressFiles(saveFile1, txt_save.Text.Trim(), SPOKENPWD, null, true); //授权码加密zip //int result2 = SecModule.FileVerify(sqmm, saveFile1); } catch { } }
/// <summary> /// 解压nets试卷包 /// </summary> /// <param name="filePaper"></param> /// <param name="fileCode"></param> /// <param name="tempPath"></param> private void unZipNetsPaper(FileInfo[] netsPaperFileList) { string tempPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "netsTemp"); FileHelper.DeleteFolder(tempPath); Directory.CreateDirectory(tempPath); foreach (FileInfo f in netsPaperFileList) { string filePaper = f.FullName; string fileCode = filePaper.Replace(".otp", ".osqm"); if (f.Extension.Equals(".otp")) { //1、复制源文件到临时目录 string filePaperTemp = Path.Combine(tempPath, new FileInfo(filePaper).Name); string fileCodeTemp = Path.Combine(tempPath, new FileInfo(fileCode).Name); FileHelper.FileCopy(filePaper, filePaperTemp, true); FileHelper.FileCopy(fileCode, fileCodeTemp, true); //2、固定密码解密otp,并解压 string fileName = f.Name.Replace(".otp", ""); string paperTemp = tempPath + "\\paperTemp\\" + fileName; int result1 = SecModule.FileVerify(NETSPWD, filePaperTemp); FileCompress.DecompressFile(filePaperTemp, paperTemp, NETSPWD, null); //3、固定密码解密osqm,并解压 string codeTemp = tempPath + "\\codeTemp\\" + fileName; int result2 = SecModule.FileVerify(NETSPWD, fileCodeTemp); FileCompress.DecompressFile(fileCodeTemp, codeTemp, NETSPWD, null); //4、授权码解密试卷包,并解压 string sqmm = XmlHelper.Read(codeTemp + "\\Codeinfo.xml", "CodeInfo/CodeData/sqmm", ""); FileInfo[] fileList = new DirectoryInfo(paperTemp).GetFiles(); foreach (FileInfo fi in fileList) { if (fi.Extension.Equals(".zip")) { int a = SecModule.FileVerify(sqmm, fi.FullName); FileCompress.DecompressFile(fi.FullName, paperTemp, NETSPWD, null); } } //5、固定密码解密kjs,并解压 string kjsForder = ""; fileList = new DirectoryInfo(paperTemp).GetFiles(); foreach (FileInfo fi in fileList) { if (fi.Extension.Equals(".kjs")) { int result3 = SecModule.FileVerify(NETSPWD, fi.FullName); kjsForder = paperTemp + "\\" + fi.Name.Replace(".kjs", ""); FileCompress.DecompressFile(fi.FullName, kjsForder, NETSPWD, null); //提取nets试卷xml中数据 FileInfo[] filePaperXmlList = new DirectoryInfo(paperTemp).GetFiles("PaperInfo.xml"); FileInfo filePaperXml = filePaperXmlList[0]; XmlElement xe = XmlHelper.GetXmlElement(filePaperXml.FullName, "/PaperInfo/PaperList"); XmlNodeList xnl = xe.ChildNodes; PaperEntity pe = new PaperEntity();; foreach (XmlNode xn in xnl) { pe.paperNo = xn.SelectSingleNode("sjdm").InnerText; } XmlElement xe1 = XmlHelper.GetXmlElement(filePaperXml.FullName, "/PaperInfo/ItemList"); XmlNodeList xnl1 = xe1.ChildNodes; List <string> lists = new List <string>(); foreach (XmlNode xn1 in xnl1) { lists.Add(xn1.SelectSingleNode("xtdm").InnerText); } pe.questionNo = lists; listPaperEntity.Add(pe); } } } //DoPaper(paperTemp + "\\PaperInfo.xml", kjsForder + "\\js\\requestData.json"); } }