/// <summary> /// Performs a raw, unfiltered search at the SPI level, /// eliminating duplicates from the result set. /// </summary> /// <param name="search">The search SPI</param> /// <param name="oclass">The object class - passed through to /// connector so it may be null if the connecor /// allowing it to be null. (This is convenient for /// unit tests, but will not be the case in general)</param> /// <param name="filter">The filter to search on</param> /// <param name="handler">The result handler</param> /// <param name="options">The options - may be null - will /// be cast to an empty OperationOptions</param> public SearchResult Search <T>(SearchOp <T> search, ObjectClass objectClass, Filter filter, ResultsHandler handler, OperationOptions options) where T : class { Assertions.NullCheck(objectClass, "objectClass"); if (ObjectClass.ALL.Equals(objectClass)) { throw new System.NotSupportedException("Operation is not allowed on __ALL__ object class"); } Assertions.NullCheck(handler, "handler"); //convert null into empty if (options == null) { options = new OperationOptionsBuilder().Build(); } SearchResult result = null; RawSearcherImpl <T> .RawSearch(search, objectClass, filter, new SearchResultsHandler() { Handle = obj => { return(handler.Handle(obj)); }, HandleResult = obj => { result = obj; } }, options); return(result != null ? result : new SearchResult()); }
/// <summary> /// Performs a raw, unfiltered search at the SPI level, /// eliminating duplicates from the result set. /// </summary> /// <param name="search">The search SPI</param> /// <param name="oclass">The object class - passed through to /// connector so it may be null if the connecor /// allowing it to be null. (This is convenient for /// unit tests, but will not be the case in general)</param> /// <param name="filter">The filter to search on</param> /// <param name="handler">The result handler</param> /// <param name="options">The options - may be null - will /// be cast to an empty OperationOptions</param> public static void Search <T>(SearchOp <T> search, ObjectClass oclass, Filter filter, ResultsHandler handler, OperationOptions options) where T : class { GetSpi().Search(search, oclass, filter, handler, options); }
/// <summary> /// Performs a raw, unfiltered search at the SPI level, /// eliminating duplicates from the result set. /// </summary> /// <param name="search">The search SPI</param> /// <param name="oclass">The object class - passed through to /// connector so it may be null if the connecor /// allowing it to be null. (This is convenient for /// unit tests, but will not be the case in general)</param> /// <param name="filter">The filter to search on</param> /// <param name="options">The options - may be null - will /// be cast to an empty OperationOptions</param> /// <returns>The list of results.</returns> public static IList <ConnectorObject> SearchToList <T>(SearchOp <T> search, ObjectClass oclass, Filter filter, OperationOptions options) where T : class { ToListResultsHandler handler = new ToListResultsHandler(); Search(search, oclass, filter, handler.ResultsHandler, options); return(handler.Objects); }
/// <summary> /// Performs a raw, unfiltered search at the SPI level, /// eliminating duplicates from the result set. /// </summary> /// <param name="search">The search SPI</param> /// <param name="oclass">The object class - passed through to /// connector so it may be null if the connecor /// allowing it to be null. (This is convenient for /// unit tests, but will not be the case in general)</param> /// <param name="filter">The filter to search on</param> /// <param name="handler">The result handler</param> /// <param name="options">The options - may be null - will /// be cast to an empty OperationOptions</param> public void Search <T>(SearchOp <T> search, ObjectClass oclass, Filter filter, ResultsHandler handler, OperationOptions options) where T : class { if (options == null) { options = new OperationOptionsBuilder().Build(); } RawSearcherImpl <T> .RawSearch( search, oclass, filter, handler, options); }
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(); } }
/// <summary> /// Construct a Query object that can be used to perform a search. /// </summary> /// <param name="collectionId">The Collection to perform the search in.</param> /// <param name="property">The property that contains the value.</param> /// <param name="op">The operator used for the match criteria.</param> /// <param name="value">The value to match.</param> /// <param name="type">The Type of the value to search for.</param> public Query(string collectionId, string property, SearchOp op, string value, Syntax type) { this.collectionId = collectionId; this.property = property; this.operation = op; this.type = type; if (type == Syntax.Boolean) { this.value = (String.Compare(value, "true", true) == 0 || String.Compare(value, "1", false) == 0) ? "1" : "0"; } else { this.value = value; } }
/// <summary> /// Method to search for the specified value for the given property. /// </summary> /// <param name="name">Property to search</param> /// <param name="op">Query operation</param> /// <param name="value">Value to match</param> /// <param name="type">The type of the value.</param> /// <param name="shouldMatch">If true the search should return a result.</param> private void internalSearch(string name, SearchOp op, string value, Syntax type, bool shouldMatch) { IResultSet results; bool foundMatch = false; //results = provider.Search(new Query(name, op, value, type)); results = provider.Search(new Query(collectionId, name, op, value, type)); if (results != null) { char [] buf = new char[4096]; int len; while ((len = results.GetNext(ref buf)) != 0) { foundMatch = true; //writeXml(new string(buf, 0, len)); } if ((shouldMatch && !foundMatch) || (!shouldMatch && foundMatch)) { Console.WriteLine(string.Format("Failed searching for \"{0}\" {1} \"{2}\" type = {3}", name, op.ToString(), value, type)); //throw (new ApplicationException(string.Format("Searching for \"{0}\" {1} \"{2}\" type = {3}", name, op.ToString(), value, type))); } results.Dispose(); } }
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 GaimBuddy[] SearchForBuddies(string attributeName, string searchString, SearchOp operation) { ArrayList buddies = new ArrayList(); GaimBuddy[] allBuddies = allBuddies = GetBuddies(); if (allBuddies != null && allBuddies.Length > 0) { foreach (GaimBuddy buddy in allBuddies) { if (searchString == null) { try { buddies.Add(buddy); } catch {} continue; } string compareString = null; if (attributeName != null && attributeName == "Alias") { compareString = buddy.Alias; } if (compareString == null) { compareString = buddy.Name; } if (compareString != null) { compareString = compareString.ToLower(); searchString = searchString.ToLower(); switch(operation) { case SearchOp.Begins: if (compareString.StartsWith(searchString)) { try { buddies.Add(buddy); } catch {} } break; case SearchOp.Exists: case SearchOp.Contains: default: if (compareString.IndexOf(searchString) >= 0) { try { buddies.Add(buddy); } catch {} } break; } } } } else { return (GaimBuddy[])buddies.ToArray(typeof(Simias.Gaim.GaimBuddy)); } try { buddies.Sort(BuddyComparer.GetInstance()); } catch{} return (GaimBuddy[])buddies.ToArray(typeof(Simias.Gaim.GaimBuddy)); }
/// <summary> /// Performs a raw, unfiltered search at the SPI level, /// eliminating duplicates from the result set. /// </summary> /// <param name="search">The search SPI</param> /// <param name="oclass">The object class - passed through to /// connector so it may be null if the connecor /// allowing it to be null. (This is convenient for /// unit tests, but will not be the case in general)</param> /// <param name="filter">The filter to search on</param> /// <param name="options">The options - may be null - will /// be cast to an empty OperationOptions</param> /// <returns>The list of results.</returns> public static IList <ConnectorObject> SearchToList <T>(SearchOp <T> search, ObjectClass oclass, Filter filter) where T : class { return(SearchToList(search, oclass, filter, null)); }
/// <summary> /// Starts a search for a specific set of domain members. /// </summary> /// <param name="domainID">The identifier of the domain to search for members in.</param> /// <param name="attributeName">Name of attribute to search.</param> /// <param name="searchString">String that contains a pattern to search for.</param> /// <param name="operation">Type of search operation to perform.</param> /// <param name="count">Maximum number of member objects to return.</param> /// <param name="searchContext">Receives a provider specific search context object. This object must be serializable.</param> /// <param name="memberList">Receives an array object that contains the domain Member objects.</param> /// <param name="total">Receives the total number of objects found in the search.</param> /// <returns>True if there are more domain members. Otherwise false is returned.</returns> public bool FindFirstDomainMembers(string domainID, string attributeName, string searchString, SearchOp operation, int count, out string searchContext, out Member[] memberList, out int total) { searchContext = null; memberList = null; total = 0; return(false); }
public bool FindFirstDomainMembers( string domainID, string attributeName, string searchString, SearchOp operation, int count, out string searchContext, out Member[] memberList, out int total ) { ArrayList members = new ArrayList(); ArrayList allMembers = new ArrayList(); searchContext = null; total = 0; GaimBuddy[] buddies = GaimDomain.SearchForBuddies(mapSimiasAttribToGaim(attributeName), searchString, operation); if (buddies != null && buddies.Length > 0) { total = buddies.Length; foreach (GaimBuddy buddy in buddies) { string[] machineNames = buddy.MachineNames; for (int i = 0; i < machineNames.Length; i++) { Member member = GaimDomain.FindBuddyInDomain(buddy, machineNames[i]); if (member == null) { member = new Member(buddy.GetSimiasMemberName(machineNames[i]), buddy.GetSimiasUserID(machineNames[i]), Simias.Storage.Access.Rights.ReadWrite, null, null); string alias = buddy.Alias; if (alias != null) { member.FN = string.Format("{0} ({1})", alias, machineNames[i]); } } if (members.Count < count) { members.Add(member); } allMembers.Add(member); } } } memberList = members.ToArray(typeof(Member)) as Member[]; if (allMembers.Count > 0) { GaimDomainSearchContext newSearchContext = new GaimDomainSearchContext(); newSearchContext.Members = allMembers; newSearchContext.CurrentIndex = members.Count; searchContext = newSearchContext.ID; lock (searchContexts.SyncRoot) { searchContexts.Add(searchContext, newSearchContext); } } return members.Count < allMembers.Count ? true : false; }
void Search(SearchOp op, SearchBy by, object criteria) { List <GameObject> query = new List <GameObject>(); var all = FindAllSceneObjects(); switch (by) { case SearchBy.Name: foreach (var go in all) { if (go.name.Contains((string)criteria)) { query.Add(go); } } break; case SearchBy.Tag: query.AddRange(GameObject.FindGameObjectsWithTag((string)criteria)); break; case SearchBy.Layer: foreach (var go in all) { if (go.layer == LayerMask.NameToLayer((string)criteria)) { query.Add(go); } } break; case SearchBy.ComponentType: if (s_assemblyTypes.ContainsKey((string)criteria)) { Type t = s_assemblyTypes[(string)criteria]; if (typeof(Component).IsAssignableFrom(t)) { Component[] components = (Component[])Resources.FindObjectsOfTypeAll(t); if (components != null) { foreach (var c in components) { if (c.gameObject.scene != null && !query.Contains(c.gameObject)) { query.Add(c.gameObject); } } } } } break; case SearchBy.Mesh: Mesh mesh = (Mesh)criteria; foreach (var go in all) { MeshFilter filter = go.GetComponent <MeshFilter>(); if (filter != null && filter.sharedMesh == mesh) { query.Add(go); } } break; case SearchBy.Material: Material mat = (Material)criteria; foreach (var go in all) { Renderer renderer = go.GetComponent <Renderer>(); if (renderer != null) { if (renderer.sharedMaterials.Contains(mat)) { query.Add(go); } } } break; } switch (op) { case SearchOp.Find: searchResults = query; break; case SearchOp.Add: foreach (var item in query) { if (!searchResults.Contains(item)) { searchResults.Add(item); } } break; case SearchOp.Refine: List <GameObject> refined = new List <GameObject>(); foreach (var item in searchResults) { if (query.Contains(item)) { refined.Add(item); } } searchResults = refined; break; } }
/// <summary> /// Construct a Query that can be used to perform a global query. /// </summary> /// <param name="property"></param> /// <param name="op"></param> /// <param name="value"></param> /// <param name="type"></param> public Query(string property, SearchOp op, string value, Syntax type) : this(null, property, op, value, type) { }
/// <summary> /// Starts a search for a specific set of domain members. /// </summary> /// <param name="domainID">The identifier of the domain to search for members in.</param> /// <param name="attributeName">Attribute name to search.</param> /// <param name="searchString">String that contains a pattern to search for.</param> /// <param name="operation">Type of search operation to perform.</param> /// <param name="count">Maximum number of member objects to return.</param> /// <param name="searchContext">Receives a provider specific search context object.</param> /// <param name="memberList">Receives an array object that contains the domain Member objects.</param> /// <param name="total">Receives the total number of objects found in the search.</param> /// <returns>True if there are more domain members. Otherwise false is returned.</returns> static public bool FindFirstDomainMembers(string domainID, string attributeName, string searchString, SearchOp operation, int count, out string searchContext, out Member[] memberList, out int total) { bool moreEntries = false; // Initialize the outputs. searchContext = null; memberList = null; total = 0; IDomainProvider idp = GetDomainProvider(domainID); if (idp != null) { moreEntries = idp.FindFirstDomainMembers(domainID, attributeName, searchString, operation, count, out searchContext, out memberList, out total); } return(moreEntries); }
/// <summary> /// Starts a search for a specific set of domain members. /// </summary> /// <param name="domainID">The identifier of the domain to search for members in.</param> /// <param name="attributeName">Name of attribute to search.</param> /// <param name="searchString">String that contains a pattern to search for.</param> /// <param name="operation">Type of search operation to perform.</param> /// <param name="count">Maximum number of member objects to return.</param> /// <param name="searchContext">Receives a provider specific search context object. This object must be serializable.</param> /// <param name="memberList">Receives an array object that contains the domain Member objects.</param> /// <param name="total">Receives the total number of objects found in the search.</param> /// <returns>True if there are more domain members. Otherwise false is returned.</returns> public bool FindFirstDomainMembers(string domainID, string attributeName, string searchString, SearchOp operation, int count, out string searchContext, out Member[] memberList, out int total) { bool moreEntries = false; // Initialize the outputs. searchContext = null; memberList = null; total = 0; // Start the search for the specific members of the domain. Domain domain = store.GetDomain(domainID); if (domain != null) { ICSList list = domain.Search(attributeName, searchString, operation); SearchState searchState = new SearchState(domainID, list.GetEnumerator() as ICSEnumerator, list.Count); searchContext = searchState.ContextHandle; total = list.Count; moreEntries = FindNextDomainMembers(ref searchContext, count, out memberList); } return(moreEntries); }
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(); } }