1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267 |
- using Microsoft.AspNetCore.Mvc;
- using Newtonsoft.Json;
- using Newtonsoft.Json.Linq;
- using System;
- using System.Collections.Generic;
- using System.Net;
- using System.Net.Http;
- using System.Net.Http.Headers;
- using System.Text;
- using System.Threading.Tasks;
- using Microsoft.AspNetCore.SignalR;
- using Microsoft.Extensions.Logging;
- using Ropin.Environmentally.WebScada.Hubs;
- using Microsoft.AspNet.SignalR.Client;
- using Microsoft.AspNetCore.SignalR.Client;
- using FBoxClientDriver.Contract;
- using System.Threading;
- using Microsoft.AspNetCore.Http;
- using Serilog;
- using Microsoft.AspNetCore.NodeServices;
- using InfluxData.Net.InfluxDb;
- using InfluxData.Net.Common.Enums;
- using System.Linq;
- namespace Ropin.Environmentally.WebScada
- {
- public class DeviceController : Controller
- {
- private readonly IHubContext<MyHub> _hubContext;
- private readonly ILogger<DeviceController> _logger;
- private Microsoft.AspNetCore.SignalR.Client.HubConnection _hubConnection;
- private readonly INodeServices _services;
- private InfluxDbClient clientDb;
- public DeviceController(ILogger<DeviceController> logger, INodeServices services,IHubContext<MyHub> hubContext)
- {
- _logger = logger;
- _hubContext = hubContext;
- _services = services;
- }
- [HttpGet]
- public async Task<string> GetName()
- {
- string greetingMessage = await _services.InvokeAsync<string>("./scripts/greeter", "yandaniu");
- return greetingMessage;
- }
- public TokenResult GetToken(AccessUser accessUser)
- {
- var url = "https://fbox360.com/idserver/core/connect/token";
- TokenResult token;
- Dictionary<string, object> data = new Dictionary<string, object>();
- try
- {
- if (accessUser == null)
- {
- throw new Exception("参数为空");
- }
- else
- {
- Dictionary<string, string> dict = new Dictionary<string, string>();
- if (!string.IsNullOrEmpty(accessUser.refresh_token))
- {
- dict["grant_type"] = "refresh_token";
- dict["refresh_token"] = accessUser.refresh_token;
- }
- else
- {
- dict["grant_type"] = "client_credentials";
- dict["client_id"] = accessUser.client_id;
- dict["client_secret"] = accessUser.client_secret;
- dict["scope"] = "fbox";
- }
- using (HttpClient http = new HttpClient())
- {
- using (var content = new FormUrlEncodedContent(dict))
- {
- var msg = http.PostAsync(url, content);
- if (msg.IsFaulted)
- {
- return null;
- }
- else
- {
- var result = msg.Result.Content.ReadAsStringAsync().Result;
- token = JsonConvert.DeserializeObject<TokenResult>(result);
- }
-
- }
- }
- }
- return token;
- }
- catch (Exception ex)
- {
- return null;
- }
- }
- DeviceValueModel device = new DeviceValueModel();
- private void _fbox_DataMonitorValueChanged(object sender, IList<DataMonitorValueChangedArgs> e)
- {
- foreach (var dmon in e)
- {
- var deviceValue = $"dmv:{dmon.Uid},Value:{dmon.Value},Status:{dmon.Status},BoxNo:{dmon.BoxNo},Name:{dmon.Name},BoxId:{dmon.BoxId},GroupName:{dmon.GroupName},Timestamp:{dmon.Timestamp}";
-
-
- System.DateTime currentTime = new System.DateTime();
- currentTime = System.DateTime.Now;
- Console.WriteLine(currentTime);
-
- switch (dmon.Uid)
- {
- case 224873575130485457:
- device.Value = dmon.Value?.ToString();
- device.Name = dmon.Name;
- break;
- case 225981652471795782:
- device.Value10 = dmon.Value?.ToString();
- device.Name10 = dmon.Name;
- break;
- case 224873679711261516:
- device.Value11 = dmon.Value?.ToString();
- device.Name11 = dmon.Name;
- break;
- case 225975315764502499:
- device.Value12 = dmon.Value?.ToString();
- device.Name12 = dmon.Name;
- break;
- case 225975390380118077:
- device.Value13 = dmon.Value?.ToString();
- device.Name13 = dmon.Name;
- break;
- case 224872713744176788:
- device.Value14 = dmon.Value?.ToString();
- device.Name14 = dmon.Name;
- break;
- default:
- break;
- }
-
-
-
-
- }
- _hubContext.Clients.All.SendAsync("UpdateDeviceData", device);
-
-
- }
- void devRun()
- {
- using (var dmon = new demo())
- {
- dmon._fbox.DataMonitorValueChanged += _fbox_DataMonitorValueChanged;
- dmon.Start().Wait();
- string ln = "aa";
- do
- {
- ln = Console.ReadLine();
- } while (ln != "quit");
- }
- }
- public void js()
- {
-
- string jsStr = "var i=100; i++; i=i*100; var obj = {a:i};";
-
-
- object ret1 = null;
- try
- {
-
- }
- catch (Exception ex)
- {
-
- return;
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
- public async Task<object> GetDevSpotSeries()
- {
- IniInflux();
-
- var queries = new[]
- {
- " SELECT * FROM fanyidev WHERE time > now() - 5m"
- };
- var dbName = "fanyidb";
-
- var response = await clientDb.Client.QueryAsync(queries, dbName);
-
- var series = response.ToList();
-
- var list = series[0].Values;
-
-
- return list;
- }
-
-
-
-
-
-
-
- public async Task<object> GetDevSpotSeriesAsync(string[] point,DateTime start,DateTime end)
- {
- if (point?.Length == 0)
- {
- return null;
- }
- string strStart = start.ToString("yyyy-MM-ddTHH:mm:ssZ");
- string strEnd = end.ToString("yyyy-MM-ddTHH:mm:ssZ");
- string strId = point[0];
- IniInflux();
-
- var queries = new[]
- {
-
-
-
- "SELECT * FROM fanyidev WHERE time>"+strStart+" and time< "+strEnd + " and Id = "+strId+" order by time desc limit 10"
- };
- var dbName = "fanyidb";
-
- var response = await clientDb.Client.QueryAsync(queries, dbName);
-
- var series = response.ToList();
-
- var list = series[0].Values;
-
-
- return list;
- }
- private void IniInflux()
- {
-
- var infuxUrl = "http://60.204.212.71:8085/";
- var infuxUser = "admin";
- var infuxPwd = "123456";
-
- clientDb = new InfluxDbClient(infuxUrl, infuxUser, infuxPwd, InfluxDbVersion.Latest);
- }
- public async Task<IActionResult> Index()
- {
-
- string id = Request.Query["id"];
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- DeviceValueModel model = new DeviceValueModel();
-
- TokenResult tokenResult = GetToken(new AccessUser { client_id = "b19d14eeacb74522bd29627b79c18ab8", client_secret = "7b89e021586c43d3b79440ba6eea0b67" });
- using (HttpClient client = new HttpClient())
- {
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenResult.access_token);
- var requestt = new HttpRequestMessage(HttpMethod.Get, "https://fbox360.com/api/client/box/grouped");
- requestt.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
- var response = await client.SendAsync(requestt);
- string result = await response.Content.ReadAsStringAsync();
- if (response.StatusCode != HttpStatusCode.OK)
- {
- }
- else
- {
-
- }
- }
- goto getDeviceValue;
- using (HttpClient client = new HttpClient())
- {
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenResult.access_token);
- var requestt = new HttpRequestMessage(HttpMethod.Get, " https://fbox360.com/api/v2/box/4316279314564828131/dmon/grouped");
- requestt.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
- var response = await client.SendAsync(requestt);
- string result = await response.Content.ReadAsStringAsync();
- if (response.StatusCode == HttpStatusCode.OK)
- {
- List<Device> deviceVueList = JsonConvert.DeserializeObject<List<Device>>(result);
- model.Name = deviceVueList[0].items[0].grpName + deviceVueList[0].items[0].name;
- model.Value = deviceVueList[0].items[0].intDigits;
- model.Name10 = deviceVueList[0].items[1].grpName + deviceVueList[0].items[1].name;
- model.Value10 = deviceVueList[0].items[1].intDigits;
- model.Name11 = deviceVueList[0].items[2].grpName + deviceVueList[0].items[2].name;
- model.Value11 = deviceVueList[0].items[2].intDigits;
- model.Name12 = deviceVueList[0].items[3].grpName + deviceVueList[0].items[3].name;
- model.Value12 = deviceVueList[0].items[3].intDigits;
- model.Name13 = deviceVueList[0].items[4].grpName + deviceVueList[0].items[4].name;
- model.Value13 = deviceVueList[0].items[4].intDigits;
-
-
- }
- else
- {
-
- }
- }
- getDeviceValue:
- using (HttpClient client = new HttpClient())
- {
- string postData = Newtonsoft.Json.JsonConvert.SerializeObject(new
- {
-
-
-
- names = new List<string> {
- "自动油雾过滤器电子差压计D0实际值",
- "前处理过滤箱电子差压计D2实际值",
- "前处理过滤箱电子差压计D3实际值",
- "蜂窝沸石转筒电子差压计D4实际值",
- "\"数据块_1\".运行时间记录_D",
- "\"数据块_1\".运行时间记录_H",
- "\"数据块_1\".运行时间记录_M",
- "报警1",
- "主加热器1",
- "辅助加热器1",
- "主风机1"},
- groupnames = new List<string> {
- "喷漆房1",
- "喷漆房1",
- "喷漆房1",
- "喷漆房1",
- "喷漆房1",
- "喷漆房1",
- "喷漆房1",
- "喷漆房1",
- "喷漆房1",
- "喷漆房1",
- "喷漆房1"},
- timeOut = 6000
- });
-
- #region ceshi
- using (var httpClient = new HttpClient())
- {
- httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenResult.access_token);
- httpClient.BaseAddress = new Uri("http://fbcs101.fbox360.com/api/v2/dmon/value/get?boxNo=300220010352");
- httpClient.DefaultRequestHeaders.Accept.Clear();
- httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
- var jsonString = postData;
- HttpResponseMessage esponse = await httpClient.PostAsync(httpClient.BaseAddress, new StringContent(jsonString, Encoding.UTF8, "application/json"));
- if (esponse.IsSuccessStatusCode)
- {
- string json = await esponse.Content.ReadAsStringAsync();
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- #endregion
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
- model.Id = id;
- return View(model);
- }
- #region 喷漆房2
- public async Task<IActionResult> PaintRoom2()
- {
-
- DeviceValueModel model = new DeviceValueModel();
- TokenResult tokenResult = GetToken(new AccessUser { client_id = "b19d14eeacb74522bd29627b79c18ab8", client_secret = "7b89e021586c43d3b79440ba6eea0b67" });
- using (HttpClient client = new HttpClient())
- {
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenResult.access_token);
- var requestt = new HttpRequestMessage(HttpMethod.Get, "https://fbox360.com/api/client/box/grouped");
- requestt.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
- var response = await client.SendAsync(requestt);
- string result = await response.Content.ReadAsStringAsync();
- if (response.StatusCode != HttpStatusCode.OK)
- {
- }
- else
- {
-
- }
- }
- using (HttpClient client = new HttpClient())
- {
- string postData = Newtonsoft.Json.JsonConvert.SerializeObject(new
- {
- names = new List<string> {
- "自动油雾过滤器电子差压计D0实际值",
- "自动油雾过滤器电子差压计D1实际值",
- "\"前处理过滤箱电子差压计D3实际值\"",
- "蜂窝沸石转筒电子差压计D4实际值",
- "\"数据块_2\".运行时间记录_D",
- "\"数据块_2\".运行时间记录_H",
- "\"数据块_3\".运行时间记录_M",
- "报警2",
- "主加热器2",
- "辅助加热器2",
- "主风机2"},
- groupnames = new List<string> {
- "喷漆房2",
- "喷漆房2",
- "喷漆房2",
- "喷漆房2",
- "喷漆房2",
- "喷漆房2",
- "喷漆房2",
- "喷漆房2",
- "喷漆房2",
- "喷漆房2",
- "喷漆房2"},
- timeOut = 6000
- });
-
- #region ceshi
- using (var httpClient = new HttpClient())
- {
- httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenResult.access_token);
- httpClient.BaseAddress = new Uri("http://fbcs101.fbox360.com/api/v2/dmon/value/get?boxNo=300220010352");
- httpClient.DefaultRequestHeaders.Accept.Clear();
- httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
- var jsonString = postData;
- HttpResponseMessage esponse = await httpClient.PostAsync(httpClient.BaseAddress, new StringContent(jsonString, Encoding.UTF8, "application/json"));
- if (esponse.IsSuccessStatusCode)
- {
- string json = await esponse.Content.ReadAsStringAsync();
- List<DeviceVlue> deviceVueList = JsonConvert.DeserializeObject<List<DeviceVlue>>(json);
- model.Name = "自动油雾过滤器电子差压计D0实值";
- model.Value = deviceVueList[0].value.ToString().Split('.')[0];
- model.Name10 = deviceVueList[1].name;
- model.Value10 = deviceVueList[1].value.ToString().Split('.')[0];
- model.Name11 = "前处理过滤箱电子差压计D3实际值";
- model.Value11 = deviceVueList[2].value.ToString().Split('.')[0];
- model.Name12 = deviceVueList[3].name;
- model.Value12 = deviceVueList[3].value.ToString().Split('.')[0];
- model.Name13 = "运行时间";
- model.Value13 = deviceVueList[4].value.ToString().Split('.')[0];
- model.Name14 = "运行时间";
- model.Value14 = deviceVueList[5].value.ToString().Split('.')[0];
- model.Name15 = "运行时间";
- model.Value15 = deviceVueList[6].value.ToString().Split('.')[0];
- model.Name16 = deviceVueList[7].name;
- model.Value16 = deviceVueList[7].value.ToString().Split('.')[0];
- model.Name17 = "主加热器";
- model.Value17 = deviceVueList[8].value.ToString().Split('.')[0];
- model.Name18 = "辅助加热器";
- model.Value18 = deviceVueList[9].value.ToString();
- model.Name19 = "主风机";
- model.Value19 = deviceVueList[10].value.ToString().Split('.')[0];
- }
- }
- #endregion
- }
-
- return View(model);
- }
- #endregion
- #region 喷漆房3
- public async Task<IActionResult> PaintRoom3()
- {
- DeviceValueModel model = new DeviceValueModel();
- TokenResult tokenResult = GetToken(new AccessUser { client_id = "b19d14eeacb74522bd29627b79c18ab8", client_secret = "7b89e021586c43d3b79440ba6eea0b67" });
- using (HttpClient client = new HttpClient())
- {
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenResult.access_token);
- var requestt = new HttpRequestMessage(HttpMethod.Get, "https://fbox360.com/api/client/box/grouped");
- requestt.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
- var response = await client.SendAsync(requestt);
- string result = await response.Content.ReadAsStringAsync();
- if (response.StatusCode != HttpStatusCode.OK)
- {
- }
- else
- {
-
- }
- }
- using (HttpClient client = new HttpClient())
- {
- string postData = Newtonsoft.Json.JsonConvert.SerializeObject(new
- {
- names = new List<string> {
- "自动油雾过滤器电子差压计D0实际值",
- "前处理过滤箱电子差压计D2实际值",
- "前处理过滤箱电子差压计D3实际值",
- "蜂窝沸石转筒电子差压计D4实际值",
- "\"数据块_3\".运行时间记录_D",
- "\"数据块_3\".运行时间记录_H",
- "\"数据块_3\".运行时间记录_M",
- "报警3",
- "主加热器3",
- "辅助加热器3",
- "主风机3"},
- groupnames = new List<string> {
- "喷漆房3",
- "喷漆房3",
- "喷漆房3",
- "喷漆房3",
- "喷漆房3",
- "喷漆房3",
- "喷漆房3",
- "喷漆房3",
- "喷漆房3",
- "喷漆房3",
- "喷漆房3"},
- timeOut = 6000
- });
- #region ceshi
- using (var httpClient = new HttpClient())
- {
- httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenResult.access_token);
- httpClient.BaseAddress = new Uri("http://fbcs101.fbox360.com/api/v2/dmon/value/get?boxNo=300220010352");
- httpClient.DefaultRequestHeaders.Accept.Clear();
- httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
- var jsonString = postData;
- HttpResponseMessage esponse = await httpClient.PostAsync(httpClient.BaseAddress, new StringContent(jsonString, Encoding.UTF8, "application/json"));
- if (esponse.IsSuccessStatusCode)
- {
- string json = await esponse.Content.ReadAsStringAsync();
- List<DeviceVlue> deviceVueList = JsonConvert.DeserializeObject<List<DeviceVlue>>(json);
- model.Name = "自动油雾过滤器电子差压计D0实值";
- model.Value = deviceVueList[0].value.ToString().Split('.')[0];
- model.Name10 = deviceVueList[1].name;
- model.Value10 = deviceVueList[1].value.ToString().Split('.')[0];
- model.Name11 = deviceVueList[2].name;
- model.Value11 = deviceVueList[2].value.ToString().Split('.')[0];
- model.Name12 = deviceVueList[3].name;
- model.Value12 = deviceVueList[3].value.ToString().Split('.')[0];
- model.Name13 = "运行时间";
- model.Value13 = deviceVueList[4].value.ToString().Split('.')[0];
- model.Name14 = "运行时间";
- model.Value14 = deviceVueList[5].value.ToString().Split('.')[0];
- model.Name15 = "运行时间";
- model.Value15 = deviceVueList[6].value.ToString().Split('.')[0];
- model.Name16 = deviceVueList[7].name;
- model.Value16 = deviceVueList[7].value.ToString().Split('.')[0];
- model.Name17 = "主加热器";
- model.Value17 = deviceVueList[8].value.ToString().Split('.')[0];
- model.Name18 = "辅助加热器";
- model.Value18 = deviceVueList[9].value.ToString();
- model.Name19 = "主风机";
- model.Value19 = deviceVueList[10].value.ToString().Split('.')[0];
- }
- }
- #endregion
- }
- return View(model);
- }
- #endregion
- #region 喷漆房4
- public async Task<IActionResult> PaintRoom4()
- {
- DeviceValueModel model = new DeviceValueModel();
- TokenResult tokenResult = GetToken(new AccessUser { client_id = "b19d14eeacb74522bd29627b79c18ab8", client_secret = "7b89e021586c43d3b79440ba6eea0b67" });
- using (HttpClient client = new HttpClient())
- {
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenResult.access_token);
- var requestt = new HttpRequestMessage(HttpMethod.Get, "https://fbox360.com/api/client/box/grouped");
- requestt.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
- var response = await client.SendAsync(requestt);
- string result = await response.Content.ReadAsStringAsync();
- if (response.StatusCode != HttpStatusCode.OK)
- {
- }
- else
- {
-
- }
- }
- using (HttpClient client = new HttpClient())
- {
- string postData = Newtonsoft.Json.JsonConvert.SerializeObject(new
- {
- names = new List<string> {
- "自动油雾过滤器电子差压计D0实际值",
- "前处理过滤箱电子差压计D2实际值",
- "前处理过滤箱电子差压计D3实际值",
- "蜂窝沸石转筒电子差压计D4实际值",
- "\"数据块_1\".运行时间记录_D",
- "\"数据块_1\".运行时间记录_H",
- "\"数据块_1\".运行时间记录_M",
- "报警4",
- "主加热器4",
- "辅助加热器4",
- "主风机4"},
- groupnames = new List<string> {
- "喷漆房4",
- "喷漆房4",
- "喷漆房4",
- "喷漆房4",
- "喷漆房4",
- "喷漆房4",
- "喷漆房4",
- "喷漆房4",
- "喷漆房4",
- "喷漆房4",
- "喷漆房4"},
- timeOut = 6000
- });
-
- #region ceshi
- using (var httpClient = new HttpClient())
- {
- httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenResult.access_token);
- httpClient.BaseAddress = new Uri("http://fbcs101.fbox360.com/api/v2/dmon/value/get?boxNo=300220010352");
- httpClient.DefaultRequestHeaders.Accept.Clear();
- httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
- var jsonString = postData;
- HttpResponseMessage esponse = await httpClient.PostAsync(httpClient.BaseAddress, new StringContent(jsonString, Encoding.UTF8, "application/json"));
- if (esponse.IsSuccessStatusCode)
- {
- string json = await esponse.Content.ReadAsStringAsync();
- List<DeviceVlue> deviceVueList = JsonConvert.DeserializeObject<List<DeviceVlue>>(json);
- model.Name = "自动油雾过滤器电子差压计D0实值";
- model.Value = deviceVueList[0].value.ToString().Split('.')[0];
- model.Name10 = deviceVueList[1].name;
- model.Value10 = deviceVueList[1].value.ToString().Split('.')[0];
- model.Name11 = deviceVueList[2].name;
- model.Value11 = deviceVueList[2].value.ToString().Split('.')[0];
- model.Name12 = deviceVueList[3].name;
- model.Value12 = deviceVueList[3].value.ToString().Split('.')[0];
- model.Name13 = "运行时间";
- model.Value13 = deviceVueList[4].value.ToString().Split('.')[0];
- model.Name14 = "运行时间";
- model.Value14 = deviceVueList[5].value.ToString().Split('.')[0];
- model.Name15 = "运行时间";
- model.Value15 = deviceVueList[6].value.ToString().Split('.')[0];
- model.Name16 = deviceVueList[7].name;
- model.Value16 = deviceVueList[7].value.ToString().Split('.')[0];
- model.Name17 = "主加热器";
- model.Value17 = deviceVueList[8].value.ToString().Split('.')[0];
- model.Name18 = "辅助加热器";
- model.Value18 = deviceVueList[9].value.ToString();
- model.Name19 = "主风机";
- model.Value19 = deviceVueList[10].value.ToString().Split('.')[0];
- }
- }
- #endregion
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
- return View(model);
- }
- #endregion
- #region 喷漆房5
- public async Task<IActionResult> PaintRoom5()
- {
- DeviceValueModel model = new DeviceValueModel();
- TokenResult tokenResult = GetToken(new AccessUser { client_id = "b19d14eeacb74522bd29627b79c18ab8", client_secret = "7b89e021586c43d3b79440ba6eea0b67" });
- using (HttpClient client = new HttpClient())
- {
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenResult.access_token);
- var requestt = new HttpRequestMessage(HttpMethod.Get, "https://fbox360.com/api/client/box/grouped");
- requestt.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
- var response = await client.SendAsync(requestt);
- string result = await response.Content.ReadAsStringAsync();
- if (response.StatusCode != HttpStatusCode.OK)
- {
- }
- else
- {
-
- }
- }
- using (HttpClient client = new HttpClient())
- {
- string postData = Newtonsoft.Json.JsonConvert.SerializeObject(new
- {
- names = new List<string> {
- "非甲烷总烃",
- "非甲烷总烃排放速率",
- "废气温度",
- "废气压力",
- "废气流速",
- "废气湿度",
- "废气标态流量",
- "甲烷",
- "总烃",
- "苯",
- "甲苯",
- "二甲苯",
- "氧气"},
- groupnames = new List<string> {
- "Default Group",
- "Default Group",
- "Default Group",
- "Default Group",
- "Default Group",
- "Default Group",
- "Default Group",
- "Default Group",
- "Default Group",
- "Default Group",
- "Default Group",
- "Default Group",
- "Default Group"},
- timeOut = 6000
- });
-
- #region ceshi
- using (var httpClient = new HttpClient())
- {
- httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenResult.access_token);
- httpClient.BaseAddress = new Uri("http://fbcs101.fbox360.com/api/v2/dmon/value/get?boxNo=300221100748");
- httpClient.DefaultRequestHeaders.Accept.Clear();
- httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
- var jsonString = postData;
- HttpResponseMessage esponse = await httpClient.PostAsync(httpClient.BaseAddress, new StringContent(jsonString, Encoding.UTF8, "application/json"));
- if (esponse.IsSuccessStatusCode)
- {
- string json = await esponse.Content.ReadAsStringAsync();
- List<DeviceVlue> deviceVueList = JsonConvert.DeserializeObject<List<DeviceVlue>>(json);
- model.NameE = deviceVueList[0].name;
- model.ValueE = deviceVueList[0].value.ToString().Split('.')[0];
- model.NameE10 = deviceVueList[1].name;
- model.ValueE10 = deviceVueList[1].value.ToString().Split('.')[0];
- model.NameE11 = deviceVueList[2].name;
- model.ValueE11 = deviceVueList[2].value.ToString().Split('.')[0];
- model.NameE12 = deviceVueList[3].name;
- model.ValueE12 = deviceVueList[3].value.ToString().Split('.')[0];
- model.NameE13 = deviceVueList[4].name;
- model.ValueE13 = deviceVueList[4].value.ToString().Split('.')[0];
- model.NameE14 = deviceVueList[5].name;
- model.ValueE14 = deviceVueList[5].value.ToString().Split('.')[0];
- model.NameE15 = deviceVueList[6].name;
- model.ValueE15 = deviceVueList[6].value.ToString().Split('.')[0];
- model.NameE16 = deviceVueList[7].name;
- model.ValueE16 = deviceVueList[7].value.ToString().Split('.')[0];
- model.NameE17 = deviceVueList[8].name;
- model.ValueE17 = deviceVueList[8].value.ToString().Split('.')[0];
- model.NameE18 = deviceVueList[9].name;
- model.ValueE18 = deviceVueList[9].value.ToString();
- model.NameE19 = deviceVueList[10].name;
- model.ValueE19 = deviceVueList[10].value.ToString().Split('.')[0];
- }
- }
- #endregion
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
- return View(model);
- }
- #endregion
-
-
-
-
- public async Task<IActionResult> WebScada()
- {
- DeviceValueModel model = new DeviceValueModel();
- TokenResult tokenResult = GetToken(new AccessUser { client_id = "b19d14eeacb74522bd29627b79c18ab8", client_secret = "7b89e021586c43d3b79440ba6eea0b67" });
- using (HttpClient client = new HttpClient())
- {
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenResult.access_token);
- var requestt = new HttpRequestMessage(HttpMethod.Get, "https://fbox360.com/api/client/box/grouped");
- requestt.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
- var response = await client.SendAsync(requestt);
- string result = await response.Content.ReadAsStringAsync();
- if (response.StatusCode != HttpStatusCode.OK)
- {
- }
- else
- {
-
- }
- }
- using (HttpClient client = new HttpClient())
- {
- string postData = Newtonsoft.Json.JsonConvert.SerializeObject(new
- {
- names = new List<string> {
- "自动油雾过滤器电子差压计D0实际值",
- "前处理过滤箱电子差压计D2实际值",
- "前处理过滤箱电子差压计D3实际值",
- "蜂窝沸石转筒电子差压计D4实际值",
- "\"数据块_1\".运行时间记录_D",
- "\"数据块_1\".运行时间记录_H",
- "\"数据块_1\".运行时间记录_M",
- "报警4",
- "主加热器4",
- "辅助加热器4",
- "主风机4"},
- groupnames = new List<string> {
- "喷漆房4",
- "喷漆房4",
- "喷漆房4",
- "喷漆房4",
- "喷漆房4",
- "喷漆房4",
- "喷漆房4",
- "喷漆房4",
- "喷漆房4",
- "喷漆房4",
- "喷漆房4"},
- timeOut = 6000
- });
- #region ceshi
- using (var httpClient = new HttpClient())
- {
- httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenResult.access_token);
- httpClient.BaseAddress = new Uri("http://fbcs101.fbox360.com/api/v2/dmon/value/get?boxNo=300220010352");
- httpClient.DefaultRequestHeaders.Accept.Clear();
- httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
- var jsonString = postData;
- HttpResponseMessage esponse = await httpClient.PostAsync(httpClient.BaseAddress, new StringContent(jsonString, Encoding.UTF8, "application/json"));
- if (esponse.IsSuccessStatusCode)
- {
- string json = await esponse.Content.ReadAsStringAsync();
- List<DeviceVlue> deviceVueList = JsonConvert.DeserializeObject<List<DeviceVlue>>(json);
- model.Name = "自动油雾过滤器电子差压计D0实值";
- model.Value = deviceVueList[0].value.ToString().Split('.')[0];
- model.Name10 = deviceVueList[1].name;
- model.Value10 = deviceVueList[1].value.ToString().Split('.')[0];
- model.Name11 = deviceVueList[2].name;
- model.Value11 = deviceVueList[2].value.ToString().Split('.')[0];
- model.Name12 = deviceVueList[3].name;
- model.Value12 = deviceVueList[3].value.ToString().Split('.')[0];
- model.Name13 = "运行时间";
- model.Value13 = deviceVueList[4].value.ToString().Split('.')[0];
- model.Name14 = "运行时间";
- model.Value14 = deviceVueList[5].value.ToString().Split('.')[0];
- model.Name15 = "运行时间";
- model.Value15 = deviceVueList[6].value.ToString().Split('.')[0];
- model.Name16 = deviceVueList[7].name;
- model.Value16 = deviceVueList[7].value.ToString().Split('.')[0];
- model.Name17 = "主加热器";
- model.Value17 = deviceVueList[8].value.ToString().Split('.')[0];
- model.Name18 = "辅助加热器";
- model.Value18 = deviceVueList[9].value.ToString();
- model.Name19 = "主风机";
- model.Value19 = deviceVueList[10].value.ToString().Split('.')[0];
- }
- }
- #endregion
- }
- using (var httpClient = new HttpClient())
- {
- httpClient.DefaultRequestHeaders.Accept.Clear();
- httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
- HttpResponseMessage response = await httpClient.GetAsync("https://www.ropiniot.com/DigitalEnvironmentTest/api/TdevWebScada/GetWebScadaAsync/d4f4f4ac-3248-418a-a489-498478665539", HttpCompletionOption.ResponseHeadersRead);
- if (response.IsSuccessStatusCode)
- {
- var result = await response.Content.ReadAsStringAsync();
- DataResult devWebScada = JsonConvert.DeserializeObject<DataResult>(result);
- model.Html = devWebScada.data.C_Content;
- }
- }
- return View(model);
- }
- }
- public class DataResult
- {
- public TDEV_WebScada data { get; set; }
- public string code { get; set; }
- public string message { get; set; }
- }
- public class TDEV_WebScada
- {
- public string C_ID { get; set; }
- public string C_Name { get; set; }
- public string C_DevCode { get; set; }
- public string C_Content { get; set; }
- public string C_Remark { get; set; }
- public Guid C_CreateBy { get; set; }
- public DateTime D_CreateOn { get; set; }
- public Guid? C_LastUpdatedBy { get; set; }
- public DateTime? D_LastUpdatedOn { get; set; }
- public string C_Status { get; set; }
- }
- public class AccessUser
- {
- public string client_id { get; set; }
- public string client_secret { get; set; }
- public string refresh_token { get; set; }
- }
- public class TokenResult
- {
- public string access_token { get; set; }
-
-
-
- public int expires_in { get; set; }
- public string refresh_token { get; set; }
- public string token_type { get; set; }
-
-
-
- public string error { get; set; }
- }
- public class items
- {
- public string id { get; set; }
- public string grpId { get; set; }
- public string grpName { get; set; }
- public string name { get; set; }
- public string intDigits { get; set; }
- public string fracDigits { get; set; }
- public string privilege { get; set; }
- public string trafficSaving { get; set; }
- public string deadValue { get; set; }
- }
- public class Device
- {
- public string id { get; set; }
- public string name { get; set; }
- public List<items> items { get; set; }
- }
- public class DeviceVlue
- {
- public string id { get; set; }
- public string timestamp { get; set; }
- public int dataType { get; set; }
- public string name { get; set; }
- public double? value { get; set; }
- public string boxId { get; set; }
- public int status { get; set; }
- public int connState { get; set; }
- public string connStateTimestamp { get; set; }
- }
- }
|