Exemplo n.º 1
0
        public object getSegmentList(Dictionary <string, object> dicParas)
        {
            try
            {
                string errMsg      = string.Empty;
                string mobileToken = dicParas.ContainsKey("mobileToken") ? dicParas["mobileToken"].ToString() : string.Empty;
                string routerToken = dicParas.ContainsKey("routerToken") ? dicParas["routerToken"].ToString() : string.Empty;
                string groupId     = dicParas.ContainsKey("groupId") ? dicParas["groupId"].ToString() : string.Empty;

                Base_MerchInfo merch = MerchBusiness.GetMerchModel(mobileToken);
                if (merch.IsNull())
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "用户令牌无效"));
                }

                Base_DeviceInfo router = DeviceBusiness.GetDeviceModel(routerToken);
                if (router.IsNull())
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "控制器令牌无效"));
                }

                Data_GameInfo group = GameBusiness.GetGameInfoModel(Convert.ToInt32(groupId));
                if (group.IsNull())
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "分组参数无效"));
                }

                //分组集合
                var groupList = MerchSegmentBusiness.GetMerchSegmentList().Where(t => t.ParentID == router.ID && t.GroupID == group.GroupID).ToList();

                GroupInfoModel model = new GroupInfoModel();
                model.groupId   = group.GroupID;
                model.groupName = group.GroupName;

                List <Terminal> Terminals = new List <Terminal>();
                foreach (var item in groupList)
                {
                    Terminal        t       = new Terminal();
                    Base_DeviceInfo cDevice = DeviceBusiness.GetDeviceModelById((int)item.DeviceID);
                    t.terminalName  = cDevice.DeviceName ?? cDevice.SN;
                    t.terminalToken = cDevice.Token;
                    t.headAddress   = item.HeadAddress;
                    t.sn            = cDevice.SN;
                    t.deviceType    = ((DeviceTypeEnum)cDevice.DeviceType).ToDescription();
                    t.status        = DeviceStatusBusiness.GetDeviceState(cDevice.Token);

                    Terminals.Add(t);
                }
                model.Terminals = Terminals;

                return(ResponseModelFactory <GroupInfoModel> .CreateModel(isSignKeyReturn, model));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Exemplo n.º 2
0
        public object getMerchDeviceInfo(Dictionary <string, object> dicParas)
        {
            try
            {
                string errMsg      = string.Empty;
                string mobileToken = dicParas.ContainsKey("mobileToken") ? dicParas["mobileToken"].ToString() : string.Empty;
                string deviceToken = dicParas.ContainsKey("deviceToken") ? dicParas["deviceToken"].ToString() : string.Empty;

                Base_MerchInfo merch = MerchBusiness.GetMerchModel(mobileToken);
                if (merch.IsNull())
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "用户令牌无效"));
                }

                Base_DeviceInfo device = DeviceBusiness.GetDeviceModel(deviceToken);
                if (device.IsNull())
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "设备令牌无效"));
                }

                //设备所属商户不是当前商户
                if (device.MerchID != merch.ID)
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "该设备属于其他商户,您没有权限查看该设备"));
                }

                DeviceTypeEnum currDeviceType = (DeviceTypeEnum)device.DeviceType;

                DeviceInfoModel model = new DeviceInfoModel();
                model.Router      = new Router();
                model.Group       = new Group();
                model.deviceName  = device.DeviceName ?? device.SN;
                model.deviceToken = device.Token;
                model.deviceType  = currDeviceType.ToDescription();
                model.deviceSN    = device.SN;
                model.status      = DeviceStatusBusiness.GetDeviceState(device.Token);

                switch (currDeviceType)
                {
                case DeviceTypeEnum.SlotMachines:
                case DeviceTypeEnum.DepositMachine:
                {
                    //获取外设绑定关系实体
                    Data_MerchDevice md = MerchDeviceBusiness.GetMerchDeviceModel(device.ID);
                    model.headAddress = md.HeadAddress;

                    //获取控制器实体
                    Base_DeviceInfo router = DeviceBusiness.GetDeviceModelById((int)md.ParentID);
                    model.Router.routerName  = router.DeviceName ?? router.SN;
                    model.Router.routerToken = router.Token;
                    model.Router.sn          = router.SN;
                }
                break;

                case DeviceTypeEnum.Clerk:
                case DeviceTypeEnum.Terminal:
                {
                    //获取终端绑定关系实体
                    Data_MerchSegment ms = MerchSegmentBusiness.GetMerchSegmentModel(device.ID);
                    model.headAddress = ms.HeadAddress;

                    //获取分组实体
                    Data_GameInfo group = GameBusiness.GetGameInfoModel(Convert.ToInt32(ms.GroupID));
                    model.Group.groupId   = group.GroupID;
                    model.Group.groupName = group.GroupName;
                    model.Group.groupType = ((GroupTypeEnum)(int)group.GroupType).ToDescription();
                }
                break;
                }
                return(ResponseModelFactory <DeviceInfoModel> .CreateModel(isSignKeyReturn, model));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Exemplo n.º 3
0
        public object getDeviceInfo(Dictionary <string, object> dicParas)
        {
            try
            {
                string errMsg      = string.Empty;
                string mobileToken = dicParas.ContainsKey("mobileToken") ? dicParas["mobileToken"].ToString() : string.Empty;
                string deviceToken = dicParas.ContainsKey("deviceToken") ? dicParas["deviceToken"].ToString() : string.Empty;
                string routerToken = dicParas.ContainsKey("routerToken") ? dicParas["routerToken"].ToString().Trim().ToLower() : string.Empty;

                Base_MerchInfo merch = MerchBusiness.GetMerchModel(mobileToken);
                if (merch.IsNull())
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "用户令牌无效"));
                }

                Base_DeviceInfo device = DeviceBusiness.GetDeviceModel(deviceToken);
                if (device.IsNull())
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "设备令牌无效"));
                }

                string status = DeviceStatusBusiness.GetDeviceState(device.Token);

                //当前设备类型
                DeviceTypeEnum currDeviceType = (DeviceTypeEnum)device.DeviceType;

                DeviceInfoModel model = new DeviceInfoModel();
                model.Router      = new Router();
                model.Group       = new Group();
                model.deviceName  = device.DeviceName ?? device.SN;
                model.deviceToken = device.Token;
                model.deviceType  = currDeviceType.ToDescription();
                model.deviceSN    = device.SN;
                model.status      = DeviceStatusBusiness.GetDeviceState(device.Token);


                //设备未绑定
                if (device.MerchID == 0 || device.MerchID.IsNull())
                {
                    model.BindState = (int)DeviceBoundStateEnum.NotBound;
                    return(ResponseModelFactory <DeviceInfoModel> .CreateModel(isSignKeyReturn, model));
                }

                //判断设备绑定的商户是否与当前商户一致
                if (device.MerchID != merch.ID)
                {
                    //与当前商户不一致
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "没有权限查看该设备信息"));
                }

                //Base_DeviceInfo currRouter = null;
                //if (!string.IsNullOrWhiteSpace(routerToken))
                //{
                //    currRouter = DeviceBusiness.GetDeviceModel(routerToken);
                //}

                //1.如果设备绑定的商户与当前商户一致
                //2.判断设备是否已与当前商户建立绑定关系
                switch (currDeviceType)
                {
                case DeviceTypeEnum.Router:
                    model.BindState = (int)DeviceBoundStateEnum.Bound;
                    break;

                case DeviceTypeEnum.SlotMachines:
                case DeviceTypeEnum.DepositMachine:
                {
                    //获取外设绑定关系实体
                    Data_MerchDevice md = MerchDeviceBusiness.GetMerchDeviceModel(device.ID);
                    if (md.IsNull())
                    {
                        model.BindState = (int)DeviceBoundStateEnum.NotBound;
                    }
                    else
                    {
                        //获取控制器实体
                        Base_DeviceInfo router = DeviceBusiness.GetDeviceModelById((int)md.ParentID);

                        if (router.Token.Trim().ToLower() != routerToken)
                        {
                            //设备所属控制器与当前控制器不一致
                            return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "该设备不属于当前控制器"));
                        }

                        model.BindState   = (int)DeviceBoundStateEnum.Bound;
                        model.headAddress = md.HeadAddress;
                        //控制器信息
                        model.Router.routerName  = router.DeviceName ?? router.SN;
                        model.Router.routerToken = router.Token;
                        model.Router.sn          = router.SN;
                    }
                }
                break;

                case DeviceTypeEnum.Clerk:
                case DeviceTypeEnum.Terminal:
                {
                    //获取终端绑定关系实体
                    Data_MerchSegment ms = MerchSegmentBusiness.GetMerchSegmentModel(device.ID);
                    if (ms.IsNull())
                    {
                        model.BindState = (int)DeviceBoundStateEnum.NotBound;
                    }
                    else
                    {
                        //获取控制器实体
                        Base_DeviceInfo router = DeviceBusiness.GetDeviceModelById((int)ms.ParentID);

                        if (router.Token.Trim().ToLower() != routerToken)
                        {
                            //设备所属控制器与当前控制器不一致
                            return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "该设备不属于当前控制器"));
                        }

                        model.BindState   = (int)DeviceBoundStateEnum.Bound;
                        model.headAddress = ms.HeadAddress;

                        //控制器信息
                        model.Router.routerName  = router.DeviceName ?? router.SN;
                        model.Router.routerToken = router.Token;
                        model.Router.sn          = router.SN;

                        //获取分组实体
                        Data_GameInfo group = GameBusiness.GetGameInfoModel(Convert.ToInt32(ms.GroupID));
                        model.Group.groupId   = group.GroupID;
                        model.Group.groupName = group.GroupName;
                        model.Group.groupType = ((GroupTypeEnum)(int)group.GroupType).ToDescription();
                    }
                }
                break;
                }

                //返回设备信息
                return(ResponseModelFactory <DeviceInfoModel> .CreateModel(isSignKeyReturn, model));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Exemplo n.º 4
0
        public object bindDevice(Dictionary <string, object> dicParas)
        {
            try
            {
                string errMsg      = string.Empty;
                string mobileToken = dicParas.ContainsKey("mobileToken") ? dicParas["mobileToken"].ToString() : string.Empty;
                string deviceToken = dicParas.ContainsKey("deviceToken") ? dicParas["deviceToken"].ToString() : string.Empty;
                string deviceName  = dicParas.ContainsKey("deviceName") ? dicParas["deviceName"].ToString() : string.Empty;
                string level       = dicParas.ContainsKey("level") ? dicParas["level"].ToString() : string.Empty;
                string routerToken = dicParas.ContainsKey("routerToken") ? dicParas["routerToken"].ToString() : string.Empty;
                string groupId     = dicParas.ContainsKey("groupId") ? dicParas["groupId"].ToString() : string.Empty;

                Base_MerchInfo merch = MerchBusiness.GetMerchModel(mobileToken);
                if (merch.IsNull())
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "用户令牌无效"));
                }

                if (merch.State == 0)
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "当前用户已被禁用"));
                }

                Base_DeviceInfo device = DeviceBusiness.GetDeviceModel(deviceToken);
                if (device.IsNull())
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "设备令牌无效"));
                }

                //设备已被绑定
                if (!device.MerchID.IsNull() && device.MerchID != 0 && device.MerchID != merch.ID)
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "该设备已被其他商户绑定"));
                }

                //设备未绑定,开始绑定
                device.MerchID    = merch.ID;
                device.DeviceName = deviceName;
                device.Status     = (int)DeviceStatusEnum.启用;

                if (string.IsNullOrWhiteSpace(level))
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "参数错误"));
                }

                DeviceTypeEnum currDeviceType = (DeviceTypeEnum)device.DeviceType;

                switch (level)
                {
                case "1":
                {
                    if (currDeviceType == DeviceTypeEnum.Router)
                    {
                        DeviceBusiness.UpdateDevice(device);
                        return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.T, ""));
                    }
                    else if (currDeviceType == DeviceTypeEnum.SlotMachines || currDeviceType == DeviceTypeEnum.DepositMachine)
                    {
                        return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "请选定控制器后绑定该设备"));
                    }
                    else
                    {
                        return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "请在分组中绑定该设备"));
                    }
                }

                case "2":
                {
                    if (currDeviceType == DeviceTypeEnum.Router)
                    {
                        return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "请在返回上级绑定"));
                    }
                    else if (currDeviceType == DeviceTypeEnum.SlotMachines || currDeviceType == DeviceTypeEnum.DepositMachine)
                    {
                        if (string.IsNullOrWhiteSpace(routerToken))
                        {
                            return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "获取控制器参数错误"));
                        }
                        //获取控制器实体
                        Base_DeviceInfo router = DeviceBusiness.GetDeviceModel(routerToken);
                        if (router.IsNull())
                        {
                            return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "获取控制器参数错误"));
                        }

                        //获取当前控制器中的外设列表
                        var list = MerchDeviceBusiness.GetListByParentId(router.ID).OrderBy(m => m.HeadAddress).ToList();

                        if (list.Count >= 11)
                        {
                            return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "超出最大绑定数量"));
                        }

                        Data_MerchDevice md = list.FirstOrDefault(m => m.DeviceID == device.ID);
                        if (md.IsNull())
                        {
                            md          = new Data_MerchDevice();
                            md.ParentID = router.ID;
                            md.DeviceID = device.ID;

                            int index = 0;
                            foreach (var item in list)
                            {
                                string currAddress = string.Format("A{0}", index);
                                //int currIndex = int.Parse(item.HeadAddress, System.Globalization.NumberStyles.AllowHexSpecifier);
                                if (currAddress != item.HeadAddress)
                                {
                                    break;
                                }
                                index++;
                                continue;
                            }
                            //md.HeadAddress = Convert.ToString(index, 16).PadLeft(2, '0').ToUpper();
                            md.HeadAddress = string.Format("A{0}", index);
                        }

                        using (var transactionScope = new System.Transactions.TransactionScope(
                                   TransactionScopeOption.RequiresNew))
                        {
                            DeviceBusiness.UpdateDevice(device);
                            MerchDeviceBusiness.AddMerchDevice(md);

                            transactionScope.Complete();
                        }

                        return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.T, ""));
                    }
                    else
                    {
                        return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "请在分组中绑定该设备"));
                    }
                }

                case "3":
                {
                    if (currDeviceType != DeviceTypeEnum.Clerk && currDeviceType != DeviceTypeEnum.Terminal)
                    {
                        return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "请在分组中绑定该设备"));
                    }
                    else
                    {
                        if (string.IsNullOrWhiteSpace(groupId))
                        {
                            return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "获取分组参数错误"));
                        }

                        //获取分组实体
                        Data_GameInfo group = GameBusiness.GetGameInfoModel(Convert.ToInt32(groupId));
                        if (group.IsNull())
                        {
                            return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "获取分组参数错误"));
                        }

                        //根据分组获取当前分组的控制器
                        Base_DeviceInfo router = DeviceBusiness.GetDeviceModelById((int)group.DeviceID);
                        if (router.IsNull())
                        {
                            return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "获取控制器参数错误"));
                        }

                        //判断当前分组是否属于当前商户
                        if (router.MerchID != merch.ID)
                        {
                            return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "分组信息与当前商户不匹配"));
                        }

                        //获取当前分组中的终端列表
                        var list = MerchSegmentBusiness.GetListByGroupId(group.GroupID).OrderBy(m => m.HeadAddress).ToList();

                        if (list.Count >= 99)
                        {
                            return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "超出最大绑定数量"));
                        }

                        Data_MerchSegment ms = list.FirstOrDefault(m => m.ParentID == group.DeviceID && m.DeviceID == device.ID);
                        if (ms.IsNull())
                        {
                            ms          = new Data_MerchSegment();
                            ms.ParentID = group.DeviceID;
                            ms.GroupID  = group.GroupID;
                            ms.DeviceID = device.ID;

                            int index = 1;
                            foreach (var item in list)
                            {
                                int currIndex = int.Parse(item.HeadAddress, System.Globalization.NumberStyles.AllowHexSpecifier);
                                if (currIndex != index)
                                {
                                    break;
                                }
                                index++;
                                continue;
                            }
                            ms.HeadAddress = Convert.ToString(index, 16).PadLeft(2, '0').ToUpper();
                        }

                        using (var transactionScope = new System.Transactions.TransactionScope(
                                   TransactionScopeOption.RequiresNew))
                        {
                            DeviceBusiness.UpdateDevice(device);
                            MerchSegmentBusiness.AddMerchSegment(ms);

                            transactionScope.Complete();
                        }

                        return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.T, ""));
                    }
                }
                }

                DeviceStatusBusiness.SetDeviceState(device.Token, DeviceStatusEnum.离线.ToDescription());

                return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.T, ""));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Exemplo n.º 5
0
        public object addGroup(Dictionary <string, object> dicParas)
        {
            try
            {
                string MobileToken = dicParas.ContainsKey("mobileToken") ? dicParas["mobileToken"].ToString() : string.Empty; //获取手机令牌
                string RouterToken = dicParas.ContainsKey("routerToken") ? dicParas["routerToken"].ToString() : string.Empty; //获取控制器令牌
                if (RouterToken == "")
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "控制器令牌不能为空"));
                }


                string GroupName = dicParas.ContainsKey("groupName") ? dicParas["groupName"].ToString() : string.Empty;//获取分组名称
                if (GroupName == "")
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "分组名称不能为空"));
                }
                string GroupType          = dicParas.ContainsKey("groupType") ? dicParas["groupType"].ToString() : string.Empty;                               //获取分组类别
                string PushReduceFromCard = dicParas.ContainsKey("pushReduceFromCard") ? dicParas["pushReduceFromCard"].ToString() : string.Empty;             //获取投币时扣卡里币数

                string PushLevel = dicParas.ContainsKey("pushLevel") ? dicParas["pushLevel"].ToString() : string.Empty;                                        //获取投币电平

                string LotteryMode = dicParas.ContainsKey("lotteryMode") ? dicParas["lotteryMode"].ToString() : string.Empty;                                  //获取电子彩票模式

                string OnlyExitLottery = dicParas.ContainsKey("onlyExitLottery") ? dicParas["onlyExitLottery"].ToString() : string.Empty;                      //获取只退实物彩票

                string ReadCat = dicParas.ContainsKey("readCat") ? dicParas["readCat"].ToString() : string.Empty;                                              //获取刷卡即扣模式

                string ChkCheckGift = dicParas.ContainsKey("chkCheckGift") ? dicParas["chkCheckGift"].ToString() : string.Empty;                               //获取礼品掉落检测

                string ReturnCheck = dicParas.ContainsKey("returnCheck") ? dicParas["returnCheck"].ToString() : "1";                                           //获取启用遥控器偷分检测

                string OutsideAlertCheck = dicParas.ContainsKey("outsideAlertCheck") ? dicParas["outsideAlertCheck"].ToString() : string.Empty;                //获取启用游戏机外部报警检测

                string IcticketOperation = dicParas.ContainsKey("icticketOperation") ? dicParas["icticketOperation"].ToString() : string.Empty;                //获取二合一专版模式

                string NotGiveBack = dicParas.ContainsKey("notGiveBack") ? dicParas["notGiveBack"].ToString() : string.Empty;                                  //获取不参与返还

                string AllowElecPush = dicParas.ContainsKey("allowElecPush") ? dicParas["allowElecPush"].ToString() : string.Empty;                            //获取允许电子投币

                string AllowDecuplePush = dicParas.ContainsKey("allowDecuplePush") ? dicParas["allowDecuplePush"].ToString() : string.Empty;                   //获取允许十倍投币

                string GuardConvertCard = dicParas.ContainsKey("guardConvertCard") ? dicParas["guardConvertCard"].ToString() : string.Empty;                   //获取防止转卡(启用专卡专用)

                string AllowRealPush = dicParas.ContainsKey("allowRealPush") ? dicParas["allowRealPush"].ToString() : string.Empty;                            //获取允许实物投币

                string BanOccupy = dicParas.ContainsKey("banOccupy") ? dicParas["banOccupy"].ToString() : string.Empty;                                        //获取防止霸位检测

                string StrongGuardConvertCard = dicParas.ContainsKey("strongGuardConvertCard") ? dicParas["strongGuardConvertCard"].ToString() : string.Empty; //获取增强防止转卡

                string AllowElecOut = dicParas.ContainsKey("allowElecOut") ? dicParas["allowElecOut"].ToString() : string.Empty;                               //获取允许电子退币(允许打票)

                string NowExit = dicParas.ContainsKey("nowExit") ? dicParas["nowExit"].ToString() : string.Empty;                                              //获取即中即退模式

                string BOLock = dicParas.ContainsKey("bOLock") ? dicParas["bOLock"].ToString() : string.Empty;                                                 //获取退币锁定模式

                string AllowRealOut = dicParas.ContainsKey("allowRealOut") ? dicParas["allowRealOut"].ToString() : string.Empty;                               //获取允许实物出币

                string BOKeep = dicParas.ContainsKey("bOKeep") ? dicParas["bOKeep"].ToString() : string.Empty;                                                 //获取退币按钮保持

                string PushAddToGame = dicParas.ContainsKey("pushAddToGame") ? dicParas["pushAddToGame"].ToString() : string.Empty;                            //获取投币时给游戏机脉冲数

                string PushSpeed = dicParas.ContainsKey("pushSpeed") ? dicParas["pushSpeed"].ToString() : string.Empty;                                        //获取投币速度

                string PushPulse = dicParas.ContainsKey("pushPulse") ? dicParas["pushPulse"].ToString() : string.Empty;                                        //获取投币脉宽

                string PushStartInterval = dicParas.ContainsKey("pushStartInterval") ? dicParas["pushStartInterval"].ToString() : string.Empty;                //获取首次投币脉冲间隔

                string UseSecondPush = dicParas.ContainsKey("useSecondPush") ? dicParas["useSecondPush"].ToString() : string.Empty;                            //获取允许第二路上分信号

                string SecondReduceFromCard = dicParas.ContainsKey("secondReduceFromCard") ? dicParas["secondReduceFromCard"].ToString() : string.Empty;       //获取接上分线时扣卡里币数

                string SecondAddToGame = dicParas.ContainsKey("secondAddToGame") ? dicParas["secondAddToGame"].ToString() : string.Empty;                      //获取接上分线时给游戏机脉冲数

                string SecondSpeed = dicParas.ContainsKey("secondSpeed") ? dicParas["secondSpeed"].ToString() : string.Empty;                                  //获取上分速度

                string SecondPulse = dicParas.ContainsKey("secondPulse") ? dicParas["secondPulse"].ToString() : string.Empty;                                  //获取上分脉宽

                string SecondLevel = dicParas.ContainsKey("secondLevel") ? dicParas["secondLevel"].ToString() : string.Empty;                                  //获取上分电平

                string SecondStartInterval = dicParas.ContainsKey("secondStartInterval") ? dicParas["secondStartInterval"].ToString() : string.Empty;          //获取首次上分脉冲间隔

                string OutSpeed = dicParas.ContainsKey("outSpeed") ? dicParas["outSpeed"].ToString() : string.Empty;                                           //获取退币速度

                string OutPulse = dicParas.ContainsKey("outPulse") ? dicParas["outPulse"].ToString() : string.Empty;                                           //获取币脉宽

                string CountLevel = dicParas.ContainsKey("countLevel") ? dicParas["countLevel"].ToString() : string.Empty;                                     //获取数币电平

                string OutLevel = dicParas.ContainsKey("outLevel") ? dicParas["outLevel"].ToString() : string.Empty;                                           //获取退币电平(SSR)

                string OutReduceFromGame = dicParas.ContainsKey("outReduceFromGame") ? dicParas["outReduceFromGame"].ToString() : string.Empty;                //获取退币时游戏机出币数

                string OutAddToCard = dicParas.ContainsKey("outAddToCard") ? dicParas["outAddToCard"].ToString() : string.Empty;                               //获取退币时卡上加币数

                string OnceOutLimit = dicParas.ContainsKey("onceOutLimit") ? dicParas["onceOutLimit"].ToString() : string.Empty;                               //获取每次退币限额

                string OncePureOutLimit = dicParas.ContainsKey("oncePureOutLimit") ? dicParas["oncePureOutLimit"].ToString() : string.Empty;                   //获取每次净退币限额

                string SsrtimeOut = dicParas.ContainsKey("ssrtimeOut") ? dicParas["ssrtimeOut"].ToString() : string.Empty;                                     //获取SSR检测延时

                string ExceptOutTest = dicParas.ContainsKey("exceptOutTest") ? dicParas["exceptOutTest"].ToString() : string.Empty;                            //获取异常退币检测

                string ExceptOutSpeed = dicParas.ContainsKey("exceptOutSpeed") ? dicParas["exceptOutSpeed"].ToString() : string.Empty;                         //获取异常SSR检测速度

                string Frequency = dicParas.ContainsKey("frequency") ? dicParas["frequency"].ToString() : string.Empty;                                        //获取异常退币检测次数

                if (MobileToken == "")
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "手机令牌不能为空"));
                }
                string mobile = string.Empty;
                if (!MobileTokenBusiness.ExistToken(MobileToken, out mobile))
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "手机token无效"));
                }
                IDeviceService deviceService = BLLContainer.Resolve <IDeviceService>("XCCloudRS232");
                var            devicelist    = deviceService.GetModels(x => x.Token == RouterToken && x.Status == 1).FirstOrDefault <Base_DeviceInfo>();
                if (deviceService == null)
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "路由控制器无效"));
                }
                IDataGameInfoService dataGameInfoService = BLLContainer.Resolve <IDataGameInfoService>("XCCloudRS232");
                int deviceID         = 1;
                var dataGameInfolist = dataGameInfoService.GetModels(x => x.DeviceID == deviceID).ToList();
                if (dataGameInfolist.Count < 99)
                {
                    Data_GameInfo gameInfo = new Data_GameInfo();
                    gameInfo.DeviceID               = deviceID;
                    gameInfo.GroupName              = GroupName;
                    gameInfo.GroupType              = Convert.ToInt32(GroupType);
                    gameInfo.PushReduceFromCard     = Convert.ToInt32(PushReduceFromCard);
                    gameInfo.PushLevel              = Convert.ToInt32(PushLevel);
                    gameInfo.LotteryMode            = Convert.ToInt32(LotteryMode);
                    gameInfo.OnlyExitLottery        = Convert.ToInt32(OnlyExitLottery);
                    gameInfo.ReadCat                = Convert.ToInt32(ReadCat);
                    gameInfo.chkCheckGift           = Convert.ToInt32(ChkCheckGift);
                    gameInfo.ReturnCheck            = int.Parse(ReturnCheck);
                    gameInfo.OutsideAlertCheck      = Convert.ToInt32(OutsideAlertCheck);
                    gameInfo.ICTicketOperation      = Convert.ToInt32(IcticketOperation);
                    gameInfo.NotGiveBack            = Convert.ToInt32(NotGiveBack);
                    gameInfo.AllowElecPush          = Convert.ToInt32(AllowElecPush);
                    gameInfo.AllowDecuplePush       = Convert.ToInt32(AllowDecuplePush);
                    gameInfo.GuardConvertCard       = Convert.ToInt32(GuardConvertCard);
                    gameInfo.AllowRealPush          = Convert.ToInt32(AllowRealPush);
                    gameInfo.BanOccupy              = Convert.ToInt32(BanOccupy);
                    gameInfo.StrongGuardConvertCard = Convert.ToInt32(StrongGuardConvertCard);
                    gameInfo.AllowElecOut           = Convert.ToInt32(AllowElecOut);
                    gameInfo.NowExit                = Convert.ToInt32(NowExit);
                    gameInfo.BOLock               = Convert.ToInt32(BOLock);
                    gameInfo.AllowRealOut         = Convert.ToInt32(AllowRealOut);
                    gameInfo.BOKeep               = Convert.ToInt32(BOKeep);
                    gameInfo.PushAddToGame        = Convert.ToInt32(PushAddToGame);
                    gameInfo.PushSpeed            = Convert.ToInt32(PushSpeed);
                    gameInfo.PushPulse            = Convert.ToInt32(PushPulse);
                    gameInfo.PushStartInterval    = Convert.ToInt32(PushStartInterval);
                    gameInfo.UseSecondPush        = Convert.ToInt32(UseSecondPush);
                    gameInfo.SecondReduceFromCard = Convert.ToInt32(SecondReduceFromCard);
                    gameInfo.SecondAddToGame      = Convert.ToInt32(SecondAddToGame);
                    gameInfo.SecondSpeed          = Convert.ToInt32(SecondSpeed);
                    gameInfo.SecondPulse          = Convert.ToInt32(SecondPulse);
                    gameInfo.SecondLevel          = Convert.ToInt32(SecondLevel);
                    gameInfo.SecondStartInterval  = Convert.ToInt32(SecondStartInterval);
                    gameInfo.OutSpeed             = Convert.ToInt32(OutSpeed);
                    gameInfo.OutPulse             = Convert.ToInt32(OutPulse);
                    gameInfo.CountLevel           = Convert.ToInt32(CountLevel);
                    gameInfo.OutLevel             = Convert.ToInt32(OutLevel);
                    gameInfo.OutReduceFromGame    = Convert.ToInt32(OutReduceFromGame);
                    gameInfo.OutAddToCard         = Convert.ToInt32(OutAddToCard);
                    gameInfo.OnceOutLimit         = Convert.ToInt32(OnceOutLimit);
                    gameInfo.OncePureOutLimit     = Convert.ToInt32(OncePureOutLimit);
                    gameInfo.SSRTimeOut           = Convert.ToInt32(SsrtimeOut);
                    gameInfo.ExceptOutTest        = Convert.ToInt32(ExceptOutTest);
                    gameInfo.ExceptOutSpeed       = Convert.ToInt32(ExceptOutSpeed);
                    gameInfo.Frequency            = Convert.ToInt32(Frequency);
                    dataGameInfoService.Add(gameInfo);
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.T, ""));
                }
                return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "该设备已经存在过多数据"));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Exemplo n.º 6
0
        public object SaveGameInfo(Dictionary <string, object> dicParas)
        {
            try
            {
                XCCloudUserTokenModel userTokenKeyModel = (XCCloudUserTokenModel)dicParas[Constant.XCCloudUserTokenModel];
                string storeId = (userTokenKeyModel.DataModel as UserDataModel).StoreID;

                string errMsg   = string.Empty;
                string gameId   = dicParas.ContainsKey("GameID") ? (dicParas["GameID"] + "") : string.Empty;
                string id       = dicParas.ContainsKey("ID") ? (dicParas["ID"] + "") : string.Empty;
                string gameName = dicParas.ContainsKey("GameName") ? (dicParas["GameName"] + "") : string.Empty;

                if (string.IsNullOrEmpty(gameId))
                {
                    errMsg = "游戏机编号GameID不能为空";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }
                if (gameId.Length > 4)
                {
                    errMsg = "游戏机编号GameID不能超过4个字符";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }
                if (string.IsNullOrEmpty(gameName))
                {
                    errMsg = "游戏机名称GameName不能为空";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }
                if (!string.IsNullOrEmpty(id) && !Utils.isNumber(id))
                {
                    errMsg = "游戏机参数ID格式不正确";
                    return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                }

                IData_GameInfoService data_GameInfoService = BLLContainer.Resolve <IData_GameInfoService>();
                var data_GameInfo = new Data_GameInfo();
                if (string.IsNullOrEmpty(id))
                {
                    if (data_GameInfoService.Any(a => a.GameID.Equals(gameId, StringComparison.OrdinalIgnoreCase)))
                    {
                        errMsg = "该游戏机编号已使用";
                        return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                    }

                    Utils.GetModel(dicParas, ref data_GameInfo);
                    data_GameInfo.StoreID = storeId;
                    if (!data_GameInfoService.Add(data_GameInfo))
                    {
                        errMsg = "新增游戏机信息失败";
                        return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                    }
                }
                else
                {
                    int iId = Convert.ToInt32(id);
                    if (!data_GameInfoService.Any(a => a.ID == iId))
                    {
                        errMsg = "该游戏机不存在";
                        return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                    }
                    if (data_GameInfoService.Any(a => a.ID != iId && a.GameID.Equals(gameId, StringComparison.OrdinalIgnoreCase)))
                    {
                        errMsg = "该游戏机编号已使用";
                        return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                    }

                    data_GameInfo = data_GameInfoService.GetModels(p => p.ID == iId).FirstOrDefault();
                    Utils.GetModel(dicParas, ref data_GameInfo);
                    data_GameInfo.StoreID = storeId;
                    if (!data_GameInfoService.Update(data_GameInfo))
                    {
                        errMsg = "修改游戏机信息失败";
                        return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, errMsg));
                    }
                }

                return(ResponseModelFactory.CreateSuccessModel(isSignKeyReturn));
            }
            catch (DbEntityValidationException e)
            {
                return(ResponseModelFactory.CreateFailModel(isSignKeyReturn, e.EntityValidationErrors.ToErrors()));
            }
            catch (Exception e)
            {
                return(ResponseModelFactory.CreateReturnModel(isSignKeyReturn, Return_Code.F, e.Message));
            }
        }