コード例 #1
0
        public void SendEmail(int IDInstituicao)
        {
            string _body   = "";
            string strBody = "";

            var config = new ConfigurationBuilder()
                         .SetBasePath(Directory.GetCurrentDirectory())
                         .AddJsonFile("appsettings.json")
                         .Build();

            Instituicao _instituicao = GetById(IDInstituicao);

            _body  = "<tr bgcolor='#D6EFDA'><td colspan=2  style='font-weight:bold'>INSTITUIÇÃO</td></tr>";
            _body += "<tr style='=font-weight:bold;'>";
            _body += "<td font-weight:bold'><b>Proponente: </b>" + _instituicao.sProponente + "</td>";
            _body += "<td font-weight:bold'><b>CNPJ: </b>" + _instituicao.sCNPJ + "</td></tr>";

            _body += "<tr style='=font-weight:bold;'>";
            _body += "<td font-weight:bold'><b>Endereço: </b>" + _instituicao.sEndereco + "</td>";
            _body += "<td font-weight:bold'><b>CEP: </b>" + _instituicao.sCep + "</td></tr>";

            _body += "<tr style='=font-weight:bold;'>";
            _body += "<td font-weight:bold'><b>Telefone: </b>" + _instituicao.sTelefone + "</td>";
            _body += "<td font-weight:bold'<b>Fax: </b>" + _instituicao.sFax + "</td></tr>";

            _body += "<tr style='=font-weight:bold;'>";
            _body += "<td font-weight:bold' colspan=2><b>Municipio: </b>" + _instituicao.IDCidade + "</td></tr>";

            _body += "<tr style='=font-weight:bold;'>";
            _body += "<td font-weight:bold'<b>Email: </b>" + _instituicao.sEmail + "</td>";
            _body += "<td font-weight:bold'><b>HomePage: </b>" + _instituicao.sHomePage + "</td></tr>";

            _body += "<tr style='=font-weight:bold;'>";

            switch (_instituicao.iRegime)
            {
            case 1:
                _body += "<td font-weight:bold'<b>Regime: </b>Direito Público</td>";

                break;

            case 2:
                _body += "<td font-weight:bold'<b>Regime: </b>Direito Privado</td>";

                break;
            }

            switch (_instituicao.iEsfera)
            {
            case 1:
                _body += "<td font-weight:bold'<b>Esfera: </b>Federal</td></tr>";
                break;

            case 2:
                _body += "<td font-weight:bold'<b>Esfera: </b>Estadual</td></tr>";
                break;

            case 3:
                _body += "<td font-weight:bold'<b>Esfera: </b>Municipal</td></tr>";
                break;

            case 4:
                _body += "<td font-weight:bold'<b>Esfera: </b>Organização Ambientalista</td></tr>";
                break;

            case 5:
                _body += "<td font-weight:bold'<b>Esfera: </b>Outros</td></tr>";
                break;
            }

            _body += "<tr bgcolor='#D6EFDA'><td colspan=2  style='font-weight:bold'>REPRESENTANTE</td></tr>";

            _body += "<td font-weight:bold'><b>Representante: </b>" + _instituicao.sRepresentante + "</td>";
            _body += "<td font-weight:bold'><b>Cpf: </b>" + _instituicao.sCpfRepresentante + "</td>";
            _body += "<tr><td font-weight:bold'><b>Cargo: </b>" + _instituicao.sCargo + "</td>";
            _body += "<td font-weight:bold'><b>Função: </b>" + _instituicao.sFuncao + "</td></tr>";
            _body += "<tr><td font-weight:bold'><b>Rg: </b>" + _instituicao.sRG + "</td>";
            _body += "<td font-weight:bold'><b>Órgão Expedidor: </b>" + _instituicao.sOrgaoExpedidor + "</td></tr>";
            _body += "<tr><td font-weight:bold' colspan=2><b>Endereço Representante: </b>" + _instituicao.sEnderecoRepresentante + "</td></tr>";
            _body += "<tr><td font-weight:bold'><b>Telefone: </b>" + _instituicao.sTelefoneRepresentante + "</td>";
            _body += "<td font-weight:bold'><b>CEP: </b>" + _instituicao.sCepRepresentante + "</td></tr>";

            _body += "<tr bgcolor='#D6EFDA'><td colspan=2  style='font-weight:bold'>COORDENADOR</td></tr>";
            _body += "<tr><td font-weight:bold'><b>Coordenador: </b>" + _instituicao.sCoordenador + "</td>";
            _body += "<td font-weight:bold'><b>Cpf: </b>" + _instituicao.sCPFCoordenador + "</td></tr>";
            _body += "<tr><td font-weight:bold'><b>Telefone: </b>" + _instituicao.sTelefoneCoordenador + "</TD>";
            _body += "<td font-weight:bold'><b>Fax: </b>" + _instituicao.sFaxCoordenador + "</td></tr>";

            strBody = "";
            strBody = strBody + "<html>";
            strBody = strBody + "<head>";
            strBody = strBody + "<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>";
            strBody = strBody + "<title>Untitled Document</title>";
            strBody = strBody + "</head>";
            strBody = strBody + "<body>";

            strBody = strBody + "<table style='font-family: verdana; font-size: 11px; color: #000000;' width='100%'>";
            strBody = strBody + "<tr align=center><td colspan=2><img src='cid:Imagem1' /></td></tr>";
            strBody = strBody + "<tr align=center><td colspan=2></td></tr>";
            strBody = strBody + "<tr style='=font-weight:bold;' align=center><td colspan=2>PROCURADORIA GERAL DE JUSTIÇA</td></tr>";
            strBody = strBody + "<tr style='=font-weight:bold;' align=center><td colspan=2>MINISTÉRIO PÚBLICO DO ESTADO DO CEARÁ</td></tr>";

            strBody = strBody + "<tr><td font-weight:bold'><p><p></td></tr> ";
            strBody = strBody + _body;
            strBody = strBody + "</table> ";
            strBody = strBody + "<br><br>";
            strBody = strBody + "ATENÇÃO: O cadastro da instituição somente estará completo após a anexação dos arquivos relacionados à documentação comprobatória exigida em edital! ";
            strBody = strBody + "<a href='" + config.GetSection(key: "Config")["sSite"] + "'>Clique AQUI<a>";
            strBody = strBody + " para entrar no sistema e concluir o cadastro anexando os arquivos necessários.";
            strBody = strBody + "<br><br>";
            strBody = strBody + "Esta é uma  mensagem automática enviada pelo sistema. Não precisa responder.";
            strBody = strBody + "</body>";
            strBody = strBody + "</html>";

            Diversos.SendEmail(config.GetSection(key: "Config")["sEmailSend"], "[PROJETOS FDID] Nova instituição cadastrada", strBody, null, _instituicao.sEmail);
        }
コード例 #2
0
        public void SendEmail(int IDProjeto, int iTipo)
        {
            string _body   = "";
            string strBody = "";

            var config = new ConfigurationBuilder()
                         .SetBasePath(Directory.GetCurrentDirectory())
                         .AddJsonFile("appsettings.json")
                         .Build();

            Projeto _projeto = GetById(IDProjeto);

            _body  = "<tr bgcolor='#D6EFDA'><td colspan=2  style='font-weight:bold'>INSTITUIÇÃO</td></tr>";
            _body += "<tr style='=font-weight:bold;'>";
            _body += "<td font-weight:bold'><b>Proponente: </b>" + _projeto.Instituicao.sProponente + "</td>";
            _body += "<td font-weight:bold'><b>CNPJ: </b>" + _projeto.Instituicao.sCNPJ + "</td></tr>";

            _body += "<tr style='=font-weight:bold;'>";
            _body += "<td font-weight:bold'><b>Endereço: </b>" + _projeto.Instituicao.sEndereco + "</td>";
            _body += "<td font-weight:bold'><b>CEP: </b>" + _projeto.Instituicao.sCep + "</td></tr>";

            _body += "<tr style='=font-weight:bold;'>";
            _body += "<td font-weight:bold'><b>Telefone: </b>" + _projeto.Instituicao.sTelefone + "</td>";
            _body += "<td font-weight:bold'<b>Fax: </b>" + _projeto.Instituicao.sFax + "</td></tr>";

            _body += "<tr style='=font-weight:bold;'>";
            _body += "<td font-weight:bold' colspan=2><b>Municipio: </b>" + _projeto.Instituicao.IDCidade + "</td></tr>";

            _body += "<tr style='=font-weight:bold;'>";
            _body += "<td font-weight:bold'<b>Email: </b>" + _projeto.Instituicao.sEmail + "</td>";
            _body += "<td font-weight:bold'><b>HomePage: </b>" + _projeto.Instituicao.sHomePage + "</td></tr>";

            _body += "<tr style='=font-weight:bold;'>";

            switch (_projeto.Instituicao.iRegime)
            {
            case 1:
                _body += "<td font-weight:bold'<b>Regime: </b>Direito Público</td>";

                break;

            case 2:
                _body += "<td font-weight:bold'<b>Regime: </b>Direito Privado</td>";

                break;
            }

            switch (_projeto.Instituicao.iEsfera)
            {
            case 1:
                _body += "<td font-weight:bold'<b>Esfera: </b>Federal</td></tr>";
                break;

            case 2:
                _body += "<td font-weight:bold'<b>Esfera: </b>Estadual</td></tr>";
                break;

            case 3:
                _body += "<td font-weight:bold'<b>Esfera: </b>Municipal</td></tr>";
                break;

            case 4:
                _body += "<td font-weight:bold'<b>Esfera: </b>Organização Ambientalista</td></tr>";
                break;

            case 5:
                _body += "<td font-weight:bold'<b>Esfera: </b>Outros</td></tr>";
                break;
            }

            _body += "<tr bgcolor='#D6EFDA'><td colspan=2  style='font-weight:bold'>REPRESENTANTE</td></tr>";

            _body += "<td font-weight:bold'><b>Representante: </b>" + _projeto.Instituicao.sRepresentante + "</td>";
            _body += "<td font-weight:bold'><b>Cpf: </b>" + _projeto.Instituicao.sCpfRepresentante + "</td>";
            _body += "<tr><td font-weight:bold'><b>Cargo: </b>" + _projeto.Instituicao.sCargo + "</td>";
            _body += "<td font-weight:bold'><b>Função: </b>" + _projeto.Instituicao.sFuncao + "</td></tr>";
            _body += "<tr><td font-weight:bold'><b>Rg: </b>" + _projeto.Instituicao.sRG + "</td>";
            _body += "<td font-weight:bold'><b>Órgão Expedidor: </b>" + _projeto.Instituicao.sOrgaoExpedidor + "</td></tr>";
            _body += "<tr><td font-weight:bold' colspan=2><b>Endereço Representante: </b>" + _projeto.Instituicao.sEnderecoRepresentante + "</td></tr>";
            _body += "<tr><td font-weight:bold'><b>Telefone: </b>" + _projeto.Instituicao.sTelefoneRepresentante + "</td>";
            _body += "<td font-weight:bold'><b>CEP: </b>" + _projeto.Instituicao.sCepRepresentante + "</td></tr>";

            _body += "<tr bgcolor='#D6EFDA'><td colspan=2  style='font-weight:bold'>COORDENADOR</td></tr>";
            _body += "<tr><td font-weight:bold'><b>Coordenador: </b>" + _projeto.Instituicao.sCoordenador + "</td>";
            _body += "<td font-weight:bold'><b>Cpf: </b>" + _projeto.Instituicao.sCPFCoordenador + "</td></tr>";
            _body += "<tr><td font-weight:bold'><b>Telefone: </b>" + _projeto.Instituicao.sTelefoneCoordenador + "</TD>";
            _body += "<td font-weight:bold'><b>Fax: </b>" + _projeto.Instituicao.sFaxCoordenador + "</td></tr>";

            _body += "<tr bgcolor='#D6EFDA'><td colspan=2  style='font-weight:bold'>PROJETO</td></tr>";

            _body += "<tr><td font-weight:bold' colspan=2><b>Título: </b>" + _projeto.sTitulo + "</td>";

            _body += "<tr><td font-weight:bold' colspan=2><b>Area </b></td></tr>";

            foreach (int item in _projeto.sArea)
            {
                switch (item)
                {
                case 1:
                    _body += "<tr><td font-weight:bold' colspan=2>Meio Ambiente</td></tr>";
                    break;

                case 2:
                    _body += "<tr><td font-weight:bold' colspan=2>Consumidor</td></tr>";
                    break;

                case 3:
                    _body += "<tr><td font-weight:bold' colspan=2>Defesa da Concorrencia</td></tr>";
                    break;

                case 4:
                    _body += "<tr><td font-weight:bold' colspan=2>Artístico</td></tr>";
                    break;

                case 5:
                    _body += "<tr><td font-weight:bold' colspan=2>Estítico</td></tr>";
                    break;

                case 6:
                    _body += "<tr><td font-weight:bold' colspan=2>Histórico</td></tr>";
                    break;

                case 7:
                    _body += "<tr><td font-weight:bold' colspan=2>Turístico</td></tr>";
                    break;

                case 8:
                    _body += "<tr><td font-weight:bold' colspan=2>Paisagismo</td></tr>";
                    break;

                case 9:
                    _body += "<tr><td font-weight:bold' colspan=2>Direitos Difusos</td></tr>";
                    break;

                case 10:
                    _body += "<tr><td font-weight:bold' colspan=2>Reaparelhamento e Modernização</td></tr>";
                    break;
                }
            }

            _body += "<tr><td font-weight:bold'><b>Município: </b>" + _projeto.IDCidade + "</td>";
            _body += "<tr><b>Número do Processo: </b>" + _projeto.sNoProcesso + "</td></tr>";
            _body += "<tr><td font-weight:bold'><b>Início: </b>" + _projeto.dDataInicio + "</td>";
            _body += "<td font-weight:bold'><b>Termino: </b>" + _projeto.dDataTermino + "</td></tr>";
            _body += "<tr><td font-weight:bold'><b>Valor do Projeto: </b>" + _projeto.mValor + "</td>";
            _body += "<td font-weight:bold'><b>Valor da Contrapartida: </b>" + _projeto.mValorContraPartida + "</td></tr>";
            _body += "<tr><td font-weight:bold' colspan=2><b>Resumo: </b>" + _projeto.tResumo + "</td></tr>";

            List <string> _anexos = new List <string>();

            foreach (Arquivo item in _projeto.Arquivo)
            {
                if (item != null)
                {
                    _anexos.Add(Diversos.PathArquivo(item.sNomebase, "PROJETO"));
                }
            }

            strBody = "";
            strBody = strBody + "<html>";
            strBody = strBody + "<head>";
            strBody = strBody + "<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>";
            strBody = strBody + "<title>Untitled Document</title>";
            strBody = strBody + "</head>";
            strBody = strBody + "<body>";

            strBody = strBody + "<table style='font-family: verdana; font-size: 11px; color: #000000;' width='100%'>";
            strBody = strBody + "<tr align=center><td colspan=2><img src='cid:Imagem1' /></td></tr>";
            strBody = strBody + "<tr align=center><td colspan=2></td></tr>";
            strBody = strBody + "<tr style='=font-weight:bold;' align=center><td colspan=2>PROCURADORIA GERAL DE JUSTIÇA</td></tr>";
            strBody = strBody + "<tr style='=font-weight:bold;' align=center><td colspan=2>MINISTÉRIO PÚBLICO DO ESTADO DO CEARÁ</td></tr>";

            strBody = strBody + "<tr><td font-weight:bold'><p><p></td></tr> ";
            strBody = strBody + _body;
            strBody = strBody + "</table> ";
            strBody = strBody + "<br><br>";
            strBody = strBody + "<a href='" + config.GetSection(key: "Config")["sSite"] + "'>Clique aqui para visualizar o projeto na íntegra, incluindo arquivos anexados!<a>";
            strBody = strBody + "<br><br>";
            strBody = strBody + "Esta é uma  mensagem automática enviada pelo sistema. Não precisa responder.";
            strBody = strBody + "</body>";
            strBody = strBody + "</html>";

            string sTitulo;

            if (iTipo == 1)
            {
                sTitulo = "[PROJETOS FDID] Novo projeto cadastrado";
            }
            else
            {
                sTitulo = "Atualização do Projetos FDID";
            }

            Diversos.SendEmail(config.GetSection(key: "Config")["sEmailSend"], sTitulo, strBody, _anexos, _projeto.Instituicao.sEmail);
        }
コード例 #3
0
        public int GetSend(string sCNPJ)
        {
            try
            {
                var config = new ConfigurationBuilder()
                             .SetBasePath(Directory.GetCurrentDirectory())
                             .AddJsonFile("appsettings.json")
                             .Build();

                Instituicao _instituicao = conn.Query <Instituicao>("SELECT top(1) * FROM TB_INSTITUICAO WHERE sCNPJ =@sCNPJ ", new { sCNPJ }).FirstOrDefault();

                // generate a 128-bit salt using a secure PRNG
                byte[] salt = new byte[128 / 8];
                using (var rng = RandomNumberGenerator.Create())
                {
                    rng.GetBytes(salt);
                }

                string sHash = Convert.ToBase64String(KeyDerivation.Pbkdf2(
                                                          password: sCNPJ,
                                                          salt: salt,
                                                          prf: KeyDerivationPrf.HMACSHA1,
                                                          iterationCount: 10000,
                                                          numBytesRequested: 256 / 8));

                string pattern     = @"(?i)[^0-9a-záéíóúàèìòùâêîôûãõç\s]";
                string replacement = "";
                Regex  rgx         = new Regex(pattern);
                string result      = rgx.Replace(sHash, replacement);

                conn.Execute("UPDATE TB_INSTITUICAO SET sHash=@sHash,dDataEnvioHash=GETDATE() WHERE sCNPJ = @sCNPJ ", new { sCNPJ, sHash = result });

                string _body = "";
                _body  = "<tr bgcolor='#D6EFDA'><td colspan=2  style='font-weight:bold'>INSTITUIÇÃO</td></tr>";
                _body += "<tr style='=font-weight:bold;'>";
                _body += "<td font-weight:bold'><b>Proponente: </b>" + _instituicao.sProponente + "</td>";
                _body += "<td font-weight:bold'><b>CNPJ: </b>" + _instituicao.sCNPJ + "</td></tr>";

                _body += "<tr bgcolor='#D6EFDA'><td colspan=2  style='font-weight:bold'>Não consegue lembrar sua senha? Não tem problema, acontece com todos nós. Para criar uma nova senha, clique no link abaixo:</td></tr>";
                _body += config.GetSection(key: "Config")["sHostChangeSenha"] + result;

                string strBody = "";
                strBody = strBody + "<html>";
                strBody = strBody + "<head>";
                strBody = strBody + "<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>";
                strBody = strBody + "<title>Untitled Document</title>";
                strBody = strBody + "</head>";
                strBody = strBody + "<body>";

                strBody = strBody + "<table style='font-family: verdana; font-size: 11px; color: #000000;' width='100%'>";
                strBody = strBody + "<tr align=center><td colspan=2><img src='cid:Imagem1' /></td></tr>";
                strBody = strBody + "<tr align=center><td colspan=2></td></tr>";
                strBody = strBody + "<tr style='=font-weight:bold;' align=center><td colspan=2>PROCURADORIA GERAL DE JUSTIÇA</td></tr>";
                strBody = strBody + "<tr style='=font-weight:bold;' align=center><td colspan=2>MINISTÉRIO PÚBLICO DO ESTADO DO CEARÁ</td></tr>";

                strBody = strBody + "<tr><td font-weight:bold'><p><p></td></tr> ";
                strBody = strBody + _body;
                strBody = strBody + "</table> ";
                strBody = strBody + "<br><br>";
                strBody = strBody + "Esta é uma  mensagem automática enviada pelo sistema. Não precisa responder.";
                strBody = strBody + "</body>";
                strBody = strBody + "</html>";

                Diversos.SendEmail(_instituicao.sEmail, "Mudança de senha FDID", strBody, null, null);

                return(1);
            }
            catch (Exception)
            {
                return(0);
            }
        }