public void StartRecording(Protocol protocol)
        {
            _recordStarted = true;
            try
            {
                StartRecordingParamsBuilder _startRecordingPB = new StartRecordingParamsBuilder();
                if (_userPathName != null && _userPathName.Length != 0)
                {
                    ContainsUserPathParamsBuilder _containsBuilder = new ContainsUserPathParamsBuilder();
                    _containsBuilder.name(_userPathName);
                    _userPathExist = _client.ContainsUserPath(_containsBuilder.Build());
                    if (_userPathExist)
                    {
                        _startRecordingPB.virtualUser(_userPathName + "_recording");
                    }
                    else
                    {
                        _startRecordingPB.virtualUser(_userPathName);
                    }
                }
                if (Protocol.SAP.Equals(protocol))
                {
                    _startRecordingPB.isSapGuiProtocol(true);
                    _startRecordingPB.isCreateTransactionBySapTCode(_createTransactionBySapTCode);
                }
                else if (Protocol.WEB.Equals(protocol))
                {
                    _startRecordingPB.isHTTP2Protocol(_http2);
                    if (_systemProxyHelper == null)
                    {
                        _systemProxyHelper = new SystemProxyHelper(_apiPort);
                        _systemProxyHelper.setProxy(_apiHost, _recorderProxyPort, "");
                    }
                }

                _client.StartRecording(_startRecordingPB.Build());
            } catch (Exception e)
            {
                _recordStarted     = false;
                _instance          = null;
                _systemProxyHelper = null;
                WriteExceptionToFile(e);
                throw e;
            }

            try
            {
                NeoloadRestApiInstance.GetInstance().SendUsageEvent("recording", protocol);
            } catch (Exception e)
            {
                // Do nothing if send event fails
            }
        }
Ejemplo n.º 2
0
        public void startRecording(string userPathName, bool updateUserPath, TimeSpan timeout, TimeSpan interval, string userAgent = "",
                                   bool isWebSocketProtocol = false, bool isHttp2Protocol = false, bool isAdobeRTMPProtocol = false, string addressToExclude = "")
        {
            if (_mode != Mode.DESIGN)
            {
                return;
            }

            this.CheckDesignIsConnected();

            if (!isNeoloadReady())
            {
                throw(new Exception("Error!! Can't start recording. Neoload is not ready yet."));
            }

            this.userPathName = validateUserPathName(userPathName);

            _containsUserPathPB.name(userPathName);
            pathExists = _client.ContainsUserPath(_containsUserPathPB.Build());
            if (!updateUserPath && pathExists)
            {
                string msg = String.Format("Error!! UserPath {0} already exists and update path is disabled!", userPathName);
                throw(new Exception(msg));
            }

            if (!pathExists)
            {
                _startRecordingPB.virtualUser(userPathName);
            }
            else
            {
                _startRecordingPB.virtualUser(userPathName + "_recording");
            }
            _startRecordingPB.isHTTP2Protocol(isHttp2Protocol);
            _startRecordingPB.isWebSocketProtocol(isWebSocketProtocol);
            _startRecordingPB.isAdobeRTMPProtocol(isAdobeRTMPProtocol);
            _startRecordingPB.userAgent(userAgent);

            this.CheckDesignIsConnected();

            var curState = _client.GetStatus();

            switch (curState)
            {
            case DesignState.NO_PROJECT: throw new InvalidOperationException("Failed to start test because no Project is loaded in NeoLoad.");

            default:
                this.WaitForNeoloadState(DesignState.READY, timeout, interval);
                setNeoloadProxy(getProxyHost(), getProxyPort(), addressToExclude);
                _client.StartRecording(_startRecordingPB.Build());
                break;
            }
        }
        public void start()
        {
            if (projectPath != null)
            {
                openProject();
            }

            this.userPathExist = containsUserPath();

            StartRecordingParamsBuilder startRecordingBuilder = paramBuilderProvider.newStartRecordingBuilder();

            if (!userPathExist)
            {
                startRecordingBuilder.virtualUser(userPathName);
            }
            else
            {
                startRecordingBuilder.virtualUser(userPathName + "_recording");
            }

            designApiClient.StartRecording(startRecordingBuilder.Build());
        }
 private void HandleUserPathName(StartRecordingParamsBuilder startRecordingPB)
 {
     if (_userPathName != null && _userPathName.Length != 0)
     {
         if (_updateUserPath)
         {
             ContainsUserPathParamsBuilder _containsBuilder = new ContainsUserPathParamsBuilder();
             _containsBuilder.name(_userPathName);
             _userPathExist = _client.ContainsUserPath(_containsBuilder.Build());
             if (_userPathExist)
             {
                 startRecordingPB.virtualUser(_userPathName + "_recording");
             }
             else
             {
                 startRecordingPB.virtualUser(_userPathName);
             }
         }
         else
         {
             startRecordingPB.virtualUser(_userPathName);
         }
     }
 }