流浪のwolf

卷帝

导航

简单 webapi 登录成功就返回 电脑的进程信息·

 /// <summary>
        /// 如果登录成功就返回电脑的进程信息
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public LoginResponse Login(LoginRequest req)
        {
            if(req.UserName == "admin" && req.Password == "123456")
            {
                var items = Process.GetProcesses().Select(p => new ProcessInfo(
                    p.Id, p.ProcessName, p.WorkingSet64
                    ));
                return new LoginResponse(true,items.ToArray());
            }else
            {
                return new LoginResponse(false, null);
            }

        }

        public record LoginRequest(string UserName,string Password);
        public record ProcessInfo(int Id,string Name,long WorkingSet);
        public record LoginResponse(bool OK, ProcessInfo[] ProcessInfos); /// <summary>
        

 

posted on 2023-10-11 21:44  流浪のwolf  阅读(5)  评论(0编辑  收藏  举报