Beispiel #1
0
 /// <summary>
 /// Get current word and word pair count
 /// </summary>
 /// <param name="scanJobEntity">Scan job</param>
 /// <param name="words">List of words</param>
 /// <param name="wordPairs">List of word pairs</param>
 void UpdateCount(ScanJobEntity scanJobEntity, Dictionary <string, int> words, Dictionary <string, int> wordPairs)
 {
     scanJobEntity.TopWords = (from w in words
                               orderby w.Value descending
                               select new TopWordEntity()
     {
         Word = w.Key, Count = w.Value
     }).Take(10).ToList();
     scanJobEntity.TopWordPairs = (from w in wordPairs
                                   orderby w.Value descending
                                   select new TopPairEntity()
     {
         Word = w.Key.Split(" ")[0],
         Second = w.Key.Split(" ")[1],
         Count = w.Value
     }).Take(10).ToList();
 }
Beispiel #2
0
        /// <summary>
        /// Enqueue jobs for background processing
        /// </summary>
        /// <param name="url">url to scan</param>
        /// <returns>Initial scan object before scaning is done</returns>
        public async Task <ScanJob> EnqueueJob(string url)
        {
            var job = new ScanJobEntity();

            job.Id        = Guid.NewGuid();
            job.JobStatus = ScanJobStatus.Pending;
            job.Url       = url;
            var jobData = _mapper.Map <ScanJob>(job);

            _storageManager.AddScanJobs(job);
            _queue.QueueItem(async token =>
            {
                await Process(jobData);
            });
            await Task.Yield(); //Faking await inside async method

            return(jobData);
        }