<commit_before>﻿using System;
using System.Diagnostics;
using System.IO;
using BurnSystems;
using BurnSystems.Logging;
using DatenMeister.Core.EMOF.Interface.Reflection;
using DatenMeister.Models;
using DatenMeister.Runtime;

namespace DatenMeister.Modules.Actions.ActionHandler
{
    public class PowershellExecutionActionHandler : IActionHandler
    {
        /// <summary>
        /// Defines the logger 
        /// </summary>
        private readonly ClassLogger Logger = new ClassLogger(typeof(CommandExecutionActionHandler));
        
        public bool IsResponsible(IElement node)
        {
            return node.getMetaClass()?.@equals(
                _Actions.TheOne.__PowershellExecutionAction) == true;
        }

        public void Evaluate(ActionLogic actionLogic, IElement action)
        {
            var script = action.getOrDefault<string>(_Actions._PowershellExecutionAction.script);
            var workingDirectory = action.getOrDefault<string>(_Actions._PowershellExecutionAction.workingDirectory);

            var tempPath = Path.Combine(Path.GetTempPath(),
                StringManipulation.RandomString(16) + ".ps1");
            
            
            File.WriteAllText(tempPath, script);

            Logger.Info($"Powershell started");
            var startInfo = new ProcessStartInfo
            {
                FileName = "powershell.exe", <commit_msg>Started Powershell and LoadExtentAction<commit_after>﻿using System;
using System.Diagnostics;
using System.IO;
using BurnSystems;
using BurnSystems.Logging;
using DatenMeister.Core.EMOF.Interface.Reflection;
using DatenMeister.Models;
using DatenMeister.Runtime;

namespace DatenMeister.Modules.Actions.ActionHandler
{
    public class PowershellExecutionActionHandler : IActionHandler
    {
        /// <summary>
        /// Defines the logger 
        /// </summary>
        private readonly ClassLogger Logger = new ClassLogger(typeof(CommandExecutionActionHandler));
        
        public bool IsResponsible(IElement node)
        {
            return node.getMetaClass()?.@equals(
                _Actions.TheOne.__PowershellExecutionAction) == true;
        }

        public void Evaluate(ActionLogic actionLogic, IElement action)
        {
            var script = action.getOrDefault<string>(_Actions._PowershellExecutionAction.script);
            var workingDirectory = action.getOrDefault<string>(_Actions._PowershellExecutionAction.workingDirectory);

            var tempPath = Path.Combine(Path.GetTempPath(),
                StringManipulation.RandomString(16) + ".ps1");

            File.WriteAllText(tempPath, script);

            Logger.Info($"Powershell started");
            var startInfo = new ProcessStartInfo
            {
                FileName = "powershell.exe", 
{'fraction_non_alphanumeric': 0.08664518438954529, 'fraction_numerical': 0.0021482277121374865, 'mean_word_length': 2.690885072655218, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4559018', 'n_tokens_mistral': 744, 'n_tokens_neox': 711, 'n_words': 139}