⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 paperhelper.cs

📁 本在线考试系统采用了面向对象的分析和设计
💻 CS
字号:
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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -