Ejemplo n.º 1
0
        public static async Task <string> DownloadAndUpdateAudio(string waveFile)
        {
            if (string.IsNullOrWhiteSpace(waveFile))
            {
                return("");
            }

            var stream = await MariamWebseter.DownlaodAudioAsync(waveFile);

            return(AzureBlobStorage.Upload(waveFile, stream));
        }
Ejemplo n.º 2
0
        public async static Task <WordDefinitions> CachedLookUp(string word, TraceWriter log = null)
        {
            log?.Info($"cache lookup: {word}");
            string xmlText = await AzureTableStorage.LookupCachedWord(word);

            var definitions = MariamWebseter.Parse(word, xmlText);

            if (definitions.Entreis.Any())
            {
                return(definitions);
            }

            log?.Info($"2nd level lookup: {word}");
            xmlText = await MariamWebseter.LookupMarimWebsterStudent2(word);

            definitions = MariamWebseter.Parse(word, xmlText);
            if (definitions.Entreis.Any())
            {
                definitions.AudioFiles = DownloadAndUpdateAudios(definitions.AudioFiles);
                await AzureTableStorage.SaveWordDefinition(word, xmlText, definitions.AudioFiles);

                return(definitions);
            }

            log?.Info($"3nd level lookup: {word}");
            xmlText = await MariamWebseter.LookupMarimWebsterStudent3(word);

            definitions = MariamWebseter.Parse(word, xmlText);
            if (definitions.Entreis.Any())
            {
                definitions.AudioFiles = DownloadAndUpdateAudios(definitions.AudioFiles);
                await AzureTableStorage.SaveWordDefinition(word, xmlText, definitions.AudioFiles);

                return(definitions);
            }

            return(definitions);
        }