paperhelper.cs
来自「本在线考试系统采用了面向对象的分析和设计」· CS 代码 · 共 57 行
CS
57 行
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml;
using System.Xml.Xsl;
using System.Xml.XPath;
using System.IO;
using ExaminationSystem.BLL.Domain;
using ExaminationSystem.BLL.Service;
/// <summary>
/// PaperTranslateHelper 的摘要说明
/// </summary>
public class PaperHelper
{
public static string TranslateXmlToHtmlString(string xml, string xslFilePath)
{
XmlReader reader = XmlReader.Create(new StringReader(xml));
XPathDocument xpathDoc = new XPathDocument(reader);
XslCompiledTransform xslt = new XslCompiledTransform();
XsltSettings setting = new XsltSettings();
setting.EnableScript = true;
xslt.Load(HttpContext.Current.Server.MapPath(xslFilePath), setting, new XmlUrlResolver());
StringWriter writer = new StringWriter();
xslt.Transform(xpathDoc, null, writer);
return HttpContext.Current.Server.HtmlDecode(writer.ToString());
}
public static void SaveAnswer(HttpContext context)
{
//Student student = new StudentService().GetById(long.Parse(context.Request.Form["ID"].ToString()));
QuestionService service = new QuestionService();
foreach (String key in context.Request.Form.AllKeys)
{
long questionId = 0;
if (long.TryParse(key, out questionId))
{
service.GetById(questionId).StudentAnswer = context.Request.Form[key];
}
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?