public ICabecalhoRodape ObterEnderecoSetor(ICabecalhoRodape cabecalhoRodape, int setorId) { CabecalhoRodapeDa da = new CabecalhoRodapeDa(); SetorEndereco end = da.ObterEndSetor(setorId); cabecalhoRodape = FormatarEndereco(cabecalhoRodape, end); cabecalhoRodape.SetorNome = _configFunc.Obter <List <Setor> >(ConfiguracaoFuncionario.KeySetores).Single(x => x.Id == setorId).Nome; return(cabecalhoRodape); }
public ICabecalhoRodape ObterEnderecoFuncLogado(ICabecalhoRodape cabecalhoRodape) { CabecalhoRodapeDa da = new CabecalhoRodapeDa(); if ((HttpContext.Current.User.Identity as EtramiteIdentity) == null || (HttpContext.Current.User.Identity as EtramiteIdentity).FuncionarioId <= 0 || (HttpContext.Current.User.Identity as EtramiteIdentity).ExecutorTipo != (int)eExecutorTipo.Interno) { return(cabecalhoRodape); } int setorId = da.ObterFuncSetor((HttpContext.Current.User.Identity as EtramiteIdentity).FuncionarioId); SetorEndereco end = da.ObterEndSetor(setorId); cabecalhoRodape = FormatarEndereco(cabecalhoRodape, end); var setor = _configFunc.Obter <List <Setor> >(ConfiguracaoFuncionario.KeySetores).SingleOrDefault(x => x.Id == setorId); setor = setor ?? new Setor(); cabecalhoRodape.SetorNome = setor.Nome; return(cabecalhoRodape); }
public MemoryStream GerarLaudoFiscalizacaoNovo(int id, bool gerarTarja = true, BancoDeDados banco = null) { ArquivoDocCaminho = @"~/Content/_pdfAspose/Laudo_de_Fiscalizacao_Novo.docx"; FiscalizacaoRelatorioNovo dataSource = _da.ObterNovo(id, banco); dataSource.Sessao = new Sessoes() { Empreendimento = AsposeData.Empty, Multa = AsposeData.Empty, InterdicaoEmbargo = AsposeData.Empty, Apreensao = AsposeData.Empty, OutrasPenalidades = AsposeData.Empty }; ConfiguracaoDefault.TextoTagAssinante = "«Assinante.Nome»"; ConfiguracaoDefault.TextoTagAssinantes1 = "«TableStart:Assinantes1»"; ConfiguracaoDefault.TextoTagAssinantes2 = "«TableStart:Assinantes2»"; if (dataSource.ConsideracoesFinais != null && dataSource.ConsideracoesFinais.Assinantes != null && dataSource.ConsideracoesFinais.Assinantes.Count > 0) { var autor = dataSource.ConsideracoesFinais.Assinantes.First(x => x.Id == dataSource.UsuarioCadastro.Id); if (autor != null) { dataSource.ConsideracoesFinais.Assinantes.Remove(autor); dataSource.ConsideracoesFinais.Assinantes.Insert(0, autor); } ConfiguracaoDefault.Assinantes = dataSource.ConsideracoesFinais.Assinantes.Cast <IAssinante>().ToList(); } ConfigurarCabecarioRodape(dataSource.LocalInfracao.SetorId); if (dataSource.ConsideracoesFinais.Anexos != null && dataSource.ConsideracoesFinais.Anexos.Count > 0) { foreach (ConsideracoesFinaisAnexoRelatorio anexo in dataSource.ConsideracoesFinais.Anexos) { anexo.Arquivo.Conteudo = AsposeImage.RedimensionarImagem(File.ReadAllBytes(anexo.Arquivo.Caminho), 11, eAsposeImageDimensao.Ambos); } } ObterArquivoTemplate(); object objeto = dataSource; #region Remover this.ConfiguracaoDefault.AddLoadAcao((doc, a) => { List <Table> itenRemover = new List <Table>(); FiscalizacaoRelatorioNovo fiscalizacao = (FiscalizacaoRelatorioNovo)dataSource; CabecalhoRodapeDa _daCabecalho = new CabecalhoRodapeDa(); SetorEndereco endereco = _daCabecalho.ObterEndSetor(fiscalizacao.LocalInfracao.SetorId); fiscalizacao.OrgaoMunicipio = endereco.MunicipioTexto; fiscalizacao.OrgaoUF = endereco.EstadoTexto; //fiscalizacao.OrgaoMunicipio = _configSys.Obter<String>(ConfiguracaoSistema.KeyOrgaoMunicipio); //fiscalizacao.OrgaoUF = _configSys.Obter<String>(ConfiguracaoSistema.KeyOrgaoUf); if (fiscalizacao.Infracao.Campos.Count == 0) { doc.Find <Row>("«TableStart:Infracao.Campos»").Remove(); } if (fiscalizacao.Infracao.Perguntas.Count == 0) { doc.Find <Row>("«TableStart:Infracao.Perguntas»").Remove(); } if (fiscalizacao.ConsideracoesFinais.Anexos.Count == 0) { itenRemover.Add(doc.Last <Table>("«TableStart:ConsideracoesFinais.Anexos»")); doc.RemovePageBreak(); } //Remove as seções que não foram preenchidas if (fiscalizacao.Multa == null) { doc.Find <Row>("«Secao.Multa»").Remove(); } else { } if (fiscalizacao.ObjetoInfracao == null) { doc.Find <Row>("«Secao.InterdicaoEmbargo»").Remove(); } if (fiscalizacao.MaterialApreendido == null) { doc.Find <Row>("«Secao.Apreensao»").Remove(); } else { if (fiscalizacao.MaterialApreendido.ProdutosDestinacoes == null || fiscalizacao.MaterialApreendido.ProdutosDestinacoes.Count == 0) { doc.Find <Row>("«TableStart:MaterialApreendido.ProdutosDestinacoes»").Remove(); } } if (fiscalizacao.OutrasPenalidades == null) { doc.Find <Row>("«Secao.OutrasPenalidades»").Remove(); } if (fiscalizacao.LocalInfracao.EmpreendimentoId == 0) { doc.Find <Row>("«Secao.Empreendimento»").Remove(); } AsposeExtensoes.RemoveTables(itenRemover); }); #endregion Remover ConfiguracaoDefault.ExibirSimplesConferencia = gerarTarja; return(GerarPdf(dataSource)); }
private ICabecalhoRodape FormatarEndereco(ICabecalhoRodape cabecalhoRodape, SetorEndereco end) { if (!String.IsNullOrEmpty(end.Logradouro) || !String.IsNullOrEmpty(end.Numero) || !String.IsNullOrEmpty(end.Bairro)) { cabecalhoRodape.OrgaoEndereco = String.Empty; if (!String.IsNullOrEmpty(end.Logradouro)) { cabecalhoRodape.OrgaoEndereco = end.Logradouro; } if (!String.IsNullOrEmpty(end.Numero)) { cabecalhoRodape.OrgaoEndereco = String.Format("{0}, Nº {1}", cabecalhoRodape.OrgaoEndereco, end.Numero); } if (!String.IsNullOrEmpty(end.Bairro)) { cabecalhoRodape.OrgaoEndereco = String.Format("{0} - {1}", cabecalhoRodape.OrgaoEndereco, end.Bairro); } if (!String.IsNullOrEmpty(cabecalhoRodape.OrgaoEndereco)) { cabecalhoRodape.OrgaoEndereco += ", "; } } else { cabecalhoRodape.OrgaoEndereco = AsposeData.Empty; } if (!String.IsNullOrEmpty(end.MunicipioTexto) && !String.IsNullOrEmpty(end.EstadoTexto)) { cabecalhoRodape.OrgaoMunicipio = String.Format("{0}/", end.MunicipioTexto); cabecalhoRodape.OrgaoUF = String.Format("{0}, ", end.EstadoTexto); } else { cabecalhoRodape.OrgaoMunicipio = AsposeData.Empty; cabecalhoRodape.OrgaoUF = AsposeData.Empty; } if (!String.IsNullOrEmpty(end.CEP)) { cabecalhoRodape.OrgaoCep = String.Format("CEP: {0}.", end.CEP); } else { cabecalhoRodape.OrgaoCep = AsposeData.Empty; } if (!String.IsNullOrEmpty(end.Fone) || !String.IsNullOrEmpty(end.FoneFax)) { if (!String.IsNullOrEmpty(end.Fone)) { cabecalhoRodape.OrgaoContato = String.Format("Fone: {0}", end.Fone); } if (!String.IsNullOrEmpty(end.FoneFax)) { cabecalhoRodape.OrgaoContato = String.Format("{0}{1}", cabecalhoRodape.OrgaoContato, (!String.IsNullOrEmpty(end.Fone) ? " - " : string.Empty)); cabecalhoRodape.OrgaoContato += String.Format("Fax: {0}", end.FoneFax); } } else { cabecalhoRodape.OrgaoContato = AsposeData.Empty; } return(cabecalhoRodape); }
public SetorEndereco ObterEndSetor(int setorId, BancoDeDados banco = null) { SetorEndereco end = new SetorEndereco(); using (BancoDeDados bancoDeDados = BancoDeDados.ObterInstancia(banco)) { Comando comando = bancoDeDados.CriarComando(@"select e.id, e.setor, e.cep, e.logradouro, e.bairro, e.estado estadoid, le.sigla estadotexto, e.municipio municipioid, lm.texto municipiotexto, e.numero, e.distrito, e.complemento, e.fone, e.fone_fax, e.tid from {0}tab_setor_endereco e, {0}lov_estado le, {0}lov_municipio lm where e.setor = :setor and e.estado = le.id(+) and e.municipio = lm.id(+)" , EsquemaBanco); comando.AdicionarParametroEntrada("setor", setorId, DbType.Int32); IDataReader reader = bancoDeDados.ExecutarReader(comando); if (reader.Read()) { end = new SetorEndereco(); if (reader["cep"] != null && !Convert.IsDBNull(reader["cep"])) { end.CEP = reader["cep"].ToString(); } if (reader["logradouro"] != null && !Convert.IsDBNull(reader["logradouro"])) { end.Logradouro = reader["logradouro"].ToString(); } if (reader["bairro"] != null && !Convert.IsDBNull(reader["bairro"])) { end.Bairro = reader["bairro"].ToString(); } if (reader["estadoid"] != null && !Convert.IsDBNull(reader["estadoid"])) { end.EstadoId = Convert.ToInt32(reader["estadoid"]); } if (reader["estadotexto"] != null && !Convert.IsDBNull(reader["estadotexto"])) { end.EstadoTexto = reader["estadotexto"].ToString(); } if (reader["municipioid"] != null && !Convert.IsDBNull(reader["municipioid"])) { end.MunicipioId = Convert.ToInt32(reader["municipioid"]); } if (reader["municipiotexto"] != null && !Convert.IsDBNull(reader["municipiotexto"])) { end.MunicipioTexto = reader["municipiotexto"].ToString(); } if (reader["numero"] != null && !Convert.IsDBNull(reader["numero"])) { end.Numero = reader["numero"].ToString(); } if (reader["distrito"] != null && !Convert.IsDBNull(reader["distrito"])) { end.Distrito = reader["distrito"].ToString(); } if (reader["complemento"] != null && !Convert.IsDBNull(reader["complemento"])) { end.Complemento = reader["complemento"].ToString(); } if (reader["fone"] != null && !Convert.IsDBNull(reader["fone"])) { end.Fone = reader["fone"].ToString(); } if (reader["fone_fax"] != null && !Convert.IsDBNull(reader["fone_fax"])) { end.FoneFax = reader["fone_fax"].ToString(); } if (reader["tid"] != null && !Convert.IsDBNull(reader["tid"])) { end.Tid = reader["tid"].ToString(); } } reader.Close(); } return(end); }