Esempio n. 1
0
        /// <summary>
        /// Asynchronously creates a new search <see cref="Job"/>.
        /// </summary>
        /// <remarks>
        /// This method uses the <a href="http://goo.gl/JZcPEb">POST search/jobs</a>
        /// endpoint to start a new search <see cref="Job"/> as specified by
        /// <paramref name="args"/>.
        /// </remarks>
        /// <param name="search">
        /// Search string.
        /// </param>
        /// <param name="count">
        ///
        /// </param>
        /// <param name="mode">
        ///
        /// </param>
        /// <param name="args">
        /// Optional search arguments.
        /// </param>
        /// <param name="customArgs">
        ///
        /// </param>
        /// <param name="requiredState">
        ///
        /// </param>
        /// <returns>
        /// An object representing the search job that was created.
        /// </returns>
        public virtual async Task <Job> CreateAsync(string search, int count    = 100,
                                                    ExecutionMode mode          = ExecutionMode.Normal, JobArgs args = null,
                                                    CustomJobArgs customArgs    = null,
                                                    DispatchState requiredState = DispatchState.Running)
        {
            var arguments = new Argument[]
            {
                new Argument("search", search),
                new Argument("count", count)
            }
            .AsEnumerable();

            if (args != null)
            {
                arguments = arguments.Concat(args);
            }

            if (customArgs != null)
            {
                arguments = arguments.Concat(customArgs);
            }

            var job = await this.CreateAsync(arguments, requiredState).ConfigureAwait(false);

            return(job);
        }
Esempio n. 2
0
 public Task <Job> SearchAsync(string search, int count = 0,
                               ExecutionMode mode       = ExecutionMode.Normal, JobArgs args = null,
                               CustomJobArgs customArgs = null)
 {
     Contract.Requires <ArgumentNullException>(search != null);
     return(default(Task <Job>));
 }
Esempio n. 3
0
 public Task <TJob> CreateAsync(string search, int count    = 100, ExecutionMode mode        = ExecutionMode.Normal,
                                JobArgs args                = null, CustomJobArgs customArgs = null,
                                DispatchState requiredState = DispatchState.Running)
 {
     Contract.Requires <ArgumentNullException>(search != null);
     return(default(Task <TJob>));
 }
        public virtual async Task <Job> Create(string search, int count = 0, // This version doesn't wait
                                               ExecutionMode mode       = ExecutionMode.Normal, JobArgs args = null,
                                               CustomJobArgs customArgs = null)
        {
            var arguments = new Argument[]
            {
                new Argument("search", search),
                new Argument("count", count)
            }
            .AsEnumerable();

            if (args != null)
            {
                arguments = arguments.Concat(args);
            }

            if (customArgs != null)
            {
                arguments = arguments.Concat(customArgs);
            }

            var job = await this.Create(arguments).ConfigureAwait(false);

            return(job);
        }
Esempio n. 5
0
        /// <inheritdoc/>
        public virtual async Task <Job> SearchAsync(string search, int count = 0,
                                                    ExecutionMode mode       = ExecutionMode.Normal, JobArgs args = null,
                                                    CustomJobArgs customArgs = null)
        {
            var job = await this.Jobs.CreateAsync(search, count, mode, args, customArgs).ConfigureAwait(false);

            return(job);
        }
Esempio n. 6
0
 public Task <SearchResultStream> SearchOneShotAsync(string search, int count = 0, JobArgs args = null, CustomJobArgs customArgs = null)
 {
     Contract.Requires <ArgumentNullException>(search != null);
     return(default(Task <SearchResultStream>));
 }
Esempio n. 7
0
 /// <inheritdoc/>
 public virtual async Task <bool> UpdateAsync(CustomJobArgs arguments)
 {
     return(await this.UpdateAsync(arguments.AsEnumerable()).ConfigureAwait(false));
 }
Esempio n. 8
0
        /// <inheritdoc/>
        public virtual async Task <SearchResultStream> SearchOneShotAsync(string search, int count = 0,
                                                                          JobArgs args             = null, CustomJobArgs customArgs = null)
        {
            var resourceName = JobCollection.ClassResourceName;

            var arguments = new SearchArgs
            {
                Search        = search,
                Count         = count,
                ExecutionMode = ExecutionMode.OneShot
            }
            .AsEnumerable();

            if (args != null)
            {
                arguments = arguments.Concat(args.Where(arg => arg.Name != "exec_mode"));
            }

            if (customArgs != null)
            {
                arguments = arguments.Concat(customArgs);
            }

            Response response = await this.Context.PostAsync(this.Namespace, resourceName, arguments).ConfigureAwait(false);

            try
            {
                await response.EnsureStatusCodeAsync(HttpStatusCode.OK).ConfigureAwait(false);

                var stream = await SearchResultStream.CreateAsync(response).ConfigureAwait(false); // Transfers response ownership

                return(stream);
            }
            catch
            {
                response.Dispose();
                throw;
            }
        }
Esempio n. 9
0
 public Task<SearchResultStream> SearchOneShotAsync(string search, int count = 0, JobArgs args = null, CustomJobArgs customArgs = null)
 {
     Contract.Requires<ArgumentNullException>(search != null);
     return default(Task<SearchResultStream>);
 }
Esempio n. 10
0
 public Task<Job> SearchAsync(string search, int count = 0, 
     ExecutionMode mode = ExecutionMode.Normal, JobArgs args = null,
     CustomJobArgs customArgs = null)
 {
     Contract.Requires<ArgumentNullException>(search != null);
     return default(Task<Job>);
 }
Esempio n. 11
0
 public Task<bool> UpdateAsync(CustomJobArgs arguments)
 {
     Contract.Requires(arguments != null);
     return default(Task<bool>);
 }
Esempio n. 12
0
 public Task <bool> UpdateAsync(CustomJobArgs arguments)
 {
     Contract.Requires(arguments != null);
     return(default(Task <bool>));
 }