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));
            }
        }
Ejemplo n.º 2
0
 public MainController(IStepModel stepModel)
 {
     converter = new Converter();
     streamManager = new StreamManager();
     this.stepModel = stepModel;
     rootPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"Stream Companion");
     folderPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"Stream Companion\settings");
     dataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"Stream Companion\settings\data.json");
     streamTemplatePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"Stream Companion\settings\streams.json");;
     historyPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"Stream Companion\settings\history.json"); ;
     semaphoreSlim = new SemaphoreSlim(1);
     TryLoadSettings();
 }
        public static void FindInReplayLog(IStepModel step)
        {
            if (step == null || step.FunctionCall == null || step.FunctionCall.Location == null)
            return;

              if (!UttOutputService.Instance.CategoryExists(OutputCategories.ReplayCategory))
            return;

              IFunctionCallLocation location = step.FunctionCall.Location;
              string fileName = Path.GetFileName(location.FilePath);
              string pattern = GenerateSearchPattern(location.Start.Item1, fileName);

              UttOutputService.Instance.BringPadToFront();
              UttOutputService.Instance.JumpToCategoryPosition(OutputCategories.ReplayCategory, 0, 0, false);
              UttOutputService.Instance.FindNext(pattern, false, false, true);
        }
Ejemplo n.º 4
0
 public IStep Create(IStepModel model) => createStep(model);
        public bool SetSelectedSteps(IStepService stepService, ITextEditor editor)
        {
            try
            {
                firstSelectedStep = stepService.CurrentStep;
                lastSelectedStep = stepService.CurrentStep;

                //Check if we have selected more than 1 step, then we'll find the first and last selected steps
                if (editor.SelectionLength > 0)
                {
                    int selectionStart = editor.SelectionStart;
                    int selectionEnd = editor.SelectionStart + editor.SelectionLength;

                    editor.Caret.Offset = selectionEnd;
                    //Get the last selected line
                    int lastSelectedLine = editor.Caret.Line;

                    //Move the cursor to the start of selection to find out the line of the first step
                    editor.Caret.Offset = selectionStart;
                    //Get the first selected line
                    int firstSelectedLine = editor.Caret.Line;

                    //Check if the line contains a step. If it doesn't move the line down the script
                    //until we find a step or we reach the selection end
                    firstSelectedStep = GetLastSelectedStep(lastSelectedLine, false);
                    //Move the cursor to the end of selection to find out the end line
                    editor.Caret.Offset = selectionEnd;
                    //Check if the line contains a step. If it doesn't move the line up the script
                    //until we reach the selection start
                    lastSelectedStep = GetLastSelectedStep(firstSelectedLine, true);
                }

                if (firstSelectedStep == null && lastSelectedStep == null)
                    return false;
                return true;
            }
            catch (Exception ex)
            {
                MessageService.ShowMessage(ex.Message);
                Log.VuGen.Error(string.Format("Error occurred when searching for selected step, (Type: '{0}', Exception: '{1}')", Owner.GetType(), ex));
                return false;
            }
        }
Ejemplo n.º 6
0
 public void addStep(IStepModel step)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 7
0
 public ViewModel(IStepModel stepModel, IModel model, IController controller)
     : base(stepModel, model, controller)
 {
 }
Ejemplo n.º 8
0
 public ViewModel(IStepModel stepModel, IModel model, IController controller)
     : base(stepModel, model, controller)
 {
 }
Ejemplo n.º 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));
            }
        }