private void LogOutUserByUserId(string userId) { if (!string.IsNullOrWhiteSpace(userId)) { Guid uId = new Guid(userId); try { using (var client = new AccessTokenClient()) { var result = client.RemoveAll(uId, "Setting站点工具登出"); result.ThrowIfException(true); } using (var useraccoutClient = new UserAccountClient()) { var insertLog = useraccoutClient.LogUserAction(new UserLog { Action = UserActionEnum.LogOut, CreatedTime = DateTime.Now, UserId = uId, ChannelIn = nameof(ChannelIn.H5), Content = "Setting站点内手动登出该用户" }); insertLog.ThrowIfException(true); } } catch (Exception ex) { WebLog.LogException(ex); } } }
public JsonResult LogOffUserById(string userId, string mobile) { int flag = 0; if (!string.IsNullOrWhiteSpace(userId) && !string.IsNullOrWhiteSpace(mobile)) { Guid uId = new Guid(userId); try { var existYlh = false; var logoffResult = false; using (var ylhClient = new YLHUserAccountClient()) { var ylhUser = ylhClient.GetYLHUserInfoByMobile(mobile); ylhUser.ThrowIfException(true); if (ylhUser.Result != null && ylhUser.Result.UserId != Guid.Empty) { existYlh = true; } } if (existYlh) { flag = -1; } else { using (var client = new UserAccountClient()) { var logoff = client.LogOffUser(uId); logoff.ThrowIfException(true); logoffResult = logoff.Result; } if (logoffResult) { flag = 1; } using (var useraccoutClient = new UserAccountClient()) { var insertLog = useraccoutClient.LogUserAction(new UserLog { Action = UserActionEnum.LogOff, CreatedTime = DateTime.Now, UserId = uId, ChannelIn = nameof(ChannelIn.H5), Content = ThreadIdentity.Operator.Name + "在Setting站点内手动注销该用户" }); insertLog.ThrowIfException(true); } } } catch (Exception ex) { WebLog.LogException(ex); } } return(Json(flag)); }
public JsonResult LogOutUserById(string userId) { bool flag = false; if (!string.IsNullOrWhiteSpace(userId)) { Guid uId = new Guid(userId); try { var cleanTokenResult = 0; using (var client = new AccessTokenClient()) { var result = client.RemoveAll(uId, "Setting站点工具登出"); result.ThrowIfException(true); cleanTokenResult = result.Result; } if (cleanTokenResult >= 0) { flag = true; } using (var useraccoutClient = new UserAccountClient()) { var insertLog = useraccoutClient.LogUserAction(new UserLog { Action = UserActionEnum.LogOut, CreatedTime = DateTime.Now, UserId = uId, ChannelIn = nameof(ChannelIn.H5), Content = "Setting站点内手动登出该用户" }); insertLog.ThrowIfException(true); } } catch (Exception ex) { WebLog.LogException(ex); } } return(Json(flag)); }