示例#1
0
 private void button2_Click(object sender, EventArgs e)
 {
     using (sr.CacheServiceClient csc = new NetSqlAzMan_WinTest.sr.CacheServiceClient())
     {
         csc.Open();
         csc.InvalidateCache();
         ((IDisposable)csc).Dispose();
     }
 }
 private void button2_Click(object sender, EventArgs e)
 {
     using (sr.CacheServiceClient csc = new NetSqlAzMan_WinTest.sr.CacheServiceClient())
     {
         csc.Open();
         csc.InvalidateCache();
         ((IDisposable)csc).Dispose();
     }
 }
示例#3
0
        private void button1_Click(object sender, EventArgs e)
        {
            int max = 1000;

            this.errors = 0;
            this.progressBar1.Minimum = 0;
            this.progressBar1.Maximum = max - 1;
            for (int i = 0; i < max; i++)
            {
                Thread t = new Thread(new ThreadStart(
                                          delegate()
                {
                    using (sr.CacheServiceClient csc = new NetSqlAzMan_WinTest.sr.CacheServiceClient())
                    {
                        try
                        {
                            csc.Open();
                            //KeyValuePair<string, string>[] attrs = null;

                            AuthorizationType auth = csc.CheckAccessForWindowsUsersWithoutAttributesRetrieve("Eidos", "DB Persone",
                                                                                                             "Gestore", WindowsIdentity.GetCurrent().GetUserBinarySSid(), WindowsIdentity.GetCurrent().GetGroupsBinarySSid(),
                                                                                                             DateTime.Now, false, null);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message);
                            if (ex.InnerException != null)
                            {
                                MessageBox.Show(ex.InnerException.Message);
                            }
                            this.errors++;
                        }
                        finally
                        {
                            ((IDisposable)csc).Dispose();
                        }
                    }
                    Thread.Sleep(new Random().Next(300));
                }));
                this.progressBar1.Value = i;
                Application.DoEvents();
                t.Start();
                Thread.Sleep(new Random().Next(100));
            }
            MessageBox.Show(this.errors.ToString());
        }
        private void button1_Click(object sender, EventArgs e)
        {
            int max = 1000;
            this.errors = 0;
            this.progressBar1.Minimum = 0;
            this.progressBar1.Maximum = max - 1;
            for (int i=0;i<max;i++)
            {
                Thread t = new Thread(new ThreadStart(
                    delegate()
                    {
                        using (sr.CacheServiceClient csc = new NetSqlAzMan_WinTest.sr.CacheServiceClient())
                        {
                            try
                            {
                                csc.Open();
                                //KeyValuePair<string, string>[] attrs = null;

                                AuthorizationType auth = csc.CheckAccessForWindowsUsersWithoutAttributesRetrieve("Eidos", "DB Persone",
                                    "Gestore", WindowsIdentity.GetCurrent().GetUserBinarySSid(), WindowsIdentity.GetCurrent().GetGroupsBinarySSid(),
                                    DateTime.Now, false, null);
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(ex.Message);
                                if (ex.InnerException != null)
                                    MessageBox.Show(ex.InnerException.Message);
                                this.errors++;
                            }
                            finally
                            {
                                ((IDisposable)csc).Dispose();
                            }
                        }
                        Thread.Sleep(new Random().Next(300));
                    }));
                this.progressBar1.Value = i;
                Application.DoEvents();
                t.Start();
                Thread.Sleep(new Random().Next(100));
            }
            MessageBox.Show(this.errors.ToString());
        }
示例#5
0
        private void btnCacheServiceTest_Click(object sender, EventArgs e)
        {
            List<TimeSpan> times = new List<TimeSpan>();
            List<System.Threading.Thread> threads = new List<System.Threading.Thread>();
            int max = 100;
            for (int i = 0; i < max; i++)
            {
                System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(
                () =>
                {
                    int k = i;
                    Random r = new Random();
                    //System.Threading.Thread.Sleep(r.Next(300));
                    DateTime now = DateTime.Now;
                    sr.CacheServiceClient c = new NetSqlAzMan_WinTest.sr.CacheServiceClient();
                    c.Open();
                    KeyValuePair<string, string>[] attributes;
                    string user = WindowsIdentity.GetCurrent().GetUserBinarySSid();
                    string[] groups = WindowsIdentity.GetCurrent().GetGroupsBinarySSid();
                    AuthorizationType auth = c.CheckAccessForWindowsUsersWithAttributesRetrieve(out attributes, "Italferr", "CartaDeiServizi", "Visualizza Dettagli Richiesta", user, groups, DateTime.Now, false, null);
                    c.Close();
                    TimeSpan ts = DateTime.Now.Subtract(now);
                    if (auth != AuthorizationType.Allow)
                    {
                        throw new Exception("Error");
                    }
                    times.Add(ts);
                }));
                threads.Add(t);
                t.Start();
            }
            foreach (System.Threading.Thread t in threads)
            {
                t.Join();
            }
            this.textBox1.Text = String.Empty;
            int cc = 0;
            foreach (TimeSpan ts in times)
            {
                this.textBox1.Text += String.Format("{0}) {1}\r\n",++cc, ts);
            }
            MessageBox.Show("Done");

            //DateTime now = DateTime.Now;
            //NetSqlAzMan.Cache.StorageCache sc = new StorageCache("data source=.;initial catalog=NetSqlAzManStorage;user id=sa;password="******"Italferr", "CartaDeiServizi");
            //WindowsIdentity wid = WindowsIdentity.GetCurrent();
            //string user = wid.GetUserBinarySSid(); //using NetSqlAzMan.Cache needed
            //string[] groups = wid.GetGroupsBinarySSid(); //using NetSqlAzMan.Cache needed
            //AuthorizationType au = sc.CheckAccess("Italferr", "CartaDeiServizi", "Approvatore Sistemi Informativi", user, groups, DateTime.Now, false);
            //MessageBox.Show(au.ToString());
            //return;

            //int max = 100;

            //sr.CacheServiceClient client = new NetSqlAzMan_WinTest.sr.CacheServiceClient();
            //for (int i = 0; i < max; i++)
            //{
            //    KeyValuePair<string, string>[] attributes;
            //    auth = client.CheckAccessForWindowsUsersWithAttributesRetrieve(out attributes, "Italferr", "CartaDeiServizi", "Visualizza Dettagli Richiesta", user, groups, DateTime.Now, false, null);
            //}
            //client.Close();
            //MessageBox.Show(auth.ToString());
            //TimeSpan ts = DateTime.Now.Subtract(now);
            //MessageBox.Show(String.Format("Total: {0} - Single: {1}", ts.TotalMilliseconds, ts.TotalMilliseconds / (double)max));

            //NetSqlAzMan.Cache.StorageCache sc = new NetSqlAzMan.Cache.StorageCache("data source=.;initial catalog=NetSqlAzManStorage;user id=sa;password="******"ItalferR", "CartadeiServizi", "Visualizza dettagli Richiesta ", wid.User, wid.Groups, DateTime.Now, false, out attributes);
            //DateTime now = DateTime.Now;
            //int max = 10000;
            //string user = wid.GetUserBinarySSid();
            //string[] groups = wid.GetGroupsBinarySSid();
            //for (int i = 0; i < max; i++)
            //{
            //    AuthorizationType auth = sc.CheckAccess("Italferr", "CartaDeiServizi", "visualizza dettagli richiesta", user, groups, DateTime.Now, false, out attributes);
            //}
            //TimeSpan ts = DateTime.Now.Subtract(now);
            //MessageBox.Show(String.Format("Total: {0} - Single: {1}",ts.TotalMilliseconds, ts.TotalMilliseconds/(double)max));
        }