예제 #1
0
        /// <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);
            }
        }
예제 #2
0
        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);
            }
        }
예제 #3
0
        /// <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);
            }
        }