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");