public void ProcessRequest(HttpContext context) { int catchId = 0; int queryStart = 0, queryNum = 500; try { catchId = Convert.ToInt32(context.Request.Params["catchId"].ToLower()); } catch { context.Response.Write(null); context.Response.End(); return; } context.Response.ContentType = "text/plain"; context.Response.Clear(); List <DataOverview> dataOverviews = new List <DataOverview>(); MetroTunnelDB Database = null; try { Database = new MetroTunnelDB(); Database.QueryDataOverview(ref dataOverviews, catchId, queryStart, queryNum); } catch (System.Exception) { context.Response.Write(null); context.Response.End(); return; } if (dataOverviews.Count < 1) { context.Response.Write(null); context.Response.End(); return; } RootJson rootJson = new RootJson(); rootJson.data = new DataJson(); rootJson.data.records = new List <RecordsJson>(); int records_count = 0; for (int i = 0; i < dataOverviews.Count; i++) { if (dataOverviews[i].Crack) { rootJson.data.records.Add(new RecordsJson(dataOverviews[i].Distance, dataOverviews[i].Distance)); records_count++; } } rootJson.data.recordsCount = records_count.ToString(); string rootJsonStr = JsonConvert.SerializeObject(rootJson); context.Response.Write(rootJsonStr); context.Response.End(); }
public void ProcessRequest(HttpContext context) { int catchId = 0, queryStart = 0, queryNum = 0; try { catchId = Convert.ToInt32(context.Request.Params["catchId"].ToLower()); queryStart = Convert.ToInt32(context.Request.Params["queryStart"].ToLower()); queryNum = Convert.ToInt32(context.Request.Params["queryNum"].ToLower()); } catch (System.Exception) { context.Response.Write(null); context.Response.End(); return; } context.Response.ContentType = "text/plain"; context.Response.Clear(); List <DataDisp> dataDisps = new List <DataDisp>(); MetroTunnelDB Database = null; try { Database = new MetroTunnelDB(); Database.QueryDataDisp(ref dataDisps, catchId, queryStart, queryNum); } catch (System.Exception) { context.Response.Write(null); context.Response.End(); return; } if (dataDisps.Count < 1) { context.Response.Write(null); context.Response.End(); return; } RootJson rootJson = new RootJson(); rootJson.data = new DataJson(); rootJson.data.records = "["; for (int i = 0; i < dataDisps.Count; i++) { rootJson.data.records += dataDisps[i].JsonString.Substring(1, dataDisps[i].JsonString.Length - 2); } rootJson.data.records += "]"; string rootJsonStr = JsonConvert.SerializeObject(rootJson).Replace("\\", "").Replace("\"[{", "[{").Replace("}]\"", "}]"); context.Response.Write(rootJsonStr); context.Response.End(); }
public void ProcessRequest(HttpContext context) { int lineId = Convert.ToInt32(context.Request.Params["lineId"].ToLower()); context.Response.ContentType = "text/plain"; context.Response.Clear(); List <DetectRecord> detectRecords = new List <DetectRecord>(); try { MetroTunnelDB Database = new MetroTunnelDB(); Database.QueryDetectRecord(ref detectRecords, lineId); } catch (System.Exception) { context.Response.Write(null); context.Response.End(); return; } RootJson rootJson = new RootJson(); rootJson.data = new DataJson(); rootJson.data.dates = new List <string>(); if (detectRecords.Count < 1) { context.Response.Write(null); context.Response.End(); return; } for (int i = 0; i < detectRecords.Count; i++) { rootJson.data.dates.Add(detectRecords[i].DetectTime.ToString("yyyy-MM-dd")); } string rootJsonStr = JsonConvert.SerializeObject(rootJson); context.Response.Write(rootJsonStr); context.Response.End(); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; context.Response.Clear(); List <Line> lines = new List <Line>(); try { MetroTunnelDB Database = new MetroTunnelDB(); Database.QueryLine(ref lines); } catch (System.Exception) { context.Response.Write(null); context.Response.End(); return; } RootJson rootJson = new RootJson(); rootJson.data = new DataJson(); rootJson.data.lines = new List <LinesJson>(); if (lines.Count < 1) { context.Response.Write(null); context.Response.End(); return; } for (int i = 0; i < lines.Count; i++) { rootJson.data.lines.Add(new LinesJson(lines[i].LineNumber, lines[i].LineName)); } string rootJsonStr = JsonConvert.SerializeObject(rootJson); context.Response.Write(rootJsonStr); context.Response.End(); }
public void ProcessRequest(HttpContext context) { int lineId = 0; DateTime date, end_date; try { lineId = Convert.ToInt32(context.Request.Params["lineId"].ToLower()); date = Convert.ToDateTime(context.Request.Params["date"].ToLower()); end_date = date.AddDays(1); } catch (System.Exception) { context.Response.Write(null); context.Response.End(); return; } context.Response.ContentType = "text/plain"; context.Response.Clear(); List <DetectRecord> detectRecords = new List <DetectRecord>(); MetroTunnelDB Database = null; try { Database = new MetroTunnelDB(); Database.QueryDetectRecord(ref detectRecords, lineId, date, end_date); } catch (System.Exception) { context.Response.Write(null); context.Response.End(); return; } RootJson rootJson = new RootJson(); rootJson.data = new DataJson(); rootJson.data.devices = new List <DevicesJson>(); if (detectRecords.Count < 1) { context.Response.Write(null); context.Response.End(); return; } // 清除重复设备名 Dictionary <string, string> device_dict = new Dictionary <string, string>(); for (int i = 0; i < detectRecords.Count; i++) { if (!device_dict.ContainsKey(detectRecords[i].DeviceID)) { List <DetectDevice> detectDevices = new List <DetectDevice>(); try { Database.QueryDetectDevice(ref detectDevices, detectRecords[i].DeviceID); } catch (System.Exception) { continue; } device_dict.Add(detectRecords[i].DeviceID, detectDevices[0].DetectDeviceName); } } // 遍历非重复设备 foreach (string deviceId in device_dict.Keys) { rootJson.data.devices.Add(new DevicesJson(deviceId, device_dict[deviceId])); } string rootJsonStr = JsonConvert.SerializeObject(rootJson); context.Response.Write(rootJsonStr); context.Response.End(); }
public void ProcessRequest(HttpContext context) { int lineId = 0; DateTime date, end_date; try { lineId = Convert.ToInt32(context.Request.Params["lineId"].ToLower()); date = Convert.ToDateTime(context.Request.Params["date"].ToLower()); end_date = date.AddDays(1); } catch (System.Exception) { context.Response.Write(null); context.Response.End(); return; } context.Response.ContentType = "text/plain"; context.Response.Clear(); List <DetectRecord> detectRecords = new List <DetectRecord>(); MetroTunnelDB Database = null; try { Database = new MetroTunnelDB(); Database.QueryDetectRecord(ref detectRecords, lineId, date, end_date); } catch (System.Exception) { context.Response.Write(null); context.Response.End(); return; } if (detectRecords.Count < 1) { context.Response.Write(null); context.Response.End(); return; } RootJson rootJson = new RootJson(); rootJson.data = new DataJson(); rootJson.data.records = new List <RecordsJson>(); for (int i = 0; i < detectRecords.Count; i++) { List <DataOverview> dataOverviews = new List <DataOverview>(); int recordsCount = 0; try { Database.QueryDataOverview(ref dataOverviews, (int)(detectRecords[i].RecordID)); recordsCount = dataOverviews.Count(); } catch (System.Exception) { ; } rootJson.data.records.Add(new RecordsJson((int)detectRecords[i].RecordID, detectRecords[i].DeviceID, detectRecords[i].Length, recordsCount)); } string rootJsonStr = JsonConvert.SerializeObject(rootJson); context.Response.Write(rootJsonStr); context.Response.End(); }