gyhlw_dotnet/网站项目/VRS/Handler/SubjectResult2D.ashx.cs

160 lines
8.8 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Script.Serialization;
namespace VRS.Handler
{
/// <summary>
/// SubjectResult2D 的摘要说明
/// </summary>
public class SubjectResult2D : BasePage, IHttpHandler
{
DataService.BLL.admin_user bll_user = new DataService.BLL.admin_user();
DataService.BLL.pro_subject bll_subject = new DataService.BLL.pro_subject();
DataService.BLL.admin_log log = new DataService.BLL.admin_log();
DataService.BLL.pro_result_detail pro_result_detail = new DataService.BLL.pro_result_detail();
DataService.BLL.pro_subject_proc bll_subject_proc = new DataService.BLL.pro_subject_proc();
DataService.BLL.pro_fault_exam_paper_item bll_paper_item = new DataService.BLL.pro_fault_exam_paper_item();
DataService.BLL.pro_fault_exam_paper bll_fault_exam_paper = new DataService.BLL.pro_fault_exam_paper();
DataService.BLL.pro_exam_batch bll_pro_exam_batch = new DataService.BLL.pro_exam_batch();
DataService.BLL.pro_exam_batch bll_batch = new DataService.BLL.pro_exam_batch();
/*
public void ProcessRequest0(HttpContext context)
{
context.Response.ContentType = "text/plain";
string login_name = context.Request.Params["loginname"];//登录账号
string content = context.Request.Params["content"]; //备注内容
var user = bll_user.GetModelByJobNumber(login_name);
if (null == user)
{
context.Response.Write(GetJsonWithCode(APICode.Fail, "登录账号:" + login_name + ",的学员不存在!"));
context.Response.End();
}
log.write_user_log(user, "学员姓名:" + user.real_name + ",学员学号:" + login_name + ",故障现象考试内容:" + content);
var start_batch = bll_batch.GetModelList(" state =1 and grade='" + user.grade + "' and major='" + user.major + "'").FirstOrDefault();
if (null == start_batch)
{
log.write_user_log(user, "学员姓名:" + user.real_name + ",学员学号:" + login_name + ",故障现象考试批次不存在或未启用!");
context.Response.Write(GetJsonWithCode(APICode.Fail, "学员姓名:" + user.real_name + ",学员学号:" + login_name + ",故障现象考试考试批次不存在或未启用!"));
context.Response.End();
}
var exist_fault_exam_paper = bll_fault_exam_paper.GetModelList(" login_name='" + login_name + "' and state>0 and batch_id='" + start_batch.batch_id + "'").FirstOrDefault();
if (null != exist_fault_exam_paper)
{
log.write_user_log(user, "学员姓名:" + user.real_name + ",学员学号:" + login_name + "批次id" + start_batch.batch_id + ",批次名称:" + start_batch.batch_name + ",考试已经考过试!" + (exist_fault_exam_paper.state == 2 ? "分数:" + exist_fault_exam_paper.score : ""));
context.Response.Write(GetJsonWithCode(APICode.Fail, "学员姓名:" + user.real_name + ",学员学号:" + login_name + ",考试已经考过试!"));
context.Response.End();
}
var paper = bll_fault_exam_paper.GetModelList(" login_name='" + login_name + "' and state=0 and batch_id='" + start_batch.batch_id + "'").FirstOrDefault();
if (null == paper)
{
log.write_user_log(user, "学员姓名:" + user.real_name + ",学员学号:" + login_name + "批次id" + start_batch.batch_id + ",批次名称:" + start_batch.batch_name + ",故障现象考试未配置!");
context.Response.Write(GetJsonWithCode(APICode.Fail, "登录账号:" + login_name + ",故障现象考试未配置!"));
context.Response.End();
}
//exam_id,exam_title,原因分析,故障定位,排除方法$exam_id,exam_title,原因分析,故障定位,排除方法
var array = content.Split(new char[] { '$' }, StringSplitOptions.RemoveEmptyEntries);
var batch = bll_pro_exam_batch.GetModel(paper.batch_id);
var result = bll_fault_exam_paper.SaveResult(paper.paper_id, batch.sjms, content);
if (result > 0)
{
context.Response.Write(GetJsonWithCode(APICode.Success, "保存成绩成功!"));
context.Response.End();
}
else
{
context.Response.Write(GetJsonWithCode(APICode.Success, "保存成绩失败!"));
context.Response.End();
}
}
*/
public override void ProcessRequest(HttpContext context)
{
JavaScriptSerializer serializer = new JavaScriptSerializer();
StreamReader reader = new StreamReader(context.Request.InputStream);
//String decodeStr = HttpUtility.UrlDecode(reader.ReadToEnd());
var decodeStr = reader.ReadToEnd();
JavaScriptSerializer jss = new JavaScriptSerializer();
//将json字符串反序列化成一个Dictionary对象
Dictionary<String, String> dicParameter = jss.Deserialize<Dictionary<String, String>>(decodeStr);
var login_name = dicParameter["loginname"];
var content = dicParameter["content"];
var user = bll_user.GetModelByJobNumber(login_name);
if (null == user)
{
var admin = bll_user.GetModelByJobNumber("admin");
log.write_user_log(admin, "故障现象简答内容:" + decodeStr);
context.Response.Write(GetJsonWithCode(APICode.Fail, "登录账号:" + login_name + ",的学员不存在!"));
context.Response.End();
}
log.write_user_log(user, "学员姓名:" + user.real_name + ",学员学号:" + login_name + ",故障现象考试内容:" + content);
var start_batch = bll_batch.GetModelList(" state =1 ").FirstOrDefault();
if (null == start_batch)
{
log.write_user_log(user, "学员姓名:" + user.real_name + ",学员学号:" + login_name + ",故障现象考试批次不存在或未启用!");
context.Response.Write(GetJsonWithCode(APICode.Fail, "学员姓名:" + user.real_name + ",学员学号:" + login_name + ",故障现象考试考试批次不存在或未启用!"));
context.Response.End();
}
var exist_fault_exam_paper = bll_fault_exam_paper.GetModelList(" login_name='" + login_name + "' and state>0 and batch_id='" + start_batch.batch_id + "'").FirstOrDefault();
if (null != exist_fault_exam_paper)
{
log.write_user_log(user, "学员姓名:" + user.real_name + ",学员学号:" + login_name + "批次id" + start_batch.batch_id + ",批次名称:" + start_batch.batch_name + ",考试已经考过试!" + (exist_fault_exam_paper.state == 2 ? "分数:" + exist_fault_exam_paper.score : ""));
context.Response.Write(GetJsonWithCode(APICode.Fail, "学员姓名:" + user.real_name + ",学员学号:" + login_name + ",考试已经考过试!"));
context.Response.End();
}
var paper = bll_fault_exam_paper.GetModelList(" login_name='" + login_name + "' and state=0 and batch_id='" + start_batch.batch_id + "'").FirstOrDefault();
if (null == paper)
{
log.write_user_log(user, "学员姓名:" + user.real_name + ",学员学号:" + login_name + "批次id" + start_batch.batch_id + ",批次名称:" + start_batch.batch_name + ",故障现象考试未配置!");
context.Response.Write(GetJsonWithCode(APICode.Fail, "登录账号:" + login_name + ",故障现象考试未配置!"));
context.Response.End();
}
//exam_id^exam_title^原因分析^故障定位^排除方法$exam_id^exam_title^原因分析^故障定位^排除方法
var array = content.Split(new char[] { '$' }, StringSplitOptions.RemoveEmptyEntries);
var batch = bll_pro_exam_batch.GetModel(paper.batch_id);
var result = bll_fault_exam_paper.SaveResult(paper.paper_id, batch.sjms, content);
if (result > 0)
{
context.Response.Write(GetJsonWithCode(APICode.Success, "保存成绩成功!"));
context.Response.End();
}
else
{
context.Response.Write(GetJsonWithCode(APICode.Success, "保存成绩失败!"));
context.Response.End();
}
}
public new bool IsReusable
{
get
{
return false;
}
}
}
}