public async Task<InformNewAppOutput> InformNewDevice(InformNewAppInput input) { try { if (string.IsNullOrEmpty(input.ClientId)) input.ClientId = "MSoatVe"; return await _deviceBll.InformNewApp(input); } catch (Exception ex) { ErrorStore.LogExceptionWithoutContext(ex); return new InformNewAppOutput(); } }
public Task<InformNewAppOutput> InformNewApp(InformNewAppInput newApp) { int num = 0; string str = null; if (_deviceTable.GetDevice(newApp.ClientId, newApp.DeviceKey) == null) { if (!_requestDeviceTable.IsExistRequestDevice(newApp.ClientId, newApp.DeviceKey)) _requestDeviceTable.CreateRequestDevice(newApp); else _requestDeviceTable.UpdateRequestDevice(newApp); RequestDevice requestDevice = _requestDeviceTable.GetRequestDevice(newApp.ClientId, newApp.DeviceKey); if (requestDevice != null) { if (!requestDevice.IsApproved) str = string.Format("R{0}", requestDevice.Id.ToString("D4")); else num = 3; } else num = 2; } else num = 1; return Task.FromResult(new InformNewAppOutput { Status = num, DeviceName = str }); }
public int UpdateRequestDevice(InformNewAppInput newApp) { return UpdateRequestDevice(newApp, false); }
public int UpdateRequestDevice(InformNewAppInput newApp, bool isApproved) { if (isApproved) return _database.Execute("Update RequestDevices Set ClientId=@clientId, SerialNumber=@serialNumber, IMEI=@iMEI, Manufacturer=@manufacturer, Model=@model, Platform=@platform, PlatformVersion=@platformVersion, IsApproved = @isApproved, Updated = @updated Where DeviceKey = @deviceKey", new Dictionary<string, object>() { { "@clientId", newApp.ClientId }, { "@deviceKey", newApp.DeviceKey }, { "@serialNumber", newApp.SerialNumber }, { "@iMEI", newApp.IMEI }, { "@manufacturer", newApp.Manufacturer }, { "@model", newApp.Model }, { "@platform", newApp.Platform }, { "@platformVersion", newApp.PlatformVersion }, { "@isApproved", isApproved ? 1 : 0 }, { "@updated", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") } }); return _database.Execute("Update RequestDevices Set ClientId=@clientId, SerialNumber=@serialNumber, IMEI=@iMEI, Manufacturer=@manufacturer, Model=@model, Platform=@platform, PlatformVersion=@platformVersion, Created = @created Where DeviceKey = @deviceKey and IsApproved = @isApproved", new Dictionary<string, object>() { { "@clientId", newApp.ClientId }, { "@deviceKey", newApp.DeviceKey }, { "@serialNumber", newApp.SerialNumber }, { "@iMEI", newApp.IMEI }, { "@manufacturer", newApp.Manufacturer }, { "@model", newApp.Model }, { "@platform", newApp.Platform }, { "@platformVersion", newApp.PlatformVersion }, { "@isApproved", isApproved ? 1 : 0 }, { "@created", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") } }); }
public int CreateRequestDevice(InformNewAppInput newApp) { return _database.Execute("Insert into RequestDevices (Id, ClientId, DeviceKey, SerialNumber, IMEI, Manufacturer, Model, Platform, PlatformVersion, IsApproved, Created, Updated) " + "values (@id, @clientId, @deviceKey, @serialNumber, @iMEI, @manufacturer, @model, @platform, @platformVersion, @isApproved, @created, @updated)", new Dictionary<string, object>() { { "@id", null }, { "@clientId", newApp.ClientId }, { "@deviceKey", newApp.DeviceKey }, { "@serialNumber", newApp.SerialNumber }, { "@iMEI", newApp.IMEI }, { "@manufacturer", newApp.Manufacturer }, { "@model", newApp.Model }, { "@platform", newApp.Platform }, { "@platformVersion", newApp.PlatformVersion }, { "@isApproved", false }, { "@created", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }, { "@updated", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") } }); }