コード例 #1
0
ファイル: Device.ashx.cs プロジェクト: tongxin3267/XCCloud
        public object register(Dictionary <string, object> dicParas)
        {
            try
            {
                string storeId = dicParas.ContainsKey("storeId") ? dicParas["storeId"].ToString() : string.Empty;
                string mcuId   = dicParas.ContainsKey("mcuId") ? dicParas["mcuId"].ToString() : string.Empty;
                XCCloudService.Model.CustomModel.XCGameManager.StoreCacheModel storeCacheModel = null;
                string errMsg      = string.Empty;
                string deviceToken = string.Empty;
                //验证门店信息
                XCCloudService.Business.XCGameMana.StoreBusiness xcGameManaStoreBusiness = new XCCloudService.Business.XCGameMana.StoreBusiness();
                if (!xcGameManaStoreBusiness.IsEffectiveStore(storeId, ref storeCacheModel, out errMsg))
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "门店不存在"));
                }
                //获取子库中是否存在mcuId
                XCCloudService.BLL.IBLL.XCGame.IDeviceService xcGameDeviceService = BLLContainer.Resolve <XCCloudService.BLL.IBLL.XCGame.IDeviceService>(storeCacheModel.StoreDBName);
                var xcGameDeviceModel = xcGameDeviceService.GetModels(p => p.MCUID.Equals(mcuId)).FirstOrDefault <XCCloudService.Model.XCGame.t_device>();
                if (xcGameDeviceModel == null)
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "设备不存在"));
                }
                //获取总库中是否存在
                XCCloudService.BLL.IBLL.XCGameManager.IDeviceService xcGameManaDeviceService = BLLContainer.Resolve <XCCloudService.BLL.IBLL.XCGameManager.IDeviceService>();
                var xcGameManaDeviceModel = xcGameManaDeviceService.GetModels(p => p.StoreType == (int)(XCGameManaDeviceStoreType.Store) && p.DeviceId.Equals(mcuId)).FirstOrDefault <XCCloudService.Model.XCGameManager.t_device>();
                if (xcGameManaDeviceModel != null)
                {
                    if (!xcGameManaDeviceModel.DeviceName.Equals(xcGameDeviceModel.name) || !xcGameManaDeviceModel.DeviceType.Equals(xcGameDeviceModel.type))
                    {
                        xcGameManaDeviceModel.DeviceType = xcGameDeviceModel.type;
                        xcGameManaDeviceModel.DeviceName = xcGameDeviceModel.name;
                        xcGameManaDeviceService.Update(xcGameManaDeviceModel);
                    }
                    deviceToken = xcGameManaDeviceModel.TerminalNo;
                }
                else
                {
                    deviceToken = DeviceManaBusiness.GetDeviceToken();
                    bool isExist = false;
                    while (isExist == false)
                    {
                        if (xcGameManaDeviceService.GetCount(p => p.TerminalNo.Equals(deviceToken)) == 0)
                        {
                            isExist = true;
                        }
                        else
                        {
                            deviceToken = DeviceManaBusiness.GetDeviceToken();
                        }
                        System.Threading.Thread.Sleep(100);
                    }
                    xcGameManaDeviceModel            = new XCCloudService.Model.XCGameManager.t_device();
                    xcGameManaDeviceModel.DeviceId   = xcGameDeviceModel.MCUID;
                    xcGameManaDeviceModel.TerminalNo = deviceToken;
                    xcGameManaDeviceModel.DeviceName = xcGameDeviceModel.name;
                    xcGameManaDeviceModel.DeviceType = xcGameDeviceModel.type;
                    xcGameManaDeviceModel.StoreId    = storeId;
                    xcGameManaDeviceModel.Note       = xcGameDeviceModel.note;
                    xcGameManaDeviceModel.StoreType  = (int)(XCGameManaDeviceStoreType.Store);
                    xcGameManaDeviceService.Add(xcGameManaDeviceModel);
                }

                var obj = new { deviceToken = deviceToken };
                return(ResponseModelFactory.CreateAnonymousSuccessModel(isSignKeyReturn, obj));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
コード例 #2
0
        public object saveCoins(Dictionary <string, object> dicParas)
        {
            try
            {
                string state         = string.Empty;
                string stateName     = string.Empty;
                string xcGameDBName  = string.Empty;
                string errMsg        = string.Empty;
                string storePassword = string.Empty;
                string terminalNo    = dicParas.ContainsKey("deviceToken") ? dicParas["deviceToken"].ToString() : string.Empty;

                XCGameMemberTokenModel memberTokenModel = (XCGameMemberTokenModel)(dicParas[Constant.XCGameMemberTokenModel]);
                MobileTokenModel       mobileTokenModel = (MobileTokenModel)(dicParas[Constant.MobileTokenModel]);

                //根据终端号查询终端号是否存在
                XCCloudService.BLL.IBLL.XCGameManager.IDeviceService deviceService = BLLContainer.Resolve <XCCloudService.BLL.IBLL.XCGameManager.IDeviceService>();
                var deviceModel = deviceService.GetModels(p => p.TerminalNo.Equals(terminalNo, StringComparison.OrdinalIgnoreCase)).FirstOrDefault <XCCloudService.Model.XCGameManager.t_device>();
                if (deviceModel == null)
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "终端号不存在"));
                }
                StoreBusiness store = new StoreBusiness();
                if (!store.IsEffectiveStore(deviceModel.StoreId, out xcGameDBName, out storePassword, out errMsg))
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, errMsg));
                }

                if (!deviceModel.StoreId.Equals(memberTokenModel.StoreId))
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "会员令牌对应门店和设备不一致"));
                }

                //判断设备状态是否为启用状态
                XCCloudService.BLL.IBLL.XCGame.IDeviceService ids = BLLContainer.Resolve <XCCloudService.BLL.IBLL.XCGame.IDeviceService>(xcGameDBName);
                var menlist = ids.GetModels(p => p.MCUID.Equals(deviceModel.DeviceId, StringComparison.OrdinalIgnoreCase)).FirstOrDefault <XCCloudService.Model.XCGame.t_device>();
                if (menlist == null)
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "设备不存在"));
                }

                if (menlist.state != "启用")
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "设备未启用"));
                }

                //验证缓存设备状态
                if (DeviceStateBusiness.ExistDeviceState(deviceModel.StoreId, deviceModel.DeviceId))
                {
                    state = DeviceStateBusiness.GetDeviceState(deviceModel.StoreId, deviceModel.DeviceId);
                }
                if (state != "1")
                {
                    stateName = DeviceStateBusiness.GetStateName(state);
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, stateName));
                }

                //请求雷达处理存币
                string action  = ((int)(DevieControlTypeEnum.存币)).ToString();
                string sn      = UDPSocketAnswerBusiness.GetSN();
                string orderId = System.Guid.NewGuid().ToString("N");
                DeviceControlRequestDataModel deviceControlModel = new DeviceControlRequestDataModel(deviceModel.StoreId, mobileTokenModel.Mobile, memberTokenModel.ICCardId, menlist.segment, menlist.MCUID, action, 0, sn, orderId, storePassword, 0, "");
                MPOrderBusiness.AddTCPAnswerOrder(orderId, mobileTokenModel.Mobile, 0, action, memberTokenModel.ICCardId, deviceModel.StoreId);
                IconOutLockBusiness.AddByNoTimeLimit(mobileTokenModel.Mobile);
                if (!DataFactory.SendDataToRadar(deviceControlModel, out errMsg))
                {
                    ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.F, "", Result_Code.T, errMsg);
                }

                //设置推送消息的缓存结构
                string form_id = dicParas.ContainsKey("form_id") ? dicParas["form_id"].ToString() : string.Empty;
                SAppMessageMana.SetMemberCoinsMsgCacheData(SAppMessageType.MemberCoinsOperationNotify, orderId, form_id, mobileTokenModel.Mobile, null, out errMsg);

                return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.T, ""));
            }
            catch (Exception e)
            {
                throw e;
            }
        }