1712 lines
64 KiB
C#
1712 lines
64 KiB
C#
using DataService.Model;
|
||
using Newtonsoft.Json;
|
||
using Newtonsoft.Json.Linq;
|
||
using NPOI.OpenXmlFormats.Wordprocessing;
|
||
using NPOI.SS.Formula.Functions;
|
||
using System;
|
||
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using System.Diagnostics;
|
||
using System.IO;
|
||
using System.Linq;
|
||
using System.Reflection;
|
||
using System.Text.RegularExpressions;
|
||
using System.Web;
|
||
using System.Web.Caching;
|
||
using VRS.Util;
|
||
using static Org.BouncyCastle.Math.EC.ECCurve;
|
||
|
||
|
||
namespace VRS.Handler
|
||
{
|
||
/// <summary>
|
||
/// Config 的摘要说明
|
||
/// </summary>
|
||
public class Config : 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.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.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_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.set_data_acquisition bll_data_acquisition = new DataService.BLL.set_data_acquisition();
|
||
|
||
DataService.BLL.exam_result_detail_config bll_exam_result_detail_config = new DataService.BLL.exam_result_detail_config();
|
||
DataService.BLL.admin_log log = new DataService.BLL.admin_log();
|
||
|
||
DataService.BLL.exam_result_match_record bll_exam_result_match_record = new DataService.BLL.exam_result_match_record();
|
||
|
||
DataService.BLL.breakpoint_continuation bll_breakpoint_continuation = new DataService.BLL.breakpoint_continuation();
|
||
|
||
|
||
DataService.BLL.admin_log bll_admin_log = new DataService.BLL.admin_log();
|
||
|
||
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"].ToLower();
|
||
//log.write_log("登录接口:" + action);
|
||
switch (action)
|
||
{
|
||
//保存竞赛考试
|
||
case "savemathch":
|
||
saveMatch(context);
|
||
break;
|
||
|
||
//保存实训考试
|
||
case "saveresult":
|
||
SaveExam(context);
|
||
break;
|
||
//保存用户缓存答案
|
||
case "updatecache":
|
||
UpdateCache(context);
|
||
break;
|
||
//查询用户缓存答案
|
||
case "querycache":
|
||
QueryCache(context);
|
||
break;
|
||
|
||
//查询全部答案
|
||
case "queryallanswer":
|
||
QueryAllAnswer(context);
|
||
break;
|
||
|
||
//查询正确答案
|
||
case "queryanswer":
|
||
QueryAnswer(context);
|
||
break;
|
||
|
||
//查询默认值
|
||
case "querydefault":
|
||
QueryDefault(context);
|
||
break;
|
||
|
||
//查询正确答案
|
||
case "queryanswerth":
|
||
QueryAnswerTH(context);
|
||
break;
|
||
|
||
//查询树形结构
|
||
case "queryacquisition":
|
||
QueryAcquisition(context);
|
||
break;
|
||
|
||
//查询树形结构
|
||
case "updateacquisition":
|
||
UpdateAcquisition(context);
|
||
break;
|
||
|
||
//显示图表
|
||
case "displaychart":
|
||
displaychart(context);
|
||
break;
|
||
|
||
//登录时间
|
||
case "matchrecord":
|
||
MatchRecord(context);
|
||
break;
|
||
|
||
//保存断点
|
||
case "savebreakpoint":
|
||
SaveBreakPoint(context);
|
||
break;
|
||
|
||
default:
|
||
var result = GetResult(false, "方法名不存在:" + action);
|
||
context.Response.Write(result);
|
||
break;
|
||
}
|
||
}
|
||
|
||
|
||
private void SaveBreakPoint(HttpContext context)
|
||
{
|
||
var ret = string.Empty;
|
||
|
||
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 type = context.Request.Params["type"];
|
||
if (string.IsNullOrEmpty(type))
|
||
{
|
||
ret = GetResult(false, "type参数不能为空");
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
var step = context.Request.Params["step"];
|
||
if (string.IsNullOrEmpty(step))
|
||
{
|
||
ret = GetResult(false, "step参数不能为空");
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
var data = context.Request.Params["data"];
|
||
var device_id = context.Request.Params["device_id"];
|
||
var score = context.Request.Params["score"];
|
||
|
||
DateTime dt = DateTime.Now;
|
||
var config = bll_exam_result_match_record.GetModelList(string.Format(" user_id = '{0}' and start_time<'{1}' and expire_time>'{1}' ", user_id, dt)).FirstOrDefault();
|
||
|
||
var obj = new DataService.Model.breakpoint_continuation();
|
||
obj.id = BasePage.GetId();
|
||
obj.user_id = user_id;
|
||
obj.step = step;
|
||
obj.type = type;
|
||
obj.record_time = DateTime.Now;
|
||
obj.data = data;
|
||
obj.device_id = device_id;
|
||
if (config != null)
|
||
{
|
||
obj.record_id = config.id;
|
||
}
|
||
bool add_flag = bll_breakpoint_continuation.Add(obj);
|
||
if (add_flag)
|
||
{
|
||
var result = GetResult(true, obj, "添加断点成功");
|
||
context.Response.Write(result);
|
||
context.Response.End();
|
||
}
|
||
else
|
||
{
|
||
var result = GetResult(false, null, "添加树形失败");
|
||
context.Response.Write(result);
|
||
context.Response.End();
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 比赛是否失效
|
||
/// </summary>
|
||
/// <param name="context"></param>
|
||
private void MatchRecord(HttpContext context)
|
||
{
|
||
var ret = string.Empty;
|
||
DateTime dt = DateTime.Now;
|
||
string sql = string.Format(" 1=1 and start_time<'{0}' and expire_time>'{0}' ", dt);
|
||
string sql2 = " 1=1 ";
|
||
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();
|
||
}
|
||
else
|
||
{
|
||
sql += string.Format(" and user_id='{0}' ", user_id);
|
||
}
|
||
var type = context.Request.Params["type"];
|
||
if (string.IsNullOrEmpty(type))
|
||
{
|
||
//ret = GetResult(false, "type参数不能为空");
|
||
//context.Response.Write(ret);
|
||
//context.Response.End();
|
||
}
|
||
else
|
||
{
|
||
sql2 += string.Format(" and type='{0}' ", type);
|
||
}
|
||
var step = context.Request.Params["step"];
|
||
if (string.IsNullOrEmpty(step))
|
||
{
|
||
//ret = GetResult(false, "step参数不能为空");
|
||
//context.Response.Write(ret);
|
||
//context.Response.End();
|
||
}
|
||
else
|
||
{
|
||
sql2 += string.Format(" and step='{0}' ", step);
|
||
}
|
||
|
||
|
||
var device_id = context.Request.Params["device_id"];
|
||
if (!string.IsNullOrEmpty(device_id))
|
||
{
|
||
sql2 += string.Format(" and device_id='{0}' ", device_id);
|
||
}
|
||
|
||
var config = bll_exam_result_match_record.GetModelList(sql).FirstOrDefault();
|
||
if (null != config)
|
||
{
|
||
sql2 += string.Format(" and user_id = '{0}' and record_id='{1}' order by record_time desc ", user_id, config.id);
|
||
List<breakpoint_continuation> break_list = new List<breakpoint_continuation>();
|
||
|
||
break_list = bll_breakpoint_continuation.GetModelList(sql2);
|
||
if (break_list.Count > 0)
|
||
{
|
||
var result = GetResult(true, break_list.Select(x => x.data).FirstOrDefault(), "true");
|
||
context.Response.Write(result);
|
||
context.Response.End();
|
||
}
|
||
else
|
||
{
|
||
var result = GetResult(true, "", "false");
|
||
context.Response.Write(result);
|
||
context.Response.End();
|
||
}
|
||
}
|
||
else
|
||
{
|
||
var datetime = DateTime.Now;
|
||
var obj = new DataService.Model.exam_result_match_record();
|
||
obj.id = BasePage.GetId();
|
||
obj.user_id = user_id;
|
||
obj.start_time = datetime;
|
||
obj.expire_time = datetime.AddDays(1);
|
||
bool add_flag = bll_exam_result_match_record.Add(obj);
|
||
|
||
var result = GetResult(true, "", "false");
|
||
context.Response.Write(result);
|
||
context.Response.End();
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 断点查询
|
||
/// </summary>
|
||
public class QueryBreakPoint
|
||
{
|
||
|
||
public string score { get; set; }
|
||
|
||
public string data { get; set; }
|
||
}
|
||
/// <summary>
|
||
/// 显示图表
|
||
/// </summary>
|
||
/// <param name="context"></param>
|
||
private void displaychart(HttpContext context)
|
||
{
|
||
var ret = string.Empty;
|
||
|
||
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();
|
||
}
|
||
|
||
DisplaychartClass dpClass = new DisplaychartClass();
|
||
var config_yx = bll_exam_result_detail_config.GetModelConfigList(string.Format(" mark = '{0}' and user_id='{1}' ", "CKFWQ_yx", user_id)).FirstOrDefault();
|
||
if (null != config_yx)
|
||
{
|
||
if (config_yx.score > 0)
|
||
{
|
||
dpClass.ck_yx = true;
|
||
}
|
||
|
||
}
|
||
|
||
var config_wx = bll_exam_result_detail_config.GetModelConfigList(string.Format(" mark = '{0}' and user_id='{1}' ", "CKFWQ_wx", user_id)).FirstOrDefault();
|
||
if (null != config_wx)
|
||
{
|
||
if (config_wx.score > 0)
|
||
{
|
||
dpClass.ck_wx = true;
|
||
}
|
||
|
||
}
|
||
|
||
#region old methods for lan_box1 ,wlan_box1 show
|
||
/*
|
||
var answer_wp = bll_config_answer.GetModelList(string.Format(" mark = '{0}' ", "YDPZYM_wgpz")).FirstOrDefault();
|
||
var config_wp = bll_config_cache.GetModelList(string.Format(" mark = '{0}' and user_id='{1}' ", "YDPZYM_wgpz", user_id)).FirstOrDefault();
|
||
Dictionary<string, bool> dic_wgid = new Dictionary<string, bool>();
|
||
|
||
if (answer_wp != null && config_wp != null)
|
||
{
|
||
if (answer_wp.answer != null && config_wp.mark_value != null)
|
||
{
|
||
|
||
Dictionary<string, Dictionary<string, string>> dic_list = new Dictionary<string, Dictionary<string, string>>();
|
||
Dictionary<string, Dictionary<string, string>> dic_or_list = new Dictionary<string, Dictionary<string, string>>();
|
||
|
||
List<YDPZYMWgpz> og = JsonConvert.DeserializeObject<List<YDPZYMWgpz>>(answer_wp.answer);
|
||
List<YDPZYMWgpz> nw = JsonConvert.DeserializeObject<List<YDPZYMWgpz>>(config_wp.mark_value);
|
||
|
||
foreach (YDPZYMWgpz t in og)
|
||
{
|
||
System.Reflection.FieldInfo[] fields = t.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
|
||
|
||
string field_name = "";
|
||
Dictionary<string, string> dic = new Dictionary<string, string>();
|
||
foreach (System.Reflection.FieldInfo of in fields)
|
||
{
|
||
var reflected_name = of.Name.Replace("<", "").Replace(">", "").Replace("k__BackingField", "");
|
||
if (reflected_name == "wgid")
|
||
{
|
||
field_name = of.GetValue(t).ToString();
|
||
}
|
||
object value_oj = of.GetValue(t);
|
||
if (value_oj != null)
|
||
{
|
||
dic.Add(reflected_name, value_oj.ToString());
|
||
}
|
||
else
|
||
{
|
||
dic.Add(reflected_name, "");
|
||
}
|
||
}
|
||
dic_or_list.Add(field_name, dic);
|
||
}
|
||
|
||
|
||
foreach (YDPZYMWgpz t in nw)
|
||
{
|
||
System.Reflection.FieldInfo[] fields = t.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
|
||
|
||
string field_name = "";
|
||
Dictionary<string, string> dic = new Dictionary<string, string>();
|
||
foreach (System.Reflection.FieldInfo of in fields)
|
||
{
|
||
var reflected_name = of.Name.Replace("<", "").Replace(">", "").Replace("k__BackingField", "");
|
||
if (reflected_name == "wgid")
|
||
{
|
||
field_name = of.GetValue(t).ToString();
|
||
}
|
||
object value_oj = of.GetValue(t);
|
||
if (value_oj != null)
|
||
{
|
||
dic.Add(reflected_name, value_oj.ToString());
|
||
}
|
||
else
|
||
{
|
||
dic.Add(reflected_name, "");
|
||
}
|
||
}
|
||
dic_list.Add(field_name, dic);
|
||
}
|
||
|
||
foreach (var dic in dic_or_list)
|
||
{
|
||
|
||
if (dic_list.Where(x => x.Key == dic.Key).Count() > 0)
|
||
{
|
||
var dc = dic_list.Where(x => x.Key == dic.Key).FirstOrDefault();
|
||
Dictionary<string, string> dic_or = dic.Value;
|
||
var isright = true;
|
||
foreach (var or in dic_or)
|
||
{
|
||
var m = dc.Value.Where(x => x.Key == or.Key).FirstOrDefault();
|
||
if (!Equals(or.Value, m.Value))
|
||
{
|
||
isright = false;
|
||
break;
|
||
}
|
||
}
|
||
dic_wgid.Add(dic.Key, isright);
|
||
}
|
||
else
|
||
{
|
||
dic_wgid.Add(dic.Key, false);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
Dictionary<string, bool> dic_wgid_ww = new Dictionary<string, bool>();
|
||
var answer_ww = bll_config_answer.GetModelList(string.Format(" mark = '{0}' ", "YDPZYM_wgwh")).FirstOrDefault();
|
||
var config_ww = bll_config_cache.GetModelList(string.Format(" mark = '{0}' and user_id='{1}' ", "YDPZYM_wgwh", user_id)).FirstOrDefault();
|
||
if (answer_ww != null && config_ww != null)
|
||
{
|
||
if (answer_ww.answer != null && config_ww.mark_value != null)
|
||
{
|
||
|
||
Dictionary<string, Dictionary<string, string>> dic_list1 = new Dictionary<string, Dictionary<string, string>>();
|
||
Dictionary<string, Dictionary<string, string>> dic_or_list1 = new Dictionary<string, Dictionary<string, string>>();
|
||
List<YDPZYMWgwh> og = JsonConvert.DeserializeObject<List<YDPZYMWgwh>>(answer_ww.answer);
|
||
List<YDPZYMWgwh> nw = JsonConvert.DeserializeObject<List<YDPZYMWgwh>>(config_ww.mark_value);
|
||
|
||
|
||
foreach (YDPZYMWgwh t in og)
|
||
{
|
||
System.Reflection.FieldInfo[] fields = t.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
|
||
|
||
string field_name = "";
|
||
Dictionary<string, string> dic = new Dictionary<string, string>();
|
||
foreach (System.Reflection.FieldInfo of in fields)
|
||
{
|
||
var reflected_name = of.Name.Replace("<", "").Replace(">", "").Replace("k__BackingField", "");
|
||
if (reflected_name == "sswg")
|
||
{
|
||
field_name = of.GetValue(t).ToString();
|
||
}
|
||
object value_oj = of.GetValue(t);
|
||
if (value_oj != null)
|
||
{
|
||
dic.Add(reflected_name, value_oj.ToString());
|
||
}
|
||
else
|
||
{
|
||
dic.Add(reflected_name, "");
|
||
}
|
||
}
|
||
dic_or_list1.Add(field_name, dic);
|
||
}
|
||
|
||
|
||
foreach (YDPZYMWgwh t in nw)
|
||
{
|
||
System.Reflection.FieldInfo[] fields = t.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
|
||
|
||
string field_name = "";
|
||
Dictionary<string, string> dic = new Dictionary<string, string>();
|
||
foreach (System.Reflection.FieldInfo of in fields)
|
||
{
|
||
var reflected_name = of.Name.Replace("<", "").Replace(">", "").Replace("k__BackingField", "");
|
||
if (reflected_name == "sswg")
|
||
{
|
||
field_name = of.GetValue(t).ToString();
|
||
}
|
||
object value_oj = of.GetValue(t);
|
||
if (value_oj != null)
|
||
{
|
||
dic.Add(reflected_name, value_oj.ToString());
|
||
}
|
||
else
|
||
{
|
||
dic.Add(reflected_name, "");
|
||
}
|
||
}
|
||
dic_list1.Add(field_name, dic);
|
||
}
|
||
|
||
foreach (var dic in dic_or_list1)
|
||
{
|
||
|
||
if (dic_list1.Where(x => x.Key == dic.Key).Count() > 0)
|
||
{
|
||
var dc = dic_list1.Where(x => x.Key == dic.Key).FirstOrDefault();
|
||
Dictionary<string, string> dic_or = dic.Value;
|
||
var isright = true;
|
||
foreach (var or in dic_or)
|
||
{
|
||
var m = dc.Value.Where(x => x.Key == or.Key).FirstOrDefault();
|
||
if (!Equals(or.Value, m.Value))
|
||
{
|
||
isright = false;
|
||
break;
|
||
}
|
||
}
|
||
dic_wgid_ww.Add(dic.Key, isright);
|
||
}
|
||
else
|
||
{
|
||
dic_wgid_ww.Add(dic.Key, false);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
if (dic_wgid != null && dic_wgid_ww != null && dic_wgid.Count() > 0 && dic_wgid_ww.Count() > 0)
|
||
{
|
||
|
||
foreach (var d in dic_wgid)
|
||
{
|
||
if (dic_wgid_ww.Where(x => x.Key == d.Key).Count() > 0)
|
||
{
|
||
var mod = dic_wgid_ww.Where(x => x.Key == d.Key).FirstOrDefault();
|
||
if (d.Value && mod.Value)
|
||
{
|
||
if (d.Key == "lan-box1")
|
||
{
|
||
dpClass.lan_box1 = true;
|
||
}
|
||
if (d.Key == "lan-box2")
|
||
{
|
||
dpClass.lan_box2 = true;
|
||
}
|
||
if (d.Key == "wlan-box1")
|
||
{
|
||
dpClass.wlan_box1 = true;
|
||
}
|
||
if (d.Key == "wlan-box2")
|
||
{
|
||
dpClass.wlan_box2 = true;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
*/
|
||
|
||
#endregion
|
||
|
||
var msg = "";
|
||
var if_wgpz = false;
|
||
var if_wgwh = false;
|
||
var if_line = false;
|
||
var if_db_yx = false;
|
||
var if_db_wx = false;
|
||
var if_ch_wx = false;
|
||
var if_ch_yx = false;
|
||
var matchid = "";
|
||
//网关配置
|
||
var config_YDPZYM_wgpz = bll_exam_result_detail_config.GetModelConfigList(string.Format(" mark = '{0}' and user_id='{1}' ", "YDPZYM_wgpz", user_id)).FirstOrDefault();
|
||
if (null != config_YDPZYM_wgpz)
|
||
{
|
||
matchid = config_YDPZYM_wgpz.result_id;
|
||
if (config_YDPZYM_wgpz.score > 0)
|
||
{
|
||
if_wgpz = true;
|
||
}
|
||
else
|
||
{
|
||
msg = "网关配置得分为0!";
|
||
}
|
||
}
|
||
else
|
||
{
|
||
msg = "网关配置答案不存在!";
|
||
}
|
||
//网关维护
|
||
var config_YDPZYM_wgwh = bll_exam_result_detail_config.GetModelConfigList(string.Format(" mark = '{0}' and user_id='{1}' ", "YDPZYM_wgwh", user_id)).FirstOrDefault();
|
||
if (null != config_YDPZYM_wgwh)
|
||
{
|
||
matchid = config_YDPZYM_wgwh.result_id;
|
||
if (config_YDPZYM_wgwh.score > 0)
|
||
{
|
||
if_wgwh = true;
|
||
}
|
||
else
|
||
{
|
||
msg += " 网关维护得分为0!";
|
||
}
|
||
}
|
||
else
|
||
{
|
||
msg += " 网关维护答案不存在!";
|
||
}
|
||
|
||
//产量数据监控 DB-IotLite_yx DB-IotLite网关有线
|
||
var config_DB_yx = bll_exam_result_detail_config.GetModelConfigList(string.Format(" mark = '{0}' and user_id='{1}' ", "DB-IotLite_yx", user_id)).FirstOrDefault();
|
||
if (null != config_DB_yx)
|
||
{
|
||
matchid = config_DB_yx.result_id;
|
||
if (config_DB_yx.score > 0)
|
||
{
|
||
if_db_yx = true;
|
||
}
|
||
else
|
||
{
|
||
msg += " DB-IotLite网关有线得分为0!";
|
||
}
|
||
}
|
||
else
|
||
{
|
||
msg += " DB-IotLite网关有线答案不存在!";
|
||
}
|
||
//急停状态 DB-IotLite_wx DB-IotLite网关无线
|
||
var config_DB_wx = bll_exam_result_detail_config.GetModelConfigList(string.Format(" mark = '{0}' and user_id='{1}' ", "DB-IotLite_wx", user_id)).FirstOrDefault();
|
||
if (null != config_DB_wx)
|
||
{
|
||
matchid = config_DB_wx.result_id;
|
||
if (config_DB_wx.score > 0)
|
||
{
|
||
if_db_wx = true;
|
||
}
|
||
else
|
||
{
|
||
msg += " DB-IotLite网关无线线得分为0!";
|
||
}
|
||
}
|
||
else
|
||
{
|
||
msg += " DB-IotLite网关无线答案不存在!";
|
||
}
|
||
|
||
//主轴转速
|
||
var config_CHGYWG_yx = bll_exam_result_detail_config.GetModelConfigList(string.Format(" mark = '{0}' and user_id='{1}' ", "CHGYWG_yx", user_id)).FirstOrDefault();
|
||
if (null != config_CHGYWG_yx)
|
||
{
|
||
matchid = config_CHGYWG_yx.result_id;
|
||
if (config_CHGYWG_yx.score > 0)
|
||
{
|
||
if_ch_yx = true;
|
||
}
|
||
else
|
||
{
|
||
msg += " 斥候工业网关有线 得分为0!";
|
||
}
|
||
}
|
||
else
|
||
{
|
||
msg += " 斥候工业网关有线答案不存在!";
|
||
}
|
||
|
||
//切削速度 CHGYWG_wx 斥候工业网关无线
|
||
var config_CHGYWG_wx = bll_exam_result_detail_config.GetModelConfigList(string.Format(" mark = '{0}' and user_id='{1}' ", "CHGYWG_wx", user_id)).FirstOrDefault();
|
||
if (null != config_CHGYWG_wx)
|
||
{
|
||
matchid = config_CHGYWG_wx.result_id;
|
||
if (config_CHGYWG_wx.score > 0)
|
||
{
|
||
if_ch_wx = true;
|
||
}
|
||
else
|
||
{
|
||
msg += " 斥候工业网关无线 得分为0!";
|
||
}
|
||
}
|
||
else
|
||
{
|
||
msg += " 斥候工业网关无线答案不存在!";
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
|
||
//设备连线
|
||
if (!string.IsNullOrEmpty(matchid))
|
||
{
|
||
var model = bll_exam_result_match.GetModel(matchid);
|
||
if (null != model)
|
||
{
|
||
if (model.score > 0)
|
||
{
|
||
if_line = true;
|
||
}
|
||
else
|
||
{
|
||
msg += " 设备连线得分为0!";
|
||
}
|
||
}
|
||
else
|
||
{
|
||
msg += " 设备连线成绩不存在!";
|
||
}
|
||
}
|
||
|
||
dpClass.lan_box1 = false;
|
||
dpClass.lan_box2 = false;
|
||
dpClass.wlan_box1 = false;
|
||
dpClass.wlan_box2 = false;
|
||
|
||
if (if_wgpz && if_wgwh && if_line)
|
||
{
|
||
if (if_db_yx)
|
||
{
|
||
dpClass.lan_box1 = true;//产量
|
||
}
|
||
if (if_ch_yx)
|
||
{
|
||
dpClass.lan_box2 = true; //主轴转速
|
||
}
|
||
if (if_db_wx)
|
||
{
|
||
dpClass.wlan_box1 = true; //急停
|
||
}
|
||
if (if_ch_wx)
|
||
{
|
||
dpClass.wlan_box2 = true; //切削速度
|
||
}
|
||
}
|
||
|
||
|
||
|
||
var result = GetResult(true, dpClass, msg);
|
||
context.Response.Write(result);
|
||
context.Response.End();
|
||
|
||
}
|
||
|
||
|
||
public class DisplaychartClass
|
||
{
|
||
|
||
public bool ck_yx { get; set; } = false;
|
||
|
||
public bool ck_wx { get; set; } = false;
|
||
public bool lan_box1 { get; set; } = false;
|
||
|
||
public bool lan_box2 { get; set; } = false;
|
||
|
||
public bool wlan_box1 { get; set; } = false;
|
||
|
||
public bool wlan_box2 { get; set; } = false;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取树形结构
|
||
/// </summary>
|
||
/// <param name="context"></param>
|
||
|
||
private void QueryAcquisition(HttpContext context)
|
||
{
|
||
set_data_acquisition config = new set_data_acquisition();
|
||
var ret = string.Empty;
|
||
var user_id = context.Request.Params["user_id"];
|
||
string wh = " 1=1";
|
||
var type = context.Request.Params["type"];
|
||
if (!string.IsNullOrEmpty(user_id) && user_id != "undefined")
|
||
{
|
||
wh += string.Format(" and ( user_id='{0}' or user_id IS nuLL or user_id ='') and type='{1}' ", user_id, type);
|
||
}
|
||
else
|
||
{
|
||
wh += string.Format(" and (user_id IS nuLL or user_id ='' ) and type='{0}'", type);
|
||
}
|
||
List<set_data_acquisition> config_list = bll_data_acquisition.GetModelList(wh);
|
||
if (config_list != null && config_list.Count() > 0)
|
||
{
|
||
if (config_list.Count() > 1)
|
||
{
|
||
config = config_list.Where(x => x.user_id == user_id)?.FirstOrDefault();
|
||
}
|
||
else
|
||
{
|
||
config = config_list.FirstOrDefault();
|
||
}
|
||
}
|
||
else
|
||
{
|
||
config = null;
|
||
}
|
||
var result = GetResult(true, config);
|
||
context.Response.Write(result);
|
||
context.Response.End();
|
||
|
||
}
|
||
|
||
/// <summary>
|
||
/// 查询用户缓存答案
|
||
/// </summary>
|
||
/// <param name="context"></param>
|
||
public void QueryCache(HttpContext context)
|
||
{
|
||
var ret = string.Empty;
|
||
|
||
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 mark = context.Request.Params["mark"];
|
||
if (string.IsNullOrEmpty(mark))
|
||
{
|
||
ret = GetResult(false, "mark参数不能为空");
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
DateTime datetime = DateTime.Now;
|
||
var cache = bll_config_cache.GetModelList(string.Format(" mark = '{0}' and user_id='{1}' or ( start_time<'{2}' and expire_time='{2}') ", mark, user_id, datetime)).FirstOrDefault();
|
||
if (null != cache)
|
||
{
|
||
var result = GetResult(true, cache);
|
||
context.Response.Write(result);
|
||
context.Response.End();
|
||
}
|
||
else
|
||
{
|
||
var result = GetResult(false, "参数mark:" + mark + ",user_id:" + user_id + ",用户缓存答案不存在!");
|
||
context.Response.Write(result);
|
||
context.Response.End();
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 更新树形
|
||
/// </summary>
|
||
/// <param name="context"></param>
|
||
public void UpdateAcquisition(HttpContext context)
|
||
{
|
||
var ret = string.Empty;
|
||
|
||
var user_id = context.Request.Params["user_id"];
|
||
/*
|
||
if (string.IsNullOrEmpty(user_id) || user_id == "undefined")
|
||
{
|
||
ret = GetResult(false, "user_id参数不能为空");
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
|
||
if (user_id.Contains("="))
|
||
{
|
||
ret = GetResult(false, "user_id参数不能包含等号!");
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
*/
|
||
|
||
var type = context.Request.Params["type"];
|
||
if (string.IsNullOrEmpty(type))
|
||
{
|
||
ret = GetResult(false, "type参数不能为空");
|
||
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 lang = context.Request.Params["lang"];
|
||
/*
|
||
if (string.IsNullOrEmpty(lang))
|
||
{
|
||
ret = GetResult(false, "lang参数不能为空");
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
*/
|
||
|
||
|
||
var acquisition = bll_data_acquisition.GetModelList(string.Format(" user_id='{0}' and type='{1}' ", user_id, type)).FirstOrDefault();
|
||
if (null != acquisition) //修改缓存
|
||
{
|
||
|
||
//exam_result_match_record bll_exam_result_match_record=
|
||
|
||
// acquisition.data = data; //$$$$
|
||
if (lang == "1") //英文
|
||
{
|
||
acquisition.r2 = data;
|
||
}
|
||
else
|
||
{
|
||
acquisition.data = data;
|
||
}
|
||
acquisition.type = type;
|
||
acquisition.r3 = "lang:" + lang;
|
||
bool update_flag = bll_data_acquisition.Update(acquisition);
|
||
if (update_flag)
|
||
{
|
||
var result = GetResult(true, acquisition, "修改树形成功");
|
||
context.Response.Write(result);
|
||
context.Response.End();
|
||
}
|
||
else
|
||
{
|
||
var result = GetResult(false, null, "修改树形失败");
|
||
context.Response.Write(result);
|
||
context.Response.End();
|
||
}
|
||
}
|
||
else //添加缓存
|
||
{
|
||
var obj = new DataService.Model.set_data_acquisition();
|
||
obj.id = BasePage.GetId();
|
||
obj.user_id = user_id;
|
||
//obj.data = data; //$$$$ old
|
||
if (lang == "1") //英文
|
||
{
|
||
obj.r2 = data;
|
||
}
|
||
else
|
||
{
|
||
obj.data = data;
|
||
}
|
||
|
||
obj.type = type;
|
||
obj.update_time = DateTime.Now;
|
||
obj.r3 = "lang:" + lang;
|
||
bool add_flag = bll_data_acquisition.Add(obj);
|
||
if (add_flag)
|
||
{
|
||
var result = GetResult(true, obj, "添加树形成功");
|
||
context.Response.Write(result);
|
||
context.Response.End();
|
||
}
|
||
else
|
||
{
|
||
var result = GetResult(false, null, "添加树形失败");
|
||
context.Response.Write(result);
|
||
context.Response.End();
|
||
}
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 更新用户缓存答案
|
||
/// </summary>
|
||
/// <param name="context"></param>
|
||
public void UpdateCache(HttpContext context)
|
||
{
|
||
|
||
var ret = string.Empty;
|
||
|
||
var user_id = context.Request.Params["user_id"];
|
||
/*
|
||
if (string.IsNullOrEmpty(user_id) || user_id== "undefined")
|
||
{
|
||
ret = GetResult(false, "user_id参数不能为空");
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
|
||
if (user_id.Contains("="))
|
||
{
|
||
ret = GetResult(false, "user_id参数不能包含等号!");
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
*/
|
||
|
||
var mark = context.Request.Params["mark"];
|
||
if (string.IsNullOrEmpty(mark))
|
||
{
|
||
ret = GetResult(false, "mark参数不能为空");
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
|
||
var mark_value = context.Request.Params["mark_value"];
|
||
if (string.IsNullOrEmpty(mark_value))
|
||
{
|
||
ret = GetResult(false, "mark_value参数不能为空");
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
var step = context.Request.Params["step"];
|
||
//bll_admin_log.write_log("日志 UpdateCache:mark" + mark_value);
|
||
var cache = bll_config_cache.GetModelList(string.Format(" mark = '{0}' and user_id='{1}' ", mark, user_id)).FirstOrDefault();
|
||
if (null != cache) //修改缓存
|
||
{
|
||
DateTime dt = new DateTime();
|
||
var record = bll_exam_result_match_record.GetModelList(string.Format(" start_time < '{0}' and expire_time>'{0}' and user_id='{1}' ", dt, user_id)).FirstOrDefault();
|
||
cache.step = step;
|
||
cache.mark_value = mark_value;
|
||
cache.step = step;
|
||
cache.update_time = DateTime.Now;
|
||
if (record != null)
|
||
{
|
||
cache.start_time = record.start_time;
|
||
cache.expire_time = record.expire_time;
|
||
}
|
||
bool update_flag = bll_config_cache.Update(cache);
|
||
if (update_flag)
|
||
{
|
||
var result = GetResult(true, cache, "修改缓存成功");
|
||
context.Response.Write(result);
|
||
context.Response.End();
|
||
}
|
||
else
|
||
{
|
||
var result = GetResult(false, null, "修改缓存失败");
|
||
context.Response.Write(result);
|
||
context.Response.End();
|
||
}
|
||
}
|
||
else //添加缓存
|
||
{
|
||
DateTime dt = DateTime.Now;
|
||
var config = bll_exam_result_match_record.GetModelList(string.Format(" user_id = '{0}' and start_time<'{1}' and expire_time>'{1}' ", user_id, dt)).FirstOrDefault();
|
||
var obj = new DataService.Model.exam_config_cache();
|
||
obj.id = BasePage.GetId();
|
||
obj.user_id = user_id;
|
||
obj.mark = mark;
|
||
obj.mark_value = mark_value;
|
||
obj.step = step;
|
||
obj.update_time = DateTime.Now;
|
||
if (config != null)
|
||
{
|
||
obj.start_time = obj.start_time;
|
||
obj.expire_time = obj.expire_time;
|
||
}
|
||
bool add_flag = bll_config_cache.Add(obj);
|
||
if (add_flag)
|
||
{
|
||
var result = GetResult(true, null, "添加缓存成功");
|
||
context.Response.Write(result);
|
||
context.Response.End();
|
||
}
|
||
else
|
||
{
|
||
var result = GetResult(false, null, "添加缓存失败");
|
||
context.Response.Write(result);
|
||
context.Response.End();
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 查询正确答案
|
||
/// </summary>
|
||
/// <param name="context"></param>
|
||
public void QueryAnswer(HttpContext context)
|
||
{
|
||
var ret = string.Empty;
|
||
var mark = context.Request.Params["mark"];
|
||
if (string.IsNullOrEmpty(mark))
|
||
{
|
||
ret = GetResult(false, "mark参数不能为空");
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
var config = bll_config_answer.GetModelList(string.Format(" mark = '{0}' ", mark)).FirstOrDefault();
|
||
if (null != config)
|
||
{
|
||
#region excel替换固定答案
|
||
/*
|
||
if (config.id != "10011" && config.id != "10012")
|
||
{
|
||
config.old_answer = config.answer;
|
||
config.answer = config.r2;
|
||
config.default_answer = config.r3;
|
||
}
|
||
|
||
d1.r2 = db_yx;
|
||
d1.r3 = db_yx_default;
|
||
d1.r2_en_answer = db_yx_en;
|
||
d1.r3_en_default = db_yx_default_en;
|
||
*/
|
||
if (config.id != "10011" && config.id != "10012")
|
||
{
|
||
var is_test = System.Configuration.ConfigurationManager.AppSettings["is_test"];
|
||
config.desc = "answer:过去版本答案、r2:excel答案配置-中文、r3:excel默认配置-中文、r3_en_default:excel默认配置(英文)" + ",test=" + is_test;
|
||
if (is_test == "1")
|
||
{
|
||
//测试中文默认值用的 $$$$
|
||
config.r3 = config.r2;
|
||
//测试英文默认值用的 $$$$
|
||
config.r3_en_default = config.r2_en_answer;
|
||
}
|
||
|
||
}
|
||
#endregion
|
||
|
||
var result = GetResult(true, config);
|
||
context.Response.Write(result);
|
||
context.Response.End();
|
||
}
|
||
else
|
||
{
|
||
var result = GetResult(false, "参数mark:" + mark + ",答案不存在!");
|
||
context.Response.Write(result);
|
||
context.Response.End();
|
||
}
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 查询中英文默认值
|
||
/// </summary>
|
||
/// <param name="context"></param>
|
||
public void QueryDefault(HttpContext context)
|
||
{
|
||
var ret = string.Empty;
|
||
var mark = context.Request.Params["mark"];
|
||
if (string.IsNullOrEmpty(mark))
|
||
{
|
||
ret = GetResult(false, "mark参数不能为空");
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
|
||
var lang = context.Request.Params["lang"];
|
||
if (string.IsNullOrEmpty(lang))
|
||
{
|
||
ret = GetResult(false, "lang参数不能为空");
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
if (lang != "1" && lang != "0")
|
||
{
|
||
ret = GetResult(false, "lang取值范围 0:中文、1:英文");
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
|
||
var config = bll_config_answer.GetModelList(string.Format(" mark = '{0}' ", mark)).FirstOrDefault();
|
||
if (null != config)
|
||
{
|
||
#region excel替换固定答案
|
||
var is_test = System.Configuration.ConfigurationManager.AppSettings["is_test"];
|
||
#endregion
|
||
var back = string.Empty;
|
||
if (lang == "1") //英文
|
||
{
|
||
back = config.r3_en_default; //excel默认-英文
|
||
if (is_test == "1")
|
||
{
|
||
back = config.r2_en_answer; //excel答案-英文
|
||
}
|
||
}
|
||
else if (lang == "0") //中文
|
||
{
|
||
back = config.r3; //excel默认-中文
|
||
if (is_test == "1")
|
||
{
|
||
back = config.r2; //excel答案-中文
|
||
}
|
||
}
|
||
var result = GetResult(true, back, "");
|
||
context.Response.Write(result);
|
||
context.Response.End();
|
||
}
|
||
else
|
||
{
|
||
var result = GetResult(false, "参数mark:" + mark + ",答案默认值不存在!");
|
||
context.Response.Write(result);
|
||
context.Response.End();
|
||
}
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 查询正确答案--炭黑生产制造
|
||
/// </summary>
|
||
/// <param name="context"></param>
|
||
public void QueryAnswerTH(HttpContext context)
|
||
{
|
||
var ret = string.Empty;
|
||
var id = context.Request.Params["id"];
|
||
if (string.IsNullOrEmpty(id))
|
||
{
|
||
ret = GetResult(false, "id参数不能为空");
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
var config = bll_config_answer.GetModelList(string.Format(" id = '{0}' ", id)).FirstOrDefault();
|
||
if (null != config)
|
||
{
|
||
#region excel替换固定答案
|
||
/*
|
||
if (config.id != "10011" && config.id != "10012")
|
||
{
|
||
config.old_answer = config.answer;
|
||
config.answer = config.r2;
|
||
config.default_answer = config.r3;
|
||
}
|
||
|
||
d1.r2 = db_yx;
|
||
d1.r3 = db_yx_default;
|
||
d1.r2_en_answer = db_yx_en;
|
||
d1.r3_en_default = db_yx_default_en;
|
||
*/
|
||
|
||
/*
|
||
if (config.id != "10011" && config.id != "10012")
|
||
{
|
||
var is_test = System.Configuration.ConfigurationManager.AppSettings["is_test"];
|
||
config.desc = "answer:过去版本答案、r2:excel答案配置-中文、r3:excel默认配置-中文、r3_en_default:excel默认配置(英文)" + ",test=" + is_test;
|
||
if (is_test == "1")
|
||
{
|
||
//测试中文默认值用的 $$$$
|
||
config.r3 = config.r2;
|
||
//测试英文默认值用的 $$$$
|
||
config.r3_en_default = config.r2_en_answer;
|
||
}
|
||
|
||
}
|
||
*/
|
||
#endregion
|
||
|
||
var result = GetResult(true, config);
|
||
context.Response.Write(result);
|
||
context.Response.End();
|
||
}
|
||
else
|
||
{
|
||
var result = GetResult(false, "参数id:" + id + ",答案不存在!");
|
||
context.Response.Write(result);
|
||
context.Response.End();
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 查询全部答案
|
||
/// </summary>
|
||
/// <param name="context"></param>
|
||
public void QueryAllAnswer(HttpContext context)
|
||
{
|
||
var config_list = bll_config_answer.GetModelList("");
|
||
|
||
|
||
#region excel替换固定答案
|
||
|
||
foreach (var config in config_list)
|
||
{
|
||
|
||
if (config.id != "10011" && config.id != "10012")
|
||
{
|
||
//config.old_answer = config.answer;
|
||
//config.answer = config.r2;
|
||
//config.default_answer = config.r3;
|
||
//config.desc = "answer:过去版本答案、r2:excel答案配置、r3:excel默认配置、r3_en_default:excel默认配置(英文)";
|
||
|
||
//测试用的 $$$$
|
||
//config.r3 = config.r2;
|
||
|
||
var is_test = System.Configuration.ConfigurationManager.AppSettings["is_test"];
|
||
config.desc = "answer:过去版本答案、r2:excel答案配置-中文、r3:excel默认配置-中文、r3_en_default:excel默认配置(英文)" + ",test=" + is_test;
|
||
if (is_test == "1")
|
||
{
|
||
//测试中文默认值用的 $$$$
|
||
config.r3 = config.r2;
|
||
//测试英文默认值用的 $$$$
|
||
config.r3_en_default = config.r2_en_answer;
|
||
}
|
||
}
|
||
|
||
|
||
|
||
}
|
||
|
||
#endregion
|
||
var result = GetResult(true, config_list);
|
||
context.Response.Write(result);
|
||
context.Response.End();
|
||
}
|
||
|
||
//保存竞赛考试
|
||
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();
|
||
}
|
||
|
||
|
||
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);
|
||
|
||
|
||
var now = DateTime.Now;
|
||
var result_id = BasePage.GetNewId();
|
||
result_item.id = result_id;
|
||
result_item.create_time = now;
|
||
result_item.pic_url = "~/" + uploadPath + NewfileName; //文件路径-相对路径
|
||
|
||
if (bll_exam_result_match.Add(result_item))
|
||
{
|
||
ret = GetResult(true, result_item);
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
|
||
}
|
||
|
||
|
||
//保存考试
|
||
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 = Guid.NewGuid().ToString("N");
|
||
result_item.id = result_id;
|
||
//result_item.sjms = "1"; 实训模式
|
||
result_item.create_time = now;
|
||
if (bll_exam_result.Add(result_item))
|
||
{
|
||
foreach (var item in result_detail_list_shixun)
|
||
{
|
||
item.id = Guid.NewGuid().ToString("N");
|
||
item.result_id = result_id;
|
||
item.create_time = now;
|
||
bll_exam_result_detail_shixun.Add(item);
|
||
}
|
||
|
||
ret = GetResult(true, result_item);
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
}
|
||
else //考试考核模式
|
||
{
|
||
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> 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;
|
||
var result_id = Guid.NewGuid().ToString("N");
|
||
result_item.id = result_id;
|
||
result_item.sjms = "0";
|
||
result_item.create_time = now;
|
||
if (bll_exam_result.Add(result_item))
|
||
{
|
||
foreach (var item in result_detail_list)
|
||
{
|
||
item.id = Guid.NewGuid().ToString("N");
|
||
item.result_id = result_id;
|
||
item.create_time = now;
|
||
bll_exam_result_detail.Add(item);
|
||
}
|
||
|
||
ret = GetResult(true, result_item);
|
||
context.Response.Write(ret);
|
||
context.Response.End();
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
|
||
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>
|
||
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; }
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
|
||
public bool IsReusable
|
||
{
|
||
get
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
}
|
||
} |