protected void ExecutarPDFs()
        {
            MxdLayout mxd = null;

            try
            {
                Arquivo file;

                switch (Project.Type)
                {
                case OPERACAO_DOMINIALIDADE:
                    mxd = new MxdLayout();
                    mxd.AbrirMxdLayout(ArquivoMxd.MAPA_DOMINIALIDADE, PageSize.A4);

                    #region Salvar arquivo

                    using (MemoryStream ms = _pdfCroqui.GerarPdfDominialidade(mxd))
                    {
                        //PDF com mapa = 7
                        file        = business.ObterArquivo(Project.Id, 7);
                        file.Buffer = new MemoryStream(ms.ToArray());
                        business.SalvarArquivo(file, Project.Id, 7);
                    }

                    #endregion

                    #region Alterar situação

                    log.IniciarTime("Alterar situação para PDF gerado");

                    business.SetConcluidoNaFila(Project.Id, Project.Type);
                    business.SetProcessado(Project.Id);

                    log.FinalizarTime();

                    #endregion

                    break;
                }
            }
            catch (Exception exc)
            {
                Log.GerarLog(exc);

                business.SetFalhaNaFila(Project.Id, Project.Type);
            }
            finally
            {
                if (mxd != null)
                {
                    mxd.FecharMxdLayout();
                }
            }
        }
예제 #2
0
        internal MemoryStream GerarPdfDominialidade(MxdLayout mxd)
        {
            Document doc = new Document(mxd.MxdPageSize, 85, 40, 73, 50);

            MemoryStream ms  = new MemoryStream();
            PdfWriter    wrt = PdfWriter.GetInstance(doc, ms);
            //wrt.SetEncryption(PdfWriter.STRENGTH128BITS, null, null, PdfWriter.AllowCopy | PdfWriter.AllowPrinting);


            //Cabecalho e Rodape
            Hashtable htConfiguracoes = ObterDadosCabecalhoRodapePDF(Project.Id, Project.Type);

            PdfCabecalhoRodape headerFooter = new PdfCabecalhoRodape();

            headerFooter.GovernoNome    = HasKey(htConfiguracoes, "GOVERNO_NOME") ? htConfiguracoes["GOVERNO_NOME"].ToString() : null;
            headerFooter.OrgaoCep       = HasKey(htConfiguracoes, "ORGAO_CEP") ? htConfiguracoes["ORGAO_CEP"].ToString() : null;
            headerFooter.OrgaoContato   = HasKey(htConfiguracoes, "ORGAO_CONTATO") ? htConfiguracoes["ORGAO_CONTATO"].ToString() : null;
            headerFooter.OrgaoEndereco  = HasKey(htConfiguracoes, "ORGAO_ENDERECO") ? htConfiguracoes["ORGAO_ENDERECO"].ToString() : null;
            headerFooter.OrgaoMunicipio = HasKey(htConfiguracoes, "ORGAO_MUNICIPIO") ? htConfiguracoes["ORGAO_MUNICIPIO"].ToString() : null;
            headerFooter.OrgaoNome      = HasKey(htConfiguracoes, "ORGAO_NOME") ? htConfiguracoes["ORGAO_NOME"].ToString() : null;
            headerFooter.OrgaoSigla     = HasKey(htConfiguracoes, "ORGAO_SIGLA") ? htConfiguracoes["ORGAO_SIGLA"].ToString() : null;
            headerFooter.OrgaoUF        = HasKey(htConfiguracoes, "ORGAO_UF") ? htConfiguracoes["ORGAO_UF"].ToString() : null;
            headerFooter.SecretariaNome = HasKey(htConfiguracoes, "SECRETARIA_NOME") ? htConfiguracoes["SECRETARIA_NOME"].ToString() : null;
            headerFooter.SetorNome      = HasKey(htConfiguracoes, "SETOR_NOME") ? htConfiguracoes["SETOR_NOME"].ToString() : null;

            wrt.PageEvent = headerFooter;
            //------------------------

            doc.Open();

            Hashtable hashData = ObterDadosPDF(Project.Id, Project.Type);

            mxd.GerarPdf(doc, wrt, Project.Id, hashData);
            GerarVersoDominialidade(doc, wrt, hashData);

            doc.Close();

            mxd.ApagarTempFile();

            return(ms);
        }