private void BashCollectorServiceHostCheck(PluginEnvironment environment)
        {
            if (environment.PluginSettings.ContainsKey("BashLogCollectorServiceHost"))
            {
                _bashCollectorServiceHost = environment.PluginSettings["BashLogCollectorServiceHost"];

                try
                {
                    using (TcpClient client = new TcpClient(_bashCollectorServiceHost,
                                                            (int)WcfService.BashLogcollectorService))
                    {
                        try
                        {
                            client.Connect(_bashCollectorServiceHost, (int)WcfService.BashLogcollectorService);
                        }
                        catch (Exception e)
                        {
                            MessageBox.Show(
                                $@"Please verify the setting BashLogCollectorServiceHost in PluginSettings to enable Firmware Flash through Bios method, {e.Message}",
                                @"Incorrect Plugin Setting", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            port_comboBox.Enabled = bios_radioButton.Enabled = false;
                            return;
                        }
                    }
                    using (BashLogCollectorClient client = new BashLogCollectorClient(_bashCollectorServiceHost))
                    {
                        _portList = client.GetSerialPorts();
                        if (_portList.Count > 0)
                        {
                            port_comboBox.DataSource = _portList;
                            port_comboBox.DataBindings.Add("Enabled", bios_radioButton, "Checked");
                        }
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show(
                        $@"Please verify the setting BashLogCollectorServiceHost in PluginSettings to enable Firmware Flash through Bios method, {e.Message}",
                        @"Incorrect Plugin Setting", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    port_comboBox.Enabled = bios_radioButton.Enabled = false;
                }
            }
            else
            {
                MessageBox.Show(
                    @"Please define the setting BashLogCollectorServiceHost in PluginSettings to enable Firmware Flash through Bios method",
                    @"Missing Plugin Setting", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                port_comboBox.Enabled = bios_radioButton.Enabled = false;
            }
        }
        /// <summary>
        ///Execution point for the plugin
        /// <seealso cref="PluginExecutionData"/>
        /// <seealso cref="PluginExecutionResult"/>
        /// <seealso cref="PluginResult"/>
        /// <param name="executionData">The execution data.</param>
        /// <returns>A <see cref="PluginExecutionResult"/> indicating the outcome of the
        /// execution.</returns>
        /// </summary>

        public PluginExecutionResult Execute(PluginExecutionData executionData)
        {
            var serviceHost = executionData.Environment.PluginSettings["BashLogCollectorServiceHost"];

            if (string.IsNullOrEmpty(serviceHost))
            {
                return(new PluginExecutionResult(PluginResult.Error, "Bash Logger Service Host setting missing. Please enter the value in Plugin Settings"));
            }

            _client = new BashLogCollectorClient(serviceHost);
            _data   = executionData.GetMetadata <BashLoggerActivityData>();

            try
            {
                Parallel.ForEach(executionData.Assets.OfType <IDeviceInfo>(),
                                 asset =>
                {
                    var assetId = _client.CreateLogger(asset.AssetId);
                    if (string.IsNullOrEmpty(assetId))
                    {
                        ExecutionServices.SystemTrace.LogError(
                            $"Unable to Create Logger for {asset.AssetId}, Please verify the bash logger information for the device in Asset Inventory");
                        return;
                    }
                    switch (_data.LoggerAction)
                    {
                    case LoggerAction.Start:
                        _client.StartLogging(assetId);
                        UpdateStatus($"Logging Started for device: {asset.AssetId}");
                        break;

                    case LoggerAction.Stop:
                        _client.StopLogging(assetId);
                        UpdateStatus($"Logging Stopped for device: {asset.AssetId}");
                        break;

                    case LoggerAction.CollectLog:
                        {
                            UpdateStatus($"Collecting Logs for device: {asset.AssetId}");
                            var log = _client.CollectLog(assetId);
                            UpdateStatus($"Collection of Logs completed for device: {asset.AssetId}");
                            _client.Flush(assetId);
                            UpdateStatus($"Clearing the Logs for device: {asset.AssetId}");
                            _bashLogConcurrentDictionary.AddOrUpdate(assetId, log, (key, oldvalue) => oldvalue + log);
                        }
                        break;
                    }
                });
            }
            catch (Exception e)
            {
                return(new PluginExecutionResult(PluginResult.Error, e.InnerException?.Message ?? e.Message));
            }

            if (_data.LoggerAction == LoggerAction.CollectLog)
            {
                foreach (var bashLogPair in _bashLogConcurrentDictionary)
                {
                    var fileSplitSize = _data.FileSplitSize * 1024 * 1024;
                    var numOfFiles    = bashLogPair.Value.Length / fileSplitSize + 1;

                    if (!Directory.Exists(_data.FolderPath))
                    {
                        UpdateStatus("Given path doesn't exist, switching to temporary location");
                        _data.FolderPath = Path.GetTempPath();
                    }

                    for (int i = 0; i < numOfFiles; i++)
                    {
                        using (
                            var logFile =
                                File.Create(
                                    Path.Combine(_data.FolderPath,
                                                 $"{bashLogPair.Key}_{executionData.SessionId}_BashLog_{i}.txt"), fileSplitSize,
                                    FileOptions.None))
                        {
                            byte[] buffer = new byte[fileSplitSize];

                            //complicated math below
                            //checks if the file split size is less than total file length, check for total log size is smaller than split size, check for last chunk file to be written to avoid null character entry
                            int charCount = fileSplitSize < bashLogPair.Value.Length
                                ? fileSplitSize < bashLogPair.Value.Length - i * fileSplitSize
                                    ? fileSplitSize
                                    : bashLogPair.Value.Length - i * fileSplitSize
                                : bashLogPair.Value.Length;
                            Encoding.ASCII.GetBytes(bashLogPair.Value, i * fileSplitSize, charCount, buffer,
                                                    buffer.GetLowerBound(0));
                            //write the log file
                            UpdateStatus($"Writing the log file: {logFile.Name}");
                            logFile.Write(buffer, 0, charCount);
                            logFile.Flush(true);
                        }
                    }
                }
            }

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