Exemple #1
0
        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));
        }