protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { DOORCTRLREQ vrParameter = new DOORCTRLREQ(); vrParameter.dwDCSKind = (uint)UNIDCS.DWDCSKIND.DCSKIND_DOORCTRL; UNIDOORCTRL[] vrResult; ArrayList list = new System.Collections.ArrayList(); string szError = ""; if (m_Request.DoorCtrlSrv.GetDoorCtrl(vrParameter, out vrResult) == REQUESTCODE.EXECUTE_SUCCESS) { for (int i = 0; i < vrResult.Length; i++) { ctrlRoom value = new ctrlRoom(); value.szDcsNO = vrResult[i].dwDCSSN.ToString(); value.szCtrlNo = vrResult[i].dwCtrlSN.ToString(); value.szRoomNo = vrResult[i].szRoomNo.ToString(); list.Add(value); } } string json = JsonConvert.SerializeObject(list); string path = Server.MapPath("~/") + ("padtxt\\dcsRoom.txt"); FileStream myFs = new FileStream(path, FileMode.Create); //txtFilePath为生成txt文件的路径 StreamWriter mySw = new StreamWriter(myFs); mySw.Write(json); //writeStr为要写入的字符串 mySw.Close(); myFs.Close(); MessageBox("提示:" + vrResult.Length + "条", "提示", MSGBOX.SUCCESS, MSGBOX_ACTION.OK); } }
protected string RoomExtReq() { UniClientPage clinetPage = new UniClientPage(); string szRoomNo = Request["roomno"]; CtrlRoomInfoExt roomInfo = new CtrlRoomInfoExt(); roomInfo.szCustNo = System.Web.Configuration.WebConfigurationManager.AppSettings["customNo"]; ctrlRoom ctrlRoom = GetDoorCtrl(szRoomNo); if (ctrlRoom != null) { roomInfo.szCtrlNo = ctrlRoom.szCtrlNo; roomInfo.szDcsNO = ctrlRoom.szDcsNO; } consoleRoom cosole = GetConsole(szRoomNo); if (cosole != null) { roomInfo.szConsoleIP = cosole.szIP; } XmlCtrl.XmlInfo info = clinetPage.GetDftXmlInfo(szRoomNo, "RoomPadImg"); List <string> imgList = clinetPage.GetSrcFromHtml(info.content); string szImgUrl = ""; for (int i = 0; i < imgList.Count; i++) { string szTemp = imgList[i]; szTemp = szTemp.Replace("~", ""); szTemp = szTemp.Replace("\r\n", ""); szImgUrl = szImgUrl + szTemp + ";"; } roomInfo.szServerIP = System.Web.Configuration.WebConfigurationManager.AppSettings["ServerIP"]; roomInfo.szServerPort = System.Web.Configuration.WebConfigurationManager.AppSettings["ServerPort"]; roomInfo.szRoomNo = szRoomNo; roomInfo.szimgURL = szImgUrl; return(JsonConvert.SerializeObject(roomInfo)); }
protected ctrlRoom GetDoorCtrl(string szRoomNo) { ctrlRoom res = new ctrlRoom(); string path = Server.MapPath("~/") + ("padtxt\\dcsRoom.txt"); string str2 = File.ReadAllText(path, System.Text.Encoding.UTF8); List <ctrlRoom> list = JsonConvert.DeserializeObject <List <ctrlRoom> >(str2); if (list != null) { for (int i = 0; i < list.Count; i++) { ctrlRoom temp = new ctrlRoom(); temp = list[i]; if (temp.szRoomNo == szRoomNo) { return(temp); } } } return(res); }
protected string RoomReq() { string szRoomNo = Request["roomno"]; CtrlRoomInfo roomInfo = new CtrlRoomInfo(); roomInfo.szCustNo = System.Web.Configuration.WebConfigurationManager.AppSettings["customNo"]; ctrlRoom ctrlRoom = GetDoorCtrl(szRoomNo); if (ctrlRoom != null) { roomInfo.szCtrlNo = ctrlRoom.szCtrlNo; roomInfo.szDcsNO = ctrlRoom.szDcsNO; } consoleRoom cosole = GetConsole(szRoomNo); if (cosole != null) { roomInfo.szConsoleIP = cosole.szIP; } roomInfo.szServerIP = System.Web.Configuration.WebConfigurationManager.AppSettings["ServerIP"]; roomInfo.szServerPort = System.Web.Configuration.WebConfigurationManager.AppSettings["ServerPort"]; roomInfo.szRoomNo = szRoomNo; return(JsonConvert.SerializeObject(roomInfo)); }