コード例 #1
0
        public object getDeviceInfo(Dictionary <string, object> dicParas)
        {
            try
            {
//                string MobileToken = dicParas.ContainsKey("mobileToken") ? dicParas["mobileToken"].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无效");
//                }
//                mobile = mobile.Replace("RS232", "");
//                string sql = "";
//                sql = @"select b.SN,b.Token,b.DeviceName,b.Status from Base_DeviceInfo as b
// left join Base_MerchInfo as a on a.ID=b.MerchID  where a.State='1'  and DeviceType='0' and a.Mobile='" + mobile + "'";
//                DataSet ds = XCCloudRS232BLL.ExecuteQuerySentence(sql, null);
//                DataTable dt = ds.Tables[0];
//                if (dt.Rows.Count > 0)
//                {
//                    var basedeviceinfolist = Utils.GetModelList<BaseDeviceInfoModel>(dt).ToList();
//                    BaseDeviceInfoModelList baseDeviceInfoModelList = new BaseDeviceInfoModelList();
//                    baseDeviceInfoModelList.Lists = basedeviceinfolist;
//                    return ResponseModelFactory<BaseDeviceInfoModelList>.CreateModel(isSignKeyReturn, baseDeviceInfoModelList);
//                }
                string         mobileToken = dicParas.ContainsKey("mobileToken") ? dicParas["mobileToken"].ToString() : string.Empty;
                Base_MerchInfo merch       = MerchBusiness.GetMerchModel(mobileToken);
                if (merch.IsNull())
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "用户令牌无效"));
                }

                var list = DeviceBusiness.GetDeviceList().Where(t => t.MerchID == merch.ID && (DeviceTypeEnum)(int)t.DeviceType == DeviceTypeEnum.Router && t.Status == 1).ToList();
                if (list.IsNull() || list.Count == 0)
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "无数据"));
                }

                BaseDeviceInfoModelList baseDeviceInfoModelList = new BaseDeviceInfoModelList();
                baseDeviceInfoModelList.Lists = new List <BaseDeviceInfoModel>();
                foreach (var item in list)
                {
                    BaseDeviceInfoModel model = new BaseDeviceInfoModel();
                    model.DeviceName = item.DeviceName ?? item.SN;
                    model.SN         = item.SN;
                    model.Token      = item.Token;
                    model.Status     = DeviceStatusBusiness.GetDeviceState(item.Token);

                    baseDeviceInfoModelList.Lists.Add(model);
                }

                return(ResponseModelFactory <BaseDeviceInfoModelList> .CreateModel(isSignKeyReturn, baseDeviceInfoModelList));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
コード例 #2
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;
            }
        }
コード例 #3
0
ファイル: UDPServer.cs プロジェクト: tongxin3267/XCCloud
        static void server_OnChangeState(Recv机头网络状态报告 cmd)
        {
            string routeToken  = cmd.RecvData.routeAddress;
            string headAddress = cmd.机头地址;
            int?   deviceId    = null;

            //获取控制器实体
            Base_DeviceInfo  router      = DeviceBusiness.GetDeviceModel(routeToken);
            Data_MerchDevice merchDevice = MerchDeviceBusiness.GetMerchModel(router.ID, headAddress);

            if (merchDevice != null)
            {
                deviceId = merchDevice.DeviceID;
            }

            if (deviceId == null)
            {
                Data_MerchSegment merchSegment = MerchSegmentBusiness.GetMerchSegmentModel(router.ID, headAddress);
                if (merchSegment == null)
                {
                    deviceId = merchDevice.DeviceID;
                }
            }

            if (deviceId != null)
            {
                Base_DeviceInfo device = DeviceBusiness.GetDeviceModelById((int)deviceId);
                if (device != null)
                {
                    List <HeadInfo.机头信息> headList = HeadInfo.GetAllHead();
                    HeadInfo.机头信息        head     = headList.FirstOrDefault(t => t.令牌 == device.Token);
                    string strDeviceState         = GetDeviceState(head);

                    string state = DeviceStatusBusiness.GetDeviceState(device.Token);
                    if (state != strDeviceState)
                    {
                        DeviceStatusBusiness.SetDeviceState(device.Token, strDeviceState);
                    }
                }
            }
        }
コード例 #4
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;
            }
        }
コード例 #5
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;
            }
        }
コード例 #6
0
        public object getRouterChildList(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;

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

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

                //分组集合
                var groupList = GameBusiness.GetGameList().Where(t => t.DeviceID == router.ID).ToList();

                //外设集合
                var peripheralList = MerchDeviceBusiness.GetListByParentId(router.ID).ToList();

                RouterModel model = new RouterModel();
                model.routerName   = string.IsNullOrWhiteSpace(router.DeviceName) ? router.SN : router.DeviceName;
                model.routerToken  = router.Token;
                model.routerStatus = DeviceStatusBusiness.GetDeviceState(router.Token);
                model.routerSN     = router.SN;
                model.Groups       = groupList.Select(t => new Group
                {
                    groupId   = t.GroupID,
                    groupName = t.GroupName,
                    groupType = ((GroupTypeEnum)t.GroupType).ToDescription()
                }).ToList();

                List <Peripheral> Peripherals = new List <Peripheral>();
                foreach (var item in peripheralList)
                {
                    Peripheral      p       = new Peripheral();
                    Base_DeviceInfo cDevice = DeviceBusiness.GetDeviceModelById((int)item.DeviceID);
                    p.peripheralId    = (int)item.DeviceID;
                    p.peripheralName  = cDevice.DeviceName;
                    p.peripheralToken = cDevice.Token;
                    p.sn          = cDevice.SN;
                    p.deviceType  = ((DeviceTypeEnum)cDevice.DeviceType).ToDescription();
                    p.state       = DeviceStatusBusiness.GetDeviceState(cDevice.Token);
                    p.headAddress = item.HeadAddress;

                    Peripherals.Add(p);
                }
                model.Peripherals = Peripherals;

                return(ResponseModelFactory <RouterModel> .CreateModel(isSignKeyReturn, model));
            }
            catch (Exception e)
            {
                throw e;
            }
        }