public void AddTransaction(string tType, IStepModel step, IStepService stepService, String stepName = "", String parentTransactionName = "")
        {
            try
            {
                var fc = new FunctionCall();
                var fcs = new FunctionCallSignature { Name = tType};

                //check if the step is already predefined. This is in case of surrounding web_concurrent_start and web_concurrent_end
                //String name = (stepName == "") ? tNumber + ". " + step.ComposedName : tNumber + ". " + stepName;

                fcs.Parameters.Add(new FunctionCallParameter(stepName, ParameterType.ArgtypeString));
                //if we are adding lr_start_sub_transaction add the parent transaction name
                if (tType.Contains("start_sub"))
                    fcs.Parameters.Add(new FunctionCallParameter(parentTransactionName, ParameterType.ArgtypeNumber));

                //if we are adding lr_end_transaction add the LR_AUTO parameter
                if (tType.Contains("end"))
                    fcs.Parameters.Add(new FunctionCallParameter("LR_AUTO", ParameterType.ArgtypeNumber));

                fc.Signature = fcs;
                fc.Location = new FunctionCallLocation(step.FunctionCall.Location.FilePath, null, null);
                IStepModel newStep = stepService.GenerateStep(fc);

                RelativeStep relativity = (tType.Contains("start")) ? RelativeStep.Before : RelativeStep.After;

                if (tType.Contains("end"))
                    tNumber++;

                stepService.AddStep(ref newStep, step, relativity, false);
            }
            catch (Exception ex)
            {
                MessageService.ShowMessage(string.Format(ex.StackTrace));
            }
        }
Beispiel #2
0
        public override void Run()
        {
            if (!(Owner is ISelectableEditor))
            {
                return;
            }

            try
            {
                XmlEditor editor = Owner as XmlEditor;
                if (editor == null)
                {
                    return;
                }

                _xpath       = editor.SingleDirectionData.SelectedXPath.XPath;
                _elementName = ExtractElementName(editor.SingleDirectionData.SelectedText);
                _value       = ExtractElementValue(editor.SingleDirectionData.SelectedText);

                var selectableEditor = Owner as ISelectableEditor;
                if (selectableEditor.Selected == null)
                {
                    return;
                }

                var stepService = ServiceManager.Instance.GetService <IStepService>();
                if (stepService == null)
                {
                    return;
                }

                var currentStep = stepService.CurrentStep;

                var parserStatus = stepService.GetParserStatus(currentStep.FunctionCall.Location.FilePath);
                if (parserStatus == false)
                {
                    MessageService.ShowMessage("Cannot add step");
                    return;
                }

                var functionCall = new FunctionCall();
                var signature    = new FunctionCallSignature {
                    Name = this.Name
                };


                FillParameters(signature);

                functionCall.Signature = signature;
                functionCall.Location  = new FunctionCallLocation(currentStep.FunctionCall.Location.FilePath, null, null);

                IStepModel stepModel = stepService.GenerateStep(functionCall);
                stepModel.ShowArguments(asyncResult =>
                {
                    var result = (ShowArgumentsResult)asyncResult.AsyncState;
                    if (result.IsModified)
                    {
                        //set the last parameter to False, so it will not move cursor to the newly added step
                        stepService.AddStep(ref stepModel, currentStep,
                                            Relative, false);

                        stepService.CurrentStep = currentStep;
                    }
                });
            }
            catch (Exception ex)
            {
                Log.VuGen.Error(string.Format("Error occurred when adding the {2} step. (Type: '{0}', Exception: '{1}')", Owner.GetType(), ex, Name));
            }
        }
Beispiel #3
0
 protected override void FillParameters(FunctionCallSignature signature)
 {
     signature.Parameters.Add(new FunctionCallParameter(string.Format("FastQuery={0}", _xpath), ParameterType.ArgtypeString));
     signature.Parameters.Add(new FunctionCallParameter(String.Format("ValueParam=ParamValue_{0}", _elementName), ParameterType.ArgtypeString));
 }
Beispiel #4
0
 protected abstract void FillParameters(FunctionCallSignature signature);
 protected override void FillParameters(FunctionCallSignature signature)
 {
     signature.Parameters.Add(new FunctionCallParameter(string.Format("FastQuery={0}",_xpath), ParameterType.ArgtypeString));
       signature.Parameters.Add(new FunctionCallParameter(String.Format("ValueParam=ParamValue_{0}",_elementName), ParameterType.ArgtypeString));
 }
 protected abstract void FillParameters(FunctionCallSignature signature);
        public override void Run()
        {
            if (!(Owner is ISelectableEditor))
            return;

              try
              {
            XmlEditor editor = Owner as XmlEditor;
            if (editor == null)
              return;

            _xpath = editor.SingleDirectionData.SelectedXPath.XPath;
            _elementName = ExtractElementName(editor.SingleDirectionData.SelectedText);
            _value = ExtractElementValue(editor.SingleDirectionData.SelectedText);

            var selectableEditor = Owner as ISelectableEditor;
            if (selectableEditor.Selected == null)
              return;

            var stepService = ServiceManager.Instance.GetService<IStepService>();
            if (stepService == null)
              return;

            var currentStep = stepService.CurrentStep;

            var parserStatus = stepService.GetParserStatus(currentStep.FunctionCall.Location.FilePath);
            if (parserStatus == false)
            {
              MessageService.ShowMessage("Cannot add step");
              return;
            }

            var functionCall = new FunctionCall();
            var signature = new FunctionCallSignature { Name = this.Name };

            FillParameters(signature);

            functionCall.Signature = signature;
            functionCall.Location = new FunctionCallLocation(currentStep.FunctionCall.Location.FilePath, null, null);

            IStepModel stepModel = stepService.GenerateStep(functionCall);
            stepModel.ShowArguments(asyncResult =>
            {
              var result = (ShowArgumentsResult)asyncResult.AsyncState;
              if (result.IsModified)
              {
            //set the last parameter to False, so it will not move cursor to the newly added step
            stepService.AddStep(ref stepModel, currentStep,
                                Relative, false);

            stepService.CurrentStep = currentStep;
              }
            });
              }
              catch (Exception ex)
              {
            Log.VuGen.Error(string.Format("Error occurred when adding the {2} step. (Type: '{0}', Exception: '{1}')", Owner.GetType(), ex, Name));
              }
        }
        public override void Run()
        {
            if (!(Owner is ISelectableEditor))
            return;

              try
              {
            XmlEditor editor = Owner as XmlEditor;
            if (editor == null)
              return;

            _xpath = editor.SingleDirectionData.SelectedXPath.XPath;
            _elementName = ExtractElementName(editor.SingleDirectionData.SelectedText);
            _value = ExtractElementValue(editor.SingleDirectionData.SelectedText);

            var selectableEditor = Owner as ISelectableEditor;
            if (selectableEditor.Selected == null)
              return;

            var stepService = ServiceManager.Instance.GetService<IStepService>();
            if (stepService == null)
              return;

            var currentStep = stepService.CurrentStep;

            var parserStatus = stepService.GetParserStatus(currentStep.FunctionCall.Location.FilePath);
            if (parserStatus == false)
            {
              MessageService.ShowMessage("Cannot add step");
              return;
            }

            var functionCall = new FunctionCall();
            var signature = new FunctionCallSignature { Name = this.Name };

            string currentParameterName = GetCurrentStepResponseParameter();
            if (!string.IsNullOrEmpty(currentParameterName))
            {
              signature.Parameters.Add(new FunctionCallParameter(String.Format("XML={0}", currentParameterName),
                                                  ParameterType.ArgtypeString));

            }

            FillParameters(signature);

            functionCall.Signature = signature;
            functionCall.Location = new FunctionCallLocation(currentStep.FunctionCall.Location.FilePath, null, null);

            IStepModel stepModel = stepService.GenerateStep(functionCall);
            stepModel.ShowArguments(asyncResult =>
            {
              var result = (ShowArgumentsResult)asyncResult.AsyncState;
              if (result.IsModified)
              {
            //set the last parameter to False, so it will not move cursor to the newly added step
            stepService.AddStep(ref stepModel, currentStep,
                                Relative, false);

            if (string.IsNullOrEmpty(currentParameterName))
            {
              FunctionCallParameter userParameter = stepModel.FunctionCall.Signature.Parameters.Find(p =>
              {
                return p.Value.StartsWith("XML=", StringComparison.InvariantCultureIgnoreCase);
              });
              if (userParameter != null)
              {
                SetCurrentStepResponseParameter(stepModel.ScriptItem.Script as IVuGenScript, userParameter.Value.Remove(0, 4));
              }
            }

            stepService.CurrentStep = currentStep;
              }
            });
              }
              catch (Exception ex)
              {
            Log.VuGen.Error(string.Format("Error occurred when adding the {2} step. (Type: '{0}', Exception: '{1}')", Owner.GetType(), ex, Name));
              }
        }
Beispiel #9
0
        public override void Run()
        {
            if (!(Owner is ISelectableEditor))
            {
                return;
            }

            try
            {
                XmlEditor editor = Owner as XmlEditor;
                if (editor == null)
                {
                    return;
                }

                _xpath       = editor.SingleDirectionData.SelectedXPath.XPath;
                _elementName = ExtractElementName(editor.SingleDirectionData.SelectedText);
                _value       = ExtractElementValue(editor.SingleDirectionData.SelectedText);

                var selectableEditor = Owner as ISelectableEditor;
                if (selectableEditor.Selected == null)
                {
                    return;
                }

                var stepService = ServiceManager.Instance.GetService <IStepService>();
                if (stepService == null)
                {
                    return;
                }

                var currentStep = stepService.CurrentStep;

                var parserStatus = stepService.GetParserStatus(currentStep.FunctionCall.Location.FilePath);
                if (parserStatus == false)
                {
                    MessageService.ShowMessage("Cannot add step");
                    return;
                }

                var functionCall = new FunctionCall();
                var signature    = new FunctionCallSignature {
                    Name = this.Name
                };

                string currentParameterName = GetCurrentStepResponseParameter();
                if (!string.IsNullOrEmpty(currentParameterName))
                {
                    signature.Parameters.Add(new FunctionCallParameter(String.Format("XML={0}", currentParameterName),
                                                                       ParameterType.ArgtypeString));
                }

                FillParameters(signature);

                functionCall.Signature = signature;
                functionCall.Location  = new FunctionCallLocation(currentStep.FunctionCall.Location.FilePath, null, null);


                IStepModel stepModel = stepService.GenerateStep(functionCall);
                stepModel.ShowArguments(asyncResult =>
                {
                    var result = (ShowArgumentsResult)asyncResult.AsyncState;
                    if (result.IsModified)
                    {
                        //set the last parameter to False, so it will not move cursor to the newly added step
                        stepService.AddStep(ref stepModel, currentStep,
                                            Relative, false);

                        if (string.IsNullOrEmpty(currentParameterName))
                        {
                            FunctionCallParameter userParameter = stepModel.FunctionCall.Signature.Parameters.Find(p =>
                            {
                                return(p.Value.StartsWith("XML=", StringComparison.InvariantCultureIgnoreCase));
                            });
                            if (userParameter != null)
                            {
                                SetCurrentStepResponseParameter(stepModel.ScriptItem.Script as IVuGenScript, userParameter.Value.Remove(0, 4));
                            }
                        }

                        stepService.CurrentStep = currentStep;
                    }
                });
            }
            catch (Exception ex)
            {
                Log.VuGen.Error(string.Format("Error occurred when adding the {2} step. (Type: '{0}', Exception: '{1}')", Owner.GetType(), ex, Name));
            }
        }