예제 #1
0
        protected Config_Fields Salvar_Registro(Config_Fields oJSON)
        {
            //******************************
            //* Obtem dados da configuração
            //******************************
            Config_Manager oManager = new Config_Manager(oLogin.LoginInfo.Master_ConexaoString);

            //*****************************************
            //* Executa inclusão e retorna novo código
            //*****************************************
            try
            {
                //*************************
                //* Salva dados do usuário
                //*************************
                oManager.ApplyRecord(oJSON);

                //*****************************
                //* Retorna status da operação
                //*****************************
                return(oJSON);
            }
            catch (Exception oException)
            {
                //******************************
                //* Retorna erro no manupulador
                //******************************
                oJSON.ErrorText = oException.Message;
                oJSON.Error     = true;
                return(oJSON);
            }
        }
예제 #2
0
        protected Config_Fields Teste_SMTP(Config_Fields oJSON)
        {
            //**************
            //* Declarações
            //**************
            SendEmail oMail = new SendEmail();

            //***************
            //* Efetua envio
            //***************
            try
            {
                //**************************
                //* Envia e retorna sucesso
                //**************************
                oJSON = oMail.EnviaTesteSMTP(oJSON, oLogin.LoginInfo.Master_Codigo, oLogin.LoginInfo.Posto_Codigo);
            }
            catch (Exception oException)
            {
                //*************************
                //* Retorna falha de envio
                //*************************
                oJSON.ErrorText = "Erro ao enviar mensagem: " + oException.Message;
                oJSON.Error     = true;
            }

            //*****************************
            //* Retorna status da operação
            //*****************************
            return(oJSON);
        }
예제 #3
0
        protected void PopulaJSON()
        {
            //******************************
            //* Obtem dados da configuração
            //******************************
            Config_Manager oManager = new Config_Manager(oLogin.LoginInfo.Master_ConexaoString);

            //****************************
            //* Obtém registro do usuário
            //****************************
            oJSON = oManager.GetRecord();

            //********************
            //* Parâmetros comuns
            //********************
            oJSON.Parametros.Add("Operacao", "Popular");
        }
예제 #4
0
        private bool ObtemConfiguracaoPadrao()
        {
            //**************************************
            //* Obtem configurações gerais de envio
            //**************************************
            Config_Manager oConfigManager = new Config_Manager(oLogin.LoginInfo.Master_ConexaoString);
            Config_Fields  oConfig        = oConfigManager.GetRecord();

            //***********************************************
            //* Os dados da configuração padrão são válidos?
            //***********************************************
            if (oConfig.SMTP_Endereco.Trim() == string.Empty || oConfig.SMTP_Porta < 25)
            {
                return(false);
            }
            else
            if (oConfig.SMTP_Autenticacao)
            {
                if (oConfig.SMTP_Usuario.Trim() == string.Empty || oConfig.SMTP_Senha.Trim() == string.Empty)
                {
                    return(false);
                }
            }

            //*******************************
            //* Define configuração de envio
            //*******************************
            oSmtpClient.UseDefaultCredentials = !oConfig.SMTP_Autenticacao;
            oSmtpClient.Credentials           = new NetworkCredential(oConfig.SMTP_Usuario.Trim(), oConfig.SMTP_Senha.Trim());
            oSmtpClient.DeliveryMethod        = System.Net.Mail.SmtpDeliveryMethod.Network;
            oSmtpClient.EnableSsl             = oConfig.SMTP_SSL;
            oSmtpClient.Host    = oConfig.SMTP_Endereco.Trim();
            oSmtpClient.Port    = oConfig.SMTP_Porta;
            oSmtpClient.Timeout = 100000;
            return(true);
        }
예제 #5
0
        protected void clbAtualizar_Callback(object source, DevExpress.Web.CallbackEventArgs e)
        {
            //**********************************
            //* É uma chamada de inicializãção?
            //**********************************
            if (e.Parameter == string.Empty)
            {
                //**************
                //* Declarações
                //**************
                Int32 CodigoUsuario = 0;

                //***************************
                //* Edição ou novo registro?
                //***************************
                if (Request.QueryString["codigo"] == null)
                {
                    CodigoUsuario = 0;
                }
                else
                {
                    CodigoUsuario = Convert.ToInt32(Request.QueryString["codigo"]);
                }

                //******************************
                //* Popula dados no objeto JSON
                //******************************
                PopulaJSON();

                //*******************************
                //* Devolve estrutura JSON vazia
                //*******************************
                e.Result = new JavaScriptSerializer().Serialize(oJSON);
            }
            else
            {
                //*************************
                //* Deserializa requisição
                //*************************
                JavaScriptSerializer oSerializer = new JavaScriptSerializer();
                oJSON = oSerializer.Deserialize <Config_Fields>(e.Parameter);

                //******************************
                //* Realiza operação solicitada
                //******************************
                switch (oJSON.Parametros["Operacao"])
                {
                case "Salvar_Registro":

                    //*************************************
                    //* Coleta código da nova oportunidade
                    //*************************************
                    oJSON = Salvar_Registro(oJSON);

                    //*******************************
                    //* Devolve estrutura JSON vazia
                    //*******************************
                    e.Result = new JavaScriptSerializer().Serialize(oJSON);
                    break;

                case "Teste_SMTP":

                    //*************************************
                    //* Coleta código da nova oportunidade
                    //*************************************
                    oJSON = Salvar_Registro(oJSON);

                    //*************************************
                    //* Coleta código da nova oportunidade
                    //*************************************
                    oJSON = Teste_SMTP(oJSON);

                    //*******************************
                    //* Devolve estrutura JSON vazia
                    //*******************************
                    e.Result = new JavaScriptSerializer().Serialize(oJSON);
                    break;
                }
            }
        }
예제 #6
0
        public Config_Fields EnviaTesteSMTP(Config_Fields oJSON, Int32 Master_Codigo, Int32 Posto_Codigo)
        {
            //**********************************
            //* Obtem base de carregamento HTML
            //**********************************
            string HTML_Base = Properties.Settings.Default.html_base;

            //***************
            //* Efetua envio
            //***************
            try
            {
                //*******************************
                //* Define configuração de envio
                //*******************************
                oSmtpClient.UseDefaultCredentials = !oJSON.SMTP_Autenticacao;
                oSmtpClient.Credentials           = new NetworkCredential(oJSON.SMTP_Usuario.Trim(), oJSON.SMTP_Senha.Trim());
                oSmtpClient.DeliveryMethod        = System.Net.Mail.SmtpDeliveryMethod.Network;
                oSmtpClient.EnableSsl             = oJSON.SMTP_SSL;
                oSmtpClient.Host    = oJSON.SMTP_Endereco.Trim();
                oSmtpClient.Port    = oJSON.SMTP_Porta;
                oSmtpClient.Timeout = 10000;

                //***************
                //* Captura HTML
                //***************
                oHTTPClient.Encoding = System.Text.Encoding.UTF8;
                string URL = "/smtp_teste_email.aspx";
                URL += "?CMA=" + Master_Codigo;
                URL += "&CPO=" + Posto_Codigo;
                URL += "&Destinatario=" + oJSON.Parametros["NomeDestinatario"];
                string Html = oHTTPClient.DownloadString(HTML_Base + URL);

                //************************
                //* Define dados de envio
                //************************
                oMailMessage.To.Add(new MailAddress(oJSON.Parametros["EmailDestinatario"], oJSON.Parametros["NomeDestinatario"]));
                oMailMessage.Subject      = "Teste de servidor de envio (SMTP)";
                oMailMessage.IsBodyHtml   = true;
                oMailMessage.BodyEncoding = System.Text.Encoding.UTF8;
                oMailMessage.Body         = Html;

                //**************************
                //* Envia e retorna sucesso
                //**************************
                oSmtpClient.Send(oMailMessage);
            }
            catch (Exception oException)
            {
                //*************************
                //* Retorna falha de envio
                //*************************
                oJSON.ErrorText = oException.Message;
                oJSON.Error     = true;
                return(oJSON);
            }

            //*****************************
            //* Retorna status da operação
            //*****************************
            oJSON.ErrorText = string.Empty;
            oJSON.Error     = false;
            return(oJSON);
        }