Пример #1
0
        /// <summary>
        /// 转换事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_change_Click(object sender, EventArgs e)
        {
            string tempPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "temp_nets_paper");

            FileHelper.DeleteFolder(tempPath);
            Directory.CreateDirectory(tempPath);

            if (!File.Exists(filePaper) || !File.Exists(fileCode))
            {
                MessageBox.Show("请选择试卷包和授权码!");
                return;
            }
            //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 paperTemp = tempPath + "\\paperTemp";
            int    result1   = SecModule.FileVerify(PWD, filePaperTemp);

            FileCompress.DecompressFile(filePaperTemp, paperTemp, PWD, null);

            //3、固定密码解密osqm,并解压
            string codeTemp = tempPath + "\\codeTemp";
            int    result2  = SecModule.FileVerify(PWD, fileCodeTemp);

            FileCompress.DecompressFile(fileCodeTemp, codeTemp, PWD, 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, PWD, null);
                }
            }

            //5、固定密码解密kjs,并解压
            string kjsForder = "";

            fileList = new DirectoryInfo(paperTemp).GetFiles();
            foreach (FileInfo fi in fileList)
            {
                if (fi.Extension.Equals(".kjs"))
                {
                    int result3 = SecModule.FileVerify(PWD, fi.FullName);
                    kjsForder = paperTemp + "\\" + fi.Name.Replace(".kjs", "");
                    FileCompress.DecompressFile(fi.FullName, kjsForder, PWD, null);
                }
            }

            //DoPaper(paperTemp + "\\PaperInfo.xml", kjsForder + "\\js\\requestData.json");

            //打开文件夹
            System.Diagnostics.Process.Start("Explorer.exe", tempPath);
        }