[Backend] N4同步資料 改取線上的
This commit is contained in:
		
							parent
							
								
									821d787ceb
								
							
						
					
					
						commit
						e5c7b5077d
					
				@ -40,11 +40,12 @@ namespace Backend.Controllers
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                List<Device_value> 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;
 | 
			
		||||
 | 
			
		||||
@ -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 = "<str val='" + bql + "'/>";
 | 
			
		||||
 | 
			
		||||
                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");
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user