private void TestSuNetSqlAzMan(string connectionString, int max) { WindowsIdentity id = WindowsIdentity.GetCurrent(); int rnd = new Random().Next(max); IAzManStorage storage = new SqlAzManStorage(connectionString); storage.OpenConnection(); AuthorizationType res = storage.CheckAccess("Store Stress Test", "Application" + rnd.ToString(), "Operation" + rnd.ToString(), id, DateTime.Now, true, new KeyValuePair <string, object>("chiave", "valore")); //AuthorizationType res = storage.CheckAccess("Store Stress Test", "Application" + rnd.ToString(), "Operation" + rnd.ToString(), storage.GetDBUser("Andrea"), DateTime.Now, true, new KeyValuePair<string, object>("chiave", "valore")); storage.CloseConnection(); storage.Dispose(); }
private void btnTestNetSqlAzMan_Click(object sender, EventArgs e) { this.Clessidra(true); this.StartTimer(); int n = int.Parse(this.txtNetSqlAzManThreads.Text); int max = int.Parse(this.txtUnita.Text); this.pb.Maximum = n - 1; if (!this.chkNetSqlAzManMultiThread.Checked) { if (!this.chkCache.Checked) { for (int i = 0; i < n; i++) { this.TestSuNetSqlAzMan(this.txtNetSqlAzManConnectionString.Text, max); this.pb.Value = i; Application.DoEvents(); } } else { WindowsIdentity id = WindowsIdentity.GetCurrent(); IAzManStorage storage = new SqlAzManStorage(this.txtNetSqlAzManConnectionString.Text); storage.OpenConnection(); int rnd = new Random().Next(max); NetSqlAzMan.Cache.UserPermissionCache c = new NetSqlAzMan.Cache.UserPermissionCache(storage, "Store Stress Test", "Application" + rnd.ToString(), id, true, true); for (int i = 0; i < n; i++) { List <KeyValuePair <string, string> > attr; AuthorizationType res = c.CheckAccess("Operation" + rnd.ToString(), DateTime.Now, out attr); this.pb.Value = i; Application.DoEvents(); } storage.CloseConnection(); storage.Dispose(); } } else { Thread[] tt = new Thread[n]; //Threads Prepare for (int i = 0; i < n; i++) { tt[i] = new Thread(new ThreadStart(this.TestSuNetSqlAzManForThread)); tt[i].Start(); this.pb.Value = i; } //Threads Consume for (int i = 0; i < n; i++) { tt[i].Join(); this.pb.Value = i; } //Threads Destroy for (int i = 0; i < n; i++) { tt[i] = null; this.pb.Value = i; } } this.StopTimer(this.txtNetSqlAzManElapsed); this.Clessidra(false); }