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 object register(Dictionary <string, object> dicParas) { //MerchID,DeviceName,DeviceType,SN,Token,QRURL,Status,motor1,motor2,nixie_tube_type,motor2_coin,motor1_coin,FromDevice,ToCard,SSR,alert_value string deviceName = dicParas.ContainsKey("deviceName") ? dicParas["deviceName"].ToString() : string.Empty; string deviceType = dicParas.ContainsKey("deviceType") ? dicParas["deviceType"].ToString() : string.Empty; string sn = dicParas.ContainsKey("sn") ? dicParas["sn"].ToString() : string.Empty; string qrUrl = dicParas.ContainsKey("qrUrl") ? dicParas["qrUrl"].ToString() : string.Empty; string motor1 = dicParas.ContainsKey("motor1") ? dicParas["motor1"].ToString() : string.Empty; string motor2 = dicParas.ContainsKey("motor2") ? dicParas["motor2"].ToString() : string.Empty; string nixie_tube_type = dicParas.ContainsKey("nixie_tube_type") ? dicParas["nixie_tube_type"].ToString() : string.Empty; string motor2_coin = dicParas.ContainsKey("motor2_coin") ? dicParas["motor2_coin"].ToString() : string.Empty; string motor1_coin = dicParas.ContainsKey("motor1_coin") ? dicParas["motor1_coin"].ToString() : string.Empty; string fromDevice = dicParas.ContainsKey("fromDevice") ? dicParas["fromDevice"].ToString() : string.Empty; string toCard = dicParas.ContainsKey("toCard") ? dicParas["toCard"].ToString() : string.Empty; string ssr = dicParas.ContainsKey("ssr") ? dicParas["ssr"].ToString() : string.Empty; string alert_value = dicParas.ContainsKey("alert_value") ? dicParas["alert_value"].ToString() : string.Empty; if (int.Parse(deviceType) < 0 || int.Parse(deviceType) > 4) { return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "设备类型不正确")); } XCCloudService.BLL.IBLL.XCCloudRS232.IDeviceService xcCloudRS232DeviceService = BLLContainer.Resolve <XCCloudService.BLL.IBLL.XCCloudRS232.IDeviceService>(); XCCloudService.BLL.IBLL.XCGameManager.IDeviceService xcGameManaDeviceService = BLLContainer.Resolve <XCCloudService.BLL.IBLL.XCGameManager.IDeviceService>(); var xcCloudRS232DeviceModel = xcCloudRS232DeviceService.GetModels(p => p.SN.Equals(sn)).FirstOrDefault <Base_DeviceInfo>(); if (xcCloudRS232DeviceModel == null) { string deviceToken = DeviceManaBusiness.GetDeviceToken(); bool isExist = false; while (isExist == false) { if (xcGameManaDeviceService.GetCount(p => p.TerminalNo.Equals(deviceToken)) == 0 && xcCloudRS232DeviceService.GetCount(p => p.SN.Equals(deviceToken)) == 0) { isExist = true; } else { deviceToken = DeviceManaBusiness.GetDeviceToken(); } System.Threading.Thread.Sleep(100); } Base_DeviceInfo deviceModel = new Base_DeviceInfo(); deviceModel.MerchID = 0; deviceModel.DeviceName = deviceName; deviceModel.DeviceType = int.Parse(deviceType); deviceModel.SN = sn; deviceModel.Token = deviceToken; deviceModel.QRURL = qrUrl; deviceModel.Status = 1; deviceModel.motor1 = int.Parse(motor1); deviceModel.motor2 = int.Parse(motor2); deviceModel.nixie_tube_type = int.Parse(nixie_tube_type); deviceModel.motor1_coin = int.Parse(motor1_coin); deviceModel.motor2_coin = int.Parse(motor2_coin); deviceModel.FromDevice = int.Parse(fromDevice); deviceModel.ToCard = int.Parse(toCard); deviceModel.SSR = int.Parse(ssr); deviceModel.alert_value = int.Parse(alert_value); xcCloudRS232DeviceService.Add(deviceModel); return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.T, "")); } else { return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "设备信息已存在")); } }
public object register(Dictionary <string, object> dicParas) { try { string storeId = dicParas.ContainsKey("storeId") ? dicParas["storeId"].ToString() : string.Empty; string mcuId = dicParas.ContainsKey("mcuId") ? dicParas["mcuId"].ToString() : string.Empty; XCCloudService.Model.CustomModel.XCGameManager.StoreCacheModel storeCacheModel = null; string errMsg = string.Empty; string deviceToken = string.Empty; //验证门店信息 XCCloudService.Business.XCGameMana.StoreBusiness xcGameManaStoreBusiness = new XCCloudService.Business.XCGameMana.StoreBusiness(); if (!xcGameManaStoreBusiness.IsEffectiveStore(storeId, ref storeCacheModel, out errMsg)) { return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "门店不存在")); } //获取子库中是否存在mcuId XCCloudService.BLL.IBLL.XCGame.IDeviceService xcGameDeviceService = BLLContainer.Resolve <XCCloudService.BLL.IBLL.XCGame.IDeviceService>(storeCacheModel.StoreDBName); var xcGameDeviceModel = xcGameDeviceService.GetModels(p => p.MCUID.Equals(mcuId)).FirstOrDefault <XCCloudService.Model.XCGame.t_device>(); if (xcGameDeviceModel == null) { return(ResponseModelFactory.CreateModel(isSignKeyReturn, Return_Code.T, "", Result_Code.F, "设备不存在")); } //获取总库中是否存在 XCCloudService.BLL.IBLL.XCGameManager.IDeviceService xcGameManaDeviceService = BLLContainer.Resolve <XCCloudService.BLL.IBLL.XCGameManager.IDeviceService>(); var xcGameManaDeviceModel = xcGameManaDeviceService.GetModels(p => p.StoreType == (int)(XCGameManaDeviceStoreType.Store) && p.DeviceId.Equals(mcuId)).FirstOrDefault <XCCloudService.Model.XCGameManager.t_device>(); if (xcGameManaDeviceModel != null) { if (!xcGameManaDeviceModel.DeviceName.Equals(xcGameDeviceModel.name) || !xcGameManaDeviceModel.DeviceType.Equals(xcGameDeviceModel.type)) { xcGameManaDeviceModel.DeviceType = xcGameDeviceModel.type; xcGameManaDeviceModel.DeviceName = xcGameDeviceModel.name; xcGameManaDeviceService.Update(xcGameManaDeviceModel); } deviceToken = xcGameManaDeviceModel.TerminalNo; } else { deviceToken = DeviceManaBusiness.GetDeviceToken(); bool isExist = false; while (isExist == false) { if (xcGameManaDeviceService.GetCount(p => p.TerminalNo.Equals(deviceToken)) == 0) { isExist = true; } else { deviceToken = DeviceManaBusiness.GetDeviceToken(); } System.Threading.Thread.Sleep(100); } xcGameManaDeviceModel = new XCCloudService.Model.XCGameManager.t_device(); xcGameManaDeviceModel.DeviceId = xcGameDeviceModel.MCUID; xcGameManaDeviceModel.TerminalNo = deviceToken; xcGameManaDeviceModel.DeviceName = xcGameDeviceModel.name; xcGameManaDeviceModel.DeviceType = xcGameDeviceModel.type; xcGameManaDeviceModel.StoreId = storeId; xcGameManaDeviceModel.Note = xcGameDeviceModel.note; xcGameManaDeviceModel.StoreType = (int)(XCGameManaDeviceStoreType.Store); xcGameManaDeviceService.Add(xcGameManaDeviceModel); } var obj = new { deviceToken = deviceToken }; return(ResponseModelFactory.CreateAnonymousSuccessModel(isSignKeyReturn, obj)); } catch (Exception e) { throw e; } }