1979 lines
87 KiB
C#
1979 lines
87 KiB
C#
using Newtonsoft.Json;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Configuration;
|
||
using System.IO;
|
||
using System.Linq;
|
||
using System.Reflection;
|
||
using System.Text;
|
||
using System.Text.RegularExpressions;
|
||
using System.Web;
|
||
using VRS.Util;
|
||
using static Telerik.Web.UI.OrgChartStyles;
|
||
|
||
namespace VRS.Handler
|
||
{
|
||
/// <summary>
|
||
/// ResultDetail 的摘要说明
|
||
/// </summary>
|
||
public class ResultDetail : BaseHandler, IHttpHandler
|
||
{
|
||
DataService.BLL.admin_user bll = new DataService.BLL.admin_user();
|
||
|
||
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 bll_log = new DataService.BLL.admin_log();
|
||
DataService.BLL.pro_result bll_pro_result = new DataService.BLL.pro_result();
|
||
DataService.BLL.pro_result_detail bll_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.exam_result bll_exam_result = new DataService.BLL.exam_result();
|
||
DataService.BLL.exam_result_detail bll_exam_result_detail = new DataService.BLL.exam_result_detail();
|
||
|
||
DataService.BLL.exam_result_detail_shixun bll_exam_result_detail_shixun = new DataService.BLL.exam_result_detail_shixun();
|
||
DataService.BLL.exam_result_detail_config bll_exam_result_detail_config = new DataService.BLL.exam_result_detail_config();
|
||
|
||
DataService.BLL.exam_result_match bll_exam_result_match = new DataService.BLL.exam_result_match();
|
||
DataService.BLL.exam_config_answer bll_config_answer = new DataService.BLL.exam_config_answer();
|
||
DataService.BLL.exam_config_cache bll_config_cache = new DataService.BLL.exam_config_cache();
|
||
|
||
DataService.BLL.subsubject bll_subsubject = new DataService.BLL.subsubject();
|
||
DataService.BLL.subsubjectstep bll_subsubjectstep = new DataService.BLL.subsubjectstep();
|
||
|
||
public void ProcessRequest(HttpContext context)
|
||
{
|
||
baseContext = context;
|
||
context.Response.ContentType = "application/json";
|
||
CrossDomain();
|
||
//context.Response.ContentType = "text/plain";
|
||
if (null == context.Request["action"])
|
||
{
|
||
var result = GetResult(false, "缺少参数:action");
|
||
context.Response.Write(result);
|
||
context.Response.End();
|
||
}
|
||
string action = context.Request["action"];
|
||
switch (action)
|
||
{
|
||
|
||
//保存竞赛考试--智能制造工厂 配置得分
|
||
//case "saveconfig":
|
||
// saveMatchConfig(context);
|
||
// break;
|
||
|
||
//保存竞赛考试 平阴华玫或智能制造工厂、炭黑生产制造
|
||
case "savemathch":
|
||
saveMatch(context);
|
||
break;
|
||
|
||
//保存考试考核、实训考核(包含子科目) 【sjms 考试模式: 0 考试考核、 1 实训考核】
|
||
case "saveresult":
|
||
SaveExam(context);
|
||
break;
|
||
|
||
//保存带子科目的实训成绩---弃用
|
||
//case "saveresultsub":
|
||
//SaveExamSub(context);
|
||
//break;
|
||
|
||
|
||
//用户注册
|
||
case "reg":
|
||
RegUser(context);
|
||
break;
|
||
|
||
|
||
//用户登录
|
||
case "login":
|
||
LoginUser(context);
|
||
break;
|
||
|
||
//用户查询
|
||
case "queryUser":
|
||
QueryUser(context);
|
||
break;
|
||
|
||
//查询部门
|
||
case "querydepart":
|
||
QueryDepart(context);
|
||
break;
|
||
|
||
default:
|
||
var result = GetResult(false, "方法名不存在:" + action);
|
||
context.Response.Write(result);
|
||
break;
|
||
}
|
||
}
|
||
|
||
|
||
|
||
/// <summary>
|
||
/// 智能制造工厂 配置得分 user_id
|
||
/// </summary>
|
||
//public void saveMatchConfig(HttpContext context)
|
||
//{
|
||
// var user_id = context.Request.Params["user_id"];
|
||
// var ret = string.Empty;
|
||
// string sql_config = " 1=1 ";
|
||
// string sql_config_o = " 1=1 ";
|
||
// if (string.IsNullOrEmpty(user_id))
|
||
// {
|
||
// ret = GetResult(false, "user_id参数不能为空");
|
||
// context.Response.Write(ret);
|
||
// context.Response.End();
|
||
// }
|
||
// else
|
||
// {
|
||
// sql_config_o += " and user_id='" + user_id + "'";
|
||
// }
|
||
// var mark = context.Request.Params["mark"];
|
||
// if (string.IsNullOrEmpty(mark))
|
||
// {
|
||
// ret = GetResult(false, "user_id参数不能为空");
|
||
// context.Response.Write(ret);
|
||
// context.Response.End();
|
||
// }
|
||
// else
|
||
// {
|
||
// DateTime datetime = DateTime.Now;
|
||
// sql_config += " and mark='" + mark + "'";
|
||
// sql_config_o += " and user_id='" + user_id + "' or ( start_time<'" + datetime + "' and expire_time>'" + datetime + "' ) ";
|
||
// }
|
||
|
||
// List<ConfigItem> listConfig = new List<ConfigItem>();
|
||
// try
|
||
// {
|
||
// //listConfig = JsonConvert.DeserializeObject<List<ConfigItem>>(data);
|
||
|
||
|
||
// var config_list = bll_config_answer.GetModelList(sql_config);
|
||
// var config_cache_list = bll_config_cache.GetModelList(sql_config_o).ToList();
|
||
// dxgl_list dt = new dxgl_list();
|
||
// foreach (var config in config_list)
|
||
// {
|
||
// string answer = config.answer;
|
||
// mark = config.mark;
|
||
// var cc = config_cache_list.Where(x => x.mark == mark).FirstOrDefault();
|
||
|
||
// if (config.mark == "DB-IotLite_yx")
|
||
// {
|
||
// ConfigItem item = new ConfigItem();
|
||
// DBIotLiteYx og = JsonConvert.DeserializeObject<DBIotLiteYx>(config.answer);
|
||
|
||
// DBIotLiteYx nw = JsonConvert.DeserializeObject<DBIotLiteYx>(cc.mark_value);
|
||
// if (CompareObject.IsConsistent(og, nw, dt, out string field, out string field_yes, out string field_no))
|
||
// {
|
||
// listConfig.Add(GetConfigItem("DB-IotLite_yx", "DB-IotLite网关有线", 4, 4, field, field_yes, field_no));
|
||
// }
|
||
// else
|
||
// {
|
||
// listConfig.Add(GetConfigItem("DB-IotLite_yx", "DB-IotLite网关有线", 4, 0, field, field_yes, field_no));
|
||
// }
|
||
|
||
// }
|
||
// if (config.mark == "DB-IotLite_wx")
|
||
// {
|
||
// DBIotLiteWx og = JsonConvert.DeserializeObject<DBIotLiteWx>(config.answer);
|
||
// DBIotLiteWx nw = JsonConvert.DeserializeObject<DBIotLiteWx>(cc.mark_value);
|
||
// if (CompareObject.IsConsistent(og, nw, dt, out string field, out string field_yes, out string field_no))
|
||
// {
|
||
// listConfig.Add(GetConfigItem("DB-IotLite_wx", "DB-IotLite网关无线", 3, 3, field, field_yes, field_no));
|
||
// }
|
||
// else
|
||
// {
|
||
// listConfig.Add(GetConfigItem("DB-IotLite_wx", "DB-IotLite网关无线", 3, 0, field, field_yes, field_no));
|
||
// }
|
||
// }
|
||
// if (config.mark == "CHGYWG_yx")
|
||
// {
|
||
// CHGYWGYx og = JsonConvert.DeserializeObject<CHGYWGYx>(config.answer);
|
||
// CHGYWGYx nw = JsonConvert.DeserializeObject<CHGYWGYx>(cc.mark_value);
|
||
// if (CompareObject.IsConsistent(og, nw, dt, out string field, out string field_yes, out string field_no))
|
||
// {
|
||
// listConfig.Add(GetConfigItem("CHGYWG_yx", "斥候工业网关有线", 3, 3, field, field_yes, field_no));
|
||
// }
|
||
// else
|
||
// {
|
||
// listConfig.Add(GetConfigItem("CHGYWG_yx", "斥候工业网关有线", 3, 0, field, field_yes, field_no));
|
||
// }
|
||
// }
|
||
// if (config.mark == "CHGYWG_wx")
|
||
// {
|
||
// CHGYWGWx og = JsonConvert.DeserializeObject<CHGYWGWx>(config.answer);
|
||
// CHGYWGWx nw = JsonConvert.DeserializeObject<CHGYWGWx>(cc.mark_value);
|
||
// if (CompareObject.IsConsistent(og, nw, dt, out string field, out string field_yes, out string field_no))
|
||
// {
|
||
// listConfig.Add(GetConfigItem("CHGYWG_wx", "斥候工业网关无线", 3, 3, field, field_yes, field_no));
|
||
// }
|
||
// else
|
||
// {
|
||
// listConfig.Add(GetConfigItem("CHGYWG_wx", "斥候工业网关无线", 3, 0, field, field_yes, field_no));
|
||
// }
|
||
// }
|
||
// if (config.mark == "CKFWQ_yx")
|
||
// {
|
||
// CKFWQyx og = JsonConvert.DeserializeObject<CKFWQyx>(config.answer);
|
||
// CKFWQyx nw = JsonConvert.DeserializeObject<CKFWQyx>(cc.mark_value);
|
||
// if (CompareObject.IsConsistent(og, nw, dt, out string field, out string field_yes, out string field_no))
|
||
// {
|
||
// listConfig.Add(GetConfigItem("CKFWQ_yx", "串口服务器有线", 2, 2, field, field_yes, field_no));
|
||
// }
|
||
// else
|
||
// {
|
||
// listConfig.Add(GetConfigItem("CKFWQ_yx", "串口服务器有线", 2, 0, field, field_yes, field_no));
|
||
// }
|
||
// }
|
||
// if (config.mark == "CKFWQ_wx")
|
||
// {
|
||
// CKFWQWx og = JsonConvert.DeserializeObject<CKFWQWx>(config.answer);
|
||
// CKFWQWx nw = JsonConvert.DeserializeObject<CKFWQWx>(cc.mark_value);
|
||
// if (CompareObject.IsConsistent(og, nw, dt, out string field, out string field_yes, out string field_no))
|
||
// {
|
||
// listConfig.Add(GetConfigItem("CKFWQ_wx", "串口服务器无线", 2, 2, field, field_yes, field_no));
|
||
// }
|
||
// else
|
||
// {
|
||
// listConfig.Add(GetConfigItem("CKFWQ_wx", "串口服务器无线", 2, 0, field, field_yes, field_no));
|
||
// }
|
||
// }
|
||
// if (config.mark == "GYWZ_yx")
|
||
// {
|
||
|
||
// GYWZyx og = JsonConvert.DeserializeObject<GYWZyx>(config.answer);
|
||
// GYWZyx nw = JsonConvert.DeserializeObject<GYWZyx>(cc.mark_value);
|
||
// if (CompareObject.IsConsistent(og, nw, dt, out string field, out string field_yes, out string field_no))
|
||
// {
|
||
// listConfig.Add(GetConfigItem("GYWZ_yx", "工业网闸有线", 3, 3, field, field_yes, field_no));
|
||
// }
|
||
// else
|
||
// {
|
||
// listConfig.Add(GetConfigItem("GYWZ_yx", "工业网闸有线", 3, 0, field, field_yes, field_no));
|
||
// }
|
||
// }
|
||
// if (config.mark == "GYWZ_wx")
|
||
// {
|
||
// GYWZWx og = JsonConvert.DeserializeObject<GYWZWx>(config.answer);
|
||
// GYWZWx nw = JsonConvert.DeserializeObject<GYWZWx>(cc.mark_value);
|
||
// if (CompareObject.IsConsistent(og, nw, dt, out string field, out string field_yes, out string field_no))
|
||
// {
|
||
// listConfig.Add(GetConfigItem("GYWZ_wx", "工业网闸无线", 3, 3, field, field_yes, field_no));
|
||
// }
|
||
// else
|
||
// {
|
||
// listConfig.Add(GetConfigItem("GYWZ_wx", "工业网闸无线", 3, 0, field, field_yes, field_no));
|
||
// }
|
||
// }
|
||
// if (config.mark == "YDPZYM_wgpz")
|
||
// {
|
||
// YDPZYMWgpz og = JsonConvert.DeserializeObject<YDPZYMWgpz>(config.answer);
|
||
// YDPZYMWgpz nw = JsonConvert.DeserializeObject<YDPZYMWgpz>(cc.mark_value);
|
||
|
||
// if (CompareObject.IsConsistent(og, nw, dt, out string field, out string field_yes, out string field_no))
|
||
// {
|
||
// listConfig.Add(GetConfigItem("YDPZYM_wgpz", "云端配置页面网关配置", 2, 2, field, field_yes, field_no));
|
||
// }
|
||
// else
|
||
// {
|
||
// listConfig.Add(GetConfigItem("YDPZYM_wgpz", "云端配置页面网关配置", 2, 0, field, field_yes, field_no));
|
||
// }
|
||
// }
|
||
// if (config.mark == "YDPZYM_wgwh")
|
||
// {
|
||
// YDPZYMWgwh og = JsonConvert.DeserializeObject<YDPZYMWgwh>(config.answer);
|
||
// YDPZYMWgwh nw = JsonConvert.DeserializeObject<YDPZYMWgwh>(cc.mark_value);
|
||
// if (CompareObject.IsConsistent(og, nw, dt, out string field, out string field_yes, out string field_no))
|
||
// {
|
||
// listConfig.Add(GetConfigItem("YDPZYM_wgwh", "云端配置页面网关维护", 2, 2, field, field_yes, field_no));
|
||
// }
|
||
// else
|
||
// {
|
||
// listConfig.Add(GetConfigItem("YDPZYM_wgwh", "云端配置页面网关维护", 2, 0, field, field_yes, field_no));
|
||
// }
|
||
// }
|
||
// }
|
||
// }
|
||
// catch (Exception ex)
|
||
// {
|
||
// ret = GetResult(false, "data考试详情异常:" + ex.Message);
|
||
// context.Response.Write(ret);
|
||
// context.Response.End();
|
||
// }
|
||
|
||
// //配置得分
|
||
// var pic_score = listConfig.Select(s => s.score).Sum();
|
||
|
||
// var now = DateTime.Now;
|
||
|
||
// var subject = "智能制造工厂";
|
||
// var sjms = "竞赛模式";
|
||
// //exam_result_match: {"user_id":"USER202307301109254198","subject":"平阴华玫","score":88.0,"sjms":"实践模式"}
|
||
// var result_exists = bll_exam_result_match.GetModelList(string.Format("user_id='{0}' and subject='智能制造工厂' ", user_id)).FirstOrDefault();
|
||
// if (null == result_exists)
|
||
// {
|
||
// var result_item = new DataService.Model.exam_result_match();
|
||
|
||
|
||
// var result_id = BasePage.GetId();
|
||
// result_item.id = result_id;
|
||
// result_item.user_id = user_id;
|
||
// result_item.subject = subject;
|
||
// result_item.sjms = sjms;
|
||
// result_item.create_time = now;
|
||
// result_item.pic_score = pic_score;
|
||
// result_item.sum_score = pic_score; //总分 =配置得分
|
||
// if (bll_exam_result_match.Add(result_item))
|
||
// {
|
||
// int postion = 1;
|
||
// foreach (var item in listConfig)
|
||
// {
|
||
// var config = new DataService.Model.exam_result_detail_config();
|
||
// config.id = BasePage.GetNextId(result_id, postion++);
|
||
// config.result_id = result_id;
|
||
// config.create_time = now;
|
||
// config.mark = item.mark;
|
||
// config.topic = item.topic;
|
||
// config.total = item.total;
|
||
// config.score = item.score;
|
||
|
||
// config.field = item.field;
|
||
// config.field_yes = item.field_yes;
|
||
// config.field_no = item.field_no;
|
||
// config.other = item.other;
|
||
// bll_exam_result_detail_config.Add(config);
|
||
// }
|
||
// ret = GetResult(true, result_item);
|
||
// context.Response.Write(ret);
|
||
// context.Response.End();
|
||
// }
|
||
// }
|
||
// else
|
||
// {
|
||
// //总分 =原有三维分+配置分数
|
||
// var result_id = result_exists.id;
|
||
// var listDelete = bll_exam_result_detail_config.GetModelList("result_id='" + result_id + "'").ToList();
|
||
// if (mark == null)
|
||
// {
|
||
// var array = listDelete.Select(s => s.id).ToArray();
|
||
// List<string> list = new List<string>();
|
||
// foreach (var item in array)
|
||
// {
|
||
// list.Add("'" + item + "'");
|
||
// }
|
||
// if (list.Count > 0)
|
||
// {
|
||
// var id_list = string.Join(",", list.ToArray());
|
||
// bll_exam_result_detail_config.DeleteList(id_list);
|
||
// }
|
||
// int postion = 1;
|
||
// foreach (var item in listConfig)
|
||
// {
|
||
// var config = new DataService.Model.exam_result_detail_config();
|
||
// config.id = BasePage.GetLongId();
|
||
// config.result_id = result_id;
|
||
// config.create_time = now;
|
||
// config.mark = item.mark;
|
||
// config.topic = item.topic;
|
||
// config.total = item.total;
|
||
// config.score = item.score;
|
||
|
||
// config.field = item.field;
|
||
// config.field_yes = item.field_yes;
|
||
// config.field_no = item.field_no;
|
||
// config.other = item.other;
|
||
// bll_exam_result_detail_config.Add(config);
|
||
// }
|
||
|
||
// }
|
||
// else
|
||
// {
|
||
// var model = listDelete.Where(x => x.mark == mark)?.FirstOrDefault();
|
||
// if (model != null)
|
||
// {
|
||
// var item = listConfig.FirstOrDefault();
|
||
// var config = new DataService.Model.exam_result_detail_config();
|
||
// config.id = model.id;
|
||
// config.result_id = result_id;
|
||
// config.create_time = now;
|
||
// config.mark = item.mark;
|
||
// config.topic = item.topic;
|
||
// config.total = item.total;
|
||
// config.score = item.score;
|
||
|
||
// config.field = item.field;
|
||
// config.field_yes = item.field_yes;
|
||
// config.field_no = item.field_no;
|
||
// config.other = item.other;
|
||
// bll_exam_result_detail_config.Update(config);
|
||
// }
|
||
// else
|
||
// {
|
||
// var item = listConfig.FirstOrDefault();
|
||
// var config = new DataService.Model.exam_result_detail_config();
|
||
// config.id = BasePage.GetLongId();
|
||
// config.result_id = result_id;
|
||
// config.create_time = now;
|
||
// config.mark = item.mark;
|
||
// config.topic = item.topic;
|
||
// config.total = item.total;
|
||
// config.score = item.score;
|
||
|
||
// config.field = item.field;
|
||
// config.field_yes = item.field_yes;
|
||
// config.field_no = item.field_no;
|
||
// config.other = item.other;
|
||
// bll_exam_result_detail_config.Add(config);
|
||
// }
|
||
// }
|
||
|
||
// var score = bll_exam_result_detail_config.GetModelList("result_id='" + result_id + "'").Sum(x => x.score);
|
||
// result_exists.pic_score = score;
|
||
// result_exists.sum_score = result_exists.score + score;
|
||
// bll_exam_result_match.Update(result_exists);
|
||
// ret = GetResult(true, result_exists);
|
||
// context.Response.Write(ret);
|
||
// context.Response.End();
|
||
// }
|
||
//}
|
||
|
||
|
||
public ConfigItem GetConfigItem(string mark, string topic, decimal total, decimal score, string field, string field_yes, string field_no)
|
||
{
|
||
|
||
ConfigItem item = new ConfigItem();
|
||
item.mark = mark;
|
||
item.topic = topic;
|
||
item.total = total;
|
||
item.score = score;
|
||
item.field = field;
|
||
item.field_yes = field_yes;
|
||
item.field_no = field_no;
|
||
return item;
|
||
}
|
||
|
||
//保存竞赛考试
|
||
public void saveMatch(HttpContext context)
|
||
{
|
||
var data = context.Request.Params["data"];
|
||
var ret = string.Empty;
|
||
if (string.IsNullOrEmpty(data))
|
||
{
|
||
ret = GetResult(false, "data参数不能为空");
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
DataService.Model.exam_result_match result_item = null;
|
||
try
|
||
{
|
||
result_item = JsonConvert.DeserializeObject<DataService.Model.exam_result_match>(data);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
ret = GetResult(false, "考试科目:data 异常:" + ex.Message);
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
var user_id = result_item.user_id;
|
||
string sql_config = " 1=1 ";
|
||
string sql_config_o = " 1=1 ";
|
||
|
||
if (string.IsNullOrEmpty(user_id))
|
||
{
|
||
ret = GetResult(false, "user_id参数不能为空");
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
else
|
||
{
|
||
DateTime datetime = DateTime.Now;
|
||
sql_config_o += " and user_id='" + user_id + "' or ( start_time<'" + datetime + "' and expire_time>'" + datetime + "' ) ";
|
||
}
|
||
|
||
#region 三维端上传 智能制造工厂
|
||
//三维端上传 智能制造工厂
|
||
if (result_item.subject == "智能制造工厂")
|
||
{
|
||
var lang = context.Request.Params["lang"];
|
||
var result_exists = bll_exam_result_match.GetModelList(string.Format("user_id='{0}' and subject='智能制造工厂' ", result_item.user_id)).FirstOrDefault();
|
||
if (null == result_exists)
|
||
{
|
||
var result_id = BasePage.GetId();
|
||
result_item.id = result_id;
|
||
|
||
result_item.sum_score = result_item.score; //总分 =三维得分
|
||
|
||
result_item.create_time = DateTime.Now;
|
||
result_item.r1 = "lang:" + lang;
|
||
if (!bll_exam_result_match.Add(result_item))
|
||
{
|
||
ret = GetResult(false, result_item);
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
}
|
||
else
|
||
{
|
||
result_exists.score = result_item.score;//三维得分
|
||
result_exists.sjms = result_item.sjms; //模式:竞赛模式
|
||
result_exists.sum_score = result_item.score + (result_exists.pic_score.HasValue ? result_exists.pic_score.Value : 0); //总分 =三维分+配置分数
|
||
|
||
result_exists.r2 = "updatetime:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||
result_exists.r1 = "lang:" + lang;
|
||
|
||
if (!bll_exam_result_match.Update(result_exists))
|
||
{
|
||
ret = GetResult(false, result_exists);
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
}
|
||
|
||
#region 配置得分
|
||
var config_list = bll_config_answer.GetModelList(sql_config);
|
||
|
||
|
||
|
||
//更改 标准答案 $$$$$
|
||
var systemName = ConfigurationManager.AppSettings["SystemName"];
|
||
//老版本 直接读取obj.answer ,不用处理
|
||
if (systemName == "00")
|
||
{
|
||
;
|
||
}
|
||
else //新版本导入 excel配置,用r2 当作判分标准
|
||
{
|
||
foreach (var obj in config_list)
|
||
{
|
||
if (obj.mark != "Path" && obj.mark != "wlghjs1" && obj.mark != "wlghjs2")
|
||
{
|
||
obj.answer = obj.r2; //默认中文版
|
||
//$$$英文版
|
||
if (lang=="1")
|
||
{
|
||
obj.answer = obj.r2_en_answer;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
var config_cache_list = bll_config_cache.GetModelList(sql_config_o).ToList();
|
||
dxgl_list dt = new dxgl_list();
|
||
List<ConfigItem> listConfig = new List<ConfigItem>();
|
||
if (config_cache_list.Count > 0)
|
||
{
|
||
foreach (var config in config_list)
|
||
{
|
||
string answer = config.answer;
|
||
var mark = config.mark;
|
||
var cc = config_cache_list.Where(x => x.mark == mark).FirstOrDefault();
|
||
if (cc != null)
|
||
{
|
||
if (config.mark == "DB-IotLite_yx")
|
||
{
|
||
if (cc != null)
|
||
{
|
||
ConfigItem item = new ConfigItem();
|
||
DBIotLiteYx og = JsonConvert.DeserializeObject<DBIotLiteYx>(config.answer);
|
||
|
||
DBIotLiteYx nw = JsonConvert.DeserializeObject<DBIotLiteYx>(cc.mark_value);
|
||
if (CompareObject.IsConsistent(og, nw, dt, out string field, out string field_yes, out string field_no))
|
||
{
|
||
listConfig.Add(GetConfigItem("DB-IotLite_yx", "DB-IotLite网关有线", 4, 4, field, field_yes, field_no));
|
||
}
|
||
else
|
||
{
|
||
listConfig.Add(GetConfigItem("DB-IotLite_yx", "DB-IotLite网关有线", 4, 0, field, field_yes, field_no));
|
||
}
|
||
}
|
||
else
|
||
{
|
||
listConfig.Add(GetConfigItem("DB-IotLite_yx", "DB-IotLite网关有线", 4, 0, "", "", ""));
|
||
}
|
||
|
||
}
|
||
if (config.mark == "DB-IotLite_wx")
|
||
{
|
||
if (cc != null)
|
||
{
|
||
DBIotLiteWx og = JsonConvert.DeserializeObject<DBIotLiteWx>(config.answer);
|
||
DBIotLiteWx nw = JsonConvert.DeserializeObject<DBIotLiteWx>(cc.mark_value);
|
||
if (CompareObject.IsConsistent(og, nw, dt, out string field, out string field_yes, out string field_no, "1"))
|
||
{
|
||
listConfig.Add(GetConfigItem("DB-IotLite_wx", "DB-IotLite网关无线", 3, 3, field, field_yes, field_no));
|
||
}
|
||
else
|
||
{
|
||
listConfig.Add(GetConfigItem("DB-IotLite_wx", "DB-IotLite网关无线", 3, 0, field, field_yes, field_no));
|
||
}
|
||
}
|
||
else
|
||
{
|
||
listConfig.Add(GetConfigItem("DB-IotLite_wx", "DB-IotLite网关无线", 3, 0, "", "", ""));
|
||
}
|
||
}
|
||
if (config.mark == "CHGYWG_yx")
|
||
{
|
||
if (cc != null)
|
||
{
|
||
CHGYWGYx og = JsonConvert.DeserializeObject<CHGYWGYx>(config.answer);
|
||
CHGYWGYx nw = JsonConvert.DeserializeObject<CHGYWGYx>(cc.mark_value);
|
||
if (CompareObject.IsConsistent(og, nw, dt, out string field, out string field_yes, out string field_no))
|
||
{
|
||
listConfig.Add(GetConfigItem("CHGYWG_yx", "斥候工业网关有线", 3, 3, field, field_yes, field_no));
|
||
}
|
||
else
|
||
{
|
||
listConfig.Add(GetConfigItem("CHGYWG_yx", "斥候工业网关有线", 3, 0, field, field_yes, field_no));
|
||
}
|
||
}
|
||
else
|
||
{
|
||
listConfig.Add(GetConfigItem("CHGYWG_yx", "斥候工业网关有线", 3, 0, "", "", ""));
|
||
}
|
||
}
|
||
if (config.mark == "CHGYWG_wx")
|
||
{
|
||
if (cc != null)
|
||
{
|
||
CHGYWGWx og = JsonConvert.DeserializeObject<CHGYWGWx>(config.answer);
|
||
CHGYWGWx nw = JsonConvert.DeserializeObject<CHGYWGWx>(cc.mark_value);
|
||
if (CompareObject.IsConsistent(og, nw, dt, out string field, out string field_yes, out string field_no))
|
||
{
|
||
listConfig.Add(GetConfigItem("CHGYWG_wx", "斥候工业网关无线", 3, 3, field, field_yes, field_no));
|
||
}
|
||
else
|
||
{
|
||
listConfig.Add(GetConfigItem("CHGYWG_wx", "斥候工业网关无线", 3, 0, field, field_yes, field_no));
|
||
}
|
||
}
|
||
else
|
||
{
|
||
listConfig.Add(GetConfigItem("CHGYWG_wx", "斥候工业网关无线", 3, 0, "", "", ""));
|
||
}
|
||
}
|
||
if (config.mark == "CKFWQ_yx")
|
||
{
|
||
if (cc != null)
|
||
{
|
||
CKFWQyx og = JsonConvert.DeserializeObject<CKFWQyx>(config.answer);
|
||
CKFWQyx nw = JsonConvert.DeserializeObject<CKFWQyx>(cc.mark_value);
|
||
if (CompareObject.IsConsistent(og, nw, dt, out string field, out string field_yes, out string field_no))
|
||
{
|
||
listConfig.Add(GetConfigItem("CKFWQ_yx", "串口服务器有线", 2, 2, field, field_yes, field_no));
|
||
}
|
||
else
|
||
{
|
||
listConfig.Add(GetConfigItem("CKFWQ_yx", "串口服务器有线", 2, 0, field, field_yes, field_no));
|
||
}
|
||
}
|
||
else
|
||
{
|
||
listConfig.Add(GetConfigItem("CKFWQ_yx", "串口服务器有线", 2, 0, "", "", ""));
|
||
}
|
||
}
|
||
if (config.mark == "CKFWQ_wx")
|
||
{
|
||
if (cc != null)
|
||
{
|
||
CKFWQWx og = JsonConvert.DeserializeObject<CKFWQWx>(config.answer);
|
||
CKFWQWx nw = JsonConvert.DeserializeObject<CKFWQWx>(cc.mark_value);
|
||
if (CompareObject.IsConsistent(og, nw, dt, out string field, out string field_yes, out string field_no))
|
||
{
|
||
listConfig.Add(GetConfigItem("CKFWQ_wx", "串口服务器无线", 2, 2, field, field_yes, field_no));
|
||
}
|
||
else
|
||
{
|
||
listConfig.Add(GetConfigItem("CKFWQ_wx", "串口服务器无线", 2, 0, field, field_yes, field_no));
|
||
}
|
||
}
|
||
else
|
||
{
|
||
listConfig.Add(GetConfigItem("CKFWQ_wx", "串口服务器无线", 2, 0, "", "", ""));
|
||
}
|
||
}
|
||
if (config.mark == "GYWZ_yx")
|
||
{
|
||
if (cc != null)
|
||
{
|
||
GYWZyx og = JsonConvert.DeserializeObject<GYWZyx>(config.answer);
|
||
GYWZyx nw = JsonConvert.DeserializeObject<GYWZyx>(cc.mark_value);
|
||
if (null==nw.dxgl )
|
||
{
|
||
nw.dxgl = new List<dxgl_list>();
|
||
}
|
||
if (CompareObject.IsConsistent(og, nw, dt, out string field, out string field_yes, out string field_no))
|
||
{
|
||
listConfig.Add(GetConfigItem("GYWZ_yx", "工业网闸有线", 3, 3, field, field_yes, field_no));
|
||
}
|
||
else
|
||
{
|
||
listConfig.Add(GetConfigItem("GYWZ_yx", "工业网闸有线", 3, 0, field, field_yes, field_no));
|
||
}
|
||
}
|
||
else
|
||
{
|
||
listConfig.Add(GetConfigItem("GYWZ_yx", "工业网闸有线", 3, 0, "", "", ""));
|
||
}
|
||
}
|
||
if (config.mark == "GYWZ_wx")
|
||
{
|
||
if (cc != null)
|
||
{
|
||
GYWZWx og = JsonConvert.DeserializeObject<GYWZWx>(config.answer);
|
||
GYWZWx nw = JsonConvert.DeserializeObject<GYWZWx>(cc.mark_value);
|
||
if (null == nw.dxgl)
|
||
{
|
||
nw.dxgl = new List<dxgl_list>();
|
||
}
|
||
if (CompareObject.IsConsistent(og, nw, dt, out string field, out string field_yes, out string field_no))
|
||
{
|
||
listConfig.Add(GetConfigItem("GYWZ_wx", "工业网闸无线", 3, 3, field, field_yes, field_no));
|
||
}
|
||
else
|
||
{
|
||
listConfig.Add(GetConfigItem("GYWZ_wx", "工业网闸无线", 3, 0, field, field_yes, field_no));
|
||
}
|
||
}
|
||
else
|
||
{
|
||
listConfig.Add(GetConfigItem("GYWZ_wx", "工业网闸无线", 3, 0, "", "", ""));
|
||
}
|
||
}
|
||
if (config.mark == "YDPZYM_wgpz")
|
||
{
|
||
if (cc != null)
|
||
{
|
||
YDPZYMWgpz m = new YDPZYMWgpz();
|
||
List<YDPZYMWgpz> og = JsonConvert.DeserializeObject<List<YDPZYMWgpz>>(config.answer);
|
||
List<YDPZYMWgpz> nw = JsonConvert.DeserializeObject<List<YDPZYMWgpz>>(cc.mark_value);
|
||
|
||
if (CompareObject.IsConsistentList(og, nw, dt, out string field, out string field_yes, out string field_no))
|
||
{
|
||
listConfig.Add(GetConfigItem("YDPZYM_wgpz", "云端配置页面网关配置", 2, 2, field, field_yes, field_no));
|
||
}
|
||
else
|
||
{
|
||
listConfig.Add(GetConfigItem("YDPZYM_wgpz", "云端配置页面网关配置", 2, 0, field, field_yes, field_no));
|
||
}
|
||
}
|
||
else
|
||
{
|
||
listConfig.Add(GetConfigItem("YDPZYM_wgpz", "云端配置页面网关配置", 2, 0, "", "", ""));
|
||
}
|
||
}
|
||
if (config.mark == "YDPZYM_wgwh")
|
||
{
|
||
if (cc != null)
|
||
{
|
||
YDPZYMWgwh m = new YDPZYMWgwh();
|
||
List<YDPZYMWgwh> og = JsonConvert.DeserializeObject<List<YDPZYMWgwh>>(config.answer);
|
||
List<YDPZYMWgwh> nw = JsonConvert.DeserializeObject<List<YDPZYMWgwh>>(cc.mark_value);
|
||
if (CompareObject.IsConsistentList(og, nw, dt, out string field, out string field_yes, out string field_no))
|
||
{
|
||
listConfig.Add(GetConfigItem("YDPZYM_wgwh", "云端配置页面网关维护", 2, 2, field, field_yes, field_no));
|
||
}
|
||
else
|
||
{
|
||
listConfig.Add(GetConfigItem("YDPZYM_wgwh", "云端配置页面网关维护", 2, 0, field, field_yes, field_no));
|
||
}
|
||
}
|
||
else
|
||
{
|
||
listConfig.Add(GetConfigItem("YDPZYM_wgwh", "云端配置页面网关维护", 2, 0, "", "", ""));
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
if (listConfig.Count > 0)
|
||
{
|
||
//配置得分
|
||
var pic_score = listConfig.Select(s => s.score).Sum();
|
||
|
||
var now = DateTime.Now;
|
||
|
||
var subject = "智能制造工厂";
|
||
result_exists = bll_exam_result_match.GetModelList(string.Format("user_id='{0}' and subject='智能制造工厂' ", user_id)).FirstOrDefault();
|
||
if (null != result_exists)
|
||
{
|
||
//总分 =原有三维分+配置分数
|
||
var result_id = result_exists.id;
|
||
var listDelete = bll_exam_result_detail_config.GetModelList("result_id='" + result_id + "'").ToList();
|
||
|
||
var array = listDelete.Select(s => s.id).ToArray();
|
||
List<string> list = new List<string>();
|
||
foreach (var item in array)
|
||
{
|
||
list.Add("'" + item + "'");
|
||
}
|
||
if (list.Count > 0)
|
||
{
|
||
var id_list = string.Join(",", list.ToArray());
|
||
bll_exam_result_detail_config.DeleteList(id_list);
|
||
}
|
||
foreach (var item in listConfig)
|
||
{
|
||
var config = new DataService.Model.exam_result_detail_config();
|
||
config.id = BasePage.GetLongId();
|
||
config.result_id = result_id;
|
||
config.create_time = now;
|
||
config.mark = item.mark;
|
||
config.topic = item.topic;
|
||
config.total = item.total;
|
||
config.score = item.score;
|
||
|
||
config.field = item.field;
|
||
config.field_yes = item.field_yes;
|
||
config.field_no = item.field_no;
|
||
config.other = item.other;
|
||
bll_exam_result_detail_config.Add(config);
|
||
}
|
||
|
||
result_exists.pic_score = pic_score;
|
||
result_exists.sum_score = result_exists.score + pic_score;
|
||
if (bll_exam_result_match.Update(result_exists))
|
||
{
|
||
ret = GetResult(true, result_exists);
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
else
|
||
{
|
||
ret = GetResult(false, result_exists);
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
result_exists = bll_exam_result_match.GetModelList(string.Format("user_id='{0}' and subject='智能制造工厂' ", result_item.user_id)).FirstOrDefault();
|
||
ret = GetResult(true, result_exists);
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
#endregion
|
||
|
||
}
|
||
#endregion
|
||
|
||
//三维端上传 平阴华玫
|
||
#region 三维端上传 平阴华玫
|
||
if (result_item.subject == "平阴华玫")
|
||
{
|
||
if (context.Request.Files.Count <= 0)
|
||
{
|
||
ret = GetResult(false, "文件不能为空");
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
var lang = context.Request.Params["lang"];
|
||
var file = context.Request.Files[0];
|
||
var extension = file.FileName.Substring(file.FileName.LastIndexOf("."));
|
||
var file_name = file.FileName;
|
||
string uploadPath = "Upload/";
|
||
var newid = BasePage.GetLongId();
|
||
var prefix = file.FileName.Substring(0, file.FileName.LastIndexOf("."));
|
||
string NewfileName = prefix + "_" + newid + extension;
|
||
var directory = context.Server.MapPath("~/" + uploadPath);
|
||
if (!Directory.Exists(directory))
|
||
Directory.CreateDirectory(directory);
|
||
string serverPath = directory + NewfileName;
|
||
file.SaveAs(serverPath);
|
||
|
||
result_item.pic_url = "~/" + uploadPath + NewfileName; //文件路径-相对路径
|
||
|
||
var result_exists = bll_exam_result_match.GetModelList(string.Format("user_id='{0}' and subject='平阴华玫' ", result_item.user_id)).FirstOrDefault();
|
||
if (result_exists != null)
|
||
{
|
||
var now = DateTime.Now;
|
||
result_exists.create_time = now;
|
||
|
||
result_exists.score = result_item.score; ////三维分值赋值给总分 $$$$
|
||
result_exists.sum_score = result_item.score; //三维分值赋值给总分 $$$$
|
||
|
||
result_exists.pic_url = result_item.pic_url;
|
||
result_exists.r1 = "lang:"+ lang;
|
||
if (bll_exam_result_match.Update(result_exists))
|
||
{
|
||
ret = GetResult(true, result_exists);
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
}
|
||
else
|
||
{
|
||
var now = DateTime.Now;
|
||
var result_id = BasePage.GetId();
|
||
result_item.id = result_id;
|
||
result_item.create_time = now;
|
||
result_item.r1 = "lang:" + lang;
|
||
result_item.sum_score = result_item.score; //三维分值赋值给总分 $$$$
|
||
if (bll_exam_result_match.Add(result_item))
|
||
{
|
||
ret = GetResult(true, result_item);
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
//三维端上传 炭黑生产制造
|
||
#region 三维端上传 炭黑生产制造
|
||
if (result_item.subject == "炭黑生产制造")
|
||
{
|
||
var lang = context.Request.Params["lang"];
|
||
var pic = context.Request.Params["pic"];
|
||
if (pic == "1")
|
||
{
|
||
if (context.Request.Files.Count <= 0)
|
||
{
|
||
ret = GetResult(false, "文件不能为空");
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
|
||
var file = context.Request.Files[0];
|
||
var extension = file.FileName.Substring(file.FileName.LastIndexOf("."));
|
||
var file_name = file.FileName;
|
||
string uploadPath = "Upload/";
|
||
var newid = BasePage.GetLongId();
|
||
var prefix = file.FileName.Substring(0, file.FileName.LastIndexOf("."));
|
||
string NewfileName = prefix + "_" + newid + extension;
|
||
var directory = context.Server.MapPath("~/" + uploadPath);
|
||
if (!Directory.Exists(directory))
|
||
Directory.CreateDirectory(directory);
|
||
string serverPath = directory + NewfileName;
|
||
file.SaveAs(serverPath);
|
||
|
||
result_item.pic_url = "~/" + uploadPath + NewfileName; //文件路径-相对路径
|
||
}
|
||
|
||
#region 炭黑制造各模块得分列表
|
||
var configlist = context.Request.Params["configlist"];
|
||
if (string.IsNullOrEmpty(configlist))
|
||
{
|
||
/*
|
||
ret = GetResult(false, "configlist参数不能为空");
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
*/
|
||
configlist = "[]";
|
||
}
|
||
List<ResultConfigInfo_TH> detail_list = null;
|
||
try
|
||
{
|
||
detail_list = JsonConvert.DeserializeObject<List<ResultConfigInfo_TH>>(configlist);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
ret = GetResult(false, "炭黑制造模块得分列表转换错误:" + ex.Message);
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
#endregion
|
||
|
||
|
||
var result_exists = bll_exam_result_match.GetModelList(string.Format("user_id='{0}' and subject='炭黑生产制造' ", result_item.user_id)).FirstOrDefault();
|
||
if (result_exists != null)
|
||
{
|
||
var now = DateTime.Now;
|
||
result_exists.create_time = now;
|
||
|
||
#region old score update
|
||
/*
|
||
result_exists.score = result_item.score; ////三维分值赋值给总分 $$$$
|
||
result_exists.sum_score = result_item.score; //三维分值赋值给总分 $$$$
|
||
*/
|
||
#endregion
|
||
|
||
result_exists.score = result_item.score;
|
||
result_exists.pic_score = result_item.pic_score;
|
||
result_exists.sum_score = result_item.score + result_item.pic_score;
|
||
|
||
result_exists.pic_url = result_item.pic_url;
|
||
result_exists.r1 = "lang:" + lang;
|
||
if (bll_exam_result_match.Update(result_exists))
|
||
{
|
||
addTHConfigDetails(detail_list, result_exists.id);
|
||
|
||
//ret = GetResult(true, result_exists);
|
||
ret = GetResult(success(), result_exists);
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
}
|
||
else
|
||
{
|
||
var now = DateTime.Now;
|
||
var result_id = BasePage.GetId();
|
||
result_item.id = result_id;
|
||
result_item.create_time = now;
|
||
result_item.r1 = "lang:" + lang;
|
||
#region old score add
|
||
//result_item.sum_score = result_item.score; //三维分值赋值给总分 $$$$
|
||
#endregion
|
||
|
||
#region new
|
||
result_item.sum_score = result_item.score + result_item.pic_score;
|
||
#endregion
|
||
if (bll_exam_result_match.Add(result_item))
|
||
{
|
||
addTHConfigDetails(detail_list, result_id);
|
||
//ret = GetResult(true, result_item);
|
||
ret = GetResult(success(), result_item);
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
}
|
||
}
|
||
#endregion
|
||
}
|
||
|
||
private bool success()
|
||
{
|
||
return true;
|
||
/*
|
||
if (DateTime.Now.Millisecond % 2 == 0)
|
||
return true ;
|
||
else
|
||
{
|
||
return false ;
|
||
}
|
||
*/
|
||
}
|
||
|
||
/// <summary>
|
||
/// 添加炭黑制造各模块得分列表
|
||
/// </summary>
|
||
/// <param name="detail_list"></param>
|
||
/// <param name="result_id"></param>
|
||
private int addTHConfigDetails(List<ResultConfigInfo_TH> detail_list, string result_id)
|
||
{
|
||
string id = BasePage.GetId();
|
||
int index = 1;
|
||
var now = DateTime.Now;
|
||
var list_add = new List<DataService.Model.exam_result_detail_config>();
|
||
for (int i = 0; i < detail_list.Count; i++)
|
||
{
|
||
var info = detail_list[i];
|
||
var item = new DataService.Model.exam_result_detail_config();
|
||
item.id = BasePage.GetNextId(id, index++);
|
||
item.result_id = result_id;
|
||
|
||
item.mark = info.mark;
|
||
item.topic = info.topic;
|
||
item.total = info.total;
|
||
item.score = info.score;
|
||
|
||
item.field = info.field;
|
||
item.field_yes = info.field_yes;
|
||
item.field_no = info.field_no;
|
||
item.other = info.other;
|
||
item.create_time = now;
|
||
list_add.Add(item);
|
||
}
|
||
var count = bll_exam_result_detail_config.BatchAdd_Update(list_add, result_id);
|
||
return count;
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 保存考试考核、实训考核
|
||
/// </summary>
|
||
/// <param name="context"></param>
|
||
public void SaveExam(HttpContext context)
|
||
{
|
||
|
||
var exam_result = context.Request.Params["exam_result"];
|
||
var ret = string.Empty;
|
||
if (string.IsNullOrEmpty(exam_result))
|
||
{
|
||
ret = GetResult(false, "exam_result参数不能为空");
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
|
||
DataService.Model.exam_result result_item = null;
|
||
try
|
||
{
|
||
result_item = JsonConvert.DeserializeObject<DataService.Model.exam_result>(exam_result);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
ret = GetResult(false, "考试科目:exam_result 异常:" + ex.Message);
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
|
||
//实训考核模式
|
||
if (result_item.sjms == "1")
|
||
{
|
||
var exam_result_detail = context.Request.Params["exam_result_detail"];
|
||
if (string.IsNullOrEmpty(exam_result_detail))
|
||
{
|
||
ret = GetResult(false, "exam_result_detail参数不能为空");
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
|
||
List<DataService.Model.exam_result_detail_shixun> result_detail_list_shixun = null;
|
||
try
|
||
{
|
||
result_detail_list_shixun = JsonConvert.DeserializeObject<List<DataService.Model.exam_result_detail_shixun>>(exam_result_detail);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
ret = GetResult(false, "考试详情异常:" + ex.Message);
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
|
||
var now = DateTime.Now;
|
||
var result_id = BasePage.GetId();
|
||
result_item.id = result_id;
|
||
//result_item.sjms = "1"; 实训模式
|
||
result_item.create_time = now;
|
||
if (bll_exam_result.Add(result_item))
|
||
{
|
||
var index = 1;
|
||
foreach (var item in result_detail_list_shixun)
|
||
{
|
||
// item.id = BasePage.GetNextId(result_id, index++); //$$$ old
|
||
var detail_id = BasePage.GetNextId(result_id, index++);
|
||
item.id = detail_id;
|
||
|
||
item.result_id = result_id;
|
||
item.create_time = now;
|
||
if(bll_exam_result_detail_shixun.Add(item))
|
||
{
|
||
#region 刘玉新增子科目
|
||
if (null != item.subSubjectInfos)
|
||
{
|
||
var subject_index = 1;
|
||
foreach (var subject in item.subSubjectInfos)
|
||
{
|
||
//`no` varchar(50) '题号',
|
||
//`subSubjectName` varchar(255) '子科目名称',
|
||
//`totalScore` '总分',
|
||
//`score` '得分',
|
||
var subsubject = subject;
|
||
var subject_id = BasePage.GetNextId(detail_id, subject_index++);
|
||
subsubject.id = subject_id;
|
||
subsubject.detail_id = detail_id;
|
||
subsubject.create_time = now.AddSeconds(index);
|
||
if (bll_subsubject.Add(subsubject))
|
||
{
|
||
if (null != subject.subSubjectStepInfos)
|
||
{
|
||
var step_index = 1;
|
||
foreach (var step in subject.subSubjectStepInfos)
|
||
{
|
||
//`no` varchar(50) '题号',
|
||
// `description` varchar(255) '步骤描述',
|
||
//`total` decimal(11, 3) '总分',
|
||
//`score` decimal(11, 3) '得分',
|
||
var substep = step;
|
||
var step_id = BasePage.GetNextId(subject_id, step_index++);
|
||
substep.id = step_id;
|
||
substep.subsubject_id = subject_id;
|
||
substep.create_time = now.AddSeconds(index);
|
||
bll_subsubjectstep.Add(substep);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
}
|
||
}
|
||
|
||
ret = GetResult(true, result_item);
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
}
|
||
else //考试考核模式
|
||
{
|
||
var result_id = BasePage.GetId();
|
||
var exam_result_detail = context.Request.Params["exam_result_detail"];
|
||
if (string.IsNullOrEmpty(exam_result_detail))
|
||
{
|
||
ret = GetResult(false, "exam_result_detail参数不能为空");
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
|
||
|
||
|
||
#region 添加多张填空题图片测试
|
||
/*
|
||
var qq_file = context.Request.Files["3"];
|
||
for (int i = 0; i < context.Request.Files.Count; i++)
|
||
{
|
||
var file = context.Request.Files[i];
|
||
var extension = file.FileName.Substring(file.FileName.LastIndexOf("."));
|
||
var file_name = file.FileName;
|
||
string uploadPath = "Upload/";
|
||
var newid = BasePage.GetNextId(result_id, (i + 1));
|
||
var prefix = file.FileName.Substring(0, file.FileName.LastIndexOf("."));
|
||
string NewfileName = prefix + "_" + newid + extension;
|
||
var directory = context.Server.MapPath("~/" + uploadPath);
|
||
if (!Directory.Exists(directory))
|
||
Directory.CreateDirectory(directory);
|
||
string serverPath = directory + NewfileName;
|
||
file.SaveAs(serverPath);
|
||
var pic_url = "~/" + uploadPath + NewfileName; //文件路径-相对路径
|
||
}
|
||
*/
|
||
#endregion
|
||
|
||
List<DataService.Model.exam_result_detail> result_detail_list = null;
|
||
try
|
||
{
|
||
result_detail_list = JsonConvert.DeserializeObject<List<DataService.Model.exam_result_detail>>(exam_result_detail);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
ret = GetResult(false, "考试详情异常:" + ex.Message);
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
|
||
var now = DateTime.Now;
|
||
result_item.id = result_id;
|
||
result_item.sjms = "0";
|
||
result_item.create_time = now;
|
||
|
||
if (bll_exam_result.Add(result_item))
|
||
{
|
||
var index = 1;
|
||
var temp = "";
|
||
foreach (var item in result_detail_list)
|
||
{
|
||
var sb = new StringBuilder();
|
||
item.id = BasePage.GetNextId(result_id, index++);
|
||
item.result_id = result_id;
|
||
item.create_time = now;
|
||
#region 图片
|
||
//考生答案 no.jpg
|
||
var no_string = item.no.ToString();
|
||
var file = context.Request.Files[no_string];
|
||
if (null != file && item.questionType == "简答题" && file.ContentLength > 0)
|
||
{
|
||
var file_name = file.FileName;
|
||
sb.Append(no_string + ":" + file_name + ";");
|
||
var type = file.ContentType;
|
||
var extension = GetFileExtension(file_name, item.yourAnswer);
|
||
string uploadPath = "Upload/";
|
||
var newid = item.id;
|
||
|
||
string NewfileName = newid + extension;
|
||
var directory = context.Server.MapPath("~/" + uploadPath);
|
||
if (!Directory.Exists(directory))
|
||
Directory.CreateDirectory(directory);
|
||
string serverPath = directory + NewfileName;
|
||
file.SaveAs(serverPath);
|
||
var pic_url = "~/" + uploadPath + NewfileName; //文件路径-相对路径
|
||
|
||
item.r1 = pic_url;
|
||
item.r3 = "1";
|
||
|
||
}
|
||
|
||
//正确答案 no_2.jpg
|
||
no_string = item.no.ToString() + "_2";
|
||
var file2 = context.Request.Files[no_string];
|
||
if (null != file2 && item.questionType == "简答题" && file2.ContentLength > 0)
|
||
{
|
||
var file_name = file2.FileName;
|
||
sb.Append(no_string + ":" + file_name + "(path is " + item.path + ");");
|
||
var extension = GetFileExtension(file_name, item.path);
|
||
string uploadPath = "Upload/";
|
||
var newid = item.id + "_2";
|
||
|
||
string NewfileName = newid + extension;
|
||
var directory = context.Server.MapPath("~/" + uploadPath);
|
||
if (!Directory.Exists(directory))
|
||
Directory.CreateDirectory(directory);
|
||
string serverPath = directory + NewfileName;
|
||
file2.SaveAs(serverPath);
|
||
var pic_url = "~/" + uploadPath + NewfileName; //文件路径-相对路径
|
||
|
||
item.r2 = pic_url;
|
||
item.r3 = "1";
|
||
}
|
||
item.r5 = sb.ToString();
|
||
temp = temp + sb.ToString();
|
||
#endregion
|
||
bll_exam_result_detail.Add(item); //$$$$
|
||
}
|
||
ret = GetResult(true, result_item, temp);
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
|
||
|
||
/// <summary>
|
||
/// 保存实训考核带子科目
|
||
/// </summary>
|
||
/// <param name="context"></param>
|
||
public void SaveExamSub(HttpContext context)
|
||
{
|
||
var exam_result = context.Request.Params["exam_result"];
|
||
var ret = string.Empty;
|
||
if (string.IsNullOrEmpty(exam_result))
|
||
{
|
||
ret = GetResult(false, "exam_result参数不能为空");
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
DataService.Model.exam_result result_item = null;
|
||
try
|
||
{
|
||
result_item = JsonConvert.DeserializeObject<DataService.Model.exam_result>(exam_result);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
ret = GetResult(false, "考试科目:exam_result 异常:" + ex.Message);
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
|
||
//实训考核模式 带子科目
|
||
//if (result_item.sjms == "1")
|
||
//{
|
||
var exam_result_detail = context.Request.Params["exam_result_detail"];
|
||
if (string.IsNullOrEmpty(exam_result_detail))
|
||
{
|
||
ret = GetResult(false, "exam_result_detail参数不能为空");
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
//old exam_result_detail_shixun
|
||
List<DataService.Model.SubDetailInfos> result_detail_list_sub = null;
|
||
try
|
||
{
|
||
result_detail_list_sub = JsonConvert.DeserializeObject<List<DataService.Model.SubDetailInfos>>(exam_result_detail);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
ret = GetResult(false, "考试详情异常:" + ex.Message);
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
|
||
var now = DateTime.Now;
|
||
var result_id = BasePage.GetId();
|
||
result_item.id = result_id;
|
||
result_item.sjms = "1"; //实训模式
|
||
result_item.create_time = now;
|
||
if (bll_exam_result.Add(result_item))
|
||
{
|
||
var index = 1;
|
||
foreach (var item in result_detail_list_sub)
|
||
{
|
||
/*
|
||
item.id = BasePage.GetNextId(result_id, index++);
|
||
item.result_id = result_id;
|
||
item.create_time = now;
|
||
bll_exam_result_detail_shixun.Add(item);
|
||
*/
|
||
var detail_shixun = new DataService.Model.exam_result_detail_shixun();
|
||
var detail_id = BasePage.GetNextId(result_id, index++);
|
||
detail_shixun.id = detail_id;
|
||
detail_shixun.result_id = result_id;
|
||
detail_shixun.create_time = now.AddSeconds(index);
|
||
detail_shixun.r1 = item.no;
|
||
//detail_shixun.no = 0;
|
||
detail_shixun.description = item.description;
|
||
detail_shixun.total = item.total;
|
||
detail_shixun.score = item.score;
|
||
if (bll_exam_result_detail_shixun.Add(detail_shixun))
|
||
{
|
||
if (null != item.subSubjectInfos)
|
||
{
|
||
var subject_index = 1;
|
||
foreach (var subject in item.subSubjectInfos)
|
||
{
|
||
//`no` varchar(50) '题号',
|
||
//`subSubjectName` varchar(255) '子科目名称',
|
||
//`totalScore` '总分',
|
||
//`score` '得分',
|
||
var subsubject = subject;
|
||
var subject_id = BasePage.GetNextId(detail_id, subject_index++);
|
||
subsubject.id = subject_id;
|
||
subsubject.detail_id = detail_id;
|
||
subsubject.create_time = now.AddSeconds(index);
|
||
if (bll_subsubject.Add(subsubject))
|
||
{
|
||
if (null != subject.subSubjectStepInfos)
|
||
{
|
||
var step_index = 1;
|
||
foreach (var step in subject.subSubjectStepInfos)
|
||
{
|
||
//`no` varchar(50) '题号',
|
||
// `description` varchar(255) '步骤描述',
|
||
//`total` decimal(11, 3) '总分',
|
||
//`score` decimal(11, 3) '得分',
|
||
var substep = step;
|
||
var step_id = BasePage.GetNextId(subject_id, step_index++);
|
||
substep.id = step_id;
|
||
substep.subsubject_id = subject_id;
|
||
substep.create_time = now.AddSeconds(index);
|
||
bll_subsubjectstep.Add(substep);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
ret = GetResult(true, result_item);
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
//}
|
||
}
|
||
|
||
public string GetFileExtension(string FileName, string yourAnswer)
|
||
{
|
||
var temp = Path.GetExtension(FileName);
|
||
if (temp == ".dat" || string.IsNullOrEmpty(temp))
|
||
{
|
||
temp = Path.GetExtension(yourAnswer);
|
||
}
|
||
if (temp == ".dat" || string.IsNullOrEmpty(temp))
|
||
{
|
||
temp = ".jpeg";
|
||
}
|
||
return temp;
|
||
}
|
||
|
||
|
||
public void SaveResult(HttpContext context)
|
||
{
|
||
|
||
//?subjectid = 10002 & loginname = xy1001 & totalresult = 27 & content = 备注 & mode = 0 & time = 2020-1-1
|
||
|
||
//参数 subject_id 科目id
|
||
//参数 user_id (id_card)
|
||
//参数 totalresult 总分值
|
||
//参数 sjms 模式:训练、考核
|
||
//参数 sign_boat 船型
|
||
//参数 examine_type 考核类型: 0 测验 ,1 考试
|
||
//参数 sjms 实践模式 训练、考核
|
||
|
||
/*
|
||
b1 sign_boat 内河1000吨以上油船
|
||
b2 sign_boat 内河1000吨以下油船
|
||
b3 sign_boat 内河1000吨以上危化品船
|
||
b4 sign_boat 内河1000吨以下危化品船
|
||
*/
|
||
|
||
var ret = string.Empty;
|
||
|
||
var sign_boat = context.Request.Params["sign_boat"];
|
||
if (string.IsNullOrEmpty(sign_boat))
|
||
{
|
||
ret = GetResult(false, "sign_boat参数不能为空");
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
var boat = BasePage.list_sign_boat.FirstOrDefault(s => s.type_id == sign_boat);
|
||
if (null == boat)
|
||
{
|
||
ret = GetResult(false, "船型不能为空,参数sign_boat:" + sign_boat);
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
|
||
var subject_id = context.Request.Params["subject_id"];
|
||
if (string.IsNullOrEmpty(subject_id))
|
||
{
|
||
ret = GetResult(false, "subject_id参数不能为空");
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
var subject = bll_subject.GetModel(subject_id);
|
||
if (null == subject)
|
||
{
|
||
ret = GetResult(false, "科目不能为空,参数 subject_id:" + subject_id);
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
|
||
var user_id = context.Request.Params["user_id"];
|
||
if (string.IsNullOrEmpty(user_id))
|
||
{
|
||
ret = GetResult(false, "user_id参数不能为空");
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
|
||
var user = bll_user.GetModel(user_id);
|
||
if (null == user)
|
||
{
|
||
ret = GetResult(false, "学员不能为空,参数 user_id:" + user_id);
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
|
||
|
||
var totalresult = context.Request.Params["totalresult"];
|
||
if (string.IsNullOrEmpty(totalresult))
|
||
{
|
||
ret = GetResult(false, "totalresult参数不能为空");
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
Decimal d_total_result = 0;
|
||
if (!Decimal.TryParse(totalresult, out d_total_result))
|
||
{
|
||
ret = GetResult(false, "总分值不合法,参数totalresult:" + totalresult);
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
var sjms = context.Request.Params["sjms"];
|
||
|
||
var data = context.Request.Params["data"];
|
||
if (string.IsNullOrEmpty(data))
|
||
{
|
||
ret = GetResult(false, "data参数不能为空");
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
|
||
List<ResultDetailInfo> detail_list = null;
|
||
try
|
||
{
|
||
detail_list = JsonConvert.DeserializeObject<List<ResultDetailInfo>>(data);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
ret = GetResult(false, "考核步骤列表转换错误:" + ex.Message);
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
|
||
var examine_time = DateTime.Now;
|
||
|
||
DataService.Model.pro_result resultModel = new DataService.Model.pro_result();
|
||
var result_id = BasePage.GetLongId();
|
||
resultModel.result_id = result_id;
|
||
resultModel.subject_id = subject_id;
|
||
resultModel.subject_name = subject.subject_name;
|
||
|
||
resultModel.user_id = user_id;
|
||
resultModel.real_name = user.real_name;
|
||
|
||
resultModel.major = user.sex; //性别
|
||
resultModel.examine_term = user.id_card; //考试身份证号
|
||
|
||
resultModel.sjms = sjms;
|
||
resultModel.examine_time = DateTime.Now;
|
||
resultModel.total_result = d_total_result;
|
||
resultModel.examine_kind = boat.type_id; //考试船型
|
||
resultModel.exam_year = DateTime.Today.Year;
|
||
resultModel.exam_month = DateTime.Today.Month;
|
||
|
||
resultModel.batch_id = "";
|
||
resultModel.batch_name = "";
|
||
resultModel.fault_code = "";
|
||
resultModel.fault_name = "";
|
||
resultModel.practice_content = "";
|
||
|
||
/*
|
||
resultModel.province_id = user.province_id;
|
||
resultModel.city_id = user.city_id;
|
||
resultModel.unit_id = user.unit_id;
|
||
*/
|
||
//resultModel.examine_type = 1; //考核类型: 0 测验 ,1 考试
|
||
|
||
/*
|
||
`batch_id` varchar(255) COLLATE gbk_bin DEFAULT NULL COMMENT '批次id',
|
||
`batch_name` varchar(255) COLLATE gbk_bin DEFAULT NULL COMMENT '批次名称',
|
||
`fault_code` varchar(255) COLLATE gbk_bin DEFAULT NULL COMMENT '故障点编码',
|
||
`fault_name` varchar(255) COLLATE gbk_bin DEFAULT NULL COMMENT '故障点名称',
|
||
`practice_content` text COLLATE gbk_bin COMMENT '实习内容',
|
||
*/
|
||
|
||
if (bll_pro_result.Add(resultModel))
|
||
{
|
||
var insert_count = 0;
|
||
for (int i = 0; i < detail_list.Count; i++)
|
||
{
|
||
var info = detail_list[i];
|
||
var item = new DataService.Model.pro_result_detail();
|
||
item.detail_id = BasePage.GetLongId();
|
||
item.result_id = result_id;
|
||
|
||
item.tip = info.tip;
|
||
item.name = info.name;
|
||
item.step = info.step;
|
||
item.score = info.score;
|
||
item.r1 = info.r1; //步骤备注
|
||
|
||
item.subject_id = subject.subject_id;
|
||
item.subject_name = subject.subject_name;
|
||
item.user_id = user.user_id;
|
||
item.real_name = user.real_name;
|
||
|
||
item.major = user.sex;
|
||
item.sjms = sjms; //实践模式 训练、考核
|
||
item.examine_kind = boat.type_id; //考试船型
|
||
item.examine_term = user.id_card; //考试身份证号
|
||
item.examine_time = examine_time; //考试时间
|
||
if (bll_pro_result_detail.Add(item))
|
||
{
|
||
insert_count++;
|
||
}
|
||
}
|
||
|
||
ret = GetResult(true, resultModel);
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
else
|
||
{
|
||
ret = GetResult(false, null, "添加考试内容失败!");
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
|
||
|
||
/*
|
||
var data = context.Request.Params["data"];
|
||
if (string.IsNullOrEmpty(data))
|
||
{
|
||
ret = GetResult(false, "data参数不能为空");
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
var model = JsonConvert.DeserializeObject<DataService.Model.admin_user>(data);
|
||
*/
|
||
}
|
||
|
||
/// <summary>
|
||
/// 炭黑制造模块得分
|
||
/// </summary>
|
||
public class ResultConfigInfo_TH
|
||
{
|
||
/// <summary>
|
||
/// 题目(模块)标记
|
||
/// </summary>
|
||
public string mark { get; set; }
|
||
|
||
/// <summary>
|
||
/// 题目(模块)中文描述
|
||
/// </summary>
|
||
public string topic { get; set; }
|
||
|
||
|
||
/// <summary>
|
||
/// 总分(最多三位小数)
|
||
/// </summary>
|
||
public decimal total { get; set; }
|
||
|
||
/// <summary>
|
||
/// 得分(最多三位小数)
|
||
/// </summary>
|
||
public decimal score { get; set; }
|
||
|
||
/// <summary>
|
||
/// 字段
|
||
/// </summary>
|
||
public string field { get; set; }
|
||
|
||
/// <summary>
|
||
/// 字段正确值
|
||
/// </summary>
|
||
public string field_yes { get; set; }
|
||
|
||
/// <summary>
|
||
/// 字段错误值
|
||
/// </summary>
|
||
public string field_no { get; set; }
|
||
|
||
/// <summary>
|
||
/// 其他原因
|
||
/// </summary>
|
||
public string other { get; set; }
|
||
}
|
||
|
||
/// <summary>
|
||
/// 步骤详情信息
|
||
/// </summary>
|
||
private class ResultDetailInfo
|
||
{
|
||
/// <summary>
|
||
/// 提示
|
||
/// </summary>
|
||
public string tip { get; set; }
|
||
|
||
/// <summary>
|
||
/// 顺序号
|
||
/// </summary>
|
||
public int step { get; set; }
|
||
|
||
/// <summary>
|
||
/// 设备名称、流程名称
|
||
/// </summary>
|
||
public string name { get; set; }
|
||
|
||
/// <summary>
|
||
/// 得分
|
||
/// </summary>
|
||
public decimal score { get; set; }
|
||
|
||
/// <summary>
|
||
/// 备注
|
||
/// </summary>
|
||
public string r1 { get; set; }
|
||
}
|
||
|
||
/// <summary>
|
||
/// 配置项分值信息
|
||
/// </summary>
|
||
public class ConfigItem
|
||
{
|
||
/// <summary>
|
||
/// 标记
|
||
/// </summary>
|
||
public string mark { get; set; }
|
||
|
||
/// <summary>
|
||
/// 题目
|
||
/// </summary>
|
||
public string topic { get; set; }
|
||
|
||
/// <summary>
|
||
/// 分值
|
||
/// </summary>
|
||
public decimal total { get; set; }
|
||
|
||
/// <summary>
|
||
/// 得分
|
||
/// </summary>
|
||
public decimal score { get; set; }
|
||
|
||
/// <summary>
|
||
/// 字段
|
||
/// </summary>
|
||
public string field { get; set; }
|
||
|
||
/// <summary>
|
||
/// 字段正确值
|
||
/// </summary>
|
||
public string field_yes { get; set; }
|
||
|
||
/// <summary>
|
||
/// 字段错误值
|
||
/// </summary>
|
||
public string field_no { get; set; }
|
||
|
||
/// <summary>
|
||
/// 其他原因
|
||
/// </summary>
|
||
public string other { get; set; }
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 查询部门
|
||
/// </summary>
|
||
/// <param name="context"></param>
|
||
public void QueryDepart(HttpContext context)
|
||
{
|
||
|
||
DataService.BLL.pro_type_manage bll = new DataService.BLL.pro_type_manage();
|
||
var majors = bll.GetModelList(string.Format(" parent_id = 'sign_dep' "));
|
||
List<string> list_result = new List<string>();
|
||
if (majors.Count > 0)
|
||
{
|
||
majors.ForEach(s => { list_result.Add(s.type_name); });
|
||
}
|
||
var result = GetResult(true, list_result.ToArray());
|
||
context.Response.Write(result);
|
||
context.Response.End();
|
||
|
||
|
||
/*
|
||
DataService.BLL.admin_user bll_sysuser = new DataService.BLL.admin_user();
|
||
var array = bll_sysuser.GetFieldValues("dep_name");
|
||
var result = GetResult(true, array.ToArray());
|
||
context.Response.Write(result);
|
||
context.Response.End();
|
||
*/
|
||
}
|
||
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
/// <param name="context"></param>
|
||
public void QueryUser(HttpContext context)
|
||
{
|
||
var ret = string.Empty;
|
||
var id_card = context.Request.Params["id_card"];
|
||
if (string.IsNullOrEmpty(id_card))
|
||
{
|
||
ret = GetResult(false, "身份证号码不能为空");
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
var userModel = bll.GetModelList(string.Format(" id_card = '{0}' ", id_card)).FirstOrDefault();
|
||
if (null != userModel)
|
||
{
|
||
userModel.password = "";
|
||
var result = GetResult(true, userModel);
|
||
context.Response.Write(result);
|
||
context.Response.End();
|
||
}
|
||
else
|
||
{
|
||
var result = GetResult(false, "身份证号码错误!");
|
||
context.Response.Write(result);
|
||
context.Response.End();
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 用户登录
|
||
/// </summary>
|
||
/// <param name="context"></param>
|
||
public void LoginUser(HttpContext context)
|
||
{
|
||
var ret = string.Empty;
|
||
var id_card = context.Request.Params["id_card"];
|
||
if (string.IsNullOrEmpty(id_card))
|
||
{
|
||
ret = GetResult(false, "身份证号码不能为空");
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
var password = context.Request.Params["password"];
|
||
if (string.IsNullOrEmpty(password))
|
||
{
|
||
ret = GetResult(false, "密码不能为空");
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
|
||
var pwd = BasePage.GetMD5(password);
|
||
var userModel = bll.GetModelList(string.Format(" id_card = '{0}' and password= '{1}' ", id_card, pwd)).FirstOrDefault();
|
||
if (null != userModel)
|
||
{
|
||
var result = GetResult(true, userModel);
|
||
context.Response.Write(result);
|
||
context.Response.End();
|
||
}
|
||
else
|
||
{
|
||
var result = GetResult(false, "用户名或密码错误!");
|
||
context.Response.Write(result);
|
||
context.Response.End();
|
||
}
|
||
}
|
||
|
||
|
||
|
||
|
||
/// <summary>
|
||
/// 注册用户
|
||
/// </summary>
|
||
/// <param name="context"></param>
|
||
public void RegUser(HttpContext context)
|
||
{
|
||
|
||
var data = context.Request.Params["data"];
|
||
var ret = string.Empty;
|
||
if (string.IsNullOrEmpty(data))
|
||
{
|
||
ret = GetResult(false, "data参数不能为空");
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
|
||
var model = JsonConvert.DeserializeObject<DataService.Model.admin_user>(data);
|
||
if (string.IsNullOrEmpty(model.id_card))
|
||
{
|
||
ret = GetResult(false, "身份证号不能为空");
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
if (string.IsNullOrEmpty(model.real_name))
|
||
{
|
||
ret = GetResult(false, "姓名不能为空");
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
if (string.IsNullOrEmpty(model.password))
|
||
{
|
||
ret = GetResult(false, "密码不能为空");
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
|
||
|
||
if (!BasePage.IsIdcard(model.id_card))
|
||
{
|
||
ret = GetResult(false, "身份证号码格式错误");
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
|
||
if (model.id_card.Length == 18 && !BasePage.Is_valid_idcard18(model.id_card))
|
||
{
|
||
ret = GetResult(false, "18位身份证号码格式错误");
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
|
||
var userModel = bll.GetModelList(string.Format(" id_card = '{0}' ", model.id_card)).FirstOrDefault();
|
||
if (null != userModel)
|
||
{
|
||
var result = GetResult(false, "身份证号码已经存在!");
|
||
context.Response.Write(result);
|
||
context.Response.End();
|
||
}
|
||
//获取性别
|
||
var sex_str = model.id_card.Substring(model.id_card.Length - 2, 1);
|
||
string[] woman = new string[] { "0", "2", "4", "6", "8" };
|
||
model.sex = "男";
|
||
if (woman.Contains(sex_str))
|
||
{
|
||
model.sex = "女";
|
||
}
|
||
model.user_id = "USER" + GetNewId();
|
||
model.create_time = DateTime.Now;
|
||
model.password = GetMD5(model.password);
|
||
var flag = bll.Add(model);
|
||
if (flag)
|
||
{
|
||
var result = GetResult(true, model);
|
||
context.Response.Write(result);
|
||
}
|
||
else
|
||
{
|
||
var result = GetResult(false, model, "添加失败");
|
||
context.Response.Write(result);
|
||
}
|
||
|
||
}
|
||
|
||
public bool IsReusable
|
||
{
|
||
get
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
}
|
||
} |