/// <summary>
        /// Performs the playback of actions in this module.
        /// </summary>
        /// <remarks>You should not call this method directly, instead pass the module
        /// instance to the <see cref="TestModuleRunner.Run(ITestModule)"/> method
        /// that will in turn invoke this method.</remarks>
        void ITestModule.Run()
        {
            Mouse.DefaultMoveTime        = 300;
            Keyboard.DefaultKeyPressTime = 100;
            Delay.SpeedFactor            = 1.0;

            RanorexRepository repo          = new RanorexRepository();
            fnParseSwitches   ParseSwitches = new fnParseSwitches();

            // Get default scenario list
            //	- use DefaultScenarioList.txt for all but last register
            //  - use DefaultIterationsLastRegister.txt for the last register in a store
            string DefaultIterations = "1";
            string NumberIterations  = "";

//			if( Global.RegisterNumber == "4" || ( Global.RegisterName == "USA04285-3" )
//			  )
//				NumberIterations = "DefaultIterationsLastRegister.txt";
//			else
            NumberIterations = "DefaultIterations.txt";

            try
            {
                // Read in the default iterations from Register 1 \Ranorex Automation\DefaultInterations.txt
                using (System.IO.StreamReader RegisterIniFileGet = new System.IO.StreamReader(Global.Register1DriveLetter + @":\" + Global.AutomationFileDirectory + @"\" + NumberIterations))
                {
                    DefaultIterations = RegisterIniFileGet.ReadLine();
                    RegisterIniFileGet.Close();
                }
            }
            catch
            {
                // Write out default iterations to Register 1 \Ranorex Automation\DefaultInterations.txt
                using (System.IO.StreamWriter RegisterIniFilePut = new System.IO.StreamWriter(Global.Register1DriveLetter + @":\" + Global.AutomationFileDirectory + @"\" + NumberIterations))
                {
                    RegisterIniFilePut.WriteLine("1");
                    RegisterIniFilePut.Close();
                }
            }


            string TextInput;

            string Prompt = "Enter number of iterations\n" +
                            "    or time to stop like HH:MM PM\n" +
                            "    or time to start & stop like HH:MM AM to HH:MM PM\n\n" +
                            "Or /U for metric upload only\n\n" +

                            "Switches: put comma in front of switches #,/Q\n" +
                            "    P=Pause between scenarios off\n" +
                            "    N=Phone Numbers NonLoyalty\n" +
                            "    L=Phone Numbers Loyalty\n" +
                            "    A=All Registers use all Phone Numbers\n" +
                            "    M=Metrics file create when no save them\n" +
                            "    Q=Quit running when get error";

            string IDLine = " (TestID: " + Global.Test_ID + ", " + "RegID: " + Global.Register_ID + ", " + "VerID: " + Global.AutoVer_ID + ") ";

            if (Global.AutoRun)
            {
                if (Global.CommandLineArg2 != "")
                {
                    TextInput = Global.CommandLineArg2;
                }
                else
                {
                    TextInput = DefaultIterations;
                }
            }
            else
            {
                InputBoxResult BoxInput = InputBox.Show(Prompt, "Iterations" + IDLine, DefaultIterations);
                if (BoxInput.ReturnCode == DialogResult.Cancel)
                {
                    Environment.Exit(0);
                }                                                                                       // Exit if cancel pressed
                TextInput             = BoxInput.Text.ToUpper();
                Global.IterationsText = TextInput;
            }


            Global.TimeToStartExecution = "";
            Global.TimeToStopExecution  = "";



            // Check for Upload Metrics Only
            string[] PromptItems = TextInput.Split(',');
            if (PromptItems[0].Substring(0, 1) == "/")
            {
                if (PromptItems[0].Substring(0, 2) == "/U")
                {
                    ParseSwitches.Run(PromptItems[0]);
                }
            }
            else
            {
                if (TextInput.Contains(":"))
                {
                    if (TextInput.Contains(" TO "))
                    {
                        int ToOffset = TextInput.IndexOf(" TO ");
                        Global.TimeToStartExecution = TextInput.Substring(0, ToOffset);
                        Global.TimeToStopExecution  = TextInput.Substring(ToOffset + 4);
                    }
                    else
                    {
                        Global.TimeToStopExecution = TextInput;
                    }
                    Global.IterationsToDo = -1;
                }
                else
                {
                    Global.IterationsToDo = Convert.ToInt32(PromptItems[0]);
                }

                // Check for given switches
                if (PromptItems.Length > 1)
                {
                    if (PromptItems[1].Substring(0, 1) == "/")
                    {
                        ParseSwitches.Run(PromptItems[1]);
                    }
                }

                // Write out default iterations to Register 1 \Ranorex Automation\DefaultInterations.txt
                using (System.IO.StreamWriter RegisterIniFilePut = new System.IO.StreamWriter(Global.Register1DriveLetter + @":\" + Global.AutomationFileDirectory + @"\" + NumberIterations))
                {
                    RegisterIniFilePut.WriteLine(TextInput);
                    RegisterIniFilePut.Close();
                }
            }
        }
Example #2
0
        /// <summary>
        /// Performs the playback of actions in this module.
        /// </summary>
        /// <remarks>You should not call this method directly, instead pass the module
        /// instance to the <see cref="TestModuleRunner.Run(ITestModule)"/> method
        /// that will in turn invoke this method.</remarks>
        void ITestModule.Run()
        {
            if (!Global.SwitchUploadOnly)
            {
                Mouse.DefaultMoveTime        = 300;
                Keyboard.DefaultKeyPressTime = 100;
                Delay.SpeedFactor            = 1.0;

                RanorexRepository  repo             = new RanorexRepository();
                fnParseSwitches    ParseSwitches    = new fnParseSwitches();
                fnWriteToErrorFile WriteToErrorFile = new fnWriteToErrorFile();
                fnPlayWavFile      PlayWavFile      = new fnPlayWavFile();

                // Get default scenario list
                //	- use DefaultScenarioList.txt for all but last register
                //  - use DefaultScenarioListLastRegister.txt for the last register in a store
                string ListToUse        = "";
                string DefaultScenarios = "13,16,18,19,20,33,34,36,37,41,42,43,47";
//				if( Global.RegisterNumber == "4" || ( Global.RegisterName == "USA04285-3" )
//				  )
//					ListToUse = "DefaultScenarioListLastRegister.txt";
//				else
                ListToUse = "DefaultScenarioList.txt";

                try
                {
                    // Read in the default Scenario List from Register 1 \Ranorex Automation\DefaultScenarioList.txt
                    using (System.IO.StreamReader RegisterScenarioFileGet = new System.IO.StreamReader(Global.Register1DriveLetter + @":\" + Global.AutomationFileDirectory + @"\" + ListToUse))
                    {
                        DefaultScenarios = RegisterScenarioFileGet.ReadLine();
                        RegisterScenarioFileGet.Close();
                    }
                }
                catch
                {
                    // Write out default Scenario List to Register 1 \Ranorex Automation\DefaultScenarioList.txt
                    using (System.IO.StreamWriter RegisterScenarioFilePut = new System.IO.StreamWriter(Global.Register1DriveLetter + @":\" + Global.AutomationFileDirectory + @"\" + ListToUse))
                    {
                        RegisterScenarioFilePut.WriteLine(DefaultScenarios);
                        RegisterScenarioFilePut.Close();
                    }
                }


                string TextInput;
                string Prompt = "Enter list of scenarios like 3,5-7,/LX\n\n" +

                                "Back Office ---------------------------------------------------\n" +
                                "Scenario 13: eMail\n" +
                                "Scenario 14: Performance Dashboard\n" +
                                "Scenario 15: Performance Dashboard Loop without exiting\n" +
                                "Scenario 18: Transaction Journal\n" +
                                "Scenario 19: Cover Art\n" +
                                "Scenario 20: HR Workday Employee List\n" +
                                "Scenario 21: WIS Web-In-Store\n\n" +

                                "RETECH --------------------------------------------------------\n" +
                                "Scenario 16: Returns\n" +
                                "Scenario 33: Simple One SKU Cash\n" +
                                "Scenario 34: Simple One SKU Credit\n" +
                                "Scenario 36: Item Search\n" +
                                "Scenario 37: Reserve Pickup\n" +
                                "Scenario 38: Suspend Resume\n" +
                                "Scenario 41: GPG\n" +
                                "Scenario 42: PRP\n" +
                                "Scenario 43: Card Balance\n" +
                                "Scenario 47: Purchase 1 SKU with 5 trades and cach back\n\n" +

                                "Other --------------------------------------------------------\n" +
                                "Scenario 50: Dashboard data init (about 20 minutes)\n\n" +

                                "Switches: put comma in front of switches 2-4,7,/NXS\n" +
                                "    N=Phone Numbers NonLoyalty\n" +
                                "    L=Phone Numbers Loyalty\n" +
                                "    A=All Registers use all Phone Numbers\n" +
                                "    X=Skip Customer Lookup (NO 4,7,17,20-23,25)\n" +
                                "    M=Metrics file create when no save them\n" +
                                "    Q=Quit running when get error\n" +
                                "    S=Scenario 9 use 40 SKUs";

                if (Global.AutoRun)
                {
                    if (Global.CommandLineArg3 != "")
                    {
                        TextInput = Global.CommandLineArg3;
                    }
                    else
                    {
                        TextInput = DefaultScenarios;
                    }
                }
                else
                {
                    InputBoxResult BoxInput = InputBox.Show(Prompt, "Scenarios", DefaultScenarios);
                    if (BoxInput.ReturnCode == DialogResult.Cancel)
                    {
                        Environment.Exit(0);
                    }                                                                                           // Exit if cancel pressed
                    TextInput = BoxInput.Text.ToUpper();
                }

                // Write out default Scenario List to Register 1 \Ranorex Automation\DefaultScenarioList.txt
                using (System.IO.StreamWriter RegisterScenarioFilePut = new System.IO.StreamWriter(Global.Register1DriveLetter + @":\" + Global.AutomationFileDirectory + @"\" + ListToUse))
                {
                    RegisterScenarioFilePut.WriteLine(TextInput);
                    RegisterScenarioFilePut.Close();
                }


                // Remove all spaces from the input
                TextInput = TextInput.Replace(" ", System.String.Empty);

                // Set flag if just Scenario 32 is selected - it consumes card numbers - so cannot run as part of normal run
                if (TextInput == "32")
                {
                    Global.JustScenario32 = true;
                }

                // Clear the DoScenarioFlag array
                for (int Offset = 0; Offset <= Global.MaxScenarioNumber; Offset++)
                {
                    Global.DoScenarioFlag[Offset] = false;
                }

                string[] PromptItems = TextInput.Split(',');
                string   TempText;
                int      PromptItemsCount = PromptItems.Length;
                int      ParseOffset;
                for (ParseOffset = 0; ParseOffset <= PromptItemsCount - 1; ParseOffset++)
                {
                    TempText = PromptItems[ParseOffset];
                    ParseSwitches.Run(TempText);
                }

                // If you can connect to the PALDB then provide the option to upload the test.
                var connection = new SqlConnection(ConfigurationManager.ConnectionStrings["MetricsRepository"].ConnectionString);
                try
                {
                    Report.Log(ReportLevel.Info, "fnGetScenariosToRun", "Open connection to DB", new RecordItemIndex(0));
                    connection.Open();
                    connection.Close();
                    var mSystemInfo = new FnSystemInfo();
                    TestModuleRunner.Run(mSystemInfo);
                }
                catch (Exception e)
                {
                    Global.IsPerformanceTest = false;
                    Global.DBAvailable       = false;

                    string sayString = "";
                    if (e.ToString().IndexOf("Thread was being aborted.") == -1)
                    {
                        sayString = e.ToString().Substring(0, 28);
                        Global.TempErrorString = "Cannot connect to Metric DB: " + e.Message;
                        WriteToErrorFile.Run();
                        //MessageBox.Show(e.ToString(),Global.TempErrorString);
                    }
                }
            }
        }