Esempio n. 1
0
        private void DownloadXml(CurriculoEntry curriculumVitae, MetadataResponse response, WebClient wc)
        {
            var link = String.Format(_urlDownloadXml, response.CodRhCript);

            Logger.Debug($"Currículo {curriculumVitae.NumeroCurriculo} marcado para download ({link})...");
            var stream = wc.OpenRead(link);

            if (File.Exists(_lattesModule.GetCurriculumVitaeFileName(curriculumVitae.NumeroCurriculo)))
            {
                File.Delete(_lattesModule.GetCurriculumVitaeFileName(curriculumVitae.NumeroCurriculo));
            }

            var zis = new ZipInputStream(stream);

            zis.GetNextEntry();
            FileStream xml = new FileStream(_lattesModule.GetCurriculumVitaeFileName(curriculumVitae.NumeroCurriculo), FileMode.CreateNew);

            var buffer = new byte[4096];
            int read;

            while ((read = zis.Read(buffer, 0, buffer.Length)) > 0)
            {
                xml.Write(buffer, 0, read);
            }
            xml.Close();

            _curriculumVitaesForProcess.Send(curriculumVitae);
        }
Esempio n. 2
0
        private bool NeedsToBeUpdated(CurriculoEntry curriculumVitae, MetadataResponse response)
        {
            if (response.Document.DataAtualizacao == null || response.Document.DataAtualizacao.Length == 0)
            {
                return(true);
            }

            var horaAtualizacao = response.Document.HoraAtualizacao;

            if (horaAtualizacao == null || horaAtualizacao.Length == 0)
            {
                horaAtualizacao = "000000";
            }

            var dataAtualizacaoLattes = DateTime.ParseExact(
                $"{response.Document.DataAtualizacao} {horaAtualizacao}",
                "ddMMyyyy %Hmmss",
                null
                );

            if (dataAtualizacaoLattes == null)
            {
                return(true);
            }

            var dataAtualizacaoCorrente = GetDataAtualizacaoProfessor(curriculumVitae.NumeroCurriculo);

            if (dataAtualizacaoCorrente == null)
            {
                return(true);
            }

            if (dataAtualizacaoCorrente < dataAtualizacaoLattes)
            {
                return(true);
            }

            return(false);
        }