Exemple #1
0
        private static System.Action GetAction(int taskID, ActionModel action)
        {
            IAction actionInstance = null;

            switch (action.Action)
            {
            case ActionType.WriteFile:
                actionInstance = new WriteFileAction();
                break;

            case ActionType.IF:
                actionInstance = new IFAction();
                break;

            case ActionType.HttpRequest:
                actionInstance = new HttpRequestAction();
                break;

            case ActionType.Shutdown:
                actionInstance = new ShutdownAction();
                break;

            case ActionType.StartProcess:
                actionInstance = new StartProcessAction();
                break;

            case ActionType.OpenURL:
                actionInstance = new OpenURLAction();
                break;

            case ActionType.Snipping:
                actionInstance = new SnippingAction();
                break;

            case ActionType.DeleteFile:
                actionInstance = new DeleteFileAction();
                break;

            case ActionType.SoundPlay:
                actionInstance = new SoundPlayAction();
                break;

            case ActionType.GetIPAddress:
                actionInstance = new GetIPAddressAction();
                break;

            case ActionType.Keyboard:
                actionInstance = new KeyboardAction();
                break;
            }
            if (actionInstance != null)
            {
                return(actionInstance.GenerateAction(taskID, action));
            }
            return(null);
        }
Exemple #2
0
        public void StartProcessNotepadTest()
        {
            string             processPath        = @"notepad";
            StartProcessAction startProcessAction = new StartProcessAction()
            {
                Id             = PluginUtilities.GetUniqueId(),
                LoggingService = ServicesContainer.ServicesProvider.GetLoggingService(nameof(StartProcessAction)),
                ProcessPath    = processPath,
            };

            var actionResult = startProcessAction.Execute(ArgumentCollection.New());

            Assert.IsNotNull(actionResult);
            Assert.IsTrue(actionResult.Result);

            System.Diagnostics.Process.GetProcessesByName(processPath).FirstOrDefault()?.Kill();
        }
Exemple #3
0
        public void StartProcessTest()
        {
            string             processPath        = @"%userprofile%\Desktop\processtest\sample.bat";
            StartProcessAction startProcessAction = new StartProcessAction()
            {
                Id                 = PluginUtilities.GetUniqueId(),
                LoggingService     = ServicesContainer.ServicesProvider.GetLoggingService(nameof(StartProcessAction)),
                ProcessPath        = Environment.ExpandEnvironmentVariables(processPath),
                WaitForExit        = true,
                WaitForExitTimeout = 10000
            };

            var actionResult = startProcessAction.Execute(ArgumentCollection.New());

            Assert.IsNotNull(actionResult);
            Assert.IsTrue(actionResult.Result);
            Assert.IsNull(actionResult.AttachedException);
            Assert.IsNotNull(actionResult.AdditionalInformation);
            Assert.IsTrue(actionResult.AdditionalInformation.HasArgument(StartProcessActionResultArgs.ProcessPath));
            Assert.IsTrue(
                actionResult.AdditionalInformation.HasArgument(StartProcessActionResultArgs.ProcessArguments));
            Assert.IsTrue(
                actionResult.AdditionalInformation.HasArgument(StartProcessActionResultArgs.ProcessWorkingDirectory));
            Assert.IsTrue(actionResult.AdditionalInformation.HasArgument(StartProcessActionResultArgs.ProcessExited));
            Assert.IsTrue(actionResult.AdditionalInformation.HasArgument(StartProcessActionResultArgs.ProcessStarted));
            Assert.AreEqual(Environment.ExpandEnvironmentVariables(processPath),
                            actionResult.AdditionalInformation.GetValue <string>(StartProcessActionResultArgs.ProcessPath));
            Assert.AreEqual(Path.GetDirectoryName(Environment.ExpandEnvironmentVariables(processPath)),
                            actionResult.AdditionalInformation.GetValue <string>(
                                StartProcessActionResultArgs.ProcessWorkingDirectory));
            Assert.IsTrue(string.IsNullOrWhiteSpace(
                              actionResult.AdditionalInformation.GetValue <string>(StartProcessActionResultArgs.ProcessArguments)));
            Assert.AreEqual(true,
                            actionResult.AdditionalInformation.GetValue <bool>(StartProcessActionResultArgs.ProcessStarted));
            Assert.AreEqual(true,
                            actionResult.AdditionalInformation.GetValue <bool>(StartProcessActionResultArgs.ProcessExited));
        }
Exemple #4
0
        private static IAction GetAction(ActionModel action)
        {
            IAction actionInstance = null;

            switch (action.Action)
            {
            case ActionType.WriteFile:
                actionInstance = new WriteFileAction();
                break;

            case ActionType.IF:
                actionInstance = new IFAction();
                break;

            case ActionType.HttpRequest:
                actionInstance = new HttpRequestAction();
                break;

            case ActionType.Shutdown:
                actionInstance = new ShutdownAction();
                break;

            case ActionType.StartProcess:
                actionInstance = new StartProcessAction();
                break;

            case ActionType.OpenURL:
                actionInstance = new OpenURLAction();
                break;

            case ActionType.Snipping:
                actionInstance = new SnippingAction();
                break;

            case ActionType.DeleteFile:
                actionInstance = new DeleteFileAction();
                break;

            case ActionType.SoundPlay:
                actionInstance = new SoundPlayAction();
                break;

            case ActionType.GetIPAddress:
                actionInstance = new GetIPAddressAction();
                break;

            case ActionType.Keyboard:
                actionInstance = new KeyboardAction();
                break;

            case ActionType.SystemNotification:
                actionInstance = new SystemNotificationAction();
                break;

            case ActionType.DownloadFile:
                actionInstance = new DownloadFileAction();
                break;

            case ActionType.Dialog:
                actionInstance = new DialogAction();
                break;

            case ActionType.Delay:
                actionInstance = new DelayAction();
                break;

            case ActionType.Loops:
                actionInstance = new LoopsAction();
                break;

            case ActionType.KillProcess:
                actionInstance = new KillProcessAction();
                break;

            case ActionType.SetDeviceVolume:
                actionInstance = new SetDeviceVolumeAction();
                break;

            case ActionType.Regex:
                actionInstance = new RegexAction();
                break;

            case ActionType.ReadFile:
                actionInstance = new ReadFileAction();
                break;

            case ActionType.JsonDeserialize:
                actionInstance = new JsonDeserializeAction();
                break;
            }
            if (actionInstance != null)
            {
                return(actionInstance);
            }
            return(null);
        }