public static Dictionary <DocInfoType, List <DocLinkInfo> > LoadDocLinksForCompany(this ScrappedCompany company)
        {
            var filename = company.GetLinksFileName();

            log.Info($"Carregando links da empresa {company.RazaoSocial} - {filename}");
            string json = File.ReadAllText(filename);

            return(JsonConvert.DeserializeObject <Dictionary <DocInfoType, List <DocLinkInfo> > >(json));
        }
Exemple #2
0
        private static Dictionary <DocInfoType, List <DocLinkInfo> > LoadLinks(ScrappedCompany company)
        {
            var file = company.GetLinksFileName();

            if (!File.Exists(file))
            {
                Console.WriteLine($"arquivo de links da empresa {company.RazaoSocial} não existe");
                log.Error($"arquivo de links da empresa {company.RazaoSocial} não existe");
                return(null);
            }
            string content = File.ReadAllText(file);

            return(JsonConvert.DeserializeObject <Dictionary <DocInfoType, List <DocLinkInfo> > >(content));
        }
        public static void SaveDocLinks(this ScrappedCompany c, Dictionary <DocInfoType, List <DocLinkInfo> > links)
        {
            log.Info($"Salvando arquivo de links para a empresa {c.RazaoSocial}");

            var filename = c.GetLinksFileName();

            log.Info($"File={filename}");

            string json = JsonConvert.SerializeObject(links, Formatting.Indented);

            var dir = Path.GetDirectoryName(filename);

            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }

            File.WriteAllText(filename, json);
        }