public static string AttendanceData(string id, string randomKey, string realm) { string one = Haikan.DEncrypt.DesEncrypt.GetMd5String("Hzsf@123"); //Hzsf@123 string two = Haikan.DEncrypt.DesEncrypt.GetMd5String("system" + Test(one)); string three = Haikan.DEncrypt.DesEncrypt.GetMd5String(Test(two)); string four = Haikan.DEncrypt.DesEncrypt.GetMd5String("system:" + realm + ":" + Test(three)); string five = Haikan.DEncrypt.DesEncrypt.GetMd5String(Test(four) + ":" + randomKey); string strurl2 = "http://172.20.184.6/admin/API/accounts/authorize"; ////参数 string parmjosn2 = "{\"clientType\": \"WINPC\",\"encryptType\": \"MD5\",\"ipAddress\": \"\",\"mac\": \"\",\"randomKey\": \"" + randomKey + "\",\"signature\": \"" + Test(five) + "\",\"userName\": \"system\"}"; ////查询出结果json string datajson2 = PostGetRequest.HttpPostJson(strurl2, parmjosn2); DaHuaTwoAuthenticationModelRoot dm = null; try { //rbtcc = JsonConvert.DeserializeObject<DaHuaTwoAuthenticationModel>(datajson2); dm = JsonConvert.DeserializeObject <DaHuaTwoAuthenticationModelRoot>(datajson2); string tokens = dm.token; //令牌 DaHuaUpdateToken.AttendanceData(id, tokens, Test(five)); return(tokens); } catch (Exception e) { //AddSystemLog(e.ToString(), "第二次鉴权"); dm = null; return(""); } }
public static ResponseData GetToken(string appId, string secret) { ResponseData rsp = new ResponseData(); string charset = "UTF-8"; string url_PublicKey = "http://112.17.112.170:28100/IFCSI/public/getPublicKey"; try { var timeStamp = Helper.ConvertDateTimeToInt(DateTime.Now).ToString(); PublickeyRoot keydata = JsonConvert.DeserializeObject <PublickeyRoot>(PostGetRequest.HttpGet(url_PublicKey, "utf-8")); var publicKey = keydata.data[0].publicKey; #region secret 加密处理 var rsapublicKey = Helper.Base64Decode(publicKey, "UTF-8"); appId = "duijie"; var secretencrypt = RSACryption.RsaEncryptJava(publicKey, "123456"); #endregion //获取token string url_token = "http://112.17.112.170:28100/IFCSI/public/token"; var postdata = new { appId = appId, secret = secretencrypt, publicKey = publicKey, timeStamp = timeStamp }; var jsonstr = JsonConvert.SerializeObject(postdata); var jsontoken = PostGetRequest.HttpPostJson(url_token, jsonstr); TokenDataRoot tokeninfo = JsonConvert.DeserializeObject <TokenDataRoot>(jsontoken); var token = tokeninfo.data.token; if (token != null) { rsp.code = "200"; rsp.msg = "成功"; rsp.data = token; } else { rsp.code = "404"; rsp.msg = tokeninfo.ret_msg; LogHelper.WriteLog(typeof(Form1), "遇到错误!" + tokeninfo.ret_msg); } } catch (Exception ex) { rsp.code = "404"; rsp.msg = ex.Message; LogHelper.WriteLog(typeof(Form1), "遇到错误!" + ex.Message); } return(rsp); }
public static string AttendanceData(string id) { string strurl2 = "http://172.20.184.6/admin/API/accounts/authorize"; ////参数 string parmjosn2 = "{\"userName\": \"system\",\"clientType\": \"WINPC\",\"ipAddress\": \"\"}"; ////查询出结果json string datajson2 = PostGetRequest.HttpPostJson(strurl2, parmjosn2); DaHuaOneAuthenticationModelRoot dm = null; try { dm = JsonConvert.DeserializeObject <DaHuaOneAuthenticationModelRoot>(datajson2); string randomKey = dm.randomKey; string tokenss = DaHuaSecondAuthentication.AttendanceData(id, randomKey, dm.realm);//第二次鉴权 return(tokenss); } catch (Exception e) { //AddSystemLog(e.ToString(), "第一次鉴权"); dm = null; return(""); } }
/// <summary> /// 消防报警信息订阅 /// </summary> private void XiaofanData() { var tokendata = DahuaXiaofang.GetToken("tuisong", "Ts123456"); if (tokendata.code != "200") { LogHelper.WriteLog(typeof(Form1), "遇到错误!" + tokendata.msg); MessageBox.Show(tokendata.msg); return; } string token = tokendata.data; try { //报警订阅信息 string url_AlarmEvent = "http://112.17.112.170:28100/IFCSI/public/setAlarmEventURL"; var alarmpost = new { token = token, alarmSendUrl = "http://zaxy.hmc.edu.cn/api/v1/publicinterface/alarm/getAction", timeStamp = Helper.ConvertDateTimeToInt(DateTime.Now).ToString() }; var json_alarm = PostGetRequest.HttpPostJson(url_AlarmEvent, JsonConvert.SerializeObject(alarmpost)); alsrm_dyRoot ady = JsonConvert.DeserializeObject <alsrm_dyRoot>(json_alarm); if (ady.ret_code != 0) { MessageBox.Show(ady.ret_msg); } else { MessageBox.Show("订阅成功"); } } catch (Exception ex) { LogHelper.WriteLog(typeof(Form1), "遇到错误!" + ex.Message); MessageBox.Show(ex.Message); } }
public void TcqTongBu() { TcqModel bd = null; int pageNum = 1; var tokendata = DahuaXiaofang.GetToken("duijie", "123456"); if (tokendata.code != "200") { LogHelper.WriteLog(typeof(Form1), "遇到错误!" + tokendata.msg); MessageBox.Show(tokendata.msg); return; } string token = tokendata.data; try { //建筑物信息 string url_AlarmEvent = "http://112.17.112.170:28100/IFCSI/acquire/detector"; var alarmpost = new { token = token, timeStamp = Helper.ConvertDateTimeToInt(DateTime.Now).ToString(), pageNum = "1", pageSize = "100", }; var json_alarm = PostGetRequest.HttpPostJson(url_AlarmEvent, JsonConvert.SerializeObject(alarmpost)); TcqModel ady = JsonConvert.DeserializeObject <TcqModel>(json_alarm); if (ady.ret_Code != 0) { MessageBox.Show(ady.ret_msg); } else { List <DataItem> bdata = JsonConvert.DeserializeObject <List <DataItem> >(ady.data); int num = 0; for (int a = 1; a < Math.Ceiling(ady.total / 100.0) + 1; a++) { var post1 = new { token = token, timeStamp = Helper.ConvertDateTimeToInt(DateTime.Now).ToString(), pageNum = a.ToString() }; var json_build = PostGetRequest.HttpPostJson(url_AlarmEvent, JsonConvert.SerializeObject(post1)); TcqModel build = JsonConvert.DeserializeObject <TcqModel>(json_build); bdata = JsonConvert.DeserializeObject <List <DataItem> >(build.data); if (bdata != null) { for (int i = 0; i < bdata.Count; i++) { DataSet ds = _TcqInfoBLL.GetList("recordCode='" + bdata[i].recordCode + "'"); if (ds.Tables[0].Rows.Count == 0) { _TcqInfoModel.Guid = Guid.NewGuid(); _TcqInfoModel.detectorCode = bdata[i].detectorCode; _TcqInfoModel.detectorName = bdata[i].detectorName; _TcqInfoModel.mainframeId = bdata[i].mainframeId; _TcqInfoModel.buildingId = bdata[i].buildingId; _TcqInfoModel.detectorAddr = bdata[i].detectorAddr; _TcqInfoModel.orgId = bdata[i].orgId; _TcqInfoModel.detectorType = bdata[i].detectorType; _TcqInfoModel.ifcsSystemType = bdata[i].ifcsSystemType; _TcqInfoModel.partunitloopCode = bdata[i].partunitloopCode; _TcqInfoModel.channelNo = bdata[i].channelNo; _TcqInfoModel.hardwareVersion = bdata[i].hardwareVersion; _TcqInfoModel.softwareVersion = bdata[i].softwareVersion; _TcqInfoModel.personId = bdata[i].personId; _TcqInfoModel.deviceRange = bdata[i].deviceRange; _TcqInfoModel.registerTime = bdata[i].registerTime; _TcqInfoModel.registerStatus = bdata[i].registerStatus; _TcqInfoModel.recordCode = bdata[i].recordCode; _TcqInfoModel.communicationId = bdata[i].communicationId.ToString(); _TcqInfoBLL.Add(_TcqInfoModel); num++; } } } else { MessageBox.Show("探测器信息为空"); } } MessageBox.Show("获取探测器信息" + num); } } catch (Exception ex) { LogHelper.WriteLog(typeof(Form1), "遇到错误!" + ex.Message); MessageBox.Show(ex.Message); } }
/// <summary> /// 建筑物信息 /// </summary> private void Building() { BuildingData bd = null; int pageNum = 1; var tokendata = DahuaXiaofang.GetToken("duijie", "123456"); if (tokendata.code != "200") { LogHelper.WriteLog(typeof(Form1), "遇到错误!" + tokendata.msg); MessageBox.Show(tokendata.msg); return; } string token = tokendata.data; try { //建筑物信息 string url_AlarmEvent = "http://112.17.112.170:28100/IFCSI/acquire/building"; var alarmpost = new { token = token, timeStamp = Helper.ConvertDateTimeToInt(DateTime.Now).ToString(), pageNum = "1" }; var json_alarm = PostGetRequest.HttpPostJson(url_AlarmEvent, JsonConvert.SerializeObject(alarmpost)); Building ady = JsonConvert.DeserializeObject <Building>(json_alarm); if (ady.ret_Code != 0) { MessageBox.Show(ady.ret_msg); } else { List <BuildingData> bdata = JsonConvert.DeserializeObject <List <BuildingData> >(ady.data); int num = 0; for (int a = 1; a < Math.Ceiling(ady.total / 50.0) + 1; a++) { var post1 = new { token = token, timeStamp = Helper.ConvertDateTimeToInt(DateTime.Now).ToString(), pageNum = a.ToString() }; var json_build = PostGetRequest.HttpPostJson(url_AlarmEvent, JsonConvert.SerializeObject(post1)); Building build = JsonConvert.DeserializeObject <Building>(json_build); bdata = JsonConvert.DeserializeObject <List <BuildingData> >(build.data); if (bdata != null) { for (int i = 0; i < bdata.Count; i++) { DataSet ds = _BuildingBLL.GetList("recordCode='" + bdata[i].recordCode + "'"); if (ds.Tables[0].Rows.Count == 0) { _BuildingModel.BuildingUuid = Guid.NewGuid(); _BuildingModel.buildingName = bdata[i].buildingName; _BuildingModel.buildingType = bdata[i].buildingType; _BuildingModel.buildingUseNature = bdata[i].buildingUseNature; _BuildingModel.fireDanger = bdata[i].fireDanger; _BuildingModel.fireResistantLevel = bdata[i].fireResistantLevel; _BuildingModel.structureType = bdata[i].structureType; _BuildingModel.buildingHeight = Convert.ToDecimal(bdata[i].buildingHeight); _BuildingModel.regionCode = bdata[i].regionCode; _BuildingModel.gpsX3d = Convert.ToDecimal(bdata[i].gpsX3d); _BuildingModel.gpsY3d = Convert.ToDecimal(bdata[i].gpsY3d); _BuildingModel.gpsZ3d = Convert.ToDecimal(bdata[i].gpsZ3d); _BuildingModel.recordCode = bdata[i].recordCode; _BuildingModel.orgAbutSituation = bdata[i].orgAbutSituation; _BuildingModel.belongOrgId = bdata[i].belongOrgId; _BuildingModel.enterOrgNum = Convert.ToInt32(bdata[i].enterOrgNum); _BuildingModel.managerOrgId = bdata[i].managerOrgId; _BuildingModel.recordCode = bdata[i].recordCode; _BuildingBLL.Add(_BuildingModel); num++; } } } else { MessageBox.Show("建筑物信息为空"); } } MessageBox.Show("获取建筑信息" + num); } } catch (Exception ex) { LogHelper.WriteLog(typeof(Form1), "遇到错误!" + ex.Message); MessageBox.Show(ex.Message); } }