using Newtonsoft.Json.Linq;
|
using System;
|
using System.Collections.Generic;
|
using System.Data;
|
using System.Linq;
|
using System.Reflection;
|
using System.Web;
|
using Terra.YaoGan.Common;
|
using Terra.YaoGan.Service;
|
|
namespace Terra.YaoGan.Web.Ashx
|
{
|
/// <summary>
|
/// Firstcommon 的摘要说明
|
/// </summary>
|
public class Firstcommon : IHttpHandler
|
{
|
|
public void ProcessRequest(HttpContext context)
|
{
|
string Action = context.Request["Action"];
|
|
MethodInfo mif = this.GetType().GetMethod(Action);
|
if (mif != null)
|
{
|
mif.Invoke(this, new object[] { context });
|
}
|
|
}
|
|
//获取数据
|
public void GetAllSumData(HttpContext context)
|
{
|
try
|
{
|
string tableName = context.Request["tableName"];
|
string sql = string.Format(@"select SUM(CAST(area as FLOAT)) Area,[Year] from {0} GROUP BY [Year] ;", tableName);
|
GetTableCommon gt = new GetTableCommon();
|
DataTable dt = gt.GetTable(sql);
|
string jsonStr = DataTableToJson.DtToJson(dt);
|
context.Response.Write(jsonStr);
|
}
|
catch
|
{
|
context.Response.Write("");
|
}
|
|
}
|
|
//获取选择的数据
|
public void GetAllChooseData(HttpContext context)
|
{
|
try
|
{
|
string where = context.Request["pathName"];
|
string TableName = context.Request["tableName"];
|
//转化json对象
|
JArray jo = JArray.Parse(where);
|
|
string sql = "";
|
for (int i = 0; i < jo.Count; i++)
|
{
|
if (i == 0)
|
{
|
sql += string.Format(@"(select SUM(CAST(area as FLOAT)) Area,[Year] from {0} where [Year]='{1}' GROUP BY [Year]
|
union all
|
select '0' as Area, '{1}' as [Year] where not exists(select SUM(CAST(area as FLOAT)) Area,[Year] from {0} where [Year]='{1}'
|
GROUP BY [Year]))", TableName, jo[i]);
|
}
|
else
|
{
|
sql += string.Format(@" union all (select SUM(CAST(area as FLOAT)) Area,[Year] from {0} where [Year]='{1}' GROUP BY [Year]
|
union all
|
select '0' as Area, '{1}' as [Year] where not exists(select SUM(CAST(area as FLOAT)) Area,[Year] from {0} where [Year]='{1}'
|
GROUP BY [Year]))", TableName, jo[i]);
|
}
|
}
|
sql = sql + "order by [Year]";
|
GetTableCommon gt = new GetTableCommon();
|
DataTable dt = gt.GetTable(sql);
|
string jsonStr = DataTableToJson.DtToJson(dt);
|
context.Response.Write(jsonStr);
|
}
|
catch
|
{
|
context.Response.Write("");
|
}
|
|
}
|
|
public bool IsReusable
|
{
|
get
|
{
|
return false;
|
}
|
}
|
}
|
}
|