86 lines
2.8 KiB
C#
86 lines
2.8 KiB
C#
using Api.Framework;
|
|
using Api.Framework.Events;
|
|
using Api.Framework.Model;
|
|
using Api.Framework.SDK;
|
|
using CsharpHttpHelper;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using WebAPi.Pack;
|
|
using WebAPi.Properties;
|
|
|
|
namespace WebAPi
|
|
{
|
|
public class Class1 : Plugin
|
|
{
|
|
public Class1()
|
|
{
|
|
this.Name = Resources.PluginName;
|
|
this.Note = Resources.PluginNote;
|
|
this.Logo = Resources.WebApi;
|
|
}
|
|
|
|
#region 自定义变量
|
|
//public static Config Config;
|
|
#endregion
|
|
|
|
public override void Start()
|
|
{
|
|
try
|
|
{
|
|
SDK.WebRequestEvent += SDK_WebRequestEvent;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
this.OnLog(ex.Message);
|
|
}
|
|
}
|
|
|
|
private void SDK_WebRequestEvent(object sender, WebRequestEvents e)
|
|
{
|
|
try
|
|
{
|
|
#region
|
|
if (e.Param.ContainsKey("method"))//方法名称
|
|
{
|
|
var method = e.Param["method"].ToLower();
|
|
switch (method)
|
|
{
|
|
case "cvr"://转化率数据
|
|
{
|
|
var resultJson = string.Empty;
|
|
try
|
|
{
|
|
if (!e.Param.ContainsKey("state_time")) throw new Exception("缺少参数state_time");
|
|
if (!e.Param.ContainsKey("end_time")) throw new Exception("缺少参数end_time");
|
|
DateTime stateTime;
|
|
if (!DateTime.TryParse(e.Param["state_time"].ToLower(), out stateTime)) throw new Exception($"state_time格式不正确");
|
|
DateTime endTime;
|
|
if (!DateTime.TryParse(e.Param["end_time"].ToLower(), out endTime)) throw new Exception($"end_time格式不正确");
|
|
|
|
endTime = endTime.AddDays(1);
|
|
Qyery q = new Qyery();
|
|
resultJson = q.FindCVR(stateTime, endTime).Result;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
resultJson = Common.ErrorJson(ex.Message);
|
|
}
|
|
e.Send(resultJson, 200);
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|