Example #1
0
        public ApplicationWrapper GetApplication(ControlApplicationRequest applicationRequest)
        {
            Application application = null;

            if (applicationRequest.MethodName == LaunchByExecutable)
            {
                application = Application.Launch(new ProcessStartInfo(applicationRequest.Executable, applicationRequest.Arguments));
            }

            if (applicationRequest.MethodName == AttachToProcessByProcessId)
            {
                application = Application.Attach(applicationRequest.ProcessId);
            }

            if (applicationRequest.MethodName == AttachToProcessByProcessName)
            {
                application = Application.Attach(applicationRequest.ProcessName);
            }

            if (applicationRequest.MethodName == AttachOrLaunchByProcessName)
            {
                application = Application.AttachOrLaunch(new ProcessStartInfo(applicationRequest.ProcessName));
            }
            applicationRequest.ApplicationName = application?.Name;

            return(_applicationRepository.Save(application));
        }
Example #2
0
 // POST WinAuto/Application
 public object Post([FromBody] ControlApplicationRequest applicationRequest)
 {
     try
     {
         Console.WriteLine("Start Launching application " + applicationRequest);
         var app = Services.Application.GetApplication(applicationRequest);
         return(new ResponseModel <ApplicationWrapper>("Application has been started.", app));
     }
     catch (Exception e)
     {
         return(new ResponseModel <Exception>("Error occured while starting application", e));
     }
 }