public void UpdateDeviceInfo(Guid accountId, UserDeviceUpdateIM im, string ip, string deviceNumber) { var deviceList = new UserDeviceDAC().GetUserDeviceByAccountId(accountId); if (!deviceList.Any()) { new ApplicationException(); } if (deviceList.All(item => item.DeviceNumber != deviceNumber)) { new ApplicationException(); } new UserDeviceDAC().Update(new UserDevice() { UserAccountId = accountId, Address = im.Address, IP = ip, LastActiveTime = DateTime.UtcNow, Name = im.Name, DeviceNumber = im.DeviceNumber }); }
public ServiceResult <bool> UpdateDeviceInfo(UserDeviceUpdateIM im) { var result = new ServiceResult <bool>(); string deviceNumber = this.GetDeviceNumber(); if (string.IsNullOrEmpty(deviceNumber)) { result.Code = ReasonCode.MISSING_REQUIRED_FIELDS; return(result); } string ip = this.GetClientIPAddress(); // HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]; //if (string.IsNullOrEmpty(ip)) //{ // ip = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]; //} new UserDeviceComponent().UpdateDeviceInfo(this.GetUser().Id, im, ip, deviceNumber); result.Data = true; return(result); }