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

180 lines
5.4 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

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

using 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
{
/// <summary>
/// BreakPoint 的摘要说明
/// </summary>
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();
}
}
/// <summary>
/// 比赛是否失效
/// </summary>
/// <param name="context"></param>
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();
}
}
/// <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;
}
}
}
}