Exemple #1
0
        public PluginExecutionResult Execute(PluginExecutionData executionData)
        {
            if (!_setupDone)
            {
                Setup(executionData);
                _setupDone = true;
            }

            try
            {
                _activityData = executionData.GetMetadata <TopCatActivityData>(new[] { new TopCatActivityDataConverter() });
                //since we cannot have multiple topcat instances running on the machine, we will use lock
                var action = new Action(() =>
                {
                    TopCatExecutionController topcatExecution = new TopCatExecutionController(_activityData.Script);
                    if (!_activityData.RunOnce)
                    {
                        topcatExecution.ExecuteTopCatTest();
                    }
                    ReadResult(topcatExecution.GetResultFilePath(executionData.Environment.PluginSettings["DomainAdminUserName"]));
                });

                ExecutionServices.CriticalSection.Run(new Framework.Synchronization.LocalLockToken($"TopCat Execution:{_activityData.Script.ScriptName}", new TimeSpan(0, 2, 0), new TimeSpan(0, 5, 0)), action);

                return(new PluginExecutionResult(PluginResult.Passed));
            }

            catch (Exception genericException)
            {
                ExecutionServices.SystemTrace.LogDebug(genericException.Message);
                return(new PluginExecutionResult(PluginResult.Failed, "Activity Failed :", genericException.Message));
            }
        }
 public void Initialize(PluginEnvironment environment)
 {
     _activityData = new TopCatActivityData();
     _settings     = environment.PluginSettings;
     if (ValidateSettings())
     {
         InitializeTopCatUI();
     }
 }
 public void Initialize(PluginConfigurationData configuration, PluginEnvironment environment)
 {
     // Initialize the activity data by deserializing it from an existing copy of configuration information.
     _activityData = configuration.GetMetadata <TopCatActivityData>(new[] { new TopCatActivityDataConverter() });
     _settings     = environment.PluginSettings;
     if (ValidateSettings())
     {
         InitializeTopCatUI();
     }
 }
Exemple #4
0
        public XElement Convert(XElement xml)
        {
            XNamespace nsRoot                   = xml.GetDefaultNamespace();
            XElement   scriptElement            = xml.Element(nsRoot + "Script");
            var        scriptNamespaceAttribute = scriptElement.Attributes().Where(n => n.IsNamespaceDeclaration).First();
            XNamespace nsScript                 = XNamespace.Get(scriptNamespaceAttribute.Value);

            TopCatScript topCatScript = new TopCatScript
                                        (
                (string)scriptElement.Element(nsScript + "FileName"),
                (string)scriptElement.Element(nsScript + "ScriptName")
                                        );

            XElement selectedTestElement = scriptElement.Element(nsScript + "SelectedTests");
            var      tests = selectedTestElement.Descendants().Where(n => n.Name.LocalName == "string").Select(n => (string)n);

            foreach (string test in tests.Where(n => !string.IsNullOrEmpty(n)))
            {
                topCatScript.SelectedTests.Add(test);
            }

            var propertyNodes = scriptElement.Descendants(nsScript + "TopCatProperties");

            foreach (var propertyNode in propertyNodes.Where(n => n.FirstNode != null))
            {
                string propertyName  = (string)propertyNode.Element(nsScript + "PropertyName");
                string propertyValue = (string)propertyNode.Element(nsScript + "PropertyValue");
                topCatScript.Properties.Add(propertyName, propertyValue);
            }

            TopCatActivityData activityData = new TopCatActivityData()
            {
                CopyDirectory = (bool?)xml.Element(nsRoot + "CopyDirectory") ?? false,
                RunOnce       = (bool?)xml.Element(nsRoot + "RunOnce") ?? false,
                SetupFileName = (string)xml.Element(nsRoot + "SetupFileName"),
                Script        = topCatScript
            };

            return(Serializer.Serialize(activityData));
        }
Exemple #5
0
        public void Setup(PluginExecutionData executionData)
        {
            _activityData = executionData.GetMetadata <TopCatActivityData>(new[] { new TopCatActivityDataConverter() });

            if (_activityData.Script == null)
            {
                ExecutionServices.SystemTrace.LogWarn("No scripts were provided, returning");
                return;
            }

            if (!string.IsNullOrEmpty(_activityData.SetupFileName))
            {
                ProcessUtil.Execute(CopyInstaller(_activityData.SetupFileName, _activityData.CopyDirectory), string.Empty);
            }

            TopCatExecutionController topcatExecution = new TopCatExecutionController(_activityData.Script);

            topcatExecution.InstallPrerequisites(executionData.Environment.PluginSettings["TopCatSetup"]);

            if (_activityData.RunOnce)
            {
                topcatExecution.ExecuteTopCatTest();
            }
        }
Exemple #6
0
 public TopCatExecutionControl(TopCatActivityData activityData)
 {
     InitializeComponent();
     _activityData = activityData;
 }