public async Task Lookup_logs_search_hit_in_l1()
        {
            var location = locationCreator.Create("AddedNow");
            await fakeLocationCacheFactory.Level1Cache.InsertAsync(location);

            var result = await locationCache.LookupAsync("AddedNow");

            Assert.Contains(fakeLocationCacheFactory.Logger.LoggedEventIds, l => l.Id == (int)LogEventIds.L1CacheManagerHit);
        }
        public async Task Lookup_logs_cache_hit_debug_when_found()
        {
            var location = locationCreator.Create("AddedNow");
            await locationCacheMemory.InsertAsync(location);

            var result = await locationCacheMemory.FindByKeyAsync(location.SourceKey);

            Assert.Contains(logger.LoggedEventIds, l => l.Id == (int)LogEventIds.L1MemoryCacheFound);
        }
예제 #3
0
        static void Main()
        {
            var app = new ApplicationService();

            var training = new TrainingCreator(app);
            var location = new LocationCreator(app);
            var trainer  = new TrainerCreator(app);
            var company  = new CompanyCreator(app);
            var student  = new StudentCreator(app);
            var contact  = new ContactCreator(app, company);
            var session  = new SessionCreator(app, training, trainer, location, student, company);

            var reader    = new MsAccessReader("c:\\temp\\Database1.mdb");
            var lineCount = 1;

            foreach (DataRow row in reader.GetRows("Formation"))
            {
                Console.Write($"Traitement de la ligne {lineCount++}\r");
                training.Create(row["Formation"].ToString());
                location.Create(row["Lieu"].ToString());
                trainer.Create(row["Formateur"].ToString());
                company.Create(row["Societe"].ToString(), row["Adresse"].ToString(), row["CP"].ToString(), row["Ville"].ToString());
                student.Create(row["Stagiaire"].ToString());
                contact.Create(row["Contact"].ToString(), row["Email"].ToString(), row["Telephone"].ToString(), row["Societe"].ToString());
                session.Create(DateTime.Parse(row["DateFormation"].ToString()), int.Parse(row["NbJour"].ToString()), row["Formation"].ToString(), row["Formateur"].ToString(), row["Lieu"].ToString(), row["Stagiaire"].ToString(), row["Societe"].ToString());
            }

            /*    DisableAll("Formations", training.GetAll(), id => app.Command<DisableTraining>().Execute(id));
             *  DisableAll("Lieux", location.GetAll(), id => app.Command<DisableLocation>().Execute(id));
             *  DisableAll("Formateur", trainer.GetAll(), id => app.Command<DisableTrainer>().Execute(id));*/

            Console.WriteLine("\r\nImport terminé !");
            Console.ReadKey();
        }
        public async Task <SawmillGeocodeRequest> LookupAsync(string value)
        {
            var location = locationCreator.Create(value);

            if (location.Status != SawmillStatus.RequiresLookup)
            {
                return(location); // Failed to validate as worth looking up.
            }

            // Is this value already in our L1 local (memory) cache?
            var cachedLocation = await level1Cache.FindByKeyAsync(location.SourceKey);

            if (cachedLocation != null)
            {
                logger?.LogDebug((int)LogEventIds.L1CacheManagerHit, "L1 hit: '{value}'", value);
                return(cachedLocation);
            }

            logger?.LogInformation((int)LogEventIds.L1CacheManagerMiss, "Cache miss: '{value}'", value);

            // No, is it in our L2 cheap storage db?
            cachedLocation = await level2Cache.FindByKeyAsync(location.SourceKey);

            if (cachedLocation != null)
            {
                logger?.LogDebug((int)LogEventIds.L2CacheManagerHit, "L2 hit: '{value}'", value);
                return(cachedLocation);
            }

            logger?.LogInformation((int)LogEventIds.L2CacheManagerMiss, "Cache miss: '{value}'", value);
            location.Status = SawmillStatus.RequiresGeocoding;

            // Cache this location in L1 (local) so we don't keep checking L2 (remote) if the same key comes up again.
            await level1Cache.InsertAsync(location);

            return(location);
        }