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>
|
/// DataLake1 的摘要说明
|
/// </summary>
|
public class DataLake1 : 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 GetLakeMessage(HttpContext context)
|
{
|
string where = context.Request["type"];
|
GetTableBySql gt = new GetTableBySql();
|
DataTable dt = gt.GetLakeUrl(where);
|
string jsonStr = DataTableToJson.DtToJson(dt);
|
context.Response.Write(jsonStr);
|
|
}
|
|
//获取当前统计的数据信息
|
public void GetCurrentArea(HttpContext context)
|
{
|
string where = context.Request["pathName"];
|
DataLake gt = new DataLake();
|
DataTable dt = gt.GetCurrentArea(where);
|
string jsonStr = DataTableToJson.DtToJson(dt);
|
context.Response.Write(jsonStr);
|
}
|
|
public void GetManyYearAndManyName(HttpContext context)
|
{
|
string where = context.Request["pathName"];
|
//转化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)) lakeArea,simName,[time] from SSHP where [time]='{0}'
|
AND name='{1}' GROUP BY [time],simName
|
union all
|
select '0' as lakeArea,'{2}' as simName,'{0}' as year where not exists(select SUM(CAST(area as FLOAT))
|
lakeArea, simName,[time] from SSHP where [time] = '{0}'
|
AND name = '{1}' GROUP BY[time], simName))", jo[i]["year"].ToString(), jo[i]["name"].ToString(), jo[i]["titleName"].ToString());
|
}
|
else
|
{
|
sql += string.Format(@" union all (select SUM(CAST(area as FLOAT)) lakeArea,simName,[time] from SSHP where [time]='{0}'
|
AND name='{1}' GROUP BY [time],simName
|
union all
|
select '0' as lakeArea,'{2}' as simName,'{0}' as year where not exists(select SUM(CAST(area as FLOAT))
|
lakeArea, simName,[time] from SSHP where [time] = '{0}'
|
AND name = '{1}' GROUP BY [time], simName))", jo[i]["year"].ToString(), jo[i]["name"].ToString(), jo[i]["titleName"].ToString());
|
}
|
}
|
sql = sql + "order by simName,[time]";
|
DataLake gt = new DataLake();
|
DataTable dt = gt.GetManyYearAndManyLake(sql);
|
string jsonStr = DataTableToJson.DtToJson(dt);
|
context.Response.Write(jsonStr);
|
}
|
|
//获取数据
|
public void GetAllSumData(HttpContext context)
|
{
|
string tableName = context.Request["pathName"];
|
string sql = string.Format(@"select SUM(CAST(area as FLOAT)) Area,[Year] from {0} GROUP BY [Year] ;", tableName);
|
DataLake gt = new DataLake();
|
DataTable dt = gt.GetManyYearAndManyLake(sql);
|
string jsonStr = DataTableToJson.DtToJson(dt);
|
context.Response.Write(jsonStr);
|
}
|
|
//获取TDGF的数据
|
public void GetAllChooseDataTDGF(HttpContext context)
|
{
|
string where = context.Request["pathName"];
|
//转化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 TDGF where [Year]='{0}' GROUP BY [Year]
|
union all
|
select '0' as Area, '{0}' as [Year] where not exists(select SUM(CAST(area as FLOAT)) Area,[Year] from TDGF where [Year]='{0}'
|
GROUP BY [Year]))", jo[i]);
|
}
|
else
|
{
|
sql += string.Format(@" union all (select SUM(CAST(area as FLOAT)) Area,[Year] from TDGF where [Year]='{0}' GROUP BY [Year]
|
union all
|
select '0' as Area, '{0}' as [Year] where not exists(select SUM(CAST(area as FLOAT)) Area,[Year] from TDGF where [Year]='{0}'
|
GROUP BY [Year]))", jo[i]);
|
}
|
}
|
sql = sql + "order by [Year]";
|
DataLake gt = new DataLake();
|
DataTable dt = gt.GetManyYearAndManyLake(sql);
|
string jsonStr = DataTableToJson.DtToJson(dt);
|
context.Response.Write(jsonStr);
|
}
|
|
|
//获取湖泊的年份
|
public void GetHPyear(HttpContext context)
|
{
|
string where = context.Request["simName"];
|
string[] arr = where.Split('*');
|
string wherecase= "";
|
for(var i = 0; i < arr.Length; i++)
|
{
|
wherecase += "'"+arr[i]+"',";
|
}
|
string sql = string.Format(@"select [time] from SSHP where simName in ({0}) GROUP BY [time]",
|
wherecase.Substring(0,wherecase.Length-1));
|
DataLake gt = new DataLake();
|
DataTable dt = gt.GetYear(sql);
|
string jsonStr = DataTableToJson.DtToJson(dt);
|
context.Response.Write(jsonStr);
|
}
|
|
public bool IsReusable
|
{
|
get
|
{
|
return false;
|
}
|
}
|
}
|
}
|