public static void GetCollisionNodes( ) { Store.Initialize(SimiasDataPath, true, -1); Store store = Store.GetStore(); if (store == null) { Console.WriteLine("store could not be initialized....."); } Domain domain = store.GetDomain(store.DefaultDomain); SearchOp searchOperation = SearchOp.Begins; string pattern = "*"; int max = 0; int index = 0; Console.WriteLine(); Console.WriteLine("**************************Collision Nodes Report********************* "); Console.WriteLine(); Simias.Storage.SearchPropertyList SearchPrpList = new Simias.Storage.SearchPropertyList(); int i = 0; SearchPrpList.Add(CollisionProperty, "*", SearchOp.Exists); SearchPrpList.Add(BaseSchema.ObjectName, pattern, searchOperation); try{ ICSList searchList = Catalog.Search(SearchPrpList); SearchState searchState = new SearchState(domain.ID, searchList.GetEnumerator() as ICSEnumerator, searchList.Count); if (index != 0) { searchState.Enumerator.SetCursor(Simias.Storage.Provider.IndexOrigin.SET, index); } foreach (ShallowNode sn in searchList) { if (max != 0 && i++ >= max) { break; } CatalogEntry catEntry = Catalog.ConvertToCataloEntry(sn); Console.WriteLine("iFolder Name :{0}, iFolder ID:{1}", catEntry.Name, catEntry.CollectionID); } } catch (Exception ee) { Console.WriteLine("Got exception: " + ee.Message); } finally{ Store.DeleteInstance(); } }
public static ArrayList getAllDomainUsers(Domain domain, string username) { SearchProperty searchProperty = SearchProperty.UserName; SearchOperation searchOperation = SearchOperation.BeginsWith; string pattern = "*"; Simias.Storage.SearchPropertyList SearchPrpList = new Simias.Storage.SearchPropertyList(); //SearchPrpList.Add(searchProperty, pattern, searchOperation); SearchPrpList.Add("DN", "*", SearchOp.Exists); ICSList searchList = domain.Search(SearchPrpList); ArrayList list = new ArrayList(); Member member = null; Console.WriteLine("Total No Of Users in Domain: " + searchList.Count); foreach (ShallowNode sn in searchList) { try { if (sn.IsBaseType(NodeTypes.MemberType)) { member = new Member(domain, sn); Member mem = domain.GetMemberByID(member.UserID); //add only those members to list whose home server is current server if (mem.HomeServer != null) { if (String.Equals(mem.Name, username) && mem.HomeServer.UserID == HostNode.GetLocalHost().UserID) { list.Add(mem); break; } } } } catch (Exception ex) { Console.WriteLine("Error: " + ex.Message); Console.WriteLine("Error Trace: " + ex.StackTrace); } } Console.WriteLine("Total No Of Users for whom Home Server is current server: " + list.Count); return(list); }
public static void GetCollisionNodes( ) { Store.Initialize(SimiasDataPath, true, -1); Store store = Store.GetStore(); if (store == null) { Console.WriteLine("store could not be initialized....."); } Domain domain = store.GetDomain(store.DefaultDomain); SearchOp searchOperation = SearchOp.Begins; string pattern = "*"; int max = 0; int index = 0; //create catalog instances catalog = store.GetCollectionByID(catalogID); if (catalog == null) { Console.WriteLine("Could not get the catalog collection node from store... Exiting"); return; } Console.WriteLine(); Console.WriteLine("**************************Collision Nodes Deletion********************* "); Console.WriteLine(); Simias.Storage.SearchPropertyList SearchPrpList = new Simias.Storage.SearchPropertyList(); int i = 0; SearchPrpList.Add(CollisionProperty, "*", SearchOp.Exists); SearchPrpList.Add(BaseSchema.ObjectName, pattern, searchOperation); ICSList searchList = Catalog.Search(SearchPrpList); try{ SearchState searchState = new SearchState(domain.ID, searchList.GetEnumerator() as ICSEnumerator, searchList.Count); if (index != 0) { searchState.Enumerator.SetCursor(Simias.Storage.Provider.IndexOrigin.SET, index); } if (searchList != null && searchList.Count > 0) { Console.WriteLine("Catalog entry for all collision nodes will be deleted from Catalog Collection Node, Type yes to continue."); Console.WriteLine(); string entered = Console.ReadLine(); if (String.Equals(entered.ToLower(), "yes")) { foreach (ShallowNode sn in searchList) { if (max != 0 && i++ >= max) { break; } CatalogEntry catEntry = Catalog.ConvertToCataloEntry(sn); Console.WriteLine("Deleting catalog with iFolder Name :{0}, iFolder ID:{1}", catEntry.Name, catEntry.CollectionID); catalog.Commit(catalog.Delete(catEntry)); Thread.Sleep(100); } Console.WriteLine(); Console.WriteLine("Total number of deleted nodes: " + i); } } else { Console.WriteLine("No catalog node was found with collision!"); } }catch (Exception ee) { Console.WriteLine("Got this exception: " + ee.Message); } finally{ Store.DeleteInstance(); } }
public static void GetOrphanediFolders( ) { Store.Initialize(SimiasDataPath, true, -1); Store store = Store.GetStore(); if (store == null) { Console.WriteLine("store could not be initialized....."); } Domain domain = store.GetDomain(store.DefaultDomain); SearchOp searchOperation = SearchOp.Begins; string pattern = "*"; CatalogEntry[] catalogEntries; string OrphanedOwnerProperty = "OrphOwnerDN"; string MemberProperty = "mid"; int max = 0; int index = 0; string accessID = null; Console.WriteLine(); Console.WriteLine("**************************ORPHAN IfOLDER REPORT********************* "); Console.WriteLine(); try { Simias.Storage.SearchPropertyList SearchPrpList = new Simias.Storage.SearchPropertyList(); ArrayList list = new ArrayList(); int i = 0; int total = 0; SearchPrpList.Add(OrphanedOwnerProperty, "*", SearchOp.Exists); SearchPrpList.Add(BaseSchema.ObjectName, pattern, searchOperation); if (accessID != null) { SearchPrpList.Add(MemberProperty, accessID, SearchOp.Begins); } ICSList searchList = Catalog.Search(SearchPrpList); total = searchList.Count; SearchState searchState = new SearchState(domain.ID, searchList.GetEnumerator() as ICSEnumerator, searchList.Count); if (index != 0) { searchState.Enumerator.SetCursor(Simias.Storage.Provider.IndexOrigin.SET, index); } foreach (ShallowNode sn in searchList) { if (max != 0 && i++ >= max) { break; } CatalogEntry catEntry = Catalog.ConvertToCataloEntry(sn); DateTime lastModified = (DateTime)catEntry.Properties.GetSingleProperty("LastModified").Value; string PreviousOwner = catEntry.Properties.GetSingleProperty(OrphanedOwnerProperty).Value as string; Console.WriteLine("iFolder Name :{0}, iFolder ID:{1}, PreviousOwner:{2}, Orphaned on:{3}", catEntry.Name, catEntry.CollectionID, PreviousOwner, lastModified); //list.Add(new iFolder(Catalog.ConvertToCataloEntry(sn), accessID)); } } catch (Exception ee) { } finally { Store.DeleteInstance(); } }