Exemple #1
0
        public FrmMain()
        {
            InitializeComponent();
            Init();

            this.dataGenerator = new SqlDataGenerator(this.connection, this.spName, this.commandTimeout, this.cars, this.tasks, this.delay, this.batchSize, this.ExceptionCallback);
        }
        public FrmMain()
        {
            InitializeComponent();
            Init();

            this.dataGenerator = new SqlDataGenerator(this.connection, this.spName, this.commandTimeout, this.meters, this.numberOfDataLoadTasks, this.dataLoadCommandDelay, this.batchSize, this.deleteSPName, this.numberOfOffLoadTasks, this.offLoadCommandDelay, this.deleteBatchSize, this.numberOfRowsOfloadLimit, this.ExceptionCallback);
            StartApp();
        }
        static void Main(string[] args)
        {
            Init();
            dataGenerator = new SqlDataGenerator(connection, spName, commandTimeout, meters, tasks, delay, batchSize, ExceptionCallback);

            mainTimer.Elapsed  += mainTimer_Tick;
            rpsTimer.Elapsed   += rpsTimer_Tick;
            shockTimer.Elapsed += shockTimer_Tick;

            string commandString = string.Empty;

            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine("***********************************************************");
            Console.WriteLine("*                   Data Generator                        *");
            Console.WriteLine("*                                                         *");
            Console.WriteLine("*             Type commands to get started                *");
            Console.WriteLine("*                                                         *");
            Console.WriteLine("***********************************************************");
            Console.WriteLine("");

            // main command cycle
            while (!commandString.Equals("Exit"))
            {
                Console.ResetColor();
                Console.WriteLine("Enter command (start | stop | help | report | exit) >");
                commandString = Console.ReadLine();

                switch (commandString.ToUpper())
                {
                case "START":
                    Start();
                    break;

                case "STOP":
                    Stop();
                    break;

                case "HELP":
                    Help();
                    break;

                case "REPORT":
                    Report();
                    break;

                case "EXIT":
                    Console.WriteLine("Bye!");
                    return;

                default:
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("Invalid command.");
                    break;
                }
            }
        }
Exemple #4
0
        private void Init()
        {
            try
            {
                // Read Config Settings
                this.connection = ConfigurationManager.ConnectionStrings["Db"].ConnectionString;

                if (OnDiskRadioButton.Checked)
                {
                    this.spName = ConfigurationManager.AppSettings["sqlOndiskSPName"];
                }
                else if (InMemoryRadioButton.Checked)
                {
                    this.spName = ConfigurationManager.AppSettings["sqlInMemorySPName"];
                }
                else
                {
                    this.spName = ConfigurationManager.AppSettings["sqlInMemoryWithCCISPName"];
                }

                this.logFileName    = ConfigurationManager.AppSettings["logFileName"];
                this.tasks          = int.Parse(ConfigurationManager.AppSettings["numberOfTasks"]);
                this.batchSize      = int.Parse(ConfigurationManager.AppSettings["batchSize"]);
                this.delay          = int.Parse(ConfigurationManager.AppSettings["commandDelay"]);
                this.commandTimeout = int.Parse(ConfigurationManager.AppSettings["commandTimeout"]);
                this.rpsFrequency   = int.Parse(ConfigurationManager.AppSettings["rpsFrequency"]);

                this.dataGenerator = new SqlDataGenerator(this.connection, this.spName, this.commandTimeout, this.tasks, this.delay, this.batchSize, this.ExceptionCallback);

                // Initialize Timers
                this.rpsTimer.Interval = this.rpsFrequency;

                // Initialize Labels
                this.lblTasksValue.Text     = string.Format("{0:#,#}", this.tasks).ToString();
                this.lblBatchSizeValue.Text = string.Format("{0:#,#}", this.batchSize).ToString();

                if (batchSize <= 0)
                {
                    throw new SqlDataGeneratorException("The Batch Size cannot be less or equal to zero.");
                }

                if (tasks <= 0)
                {
                    throw new SqlDataGeneratorException("Number Of Tasks cannot be less or equal to zero.");
                }

                if (delay < 0)
                {
                    throw new SqlDataGeneratorException("Delay cannot be less than zero");
                }
            }
            catch (Exception exception) { HandleException(exception); }
        }