Ejemplo n.º 1
0
        public BasicResponse <AreaInfo> AddArea(AreaAddRequest arearequest)
        {
            var arearesponse = new BasicResponse <AreaInfo>();
            //判断缓存中是否存在
            AreaInfo oldArea = null;
            AreaCacheGetByKeyRequest AreaCacheRequest = new AreaCacheGetByKeyRequest();

            AreaCacheRequest.Areaid = arearequest.AreaInfo.Areaid;
            oldArea = _AreaCacheService.GetByKeyAreaCache(AreaCacheRequest).Data;
            if (oldArea != null)
            {
                //缓存中存在此测点
                arearesponse.Code    = 1;
                arearesponse.Message = "当前添加的区域已存在!";
                return(arearesponse);
            }

            //向网关同步数据  20180103
            if (!string.IsNullOrEmpty(arearequest.AreaInfo.Bz3) && arearequest.AreaInfo.Bz3 == "1")//如果是广播分区,则需要向网关同步数据
            {
                List <AreaInfo> SendItemList = new List <AreaInfo>();
                SendItemList.Add(arearequest.AreaInfo);
                var resultSync = SynchronousDataToGateway(SendItemList);
                if (!resultSync)
                {
                    arearesponse.Code    = 1;
                    arearesponse.Message = "向网关同步数据失败!";
                    return(arearesponse);
                }
            }

            var _area      = ObjectConverter.Copy <AreaInfo, AreaModel>(arearequest.AreaInfo);
            var resultarea = _Repository.AddArea(_area);

            //更新区域限制、禁止进入人员信息
            SaveRestrictedperson(arearequest.AreaInfo.Areaid, arearequest.AreaInfo.RestrictedpersonInfoList);
            //更新区域识别器定义限制信息
            SaveAreaRule(arearequest.AreaInfo.Areaid, arearequest.AreaInfo.AreaRuleInfoList);

            //更新区域缓存  20171128
            AreaCacheAddRequest AreaCacheAddRequest = new Sys.Safety.Request.PersonCache.AreaCacheAddRequest();

            AreaCacheAddRequest.AreaInfo = arearequest.AreaInfo;
            _AreaCacheService.AddAreaCache(AreaCacheAddRequest);

            arearesponse.Data = ObjectConverter.Copy <AreaModel, AreaInfo>(resultarea);
            return(arearesponse);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 向网关同步数据
        /// </summary>
        /// <param name="SendItemList"></param>
        /// <returns></returns>
        private bool SynchronousDataToGateway(List <Jc_DefInfo> SendItemList)
        {
            foreach (Jc_DefInfo deviceInfo in SendItemList)
            {
                TerminalControlRequest terminalControlRequest = new TerminalControlRequest();
                //查找分区标识
                AreaCacheGetByKeyRequest AreaCacheRequest = new AreaCacheGetByKeyRequest();
                AreaCacheRequest.Areaid = deviceInfo.Areaid;
                AreaInfo areaInfo = _areaCacheService.GetByKeyAreaCache(AreaCacheRequest).Data;
                if (areaInfo != null)
                {
                    terminalControlRequest.zoneId = areaInfo.Areadescribe;//分区标识
                }
                else
                {
                    Basic.Framework.Logging.LogHelper.Error("未找到广播设备对应的分区信息,设备标识:" + deviceInfo.Point);
                    return(false);
                }
                terminalControlRequest.termDN    = deviceInfo.Point; //终端号码
                terminalControlRequest.type      = deviceInfo.Bz6;   //终端类型
                terminalControlRequest.name      = deviceInfo.Wz;    //终端名称
                terminalControlRequest.record    = deviceInfo.Bz7;   //录音使能是否启用
                terminalControlRequest.auth      = deviceInfo.Bz8;   //注册鉴权是否启用
                terminalControlRequest.password  = deviceInfo.Bz9;   //注册鉴权密码
                terminalControlRequest.pa        = deviceInfo.Bz11;  //广播使能是否启用
                terminalControlRequest.cfuDN     = deviceInfo.Bz12;  //始终呼叫转移号码
                terminalControlRequest.cfxDN     = deviceInfo.Bz13;  //条件呼叫转移号码
                terminalControlRequest.InfoState = deviceInfo.InfoState;
                //调用RPC发送
                MasProtocol masProtocol = new MasProtocol(SystemType.Broadcast, DirectionType.Down, ProtocolType.TerminalControlRequest);
                masProtocol.Protocol = terminalControlRequest;
                TerminalControlResponse result = RpcService.Send <TerminalControlResponse>(masProtocol, RequestType.BusinessRequest);

                if (result == null && result.retCode != "0")
                {
                    Basic.Framework.Logging.LogHelper.Error("向网关同步广播设备信息失败!,设备标识:" + deviceInfo.Point);
                    return(false);
                }
            }
            return(true);
        }