Exemple #1
0
        public object addDevice(Dictionary <string, object> dicParas)
        {
            string storeId     = dicParas.ContainsKey("storeId") ? dicParas["storeId"].ToString() : string.Empty;
            string mcuId       = dicParas.ContainsKey("mcuId") ? dicParas["mcuId"].ToString() : string.Empty;
            string deviceToken = string.Empty;

            if (string.IsNullOrEmpty(storeId))
            {
                return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "门店号无效"));
            }

            if (string.IsNullOrEmpty(mcuId))
            {
                return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "设备ID无效"));
            }

            int           storeids     = int.Parse(storeId);
            IStoreService storeService = BLLContainer.Resolve <IStoreService>();
            var           menlist      = storeService.GetModels(x => x.id == storeids).FirstOrDefault <t_store>();

            if (menlist == null)
            {
                return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.T, "门店号无效"));
            }
            deviceToken = DeviceManaBusiness.GetDeviceToken();
            int    StoreType = 1;
            string dbname    = menlist.store_dbname;

            if (dbname == "XCCloudRS232")
            {
                StoreType = 0;
            }
            IDeviceService device     = BLLContainer.Resolve <IDeviceService>();
            var            devicelist = device.GetModels(x => x.DeviceId == mcuId && x.StoreId == storeId).FirstOrDefault <t_device>();

            if (devicelist != null)
            {
                return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "该店号已经存在该设备信息!"));
            }
            string sql = @"select a.MCUID,b.GameName,b.GameType from t_head a inner join t_game b on a.GameID = b.GameID where MCUID = '" + mcuId + "'";

            System.Data.DataSet ds = XCGameBLL.ExecuteQuerySentence(sql, dbname, null);
            if (ds.Tables[0].Rows.Count > 0)
            {
                DeviceModel deviceModel = Utils.GetModelList <DeviceModel>(ds.Tables[0])[0];
                t_device    device1     = new t_device();
                device1.TerminalNo = deviceToken;
                device1.StoreId    = storeId;
                device1.StoreType  = StoreType;
                device1.DeviceName = deviceModel.GameName;
                device1.DeviceType = deviceModel.GameType;
                device1.DeviceId   = deviceModel.MCUID;
                device.Add(device1);
                return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.T, ""));
            }
            return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "未查询到相关数据"));
        }
 public static bool ExistDevice(string deviceToken, ref t_device deviceModel, out string errMsg)
 {
     errMsg = string.Empty;
     BLL.IBLL.XCGameManager.IDeviceService deviceService = BLLContainer.Resolve <BLL.IBLL.XCGameManager.IDeviceService>();
     deviceModel = deviceService.GetModels(p => p.TerminalNo.Equals(deviceToken, StringComparison.OrdinalIgnoreCase)).FirstOrDefault <Model.XCGameManager.t_device>();
     if (deviceModel == null)
     {
         errMsg = "设备信息不存在";
         return(false);
     }
     else
     {
         return(true);
     }
 }