Пример #1
0
        public IActionResult Get(int id)
        {
            Disp user = Disps.FirstOrDefault(x => x.Id == id);

            if (user == null)
            {
                return(NotFound());
            }
            return(Ok(user));
        }
Пример #2
0
        public IActionResult Post(Disp disp)
        {
            if (string.IsNullOrWhiteSpace(disp.Name))
            {
                return(BadRequest());
            }
            var s = Process.Start(disp.Name);

            var res = new Disp
            {
                Id     = s.Id,
                Name   = $"{s.ProcessName}({s.MainWindowTitle})",
                Memory = Perm.GetMemory(s.ProcessName)
            };

            return(Ok(res));
        }
Пример #3
0
        public IActionResult Delete(int id)
        {
            var disp = (from pr in Process.GetProcesses(".")
                        where pr.Id == id
                        select pr).FirstOrDefault();

            if (disp == null)
            {
                return(BadRequest());
            }

            disp.Kill();

            var d = new Disp
            {
                Id     = disp.Id,
                Name   = $"{disp.ProcessName}({disp.MainWindowTitle})",
                Memory = ""
            };

            return(Ok(d));
        }