Example #1
0
        public static Retorno VerificaMedidas(int Width, int Height)
        {
            try
            {
                if (String.IsNullOrEmpty(ConfigurationManager.AppSettings["WIDTH"]) || String.IsNullOrEmpty(ConfigurationManager.AppSettings["HEIGHT"]))
                {
                    System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);

                    config.AppSettings.Settings.Remove("WIDTH");
                    config.AppSettings.Settings.Add("WIDTH", Width.ToString());

                    config.AppSettings.Settings.Remove("HEIGHT");
                    config.AppSettings.Settings.Add("HEIGHT", Height.ToString());

                    config.Save(ConfigurationSaveMode.Modified);
                    ConfigurationManager.RefreshSection("appSettings");
                }
                return(new Retorno(true));
            }
            catch (Exception ex)
            {
                Erro erro = new Erro()
                {
                    Descricao      = ex.Message,
                    Imagem         = Guid.NewGuid().ToString(),
                    CasoDeUso      = EnumCasoDeUso.MANTER_MEDIDAS,
                    Camada         = EnumCamada.COMMON,
                    Funcionalidade = EnumFuncionalidade.SALVAR,
                    Entidade       = "Erro"
                };
                if (Internet.Conectado())
                {
                    ISEmail.EnviarErro(erro);
                }

                return(new Retorno(false, String.Format(Mensagens.MSG_05, ex.Message, "Recuperar Medidas")));
            }
        }
Example #2
0
        public static Retorno EnviarErro(string descricaoErro)
        {
            try
            {
                if (Internet.Conectado())
                {
                    using (Bitmap bgTopo = new Bitmap(System.Environment.CurrentDirectory + @"\LogoInfinitySolutions.png"))
                    {
                        LinkedResource lrTopo       = ConverteBitmapToLinkedResource(bgTopo, ImageFormat.Png, "bgTopo");
                        StringBuilder  sbCorpoEmail = new StringBuilder();

                        sbCorpoEmail.Append("<html>");
                        sbCorpoEmail.Append("<head>");
                        sbCorpoEmail.Append("</head>");
                        sbCorpoEmail.Append("<body>");
                        sbCorpoEmail.Append("<div>");

                        sbCorpoEmail.Append("<table>");
                        sbCorpoEmail.Append("<tr>");
                        sbCorpoEmail.Append("<td>");
                        sbCorpoEmail.Append("<img id=\"imgTopo\" alt=\"Administrador\" src=\"cid:bgTopo\" />");
                        sbCorpoEmail.Append("</td>");
                        sbCorpoEmail.Append("</tr>");

                        sbCorpoEmail.Append("<tr>");
                        sbCorpoEmail.Append("<td>");
                        sbCorpoEmail.Append("<p style='color: blue'>");
                        sbCorpoEmail.Append("ERRO: ");
                        sbCorpoEmail.Append("</p>");
                        sbCorpoEmail.Append("</td>");
                        sbCorpoEmail.Append("</tr>");
                        sbCorpoEmail.Append("<tr>");
                        sbCorpoEmail.Append("<td>");
                        sbCorpoEmail.Append("<p>");
                        sbCorpoEmail.Append(descricaoErro);
                        sbCorpoEmail.Append("</p>");
                        sbCorpoEmail.Append("</td>");
                        sbCorpoEmail.Append("</tr>");

                        sbCorpoEmail.Append("<tr>");
                        sbCorpoEmail.Append("<td>");
                        sbCorpoEmail.Append("<p>");
                        sbCorpoEmail.Append(DateTime.Now);
                        sbCorpoEmail.Append("</p>");
                        sbCorpoEmail.Append("</td>");
                        sbCorpoEmail.Append("</tr>");

                        sbCorpoEmail.Append("</table>");
                        sbCorpoEmail.Append("</div>");
                        sbCorpoEmail.Append("</body>");
                        sbCorpoEmail.Append("</html>");

                        using (AlternateView viewHtml = AlternateView.CreateAlternateViewFromString(sbCorpoEmail.ToString(), null, "text/html"))
                        {
                            viewHtml.LinkedResources.Add(lrTopo);

                            using (MailMessage mail = new MailMessage())
                            {
                                mail.From = new MailAddress("*****@*****.**", Configuracao.NOME_EMPRESA);
                                mail.To.Add(new MailAddress("*****@*****.**", Configuracao.NOME_EMPRESA));
                                mail.AlternateViews.Add(viewHtml);
                                mail.Subject = "RELATÓRIO DE ERRO - " + Configuracao.NOME_EMPRESA;

                                mail.IsBodyHtml   = true;
                                mail.BodyEncoding = Encoding.UTF8;

                                using (SmtpClient client = new SmtpClient("smtp.live.com"))
                                {
                                    client.Credentials = new NetworkCredential("*****@*****.**", "Joleny123");
                                    client.EnableSsl   = true;
                                    client.Port        = 25;
                                    client.Send(mail);
                                }
                            }
                        }
                    }
                }
                return(new Retorno(true));
            }
            catch (Exception ex)
            {
                ISEmail.EnviarErro(String.Format(Mensagens.MSG_26, ex.Message, "Na camada de dados ao ENVIAR BACKUP ISEmail"));

                return(new Retorno(false, String.Format(Mensagens.MSG_05, ex.Message, "ENVIAR ERRO")));
            }
        }