Imports System.Data.SqlClient
Imports Microsoft.VisualBasic


Public Class TestPerformance
	Public Shared Sub createnUsers(ByRef n As Integer)
		Dim ConnectionString = ""

		If HttpContext.Current.Request.ServerVariables("SERVER_NAME") = "localhost" Then
			VERAG_PROG_ALLGEMEIN.cAllgemein.TESTSYSTEM = True
			'ConnectionString = "Server=DEVELOPER\DEVSQL;Database=VERAG_HOMEPAGE;Uid=sa;Pwd=BmWr501956"
			ConnectionString = "Server=DEVELOPER\DEVSQL;Database=VERAG_HOMEPAGE;Uid=AppUser;Pwd=yp/THDd?xM+pZ$;"
		Else
			VERAG_PROG_ALLGEMEIN.cAllgemein.TESTSYSTEM = False
			ConnectionString = "Server=DEVELOPER.verag.ost.dmn\DEVSQL;Database=VERAG_HOMEPAGE;Uid=AppUser;Pwd=yp/THDd?xM+pZ$;"
			'ConnectionString = "Server=db593295684.db.1and1.com;Database=db593295684;Uid=dbo593295684;Pwd=atilla#2;"
		End If

		Using con As New SqlConnection(ConnectionString)
			' Using cmd As New SqlCommand("Validate_User")
			For nzahl As Integer = 0 To n Step 1
				Dim UsrID As Integer = VERAG_VARIABLES.RandomInteger(VERAG_VARIABLES.RandomInteger(0, 15), VERAG_VARIABLES.RandomInteger(500, 45750))
				Dim usrname As String = String.Empty
				Dim pw As String = "Pw" + Convert.ToBase64String(VERAG_VARIABLES.GenerateSalt(VERAG_VARIABLES.RandomInteger(0, nzahl + 2)))
				Dim email As String = "ja@verag.ag"

				Dim monthrndm As Integer = VERAG_VARIABLES.RandomInteger(1, 12)
				Dim Yearrand As Integer = VERAG_VARIABLES.RandomInteger(2001, 2021)
				Dim dayrand As Integer = VERAG_VARIABLES.RandomInteger(1, 30)
				Dim datelastloggedin As Date = New Date(Yearrand, monthrndm, dayrand)
				Dim monthrndm2 As Integer = VERAG_VARIABLES.RandomInteger(1, 12)
				Dim Yearrand2 As Integer = VERAG_VARIABLES.RandomInteger(2001, 2021)
				Dim dayrand2 As Integer = VERAG_VARIABLES.RandomInteger(1, 30)
				Dim DateCreate As Date = New Date(Yearrand2, monthrndm2, dayrand2)

				'Namen
				Dim lstCapitals As New ArrayList
				' Capital Names
				lstCapitals.Add("Montgomery")
				lstCapitals.Add("Juneau")
				lstCapitals.Add("Phoenix")
				lstCapitals.Add("Little Rock")
				lstCapitals.Add("Sacramento")
				lstCapitals.Add("Denver")
				lstCapitals.Add("Hartford")
				lstCapitals.Add("Dover")
				lstCapitals.Add("Tallahassee")
				lstCapitals.Add("Atlanta")
				lstCapitals.Add("Honolulu")
				lstCapitals.Add("Boise")
				lstCapitals.Add("Springfield")
				lstCapitals.Add("Indianapolis")
				lstCapitals.Add("Des Moines")
				lstCapitals.Add("Topeka")
				lstCapitals.Add("Frankfort")
				lstCapitals.Add("Baton Rouge")
				lstCapitals.Add("Augusta")
				lstCapitals.Add("Annapolis")
				lstCapitals.Add("Boston")
				lstCapitals.Add("Lansing")
				lstCapitals.Add("St. Paul")
				lstCapitals.Add("Jackson")
				lstCapitals.Add("Jefferson City")
				lstCapitals.Add("Helena")
				lstCapitals.Add("Lincoln")
				lstCapitals.Add("Carson City")
				lstCapitals.Add("Concord")
				lstCapitals.Add("Trenton")
				lstCapitals.Add("Santa Fe")
				lstCapitals.Add("Albany")
				lstCapitals.Add("Raleigh")
				lstCapitals.Add("Bismarck")
				lstCapitals.Add("Columbus")
				lstCapitals.Add("Oklahoma City")
				lstCapitals.Add("Salem")
				lstCapitals.Add("Harrisburg")
				lstCapitals.Add("Providence")
				lstCapitals.Add("Columbia")
				lstCapitals.Add("Pierre")
				lstCapitals.Add("Nashville")
				lstCapitals.Add("Austin")
				lstCapitals.Add("Salt Lake City")
				lstCapitals.Add("Montpelier")
				lstCapitals.Add("Richmond")
				lstCapitals.Add("Olympia")
				lstCapitals.Add("Charleston")
				lstCapitals.Add("Madison")
				lstCapitals.Add("Cheyenne")

				'Pulls a name randomly from the list
				Dim stringname As String = lstCapitals.Item(VERAG_VARIABLES.RandomInteger(0, lstCapitals.Count))
				usrname = stringname

				Using cmd As New SqlCommand("INSERT INTO [VERAG_HOMEPAGE].[dbo].[Users] VALUES (@UserId,@Username,@Password,@Email,@Date")
					' cmd.CommandType = CommandType.StoredProcedure
					cmd.Parameters.AddWithValue("@UserId", UsrID)
					cmd.Parameters.AddWithValue("@Username", usrname)
					cmd.Parameters.AddWithValue("@Password", pw)
					cmd.Parameters.AddWithValue("@Email", email)
					cmd.Parameters.AddWithValue("@Date", DateCreate)
					cmd.Parameters.AddWithValue("Dateloggedinlast", datelastloggedin)
					cmd.Connection = con
					con.Open()
					' userId = Convert.ToInt32(cmd.ExecuteScalar())
					cmd.ExecuteScalar()
					con.Close()
				End Using
			Next

		End Using
	End Sub
	Public Shared DeleteUsers()
End Class
