Ejemplo n.º 1
0
        public async Task <IEnumerable <Anbima> > GetByDate(DateTime date)
        {
            if (DateTime.Now.Date.Subtract(date).Days >= 7)
            {
                Logger.LogInformation("Date cannot exceed 7 days limit", date);
                throw new ArgumentException("Date cannot exceed 7 days limit");
            }

            string anbimaUrl = Configuration.GetSection("Url").GetSection("Anbima").Value.Replace("{date}", date.ToString("yyMMdd"));

            string[] anbimaLines = await HttpRepository.GetAsync(anbimaUrl);

            if (anbimaLines.Length < 3)
            {
                Logger.LogWarning("Anbima don't have sufficient lines", anbimaLines);
                throw new ArgumentOutOfRangeException("Anbima don't have sufficient lines");
            }

            anbimaLines = anbimaLines.Where(x => !string.IsNullOrEmpty(x) && !x.StartsWith("\r")).ToArray();
            anbimaLines = anbimaLines.Skip(2).ToArray(); // Skiping title and headers

            IEnumerable <Anbima> buildedAnbima = new Anbima().Build(anbimaLines);

            Logger.LogInformation("file was builded");

            await AnbimaRepository.Add(buildedAnbima);

            await UnitOfWork.Commit();

            Logger.LogInformation("File was save on database");

            return(buildedAnbima);
        }
Ejemplo n.º 2
0
        public virtual async Task <object> GetTempMaterialAsync(string media_id)
        {
            var access_token = await _lazyWeChatBasic.GetAccessTokenAsync();

            var url = string.Format(CONSTANT.GETTEMPMATERIALURL, access_token, media_id);
            var res = await _httpRepository.GetAsync(url);

            if (res.Contains("video_url"))
            {
                var returnObject = UtilRepository.ParseAPIResult(res);
                return(returnObject);
            }
            else
            {
                byte[] byteArray = Encoding.Default.GetBytes(res);
                return(byteArray);
            }
        }
Ejemplo n.º 3
0
 public async Task <SearchReponse> FindById(string id)
 {
     return(await _http.GetAsync <SearchReponse>($"{_baseUrl}/{id}"));
 }