예제 #1
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;
            }
        }
예제 #2
0
        public static void InitRouterDevices()
        {
            RouterList.Clear();
            GroupList.Clear();
            CoinDeviceList.Clear();
            TerminalList.Clear();

            DataTable table = DeviceBusiness.GetRouterDetail();

            if (table.Rows.Count > 0)
            {
                foreach (DataRow row in table.Rows)
                {
                    RouterInfo router = new RouterInfo();
                    router.RouterId              = Convert.ToInt32(row["ID"].ToString());
                    router.RouterToken           = row["DeviceToken"].ToString();
                    router.DeviceInfo.Token      = row["DeviceToken"].ToString();
                    router.DeviceInfo.DeviceName = row["DeviceName"].ToString();
                    router.DeviceInfo.DeviceType = Convert.ToInt32(row["DeviceType"]);
                    router.DeviceInfo.SN         = row["SN"].ToString();
                    router.DeviceInfo.Status     = 1;

                    router.MerchInfo.MerchName = row["MerchName"].ToString();
                    router.MerchInfo.Mobile    = row["Mobile"].ToString();
                    router.MerchInfo.State     = Convert.ToInt32(row["State"]);

                    RouterList.Add(router);
                }
            }

            GroupList = GameBusiness.GetGameList().ToList().Select(g => new GroupInfo
            {
                RouterToken = g.DeviceID.IsNull() ? "" : RouterList.FirstOrDefault(r => r.RouterId == g.DeviceID).RouterToken,
                GroupId     = g.GroupID,
                GroupName   = g.GroupName,
                GroupType   = ((GroupTypeEnum)g.GroupType).ToDescription()
            }).ToList();

            DataTable coinDeviceTable = DeviceBusiness.GetCoinDeviceList();

            if (coinDeviceTable.Rows.Count > 0)
            {
                foreach (DataRow row in coinDeviceTable.Rows)
                {
                    DeviceModel device = new DeviceModel();
                    device.RouterToken = row["RouterToken"].ToString();
                    device.DeviceId    = Convert.ToInt32(row["DeviceId"].ToString());
                    device.DeviceToken = row["DeviceToken"].ToString();
                    device.DeviceName  = row["DeviceName"].ToString();
                    device.DeviceType  = ((GroupTypeEnum)Convert.ToInt32(row["DeviceType"].ToString())).ToDescription();
                    device.State       = row["State"].ToString();
                    device.SN          = row["SN"].ToString();
                    device.HeadAddress = row["HeadAddress"].ToString();

                    CoinDeviceList.Add(device);
                }
            }

            DataTable TerminalTable = DeviceBusiness.GetTerminalDeviceList();

            if (TerminalTable.Rows.Count > 0)
            {
                foreach (DataRow row in TerminalTable.Rows)
                {
                    DeviceModel device = new DeviceModel();
                    device.RouterToken = row["RouterToken"].ToString();
                    device.DeviceId    = Convert.ToInt32(row["DeviceId"].ToString());
                    device.DeviceToken = row["DeviceToken"].ToString();
                    device.DeviceName  = row["DeviceName"].ToString();
                    device.DeviceType  = ((GroupTypeEnum)Convert.ToInt32(row["DeviceType"].ToString())).ToDescription();
                    device.State       = row["State"].ToString();
                    device.SN          = row["SN"].ToString();
                    device.HeadAddress = row["HeadAddress"].ToString();
                    device.GroupId     = Convert.ToInt32(row["GroupID"].ToString());

                    TerminalList.Add(device);
                }
            }
        }