From e5c7b5077d3afab1bfe016312d0df858b610c49f Mon Sep 17 00:00:00 2001 From: wanli Date: Wed, 23 Nov 2022 12:39:17 +0800 Subject: [PATCH] =?UTF-8?q?[Backend]=20N4=E5=90=8C=E6=AD=A5=E8=B3=87?= =?UTF-8?q?=E6=96=99=20=E6=94=B9=E5=8F=96=E7=B7=9A=E4=B8=8A=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NiagaraDataSynchronizeController.cs | 5 +++-- .../Services/Implement/webRequestService.cs | 20 +++++++++++++++++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/Backend/Controllers/NiagaraDataSynchronizeController.cs b/Backend/Controllers/NiagaraDataSynchronizeController.cs index 5687558..17027ae 100644 --- a/Backend/Controllers/NiagaraDataSynchronizeController.cs +++ b/Backend/Controllers/NiagaraDataSynchronizeController.cs @@ -40,11 +40,12 @@ namespace Backend.Controllers try { List ds; - string url_slot = "slot:/Arena/H|"; + string url_slot = "slot:/TPE/B1|"; string top100 = " top 100 "; webRequestService svc = new webRequestService(); string bql = url_slot + "bql:select " + top100 + " * from control:ControlPoint "; - ds = svc.obixQuery("http://60.251.164.125:8080/obix/config/Arena/Program/ObixQuery/query/", bql); + //ds = svc.obixQuery("http://192.168.0.136:8080/obix/config/Arena/Program/ObixQuery/query/", bql); + ds = svc.obixQuery("http://localhost:8080/obix/config/Program/ObixQuery/query/", bql); apiResult.Code = "0000"; apiResult.Data = ds; diff --git a/Backend/Services/Implement/webRequestService.cs b/Backend/Services/Implement/webRequestService.cs index 57022a0..51bdae0 100644 --- a/Backend/Services/Implement/webRequestService.cs +++ b/Backend/Services/Implement/webRequestService.cs @@ -11,6 +11,7 @@ using System.Text; using System.Xml.Linq; using Repository.BackendRepository.Implement; using Repository.BackendRepository; +using Ubiety.Dns.Core; namespace Backend.Services.Implement { @@ -24,9 +25,24 @@ namespace Backend.Services.Implement String encoded = System.Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(username + ":" + password)); String API_Url = urlString; + + HttpWebRequest Postrequest = (HttpWebRequest)WebRequest.Create(API_Url); + Postrequest.Method = "POST"; + Postrequest.Headers.Add("Authorization", "Basic " + encoded); + Postrequest.PreAuthenticate = true; + + using (var streamWriter = new StreamWriter(Postrequest.GetRequestStream())) + { + string json = ""; + + streamWriter.Write(json); + } + HttpWebResponse response = (HttpWebResponse)Postrequest.GetResponse(); + var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd(); + XmlDocument xmlDoc = new XmlDocument(); - //xmlDoc.LoadXml(responseString); - xmlDoc.Load("N4v1021.xml");//N4v1021 + xmlDoc.LoadXml(responseString); + //xmlDoc.Load("N4v1021.xml");//N4v1021 //xmlDoc.Save("N4.xml");