public void ExecuteQuery(ObjectClass oclass, String query, ResultsHandler handler, OperationOptions options) { for (int i = 0; i < _config.numResults; i++) { int?delay = (int?)CollectionUtil.GetValue(options.Options, "delay", null); if (delay != null) { Thread.Sleep((int)delay); } ConnectorObjectBuilder builder = new ConnectorObjectBuilder(); builder.SetUid("" + i); builder.SetName(i.ToString()); builder.ObjectClass = oclass; for (int j = 0; j < 50; j++) { builder.AddAttribute("myattribute" + j, "myvaluevaluevalue" + j); } ConnectorObject rv = builder.Build(); if (!handler(rv)) { break; } } }
private void SubmitConnectorObject(String result, ResultsHandler handler) { ConnectorObjectBuilder cob = new ConnectorObjectBuilder(); String[] resultSplit = result.Split(new char[] { '$' }); ICollection <ConnectorAttribute> attrs = new List <ConnectorAttribute>(); foreach (String str in resultSplit) { ConnectorAttributeBuilder cab = new ConnectorAttributeBuilder(); cab.AddValue(str.Split(new char[] { ':' })[1]); if (str.StartsWith("Name")) { cob.SetName(Name.NAME); cob.SetUid(str.Split(new char[] { ':' })[1]); cab.Name = Name.NAME; } else { cab.Name = str.Split(new char[] { ':' })[0]; } attrs.Add(cab.Build()); } cob.AddAttributes(attrs); handler(cob.Build()); }
/// <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()); }
// TODO move to appropriate place /// <summary> /// helper method for searching object in AD by UID /// </summary> /// <param name="uid">Uid of the searched </param> /// <param name="oclass">Object class</param> /// <param name="options">Operation options</param> /// <returns>Connector object found by the Uid</returns> internal ConnectorObject ADSearchByUid(ExchangeConnector connector, Uid uid, ObjectClass oclass, OperationOptions options) { ExchangeConfiguration configuration = connector.Configuration; ExchangeUtility.NullCheck(uid, "uid", configuration); ExchangeUtility.NullCheck(oclass, "oclass", configuration); if (options == null) { options = new OperationOptionsBuilder().Build(); } ConnectorObject ret = null; Filter filter = FilterBuilder.EqualTo(uid); var translator = connector.ActiveDirectoryConnector.CreateFilterTranslator(oclass, options); IList <string> queries = translator.Translate(filter); if (queries.Count == 1) { ResultsHandler handler = new ResultsHandler() { Handle = cobject => { ret = cobject; return(false); } }; connector.ActiveDirectoryConnector.ExecuteQuery(oclass, queries[0], handler, options); } return(ret); }
internal ConnectorObject GetCurrentObject(UpdateOpContext context, string query) { ConnectorObject currentObject = null; LOG.Trace("Fetching object using query {0}", query); ResultsHandler handler = new ResultsHandler() { Handle = cobject => { //LOGGER.TraceEvent(TraceEventType.Verbose, CAT_DEFAULT, "Object-to-be-modified: {0}", CommonUtils.DumpConnectorAttributes(cobject.GetAttributes())); if (currentObject != null) { throw new InvalidOperationException("More than one object complying with " + query + " was found"); } currentObject = cobject; return(true); } }; ((ExchangeConnector)context.Connector).ExecuteQuery(context.ObjectClass, query, handler, null); if (currentObject == null) { throw new ObjectNotFoundException("Object with UID " + context.Uid.GetUidValue() + " was not found"); } return(currentObject); }
/// <summary> /// helper method for searching object in AD by UID /// </summary> /// <param name="uid">Uid of the searched </param> /// <param name="oclass">Object class</param> /// <param name="options">Operation options</param> /// <returns>Connector object found by the Uid</returns> private ConnectorObject ADSearchByUid(Uid uid, ObjectClass oclass, OperationOptions options) { ExchangeUtility.NullCheck(uid, "uid", this.configuration); ExchangeUtility.NullCheck(oclass, "oclass", this.configuration); if (options == null) { options = new OperationOptionsBuilder().Build(); } ConnectorObject ret = null; Filter filter = FilterBuilder.EqualTo(uid); var translator = base.CreateFilterTranslator(oclass, options); IList <string> queries = translator.Translate(filter); if (queries.Count == 1) { ResultsHandler handler = delegate(ConnectorObject cobject) { ret = cobject; return(false); }; base.ExecuteQuery(oclass, queries[0], handler, options); } return(ret); }
/// <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); }
public void ExecuteQuery(ObjectClass oclass, string query, ResultsHandler handler, OperationOptions options) { Assert.IsNotNull(oclass); Assert.IsNotNull(handler); Assert.IsNotNull(options); AddCall("ExecuteQuery", oclass, query, handler, options); }
/// <summary> /// Implementation of SearchOp.ExecuteQuery /// </summary> /// <param name="oclass">Object class</param> /// <param name="query">Query to execute</param> /// <param name="handler">Result handler</param> /// <param name="options">Operation options</param> public override void ExecuteQuery( ObjectClass oclass, string query, ResultsHandler handler, OperationOptions options) { // TODO: Implement ExecuteQuery base.ExecuteQuery(oclass, query, handler, options); }
private static void callSaveChanges(object sender, ElapsedEventArgs e) { LeaderboardHandler leaderboardHandler = new LeaderboardHandler(); ResultsHandler resultsHandler = new ResultsHandler(); resultsHandler .DoWork() .ContinueWith(async(prevTask) => { await leaderboardHandler.DoWork(); }); }
/// <summary> /// Simply return everything don't bother optimizing. /// </summary> /// /// <seealso cref="SearchOp.Search"/> public void ExecuteQuery(ObjectClass oclass, string query, ResultsHandler handler, OperationOptions options) { foreach (ConnectorObject obj in objects) { if (!handler.Handle(obj)) { break; } } }
/// <summary> /// Implementation of SearchOp.ExecuteQuery /// </summary> /// <param name="oclass">Object class</param> /// <param name="query">Query to execute</param> /// <param name="handler">Results handler</param> /// <param name="options">Operation options</param> public override void ExecuteQuery( ObjectClass oclass, string query, ResultsHandler handler, OperationOptions options) { ExchangeUtility.NullCheck(oclass, "oclass", this.configuration); // we handle accounts only if (!oclass.Is(ObjectClass.ACCOUNT_NAME)) { base.ExecuteQuery(oclass, query, handler, options); return; } ICollection <string> attsToGet = null; if (options != null && options.AttributesToGet != null) { attsToGet = CollectionUtil.NewList(options.AttributesToGet); } // delegate to get the exchange attributes if requested ResultsHandler filter = delegate(ConnectorObject cobject) { ConnectorObject filtered = ExchangeUtility.ReplaceAttributes( cobject, attsToGet, AttMapFromAD); filtered = this.AddExchangeAttributes(oclass, filtered, attsToGet); return(handler(filtered)); }; ResultsHandler handler2use = handler; OperationOptions options2use = options; if (options != null && options.AttributesToGet != null) { if (attsToGet.Contains(AttDatabase) || attsToGet.Contains(AttExternalMail) || attsToGet.Contains(AttRecipientType)) { // replace Exchange attributes with AD names var newAttsToGet = ExchangeUtility.FilterReplace(attsToGet, AttMap2AD); // we have to remove recipient type, as it is unknown to AD newAttsToGet.Remove(AttRecipientType); // build new op options var builder = new OperationOptionsBuilder(options); string[] attributesToGet = new string[newAttsToGet.Count]; newAttsToGet.CopyTo(attributesToGet, 0); builder.AttributesToGet = attributesToGet; options2use = builder.Build(); handler2use = filter; } } base.ExecuteQuery(oclass, query, handler2use, options2use); }
public void ExecuteQuery(ObjectClass oclass, string query, ResultsHandler handler, OperationOptions options) { Assert.IsNotNull(oclass); Assert.IsNotNull(handler); Assert.IsNotNull(options); AddCall("ExecuteQuery", oclass, query, handler, options); if (null != options.PageSize && options.PageSize > 0) { // This is a pages search request ((SearchResultsHandler)handler).HandleResult(new SearchResult("TOKEN==", 100)); } }
/// <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); }
// implementation of SearchSpiOp public virtual void ExecuteQuery(ObjectClass objectClass, Filter query, ResultsHandler handler, OperationOptions options) { Trace.TraceInformation("Invoke ExecuteQuery ObjectClass:{0}", objectClass.GetObjectClassValue()); try { ExecuteQuery(_configuration.SearchScriptFileName, objectClass, query, handler, options); Trace.TraceInformation("Search ok"); } catch (Exception e) { if (e.InnerException != null) { throw e.InnerException; } throw; } }
public void SearchCallPattern() { TestCallPattern(new TestOperationPattern() { MakeCall = facade => { // create an empty results handler.. ResultsHandler rh = obj => { return(true); }; // call the search method.. facade.Search(ObjectClass.ACCOUNT, null, rh, null); }, CheckCalls = calls => { Assert.AreEqual("CreateFilterTranslator", GetAndRemoveMethodName(calls)); Assert.AreEqual("ExecuteQuery", GetAndRemoveMethodName(calls)); } }); }
/// <summary> /// Implementation of SearchOp.ExecuteQuery /// </summary> /// <param name="oclass">Object class</param> /// <param name="query">Query to execute</param> /// <param name="handler">Results handler</param> /// <param name="options">Operation options</param> public void ExecuteQuery(ObjectClass oclass, string query, ResultsHandler handler, OperationOptions options) { const string operation = "ExecuteQuery"; ExchangeUtility.NullCheck(oclass, "oclass", this._configuration); if (options == null) { options = new OperationOptions(new Dictionary <string, object>()); } LOGGER_API.TraceEvent(TraceEventType.Information, CAT_DEFAULT, "Exchange.ExecuteQuery method; oclass = {0}, query = {1}", oclass, query); ExecuteQueryContext context = new ExecuteQueryContext() { Connector = this, ConnectorConfiguration = _configuration, ObjectClass = oclass, OperationName = operation, Options = options, Query = query, ResultsHandler = handler }; try { _scripting.ExecutePowerShell(context, Scripting.Position.BeforeMain); if (!_scripting.ExecutePowerShell(context, Scripting.Position.InsteadOfMain)) { ExecuteQueryMain(context); } _scripting.ExecutePowerShell(context, Scripting.Position.AfterMain); } catch (Exception e) { LOGGER.TraceEvent(TraceEventType.Error, CAT_DEFAULT, "Exception while executing ExecuteQuery operation: {0}", e); throw; } // TODO what about executing a script on each returned item? }
public virtual void ExecuteQuery(ObjectClass objectClass, string query, ResultsHandler handler, OperationOptions options) { var builder = new ConnectorObjectBuilder(); builder.SetUid("3f50eca0-f5e9-11e3-a3ac-0800200c9a66"); builder.SetName("Foo"); builder.AddAttribute(ConnectorAttributeBuilder.BuildEnabled(true)); foreach (ConnectorObject connectorObject in CollectionUtil.NewSet(builder.Build())) { if (!handler.Handle(connectorObject)) { // Stop iterating because the handler stopped processing break; } } if (options.PageSize != null && 0 < options.PageSize) { Trace.TraceInformation("Paged Search was requested"); ((SearchResultsHandler)handler).HandleResult(new SearchResult("0", 0)); } }
public void SearchAllCallPattern() { TestCallPattern(new TestOperationPattern() { MakeCall = facade => { // create an empty results handler.. ResultsHandler rh = new ResultsHandler() { Handle = obj => { return(true); } }; // call the search method.. facade.Search(ObjectClass.ALL, null, rh, null); }, CheckCalls = calls => { Assert.Fail("Should not get here.."); } }); }
private static void ExecuteScheduler(string title, IScheduler sch, bool breakOut, Query[] qs) { int q; bool complete = false; AdminForm frmAdmin = new AdminForm(); IResults[] res = sch.Init(breakOut, qs); ResultsHandler[] rh = new ResultsHandler[res.Length]; for (q = 0; q < res.Length; q++) rh[q] = new ResultsHandler(string.Format("{0}{1}", title, q), res[q]); sch.Execute(); //frmAdmin.Scheduler = sch; //frmAdmin.Show(); while (!complete && !frmAdmin.ShutdownServer) { //frmAdmin.UpdateStats(); Thread.Sleep(10000); complete = true; for (int i = 0; i < rh.Length && complete; i++) complete &= rh[i].EOF; //Log.WriteMessage(DataItemPool.ToString(), Log.eMessageType.Debug); } double totalSec = 0; for (int i = 0; i < rh.Length; i++) { Log.WriteMessage(string.Format("{0} Total Rows: {1}, Time: {2}", rh[i].Name, rh[i].DataCount, rh[i].CompletionTime), Log.eMessageType.Debug); totalSec += (((double)rh[i].CompletionTime.Minutes) * 60) + ((double)rh[i].CompletionTime.Seconds) + (((double)rh[i].CompletionTime.Milliseconds) / 1000.0); } Log.WriteMessage(string.Format("Average Time: {0}", totalSec / rh.Length), Log.eMessageType.Debug); }
// Start is called before the first frame update private void Start() { resultsHandler = GameObject.FindGameObjectWithTag("ResultsPopup").GetComponent <ResultsHandler>(); var config = new ConnectionConfig(); // Config the Channels we will use config.AddChannel(QosType.ReliableFragmented); config.AddChannel(QosType.UnreliableFragmented); // Create the client and attach the configuration _client = new NetworkClient(); _client.Configure(config, 1); // Register the handlers for the different network messages RegisterHandlers(); //start with the object offscreen and lerp onto screen transform.localPosition = new Vector3(0.0f, -1000.0f, 0.0f); StartCoroutine(LerpGameObjectY(gameObject, 0.0f, 1.0f, false, 0.0f)); _btnSubmitScore.onClick.AddListener(BtnSubmitScorePressed); _btnCancel.onClick.AddListener(BtnCancelPressed); }
public void ExecuteQuery(ExecuteQueryContext context) { ExchangeConnector exconn = (ExchangeConnector)context.Connector; ActiveDirectoryConnector adconn = exconn.ActiveDirectoryConnector; ICollection <string> attsToGet = null; if (context.Options != null && context.Options.AttributesToGet != null) { attsToGet = CollectionUtil.NewList(context.Options.AttributesToGet); } // delegate to get the exchange attributes if requested ResultsHandler filter = new SearchResultsHandler() { Handle = cobject => { LOGGER.TraceEvent(TraceEventType.Verbose, CAT_DEFAULT, "Object returned from AD connector: {0}", CommonUtils.DumpConnectorAttributes(cobject.GetAttributes())); ConnectorObject filtered = ExchangeUtility.ConvertAdAttributesToExchange(cobject); //filtered = AddExchangeAttributes(exconn, context.ObjectClass, filtered, attsToGet); LOGGER.TraceEvent(TraceEventType.Verbose, CAT_DEFAULT, "Object as passed from Exchange connector: {0}", CommonUtils.DumpConnectorAttributes(filtered.GetAttributes())); return(context.ResultsHandler.Handle(filtered)); }, HandleResult = result => { if (context.ResultsHandler is SearchResultsHandler) { ((SearchResultsHandler)context.ResultsHandler).HandleResult(result); } } }; ResultsHandler handler2use = filter; OperationOptions options2use = context.Options; // mapping AttributesToGet from Exchange to AD "language" // actually, we don't need this code any more, because there are no attribute that are not retrieved by default // Uncomment this code if necessary in the future. if (context.Options != null && context.Options.AttributesToGet != null) { /* * ISet<string> mappedExchangeAttributesToGet = new HashSet<string>(AttMap2AD.Keys); * mappedExchangeAttributesToGet.IntersectWith(options.AttributesToGet); * if (mappedExchangeAttributesToGet.Count > 0 || attsToGet.Contains(AttRecipientType)) * { * // replace Exchange attributes with AD names * var newAttsToGet = ExchangeUtility.FilterReplace(attsToGet, AttMap2AD); * * // we have to remove recipient type, as it is unknown to AD * newAttsToGet.Remove(AttRecipientType); * * // build new op options * var builder = new OperationOptionsBuilder(options); * string[] attributesToGet = new string[newAttsToGet.Count]; * newAttsToGet.CopyTo(attributesToGet, 0); * builder.AttributesToGet = attributesToGet; * options2use = builder.Build(); * } */ /* * if (attsToGet.Contains(ExchangeConnectorAttributes.AttDatabase)) * { * attsToGet.Remove(ExchangeConnectorAttributes.AttDatabase); * * // build new op options * var builder = new OperationOptionsBuilder(context.Options); * string[] attributesToGet = new string[attsToGet.Count]; * attsToGet.CopyTo(attributesToGet, 0); * builder.AttributesToGet = attributesToGet; * options2use = builder.Build(); * } */ } adconn.ExecuteQueryInternal(context.ObjectClass, context.Query, handler2use, options2use, GetAdAttributesToReturn(adconn, context.ObjectClass, context.Options)); }
public void Search(ObjectClass oclass, Filter filter, ResultsHandler handler, OperationOptions options) { ((SearchApiOp)this.GetOperationCheckSupported(SafeType <APIOperation> .Get <SearchApiOp>())).Search( oclass, filter, handler, options); }
public void ExecuteQuery(ObjectClass oclass, string query, ResultsHandler handler, OperationOptions options) { }
public void ExecuteQuery(ObjectClass oclass, string query, ResultsHandler handler, OperationOptions options) { Console.WriteLine("ExecuteQuery called"); }
private void Awake() { instance = this; DontDestroyOnLoad(this.gameObject); }
public SimulationControlHandler(MainScreen screen) { Screen = screen; Results = new ResultsHandler(Screen); }
public MsPowerShellSearchResults(ObjectClass objectClass, ResultsHandler handler) { _objectClass = objectClass; _handler = handler; }
protected void ExecuteQuery(String scriptName, ObjectClass objectClass, Filter query, ResultsHandler handler, OperationOptions options) { var arguments = new Dictionary <String, Object> { { Result, new MsPowerShellSearchResults(objectClass, handler) } }; if (query != null) { switch (_visitor) { case Visitors.Map: arguments.Add(Query, query.Accept <Dictionary <String, Object>, Hashtable>(new MapFilterVisitor(), _attrSubstitute)); break; case Visitors.AdPsModule: arguments.Add(Query, query.Accept <String, Hashtable>(new AdPsModuleFilterVisitor(), _attrSubstitute)); break; case Visitors.Ldap: arguments.Add(Query, query.Accept <String, Hashtable>(new LdapFilterVisitor(), _attrSubstitute)); break; case Visitors.NativeQuery: arguments.Add(Query, query); break; } } ExecuteScript(GetScript(scriptName), CreateBinding(arguments, OperationType.SEARCH, objectClass, null, null, options)); }
public void ExecuteQuery(ObjectClass objectClass, Filter query, ResultsHandler handler, OperationOptions options) { ICF.SortKey[] sortKeys = options.SortKeys; if (null == sortKeys) { sortKeys = new ICF.SortKey[] { new ICF.SortKey(Name.NAME, true) }; } // Rebuild the full result set. SortedSet <ConnectorObject> resultSet = new SortedSet <ConnectorObject>(new ResourceComparator(sortKeys)); if (null != query) { foreach (ConnectorObject co in collection.Values) { if (query.Accept(co)) { resultSet.Add(co); } } } else { resultSet.UnionWith(collection.Values); } // Handle the results if (null != options.PageSize) { // Paged Search string pagedResultsCookie = options.PagedResultsCookie; string currentPagedResultsCookie = options.PagedResultsCookie; int? pagedResultsOffset = null != options.PagedResultsOffset ? Math.Max(0, (int)options.PagedResultsOffset) : 0; int? pageSize = options.PageSize; int index = 0; int pageStartIndex = null == pagedResultsCookie ? 0 : -1; int handled = 0; foreach (ConnectorObject entry in resultSet) { if (pageStartIndex < 0 && pagedResultsCookie.Equals(entry.Name.GetNameValue())) { pageStartIndex = index + 1; } if (pageStartIndex < 0 || index < pageStartIndex) { index++; continue; } if (handled >= pageSize) { break; } if (index >= pagedResultsOffset + pageStartIndex) { if (handler.Handle(entry)) { handled++; currentPagedResultsCookie = entry.Name.GetNameValue(); } else { break; } } index++; } if (index == resultSet.Count) { currentPagedResultsCookie = null; } if (handler is SearchResultsHandler) { ((SearchResultsHandler)handler).HandleResult(new SearchResult(currentPagedResultsCookie, resultSet.Count - index)); } } else { // Normal Search foreach (ConnectorObject entry in resultSet) { if (!handler.Handle(entry)) { break; } } if (handler is SearchResultsHandler) { ((SearchResultsHandler)handler).HandleResult(new SearchResult()); } } }
/// <summary> /// Set the callback function from the caller to the query request /// </summary> /// <param name="finishedOperation"></param> public void SetFinishedEvent(ResultsHandler finishedOperation) { finishedQuery = finishedOperation; }