示例#1
0
        public object deviceChange(Dictionary <string, object> dicParas)
        {
            string errMsg = string.Empty;
            string token  = dicParas.ContainsKey("token") ? dicParas["token"].ToString() : string.Empty;
            string mcuid  = dicParas.ContainsKey("mcuid") ? dicParas["mcuid"].ToString() : string.Empty;
            string status = dicParas.ContainsKey("status") ? dicParas["status"].ToString() : string.Empty;

            UDPClientItemBusiness.ClientItem item = XCCloudService.SocketService.UDP.ClientList.ClientListObj.Where <UDPClientItemBusiness.ClientItem>(p => p.gID.Equals(token)).FirstOrDefault <UDPClientItemBusiness.ClientItem>();
            if (item == null)
            {
                return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "雷达token不存在"));
            }

            StoreBusiness   storeBusiness   = new StoreBusiness();
            StoreCacheModel storeCacheModel = null;

            if (!storeBusiness.IsEffectiveStore(item.StoreID, ref storeCacheModel, out errMsg))
            {
                return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "门店不存在"));
            }

            ClientService service = new ClientService();

            service.Connection();
            DeviceStateRequestDataModel dataModel = new DeviceStateRequestDataModel(token, mcuid, status, "", "");

            SignKeyHelper.SetSignKey(dataModel, storeCacheModel.StorePassword);
            byte[] data = DataFactory.CreateRequesProtocolData(TransmiteEnum.设备状态变更通知, dataModel);
            service.Send(data);

            var obj = new { token = token };

            return(ResponseModelFactory.CreateAnonymousSuccessModel(isSignKeyReturn, obj));
        }
示例#2
0
        public object radarRegister(Dictionary <string, object> dicParas)
        {
            string errMsg  = string.Empty;
            string storeId = dicParas.ContainsKey("storeId") ? dicParas["storeId"].ToString() : string.Empty;
            string segment = dicParas.ContainsKey("segment") ? dicParas["segment"].ToString() : string.Empty;

            XCGameManaAdminUserTokenModel tokenModel = (XCGameManaAdminUserTokenModel)(dicParas[Constant.XCGameManamAdminUserToken]);

            if (tokenModel == null)
            {
                errMsg = "用户没有授权";
                return(false);
            }

            StoreBusiness   storeBusiness   = new StoreBusiness();
            StoreCacheModel storeCacheModel = null;

            if (!storeBusiness.IsEffectiveStore(storeId, ref storeCacheModel, out errMsg))
            {
                return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "门店不存在"));
            }

            ClientService service = new ClientService();

            service.Connection();
            RadarRegisterRequestDataModel dataModel = new RadarRegisterRequestDataModel(storeId, segment);

            SignKeyHelper.SetSignKey(dataModel, storeCacheModel.StorePassword);
            byte[] data = DataFactory.CreateRequesProtocolData(TransmiteEnum.雷达注册授权, dataModel);
            service.Send(data);

            System.Threading.Thread.Sleep(5000);

            int count = 0;

            UDPClientItemBusiness.ClientItem item = XCCloudService.SocketService.UDP.ClientList.ClientListObj.Where <UDPClientItemBusiness.ClientItem>(p => p.StoreID.Equals(storeId) && p.Segment.Equals(segment)).FirstOrDefault <UDPClientItemBusiness.ClientItem>();
            while (item == null && count < 10)
            {
                item = XCCloudService.SocketService.UDP.ClientList.ClientListObj.Where <UDPClientItemBusiness.ClientItem>(p => p.StoreID.Equals(storeId) && p.Segment.Equals(segment)).FirstOrDefault <UDPClientItemBusiness.ClientItem>();
                System.Threading.Thread.Sleep(1000);
                count++;
            }

            if (item == null)
            {
                return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "注册失败"));
            }

            var obj = new { token = item.gID };

            return(ResponseModelFactory.CreateAnonymousSuccessModel(isSignKeyReturn, obj));
        }