67 lines
2.1 KiB
C#
67 lines
2.1 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using System.Web;
|
||
|
||
namespace VRS.Handler
|
||
{
|
||
/// <summary>
|
||
/// 参数读取与修改
|
||
/// </summary>
|
||
public class Para : BasePage, IHttpHandler
|
||
{
|
||
DataService.BLL.pro_para bll_para = new DataService.BLL.pro_para();
|
||
public override void ProcessRequest(HttpContext context)
|
||
{
|
||
context.Response.ContentType = "text/plain";
|
||
string mode = context.Request.Params["mode"]; // 类型1 修改,0 读取
|
||
var collection = context.Request.QueryString;
|
||
String[] keyArray = collection.AllKeys;
|
||
var para = bll_para.GetModelFirst();
|
||
if (null == para)
|
||
{
|
||
context.Response.Write(GetJsonWithCode(APICode.Fail, "参数配置记录不存在!"));
|
||
context.Response.End();
|
||
}
|
||
|
||
if (mode == "1") //修改参数记录
|
||
{
|
||
foreach (string attribute in keyArray)
|
||
{
|
||
if (attribute == "mode")
|
||
{
|
||
continue;
|
||
}
|
||
var value = collection.Get(attribute);
|
||
BasePage.SetValueByStrAttribute(para, attribute, value);
|
||
}
|
||
if (keyArray.Length > 1)
|
||
{
|
||
if (bll_para.Update(para))
|
||
{
|
||
context.Response.Write(GetJsonWithCode(APICode.Success, para));
|
||
context.Response.End();
|
||
}
|
||
else
|
||
{
|
||
context.Response.Write(GetJsonWithCode(APICode.Fail, "修改参数配置失败!"));
|
||
context.Response.End();
|
||
}
|
||
}
|
||
}
|
||
else //读取参数记录
|
||
{
|
||
context.Response.Write(GetJsonWithCode(APICode.Success, para));
|
||
context.Response.End();
|
||
}
|
||
}
|
||
|
||
public new bool IsReusable
|
||
{
|
||
get
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
}
|
||
} |