Example #1
0
 public void CreateItemsFromAFolder(
     string storageConnectionString,
     string storeName,
     string applicationName,
     string folderPath,
     string searchPattern,
     ItemType itemType)
 {
     using (IAzManStorage storage = new SqlAzManStorage(storageConnectionString))
     {
         storage.OpenConnection();
         storage.BeginTransaction();
         try
         {
             IAzManApplication app = storage.GetStore(storeName).GetApplication(applicationName);
             DirectoryInfo di = new DirectoryInfo(folderPath);
             foreach (FileInfo fi in di.GetFiles(searchPattern))
             {
                 //Use some recursive function to get subfolder files
                 app.CreateItem(fi.Name, String.Empty, itemType);
             }
             storage.CommitTransaction();
         }
         catch
         {
             storage.RollBackTransaction();
         }
         finally
         {
             storage.Dispose();
         }
     }
 }
Example #2
0
 /// <summary>
 /// Create an Authorization Delegate
 /// </summary>
 private void AddDBUserToRole(string dbUserName, string roleName)
 {
     //Sql Storage connection string
     string sqlConnectionString = "data source=(local);initial catalog=NetSqlAzManStorage;user id=sa;password=password";
     //Create an instance of SqlAzManStorage class
     using (IAzManStorage storage = new SqlAzManStorage(sqlConnectionString))
     {
         storage.OpenConnection();
         IAzManStore mystore = storage.GetStore("My Store"); //or storage["My Store"]
         IAzManApplication myapp = mystore.GetApplication("My Application");
         IAzManItem myRole = myapp.GetItem(roleName);
         //Retrieve DB user identity
         IAzManDBUser dbUser = storage.GetDBUser(dbUserName);
         //Add DB "My Db User" to "My Role" role.
         IAzManAuthorization auth = myRole.CreateAuthorization(new SqlAzManSID(WindowsIdentity.GetCurrent().User), WhereDefined.LDAP, dbUser.CustomSid, WhereDefined.Database, AuthorizationType.Allow, null, null);
         //Optional: add authorization attribute
         //auth.CreateAttribute("attribute key", "attribute value");
         storage.CloseConnection();
         storage.Dispose();
     }
 }
Example #3
0
 private void btnCreateItemsFromAFolder_Click(object sender, EventArgs e)
 {
     using (IAzManStorage storage = new SqlAzManStorage("Data Source=(local);Initial Catalog=NetSqlAzManStorage;Integrated Security=SSPI;"))
     {
         storage.OpenConnection();
         storage.BeginTransaction();
         var a = storage["Eidos"]["DB Persone"]["Gestore"].GetMembers();
         storage.Dispose();
     }
     this.CreateItemsFromAFolder(
         "Data Source=(local);Initial Catalog=NetSqlAzManStorage;Integrated Security=SSPI;",
         "My Store",
         "My Application",
         @"D:\Documenti\EIDOS\ICP\EIDOS.ApplicazioniAziendali\EIDOS.ApplicazioniAziendali.DBPersone.Web",
         "*.aspx",
         ItemType.Task);
 }
Example #4
0
 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);
 }
Example #5
0
 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();
 }