101 lines
4.2 KiB
C#
101 lines
4.2 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using System.Web;
|
||
|
||
namespace VRS.Handler
|
||
{
|
||
/// <summary>
|
||
/// UserSubject 的摘要说明
|
||
/// </summary>
|
||
public class UserSubject : BasePage, IHttpHandler
|
||
{
|
||
DataService.BLL.admin_user bll_user = new DataService.BLL.admin_user();
|
||
DataService.BLL.pro_fault bll_fault = new DataService.BLL.pro_fault();
|
||
DataService.BLL.pro_subject_batch_user bll_subject_batch_user = new DataService.BLL.pro_subject_batch_user();
|
||
DataService.BLL.pro_fault_exam bll_fault_exam = new DataService.BLL.pro_fault_exam();
|
||
DataService.BLL.admin_log log = new DataService.BLL.admin_log();
|
||
DataService.BLL.pro_fault_batch_user bll_fault_batch_user = new DataService.BLL.pro_fault_batch_user();
|
||
DataService.BLL.pro_fault_exam_paper bll_fault_exam_paper = new DataService.BLL.pro_fault_exam_paper();
|
||
|
||
|
||
public override void ProcessRequest(HttpContext context)
|
||
{
|
||
context.Response.ContentType = "text/plain";
|
||
string id = context.Request.Params["id"];
|
||
if (string.IsNullOrEmpty(id))
|
||
{
|
||
context.Response.Write(GetJsonWithCode(APICode.Fail, "登录账号,参数 id不能为空!"));
|
||
context.Response.End();
|
||
}
|
||
/*
|
||
if (id.ToLower() == "all")
|
||
{
|
||
context.Response.Write(GetJsonWithCode(APICode.Success, bll_fault_exam.GetModelList("")));
|
||
context.Response.End();
|
||
}*/
|
||
var user = bll_user.GetModelByJobNumber(id);
|
||
if (null == user)
|
||
{
|
||
context.Response.Write(GetJsonWithCode(APICode.Fail, "学员不存在,账号:" + id));
|
||
context.Response.End();
|
||
}
|
||
|
||
|
||
|
||
//故障科目3D故障点
|
||
//已配置批次和人员
|
||
var query = " 1=1 and batch_id in (select batch_id from pro_exam_batch where state = 1) and login_name='" + id + "' ";
|
||
//且没有考试
|
||
query = query + " and not exists(select * from pro_result where pro_result.batch_id = pro_fault_batch_user.batch_id and pro_fault_batch_user.login_name = pro_result.login_name and pro_result.subject_id = '10003') ";
|
||
var fault_batch_user = bll_fault_batch_user.GetModelList(query).FirstOrDefault();
|
||
|
||
//故障现象考试
|
||
var fault_paper_list = bll_fault_exam_paper.GetListExamPaper(user.login_name).Tables[0];
|
||
|
||
var subject_batch = bll_subject_batch_user.GetListExamPaper(user.login_name).Tables[0];
|
||
if (subject_batch.Rows.Count <= 0 && null == fault_batch_user && fault_paper_list.Rows.Count <= 0)
|
||
{
|
||
log.write_user_log(user, "该学员没有配置科目考试或者已经考过试," + "学号:" + user.login_name + " 姓名:" + user.real_name);
|
||
context.Response.Write(GetJsonWithCode(APICode.Fail, "该学员没有配置科目考试或者已经考过试," + "学号:" + user.login_name + " 姓名:" + user.real_name));
|
||
context.Response.End();
|
||
}
|
||
else
|
||
{
|
||
List<string> list = new List<string>();
|
||
for (var i = 0; i < subject_batch.Rows.Count; i++)
|
||
{
|
||
var row = subject_batch.Rows[i];
|
||
var subject_id = row["subject_id"].ToString();
|
||
if (!list.Contains(subject_id))
|
||
{
|
||
list.Add(subject_id);
|
||
}
|
||
}
|
||
if (null != fault_batch_user)
|
||
{
|
||
list.Add("10003");
|
||
}
|
||
if (fault_paper_list.Rows.Count > 0)
|
||
{
|
||
list.Add("00003");
|
||
}
|
||
var obj = new
|
||
{
|
||
subject = string.Join(",", list.ToArray())
|
||
};
|
||
|
||
context.Response.Write(GetJsonWithCode(APICode.Success, obj));
|
||
context.Response.End();
|
||
}
|
||
}
|
||
|
||
public new bool IsReusable
|
||
{
|
||
get
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
}
|
||
} |