protected void btnCreateStore_Click(object sender, EventArgs e) { IAzManStorage storage = new SqlAzManStorage(ConfigurationManager.ConnectionStrings["NetSqlAzManStorage"].ConnectionString); storage.OpenConnection(); try { storage.BeginTransaction(AzManIsolationLevel.ReadUncommitted); IAzManStore store = storage.CreateStore("Store Created Programmatically", "store description"); for (int i = 0; i < 10; i++) { IAzManApplication app = store.CreateApplication("App " + i.ToString(), "application description"); IAzManItem prevItem = null; for (int j = 0; j < 10; j++) { IAzManItem item = app.CreateItem("Item " + j.ToString(), "item description", ItemType.Operation); if (prevItem!=null) item.AddMember(prevItem); prevItem = item; } } storage.CommitTransaction(); } catch { storage.RollBackTransaction(); throw; } finally { storage.CloseConnection(); } }
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(); } } }