/// <summary> /// 加密成绩输出. /// </summary> /// <param name='sheet_name'> /// 表格sheet名字,即本案例名称. /// </param> public static void ScoreOutput(string sheet_name) { //For Excel List <string> columnName = new List <string>(); columnName.Add("序号"); columnName.Add("操作说明"); columnName.Add("得分"); List <List <string> > outputInfo = new List <List <string> >(); List <string> singleStep = new List <string>(); //For TXT string encryptedString = ""; //Time and File Path. string deskPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); string timeToWirte = ""; string currentTime = ""; currentTime += System.DateTime.Now.Year + "_"; timeToWirte += System.DateTime.Now.Year + "年"; currentTime += System.DateTime.Now.Month + "_"; timeToWirte += System.DateTime.Now.Month + "月"; currentTime += System.DateTime.Now.Day + "_"; timeToWirte += System.DateTime.Now.Day + "日 "; currentTime += System.DateTime.Now.Hour + "_"; timeToWirte += System.DateTime.Now.Hour + ":"; currentTime += System.DateTime.Now.Minute + "_"; timeToWirte += System.DateTime.Now.Minute + ":"; currentTime += System.DateTime.Now.Second; timeToWirte += System.DateTime.Now.Second; string fileName = FuncPara.studentName + "-" + FuncPara.studentID + "-" + currentTime; //Score Information string indexStr = ""; string descriptionStr = ""; string socreStr = ""; for (int i = 0; i < StepDiscription.Count; i++) { singleStep = new List <string>(); indexStr = i.ToString(); descriptionStr = StepDiscription[i]; if (OperationState[i]) { socreStr = ScorePercent[i].ToString(); } else { socreStr = "0"; } encryptedString += indexStr + "\t" + descriptionStr + "\t" + socreStr + "\n"; singleStep.Add(indexStr); singleStep.Add(descriptionStr); singleStep.Add(socreStr); outputInfo.Add(singleStep); } //总成绩,姓名,学号,考试日期 float tempScore = 0; for (int i = 0; i < OperationState.Count; i++) { if (OperationState[i]) { tempScore += ScorePercent[i]; } } FuncPara.examScore = (float)Math.Round(tempScore, 0); indexStr = ""; descriptionStr = sheet_name + "总成绩"; socreStr = Convert.ToInt32(FuncPara.examScore).ToString(); singleStep = new List <string>(); encryptedString += indexStr + "\t" + descriptionStr + "\t" + socreStr + "\n"; singleStep.Add(indexStr); singleStep.Add(descriptionStr); singleStep.Add(socreStr); outputInfo.Add(singleStep); indexStr = ""; descriptionStr = "姓名"; socreStr = FuncPara.studentName; singleStep = new List <string>(); encryptedString += indexStr + "\t" + descriptionStr + "\t" + socreStr + "\n"; singleStep.Add(indexStr); singleStep.Add(descriptionStr); singleStep.Add(socreStr); outputInfo.Add(singleStep); indexStr = ""; descriptionStr = "学号"; socreStr = FuncPara.studentID; singleStep = new List <string>(); encryptedString += indexStr + "\t" + descriptionStr + "\t" + socreStr + "\n"; singleStep.Add(indexStr); singleStep.Add(descriptionStr); singleStep.Add(socreStr); outputInfo.Add(singleStep); indexStr = ""; descriptionStr = "考试日期"; socreStr = timeToWirte; singleStep = new List <string>(); encryptedString += indexStr + "\t" + descriptionStr + "\t" + socreStr + "\n"; singleStep.Add(indexStr); singleStep.Add(descriptionStr); singleStep.Add(socreStr); outputInfo.Add(singleStep); //Write To File. ExcelOperator excelWriter = new ExcelOperator(); excelWriter.ExcelWriter(deskPath + "\\" + fileName + ".xls", sheet_name, columnName, outputInfo, true); jiami encryptOutput = new jiami(); encryptOutput.WriteTxt(deskPath, fileName, encryptedString); }