Ejemplo n.º 1
0
        private NewPayLoad StartDriver(NewPayLoad pl)
        {
            try
            {
                List <NewPayLoad> FieldsandParams = pl.GetListPayLoad();

                Dictionary <string, string> InputParams = new Dictionary <string, string>();
                foreach (NewPayLoad Np in FieldsandParams)
                {
                    string Name = Np.GetValueString();

                    string Value = Np.GetValueString();
                    if (!InputParams.ContainsKey(Name))
                    {
                        InputParams.Add(Name, Value);
                    }
                }


                ConfigureServiceParams(mService, InputParams);
                Console.WriteLine("Payload - Start Session");
                ((IServiceSession)mService).StartSession();
                NewPayLoad PLRC = new NewPayLoad("OK");
                PLRC.ClosePackage();
                return(PLRC);
            }
            catch (Exception ex)
            {
                return(NewPayLoad.Error(ex.Message));
            }
        }
Ejemplo n.º 2
0
        public static void ExecutesScreenShotActionOnAgent(Agent agent, Act act)
        {
            NewPayLoad        PL       = new NewPayLoad("ScreenshotAction");
            List <NewPayLoad> PLParams = new List <NewPayLoad>();

            NewPayLoad AIVPL = new NewPayLoad("AIV", "WindowsToCapture", act.WindowsToCapture.ToString());

            PLParams.Add(AIVPL);
            PL.AddListPayLoad(PLParams);
            // Get the action payload

            PL.ClosePackage();
            // Send the payload to the service
            NewPayLoad RC = agent.GingerNodeProxy.RunAction(PL);

            if (RC.Name == "ScreenShots")
            {
                List <NewPayLoad> FieldsandParams = RC.GetListPayLoad();

                foreach (NewPayLoad Np in FieldsandParams)
                {
                    string Name = Np.GetValueString();

                    //string base64string = Np.GetValueString();
                    act.AddScreenShot(Name);
                }
            }
            else
            {
                // The RC is not OK when we faced some unexpected exception
                //TODO:
                string Err = RC.GetValueString();
                act.Error += Err;
            }
        }
Ejemplo n.º 3
0
        private NewPayLoad TakeScreenot(NewPayLoad ActionPayload)
        {
            if (mService is IScreenShotService ScreenshotService)
            {
                Dictionary <string, string> InputParams     = new Dictionary <string, string>();
                List <NewPayLoad>           FieldsandParams = ActionPayload.GetListPayLoad();


                foreach (NewPayLoad Np in FieldsandParams)
                {
                    string Name = Np.GetValueString();

                    string Value = Np.GetValueString();
                    if (!InputParams.ContainsKey(Name))
                    {
                        InputParams.Add(Name, Value);
                    }
                }
                NewPayLoad ResponsePL       = new NewPayLoad("ScreenShots");
                string     WindowsToCapture = InputParams["WindowsToCapture"];

                List <NewPayLoad> ScreenShots = new List <NewPayLoad>();

                switch (WindowsToCapture)
                {
                case "OnlyActiveWindow":
                    ScreenShots.Add(BitmapToPayload(ScreenshotService.GetActiveScreenImage()));

                    break;

                case "AllAvailableWindows":


                    foreach (Bitmap bmp in ScreenshotService.GetAllScreensImages())
                    {
                        ScreenShots.Add(BitmapToPayload(bmp));
                    }
                    break;

                default:
                    return(NewPayLoad.Error("Service is not supporting IScreenShotService cannot delegate to take screen shot"));
                }



                Bitmap img = ScreenshotService.GetActiveScreenImage();


                ResponsePL.AddListPayLoad(ScreenShots);
                ResponsePL.ClosePackage();
                return(ResponsePL);
            }

            NewPayLoad err2 = NewPayLoad.Error("Service is not supporting IScreenShotService cannot delegate to take screen shot");

            return(err2);
        }