1.初始化项目。保险起见bin目录完整提交 2.基于现场代码为调整过的初始项目(此次提交还未解决代码差异问题)
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
using Nancy;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Nancy.ModelBinding;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace HxBusiness
|
||||
{
|
||||
public class APIContainer : NancyModule
|
||||
{
|
||||
public APIContainer()
|
||||
{
|
||||
var tasks = new Dictionary<int, string>();
|
||||
//Get["api/get"] = GetStr;
|
||||
Get("api/get", parameters => GetStr(parameters));
|
||||
//更新任务
|
||||
//Post("api/sendpermission") = UpdateTraffic;
|
||||
Post("api/sendpermission", parameters => UpdateTraffic(parameters));
|
||||
|
||||
}
|
||||
private object GetStr(dynamic o)
|
||||
{
|
||||
try
|
||||
{
|
||||
string str = Request.Query["id"];
|
||||
return "test Api" + str;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ex.ToString();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 更新任务
|
||||
/// </summary>
|
||||
/// <param name="o"></param>
|
||||
/// <returns></returns>
|
||||
private object UpdateTraffic(dynamic o)
|
||||
{
|
||||
ResponseModel resultmodel = new ResponseModel();
|
||||
try
|
||||
{
|
||||
string[] tagPoint = { "280", "282" };
|
||||
SendModel parmmodel = this.Bind<SendModel>();
|
||||
string str = JsonConvert.SerializeObject(parmmodel);
|
||||
WriteTxt.SaveLog1("接收到授权请求!" + str, "api日志");
|
||||
if (parmmodel.interchangePointCode.Equals(tagPoint[0]) || parmmodel.interchangePointCode.Equals(tagPoint[1]))
|
||||
{
|
||||
|
||||
resultmodel.code = 0;
|
||||
resultmodel.msg = "成功";
|
||||
resultmodel.data = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
resultmodel.code = -2;
|
||||
resultmodel.msg = "交汇点地标不存在!";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
resultmodel.code = -1;
|
||||
resultmodel.data = "服务器错误:" + ex.ToString();
|
||||
}
|
||||
return JsonConvert.SerializeObject(resultmodel);
|
||||
}
|
||||
|
||||
public object Root(dynamic o)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user