using DataService.Model;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Web;
using VRS.Util;
using static Org.BouncyCastle.Math.EC.ECCurve;
namespace VRS.Handler
{
///
/// BreakPoint 的摘要说明
///
public class BreakPoint : BaseHandler, IHttpHandler
{
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();
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();
switch (action)
{
//登录时间
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, "user_id参数不能为空");
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 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;
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();
}
}
///
/// 比赛是否失效
///
///
private void MatchRecord(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();
}
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();
if (null != config)
{
var result = GetResult(true, true);
context.Response.Write(result);
context.Response.End();
}
else
{
var result = GetResult(true, false);
context.Response.Write(result);
context.Response.End();
}
}
///
/// 步骤详情信息
///
private class ResultDetailInfo
{
///
/// 提示
///
public string tip { get; set; }
///
/// 顺序号
///
public int step { get; set; }
///
/// 设备名称、流程名称
///
public string name { get; set; }
///
/// 得分
///
public decimal score { get; set; }
///
/// 备注
///
public string r1 { get; set; }
}
public bool IsReusable
{
get
{
return false;
}
}
}
}