コード例 #1
0
 /// <summary>
 /// Initializes this configuration control to default values.
 /// </summary>
 /// <param name="environment">Information about the plugin environment.</param>
 public void Initialize(PluginEnvironment environment)
 {
     _data            = new GFriendExecutionActivityData();
     _requiredDevices = new List <string>();
     InitializeConfigurationControl();
     assetSelectionControl.Initialize(DeviceAttributes);
 }
コード例 #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GFriendExecutionConfigurationControl" /> class.
 /// </summary>
 public GFriendExecutionConfigurationControl()
 {
     InitializeComponent();
     _data            = new GFriendExecutionActivityData();
     _requiredDevices = new List <string>();
     InitializeConfigurationControl();
 }
コード例 #3
0
        /// <summary>
        /// Executes this plugin's workflow using the specified <see cref="PluginExecutionData" />.
        /// </summary>
        /// <param name="executionData">The execution data.</param>
        /// <returns>A <see cref="PluginExecutionResult" /> indicating the outcome of the execution.</returns>
        public PluginExecutionResult Execute(PluginExecutionData executionData)
        {
            UpdateStatus("Starting activity.");
            UpdateLabel(sessionId_value_label, executionData.SessionId);

            _workflowLogger = new DeviceWorkflowLogger(executionData);
            GFriendExecutionActivityData data = executionData.GetMetadata <GFriendExecutionActivityData>();

            UpdateStatus("Prepare Files.");
            string scriptPath;

            if (executionData.Environment.PluginSettings.ContainsKey("GFScriptPath"))
            {
                scriptPath = executionData.Environment.PluginSettings["GFScriptPath"];
            }
            else
            {
                scriptPath = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "scripts", executionData.SessionId);
            }
            UpdateStatus($"GFriend files will be saved to {scriptPath}");

            GFriendPreparationManager.PrepareFiles(data.GFriendFiles, scriptPath);

            string scriptToRun = data.GFriendFiles.Where(s => s.FileType.Equals(GFFileTypes.GFScript)).FirstOrDefault()?.FileName ?? string.Empty;

            if (string.IsNullOrEmpty(scriptToRun))
            {
                UpdateStatus("GF Script file does not exist. Please check activity data");
                return(new PluginExecutionResult(PluginResult.Failed, "Invalid activity data (No Script File)"));
            }

            scriptToRun = Path.Combine(scriptPath, scriptToRun);
            UpdateStatus($"GFriend test script {scriptToRun} will be exeucted.");

            // Run GFriend
            _consoleWriter = new OutputWriter(output_RichTextBox);
            Console.SetOut(_consoleWriter);

            IDeviceInfo           deviceInfo;
            PluginExecutionResult executionResult = new PluginExecutionResult(PluginResult.Passed);

            if (executionData.Assets.Count > 0)
            {
                var devices     = executionData.Assets.OfType <IDeviceInfo>();
                var assetTokens = devices.Select(n => new AssetLockToken(n, data.LockTimeouts));
                _workflowLogger.RecordEvent(DeviceWorkflowMarker.DeviceLockBegin);
                ExecutionServices.CriticalSection.Run(assetTokens, selectedToken =>
                {
                    deviceInfo = (selectedToken as AssetLockToken).AssetInfo as IDeviceInfo;
                    UpdateLabel(dut_value_label, deviceInfo.AssetId);
                    ExecutionServices.DataLogger.Submit(new ActivityExecutionAssetUsageLog(executionData, deviceInfo));
                    executionResult = RunGFriendScript(executionData, scriptToRun, deviceInfo);
                });
                _workflowLogger.RecordEvent(DeviceWorkflowMarker.DeviceLockEnd);
            }
            else
            {
                executionResult = RunGFriendScript(executionData, scriptToRun, null);
            }

            var standardOutput = new StreamWriter(Console.OpenStandardOutput());

            standardOutput.AutoFlush = true;
            Console.SetOut(standardOutput);

            UpdateStatus("Finished activity.");
            UpdateStatus($"Result = {executionResult.Result}");

            return(executionResult);
        }
コード例 #4
0
 /// <summary>
 /// Initializes this configuration control with the specified <see cref="PluginConfigurationData" />.
 /// </summary>
 /// <param name="configuration">The configuration data.</param>
 /// <param name="environment">Information about the plugin environment.</param>
 public void Initialize(PluginConfigurationData configuration, PluginEnvironment environment)
 {
     _data = configuration.GetMetadata <GFriendExecutionActivityData>();
     InitializeConfigurationControl();
     assetSelectionControl.Initialize(configuration.Assets, DeviceAttributes);
 }