예제 #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
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            DeviceBusiness.WriteDeviceInfo();
            ///IrisRecoInterface.initialClassifier();
            capFra = new CapFra(this);

            timer          = new DispatcherTimer();
            timer.Interval = TimeSpan.FromMilliseconds(ConstAndEnum.VEDIO_FREQUENCE);
            timer.Tick    += timer1_Tick;
            //timer.Start();

            timerEndShowLable          = new DispatcherTimer();
            timerEndShowLable.Interval = TimeSpan.FromMilliseconds(ConstAndEnum.SHOW_END_DELAY);
            timerEndShowLable.Tick    += timerEndShowLable_Tick;

            timerEndShowReco          = new DispatcherTimer();
            timerEndShowReco.Interval = TimeSpan.FromMilliseconds(ConstAndEnum.SHOW_END_DELAY);
            timerEndShowReco.Tick    += timerEndShowReco_Tick;

            timerHeart          = new DispatcherTimer();
            timerHeart.Interval = TimeSpan.FromMilliseconds(ConstAndEnum.HEART_BEAT_INTERVAL);
            timerHeart.Tick    += timerHeart_Tick;
            timerHeart.Start();

            DelayEndShowLable();
        }
예제 #3
0
        private void LoadPrinterMenu(ToolStripMenuItem parentMenu)
        {
            string             selectedPrinter = string.Empty;
            List <DeviceModel> installList     = new List <DeviceModel>();
            List <DeviceModel> list            = DeviceBusiness.GetDevice(DeviceDefine.Printer);
            List <DeviceModel> listFilter      = DeviceBusiness.GetDevice(DeviceDefine.PrinterFilter);
            DeviceModel        deviceModel     = list.Find(p => p.Selected == true);

            if (deviceModel != null)
            {
                selectedPrinter = deviceModel.Name;
            }

            foreach (string printer in PrinterSettings.InstalledPrinters)
            {
                deviceModel       = new DeviceModel();
                deviceModel.Name  = printer;
                deviceModel.Model = printer;

                if (listFilter.Find(p => p.Model.Equals(printer)) == null)
                {
                    if (selectedPrinter.Equals(printer))
                    {
                        deviceModel.Selected = true;
                    }
                    else
                    {
                        deviceModel.Selected = false;
                    }
                    installList.Add(deviceModel);
                }
            }
            DeviceBusiness.ReplaceDevice(installList, DeviceDefine.Printer);
        }
예제 #4
0
        public void handlePOSTRequest(HttpProcessor p, string postData)
        {
            Display("Connect", p.socket.Client.RemoteEndPoint.ToString(), p.http_method, p.length.ToString());
            p.outputStream.WriteLine("{0}", postData);//Test,will replace by To do
            //To do
            DeviceinfoEntity entity = DeviceBusiness.GetDeviceInfo();

            Display("Response", p.socket.Client.RemoteEndPoint.ToString(), p.http_method, postData.Length.ToString());
        }
예제 #5
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;
            }
        }
예제 #6
0
        public void ArgumentNullExceptionName()
        {
            var deviceRepositoryMock   = GetDeviceRepositoryMock();
            var categoryRepositoryMock = GetCategoryRepositoryMock();
            var deviceBusinnes         = new DeviceBusiness(deviceRepositoryMock.Object, categoryRepositoryMock.Object);
            var service = new DeviceService(deviceBusinnes);

            service.GetDevicesDtoByName(null);
        }
예제 #7
0
        public ActionResult Index()
        {
            IDeviceBusiness deviveBusiness = new DeviceBusiness();

            Business.Web.INotificationBusiness notification = new Business.Web.NotificationBusiness();
            DataAccess.Account account = (DataAccess.Account)Session["Account"];
            HomeViewModel      model   = new HomeViewModel();

            model.DeviceList = deviveBusiness.GetDeviceListByAccountId(account.AccountId);
            return(View(model));
        }
예제 #8
0
        public void TestCategories()
        {
            var deviceRepositoryMock   = GetDeviceRepositoryMock();
            var categoryRepositoryMock = GetCategoryRepositoryMock();
            var deviceBusinnes         = new DeviceBusiness(deviceRepositoryMock.Object, categoryRepositoryMock.Object);
            var service = new DeviceService(deviceBusinnes);

            var categories = service.GetAllCategories();

            Assert.AreEqual(2, categories.Count());
        }
예제 #9
0
        public void handlePOSTRequest(HttpProcessor p, string postData)
        {
            Display("Connect", p.context.Request.RemoteEndPoint.ToString(), p.http_method, p.length.ToString());

            //To do
            DeviceinfoEntity entity = DeviceBusiness.GetDeviceInfo();

            byte[] buffer = Encoding.UTF8.GetBytes(postData);
            p.context.Response.OutputStream.Write(buffer, 0, buffer.Length);
            //

            Display("Response", p.context.Request.RemoteEndPoint.ToString(), p.http_method, postData.Length.ToString());
        }
예제 #10
0
        public async Task <IHttpActionResult> Register(DeviceDTO device)
        {
            try
            {
                var deviceBusiness = new DeviceBusiness();

                var deviceResponse = deviceBusiness.Register(device);

                return(Ok(deviceResponse));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
예제 #11
0
        public async Task <IHttpActionResult> Post([FromBody] DeviceDTO device)
        {
            try
            {
                var deviceBusiness = new DeviceBusiness();

                device.TimeZone = ConfigurationManager.AppSettings["timezone"];

                var deviceResponse = deviceBusiness.Upsert(device);

                return(Ok(deviceResponse));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
예제 #12
0
        public object getRouterWarnLog(Dictionary <string, object> dicParas)
        {
            try
            {
                string errMsg       = string.Empty;
                string routerToken  = dicParas.ContainsKey("routerToken") ? dicParas["routerToken"].ToString() : string.Empty;
                string deviceSN     = dicParas.ContainsKey("deviceSN") ? dicParas["deviceSN"].ToString() : string.Empty;
                string headAddress  = dicParas.ContainsKey("headAddress") ? dicParas["headAddress"].ToString() : string.Empty;
                string alertType    = dicParas.ContainsKey("alertType") ? dicParas["alertType"].ToString() : string.Empty;
                string sDate        = dicParas.ContainsKey("sDate") ? dicParas["sDate"].ToString() : string.Empty;
                string eDate        = dicParas.ContainsKey("eDate") ? dicParas["eDate"].ToString() : string.Empty;
                string strPageIndex = dicParas.ContainsKey("pageIndex") ? dicParas["pageIndex"].ToString() : string.Empty;
                string strpageSize  = dicParas.ContainsKey("pageSize") ? dicParas["pageSize"].ToString() : string.Empty;

                if (routerToken == "")
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "控制器令牌不能为空"));
                }

                int pageIndex = 1, pageSize = 10;

                if (!string.IsNullOrWhiteSpace(strPageIndex) && strPageIndex.IsInt())
                {
                    pageIndex = Convert.ToInt32(strPageIndex);
                }

                if (!string.IsNullOrWhiteSpace(strpageSize) && strpageSize.IsInt())
                {
                    pageSize = Convert.ToInt32(strpageSize);
                }

                DataTable table = DeviceBusiness.GetRouterWarnLog(routerToken, deviceSN, headAddress, alertType, sDate, eDate, pageIndex, pageSize);

                if (table.Rows.Count == 0)
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "无数据"));
                }

                var list = Utils.GetModelList <WarnLogModel>(table).ToList();
                return(ResponseModelFactory <List <WarnLogModel> > .CreateModel(isSignKeyReturn, list));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
예제 #13
0
 public object GetFoods(Dictionary <string, object> dicParas)
 {
     try
     {
         string        MobileToken  = dicParas.ContainsKey("mobileToken") ? dicParas["mobileToken"].ToString() : string.Empty;//获取手机令牌
         string        mobile       = string.Empty;
         IMerchService merchService = BLLContainer.Resolve <IMerchService>("XCCloudRS232");
         var           merchlist    = merchService.GetModels(x => x.Token == MobileToken && x.State == 1).FirstOrDefault <Base_MerchInfo>();
         if (merchlist == null)
         {
             return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "手机令牌无效"));
         }
         string FoodID      = dicParas.ContainsKey("foodid") ? dicParas["foodid"].ToString() : string.Empty;           //获取套餐ID
         string DeviceToken = dicParas.ContainsKey("deviceToken") ? dicParas["deviceToken"].ToString() : string.Empty; //获取设备token
         var    devicelist  = DeviceBusiness.GetDeviceModel(DeviceToken);
         if (devicelist == null)
         {
             return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "设备令牌无效"));
         }
         string sql = "select * from (";
         sql += "select a.FoodID,FoodName,a.FoodPrice,a.CoinQuantity,a.IsQuickFood,a.FoodState,a.DeviceID,b.*from (select * from t_foods) a, (select id,DeviceName from Base_DeviceInfo where Status='1')  as b where a.DeviceID=b.ID ";
         sql += ")b";
         sql += " where FoodState='1'and DeviceID='" + devicelist.ID + "' ";
         if (FoodID != "")
         {
             int ID = int.Parse(FoodID);
             sql += " and FoodID='" + ID + "' ";
         }
         sql += " order by ID ";
         DataSet   ds1 = XCCloudRS232BLL.ExecuteQuerySentence(sql, null);
         DataTable dt1 = ds1.Tables[0];
         if (dt1.Rows.Count > 0)
         {
             var            StoreNamelist  = Utils.GetModelList <FoodsModel>(dt1).ToList();
             FoodsModellist foodsModellist = new FoodsModellist();
             foodsModellist.Lists = StoreNamelist;
             return(ResponseModelFactory <FoodsModellist> .CreateModel(isSignKeyReturn, foodsModellist));
         }
         return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "未查询到套餐信息"));
     }
     catch (Exception e)
     {
         throw e;
     }
 }
예제 #14
0
        public void TestDevicesSearch()
        {
            var deviceRepositoryMock   = GetDeviceRepositoryMock();
            var categoryRepositoryMock = GetCategoryRepositoryMock();
            var deviceBusinnes         = new DeviceBusiness(deviceRepositoryMock.Object, categoryRepositoryMock.Object);
            var service = new DeviceService(deviceBusinnes);

            var _result  = service.GetAllDevices();
            var _result2 = service.GetDevicesDtoByName("TV");
            var _result3 = service.GetDevicesDtoByName("Laptop");
            var _result4 = service.GetDevicesByName("super");
            var _result5 = service.GetDevicesByName("later");

            Assert.IsTrue(_result.Count() > 0);
            Assert.IsTrue(_result2.Count() == 0);
            Assert.IsTrue(_result3.Count() > 0);
            Assert.IsTrue(_result5.Count() == 0);
        }
예제 #15
0
 public void ThreadWriteDevice()
 {
     try
     {
         string iniMess = DeviceBusiness.WriteDeviceInfo();
         if (iniMess == "")
         {
             ShowLable1("初始化成功!", false);
         }
         else
         {
             ShowLable2(iniMess, false);
         }
     }
     catch (Exception ex)
     {
         ShowLable2(ex.Message, false);
     }
 }
예제 #16
0
        public object editDeviceName(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;

                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.IsNull() || device.MerchID == 0)
                {
                    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.DeviceName = deviceName;
                DeviceBusiness.UpdateDevice(device);

                return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.T, ""));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
예제 #17
0
        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);
                    }
                }
            }
        }
예제 #18
0
        private void ToolStripMenuItem_Device_Click(object sender, EventArgs e)
        {
            ToolStripMenuItem menuItem       = ((ToolStripMenuItem)(sender));
            DeviceTagModel    tagModel       = (DeviceTagModel)(menuItem.Tag);
            ToolStripMenuItem parentMenuItem = (ToolStripMenuItem)(tagModel.ParentMenuItem);

            foreach (ToolStripMenuItem item in parentMenuItem.DropDownItems)
            {
                DeviceTagModel itemTagModel = (DeviceTagModel)(item.Tag);
                if (!tagModel.Model.Equals(itemTagModel.Model))
                {
                    item.Checked = false;
                }
                else
                {
                    item.Checked = true;
                    DeviceBusiness.SetSelectedDevice(itemTagModel.Type, itemTagModel.Model);
                    DeviceBusiness.SetSelectedDeviceList(itemTagModel.Type, itemTagModel.Model);
                }
            }
        }
예제 #19
0
        public HttpResponseMessage POST(LoginAPIViewModel model)
        {
            IAccountBusiness accountBusiness = new AccountBusiness();

            ResponseLoginAPIViewModel response = new ResponseLoginAPIViewModel();

            if (model != null)
            {
                APMS.DataAccess.Account acc = accountBusiness.CheckUserAPI(model);

                if (acc != null)
                {
                    IDeviceBusiness deviceBusiness = new DeviceBusiness();
                    response.Channel      = acc.Channel;
                    response.DeviceIdList = deviceBusiness.GetDeviceIdListByAccountId(acc.AccountId);
                    response.Token        = acc.Token;
                    return(Request.CreateResponse(HttpStatusCode.OK, response));
                }
            }
            return(Request.CreateResponse(HttpStatusCode.Unauthorized));
        }
예제 #20
0
 private void Dispose(bool dispose)
 {
     if (dispose)
     {
         if (_deviceAssignationBusiness != null)
         {
             _deviceAssignationBusiness = null;
         }
         if (_deviceBusiness != null)
         {
             _deviceBusiness = null;
         }
         if (_deviceUserBusiness != null)
         {
             _deviceUserBusiness = null;
         }
         if (_dserBusiness != null)
         {
             _dserBusiness = null;
         }
     }
 }
예제 #21
0
 public object AddFoods(Dictionary <string, object> dicParas)
 {
     try
     {
         string        MobileToken  = dicParas.ContainsKey("mobileToken") ? dicParas["mobileToken"].ToString() : string.Empty;   //获取手机令牌
         string        DeviceToken  = dicParas.ContainsKey("deviceToken") ? dicParas["deviceToken"].ToString() : string.Empty;   //获取设备token
         string        FoodName     = dicParas.ContainsKey("foodname") ? dicParas["foodname"].ToString() : string.Empty;         //获取套餐名称
         string        FoodPrice    = dicParas.ContainsKey("foodprice") ? dicParas["foodprice"].ToString() : string.Empty;       //获取套餐价格
         string        CoinQuantity = dicParas.ContainsKey("coinquantity") ? dicParas["coinquantity"].ToString() : string.Empty; //获取币数量
         string        IsQuickFood  = dicParas.ContainsKey("isquickfood") ? dicParas["isquickfood"].ToString() : string.Empty;   //获取是否允许散客购买0不允许,1允许
         string        FoodState    = dicParas.ContainsKey("foodstate") ? dicParas["foodstate"].ToString() : string.Empty;       //获取是否有效 1有效
         IMerchService merchService = BLLContainer.Resolve <IMerchService>("XCCloudRS232");
         var           merchlist    = merchService.GetModels(x => x.Token == MobileToken && x.State == 1).FirstOrDefault <Base_MerchInfo>();
         if (merchlist == null)
         {
             return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "手机令牌无效"));
         }
         var devicelist = DeviceBusiness.GetDeviceModel(DeviceToken);
         if (devicelist == null)
         {
             return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "设备令牌无效"));
         }
         t_foods       foods        = new t_foods();
         IFoodsService foodsService = BLLContainer.Resolve <IFoodsService>("XCCloudRS232");
         foods.MerchID      = merchlist.ID;
         foods.DeviceID     = devicelist.ID;
         foods.FoodName     = FoodName;
         foods.FoodPrice    = Convert.ToDecimal(FoodPrice);
         foods.IsQuickFood  = int.Parse(IsQuickFood);
         foods.FoodState    = int.Parse(FoodState);
         foods.CoinQuantity = int.Parse(CoinQuantity);
         foodsService.Add(foods);
         return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.T, ""));
     }
     catch (Exception e)
     {
         throw e;
     }
 }
예제 #22
0
 public override Task OnDisconnected(bool stopCalled)
 {
     if (raspberryConnectionIdChannelDic.ContainsKey(Context.ConnectionId))
     {
         IAccountBusiness accountBusiness = new AccountBusiness();
         IDeviceBusiness  deviceBusiness  = new DeviceBusiness();
         ISensorBusiness  sensorBusiness  = new SensorBusiness();
         string           channel         = raspberryConnectionIdChannelDic[Context.ConnectionId];
         string           accountId       = accountBusiness.GetAccountByChannel(channel).AccountId;
         notification.SendWarningDisconnectionNotification(accountId);
         List <Business.Web.DeviceViewModel> deviceList = deviceBusiness.GetDeviceListByAccountId(accountId);
         SensorsDataViewModel model = new SensorsDataViewModel();
         foreach (var item in deviceList)
         {
             model.DeviceId = item.DeviceId;
             model.State    = (int)Business.Dictionary.DeviceState.Offline;
             sensorBusiness.SaveData(model);
             Clients.Group(channel).GetSensorData(model.DeviceId, (int)Business.Dictionary.DeviceState.Offline, "");
         }
     }
     return(base.OnDisconnected(stopCalled));
 }
예제 #23
0
        private void LoadDeviceMenu(ToolStripMenuItem parentMenu, string deviceType)
        {
            List <DeviceModel> listDeviceModel = DeviceBusiness.GetDevice(deviceType);

            foreach (var model in listDeviceModel)
            {
                //IC卡设备菜单
                ToolStripMenuItem toolStripMenuItem = new ToolStripMenuItem();
                toolStripMenuItem.Name         = model.Model;
                toolStripMenuItem.Size         = new System.Drawing.Size(152, 22);
                toolStripMenuItem.Text         = model.Name;
                toolStripMenuItem.Tag          = new DeviceTagModel(deviceType, model.Model, parentMenu);
                toolStripMenuItem.Checked      = model.Selected;
                toolStripMenuItem.CheckOnClick = true;
                toolStripMenuItem.Click       += ToolStripMenuItem_Device_Click;
                parentMenu.DropDownItems.Add(toolStripMenuItem);
                if (model.Selected)
                {
                    DeviceBusiness.SetSelectedDeviceList(deviceType, model.Model);
                }
            }
        }
예제 #24
0
        public object updateDeviceState(Dictionary <string, object> dicParas)
        {
            string storeId  = dicParas.ContainsKey("storeId") ? dicParas["storeId"].ToString() : string.Empty;
            string deviceId = dicParas.ContainsKey("deviceId") ? dicParas["deviceId"].ToString() : string.Empty;
            string token    = dicParas.ContainsKey("token") ? dicParas["token"].ToString() : string.Empty;
            string state    = dicParas.ContainsKey("state") ? dicParas["state"].ToString() : string.Empty;

            string        dbName        = string.Empty;
            string        password      = string.Empty;
            string        errMsg        = string.Empty;
            StoreBusiness storeBusiness = new StoreBusiness();

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

            DeviceBusiness deviceBusiness = new DeviceBusiness();

            if (!deviceBusiness.IsEffectiveStoreDevice(dbName, deviceId, out errMsg))
            {
                return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "门店不存在"));
            }

            //验证MD5
            string md5token = Utils.MD5(storeId + deviceId + password);

            if (!token.Equals(md5token))
            {
                return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "token不正确"));
            }

            //设置设备状态
            DeviceStateBusiness.SetDeviceState(storeId, deviceId, state);

            return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.T, ""));
        }
예제 #25
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;
            }
        }
예제 #26
0
        public object replaceDevice(Dictionary <string, object> dicParas)
        {
            try
            {
                string errMsg         = string.Empty;
                string mobileToken    = dicParas.ContainsKey("mobileToken") ? dicParas["mobileToken"].ToString() : string.Empty;
                string oldDeviceToken = dicParas.ContainsKey("oldDeviceToken") ? dicParas["oldDeviceToken"].ToString() : string.Empty;
                string newDeviceToken = dicParas.ContainsKey("newDeviceToken") ? dicParas["newDeviceToken"].ToString() : string.Empty;

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

                Base_DeviceInfo oldDevice = DeviceBusiness.GetDeviceModel(oldDeviceToken);
                if (oldDevice.IsNull())
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "您要替换的设备令牌无效"));
                }

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

                //新设备实体
                Base_DeviceInfo newDevice = DeviceBusiness.GetDeviceModel(newDeviceToken);
                if (newDevice.IsNull())
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "当前扫面的设备令牌无效"));
                }

                //判断设备类别是否相同
                if (oldDevice.DeviceType != newDevice.DeviceType)
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "设备类型不同,不能替换"));
                }

                DeviceTypeEnum currDeviceType = (DeviceTypeEnum)oldDevice.DeviceType;
                int            category       = 0;

                switch (currDeviceType)
                {
                case DeviceTypeEnum.Router:
                    category = 1;
                    break;

                case DeviceTypeEnum.SlotMachines:
                case DeviceTypeEnum.DepositMachine:
                    category = 2;
                    break;

                case DeviceTypeEnum.Clerk:
                case DeviceTypeEnum.Terminal:
                    category = 3;
                    break;
                }

                if (category != 0)
                {
                    string         sql        = "exec ReplaceDevice @oldDeviceId,@newDeviceId,@merchId,@category";
                    SqlParameter[] parameters = new SqlParameter[4];
                    parameters[0] = new SqlParameter("@oldDeviceId", oldDevice.ID);
                    parameters[1] = new SqlParameter("@newDeviceId", newDevice.ID);
                    parameters[2] = new SqlParameter("@merchId", merch.ID);
                    parameters[3] = new SqlParameter("@category", category);
                    int ret = XCCloudRS232BLL.ExecuteSql(sql, parameters);
                    if (ret == 0)
                    {
                        return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "设备替换失败"));
                    }
                }

                //修改设备缓存状态
                DeviceStatusBusiness.SetDeviceState(oldDevice.Token, DeviceStatusEnum.未激活.ToDescription());
                DeviceStatusBusiness.SetDeviceState(newDevice.Token, DeviceStatusEnum.离线.ToDescription());

                return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.T, ""));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
예제 #27
0
        public object updateDeviceState(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 status      = dicParas.ContainsKey("status") ? dicParas["status"].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, "该设备属于其他商户,您没有权限查看该设备"));
                }

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

                int    routerId       = 0;
                string strHeadAddress = string.Empty;

                //当前设备类型
                DeviceTypeEnum currDeviceType = (DeviceTypeEnum)device.DeviceType;
                switch (currDeviceType)
                {
                case DeviceTypeEnum.SlotMachines:
                case DeviceTypeEnum.DepositMachine:
                {
                    //获取外设绑定关系实体
                    Data_MerchDevice md = MerchDeviceBusiness.GetMerchDeviceModel(device.ID);
                    if (md.IsNull())
                    {
                        return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "设备未绑定"));
                    }

                    //获取控制器ID
                    routerId       = (int)md.ParentID;
                    strHeadAddress = md.HeadAddress;
                }
                break;

                case DeviceTypeEnum.Clerk:
                case DeviceTypeEnum.Terminal:
                {
                    //获取终端绑定关系实体
                    Data_MerchSegment ms = MerchSegmentBusiness.GetMerchSegmentModel(device.ID);
                    if (ms.IsNull())
                    {
                        return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "设备未绑定"));
                    }

                    //获取控制器ID
                    routerId       = (int)ms.ParentID;
                    strHeadAddress = ms.HeadAddress;
                }
                break;
                }

                Base_DeviceInfo router = null;

                if (routerId != 0)
                {
                    //获取当前设备所属的控制器实体
                    router = DeviceBusiness.GetDeviceModelById(routerId);
                }

                if (router == null)
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "获取控制器信息失败"));
                }

                if (string.IsNullOrWhiteSpace(strHeadAddress))
                {
                    return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "获取设备地址失败"));
                }

                //雷达处理指令
                switch (status.Trim())
                {
                //启用
                case "1":
                    device.DeviceType = (int)DeviceStatusEnum.启用;
                    DeviceBusiness.UpdateDevice(device);
                    DeviceStatusBusiness.SetDeviceState(device.Token, DeviceStatusEnum.离线.ToDescription());
                    break;

                //停用
                case "2":
                    device.DeviceType = (int)DeviceStatusEnum.停用;
                    DeviceBusiness.UpdateDevice(device);
                    DeviceStatusBusiness.SetDeviceState(device.Token, DeviceStatusEnum.停用.ToDescription());
                    break;

                //锁定
                case "3":
                    UDPServer.server.机头锁定解锁指令(router.Token, strHeadAddress, true);
                    DeviceStatusBusiness.SetDeviceState(device.Token, DeviceStatusEnum.锁定.ToDescription());
                    break;

                //解除锁定
                case "4":
                    UDPServer.server.机头锁定解锁指令(router.Token, strHeadAddress, false);
                    DeviceStatusBusiness.SetDeviceState(device.Token, DeviceStatusEnum.在线.ToDescription());
                    break;

                //解除报警
                case "5": break;
                    ////投币
                    //case "6":
                    //    UDPServer.server.远程投币上分(router.Token, strHeadAddress, "10000010", 5);
                    //    break;
                    ////退币
                    //case "7":
                    //    UDPServer.server.远程退币(router.Token, strHeadAddress);
                    //    break;
                }

                //if (state == DeviceStatusEnum.停用 || state == DeviceStatusEnum.启用)
                //{
                //    device.Status = (int)state;
                //    DeviceBusiness.UpdateDevice(device);
                //}

                return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.T, ""));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
예제 #28
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;
            }
        }
예제 #29
0
        public object removeDevice(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, "该设备已被其他商户绑定,没有权限操作该设备"));
                }

                //开始解除绑定
                device.MerchID = 0;
                device.Status  = (int)DeviceStatusEnum.未激活;

                DeviceTypeEnum currDeviceType = (DeviceTypeEnum)device.DeviceType;
                bool           ret            = false;

                switch (currDeviceType)
                {
                case DeviceTypeEnum.Router:
                {
                    string sql = string.Format("exec RemoveMerchRouter {0}", device.ID);
                    XCCloudRS232BLL.ExecuteSql(sql);

                    //ret = DeviceBusiness.UpdateDevice(device);
                }
                break;

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

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

                        transactionScope.Complete();
                    }
                }
                break;

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

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

                        transactionScope.Complete();
                    }
                }
                break;
                }

                if (ret)
                {
                    DeviceStatusBusiness.SetDeviceState(device.Token, DeviceStatusEnum.未激活.ToDescription());
                }

                return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.T, ""));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
예제 #30
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;
            }
        }