Esta es una lista de aplicaciones web que realizan la tarea tediosa de analisis de visita de sitios mobiles y varias cosas mas como ofrecernos servicios de inclusion en los motores de busquedas mobile mas reconocidos del mercado como Yahoo, google, etc., tambien algunos ofrecen servicios de billing variados como paypal mobile en el caso de Bango.
Archivo de Diciembre 2008
Mobile Analytics
Publicado por Miguel Gonzalez en 30 Diciembre 2008
Publicado en Mobile | Etiquetado: analytics, Mobile | Deja un Comentario »
Log4net con Gmail
Publicado por Miguel Gonzalez en 23 Diciembre 2008
Como el servidor de correo de gmail tiene ssl tenemos que realizar unos ajustes en una clase personalizada para tal fin. Para esto vamos a heredar de log4net.Appender.SmtpAppender para agregar estas nuevas caracteristicas. De esta forma nace la clase MyApp.SmtpSslAppender que usaremos siempre que queramos enviar nuestro logs atraves de una cuenta gmail.
public class SmtpSslAppender : log4net.Appender.SmtpAppender
{
private bool m_enableSsl = true;
public bool EnableSsl
{
get{return m_enableSsl;}
set{this.m_enableSsl = value;}
}
protected override void SendEmail(string messageBody) {
SmtpClient smtpClient = new SmtpClient();
if( SmtpHost != null & SmtpHost.Length > 0 ){
smtpClient.Host = SmtpHost;
}
smtpClient.Port = Port;
smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
smtpClient.EnableSsl = EnableSsl;
if( Authentication == SmtpAuthentication.Basic ){
smtpClient.Credentials = new System.Net.NetworkCredential(Username, Password);
}else if( Authentication == SmtpAuthentication.Ntlm ){
smtpClient.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;
}
MailMessage mailMessage = new MailMessage();
mailMessage.Body = messageBody;
mailMessage.From = new MailAddress(From);
mailMessage.To.Add(To);
mailMessage.Subject = Subject;
mailMessage.Priority = Priority;
smtpClient.Send(mailMessage);
}
}
A continuacion se ve como dentro del web.config se hace uso de esta nueva clase.
<appender name=”SmtpSslAppender” type=”MyApp.SmtpSslAppender”>
<to value=”xxx@gmail.com” />
<from value=”yyy@gmail.com” />
<subject value=”LoggerName” />
<smtpHost value=”smtp.gmail.com” />
<bufferSize value=”1″ />
<port value=”587″ />
<lossy value=”false” />
<authentication value=”Basic” />
<userName value=”usuario” />
<password value=”clave” />
<layout type=”log4net.Layout.PatternLayout”>
<conversionPattern value=”%newline%date [%thread] %-5level %logger [%property{NDC}] – %message%newline%newline%newline” />
</layout>
<filter type=”log4net.Filter.LevelRangeFilter”>
<levelMin value=”FATAL”/>
<levelMax value=”FATAL”/>
</filter>
</appender>
Publicado en Log4net | Etiquetado: ASP.NET 2.0, Log4net, web.config | 1 comentario
Log4net con Exchange
Publicado por Miguel Gonzalez en 22 Diciembre 2008
Para realizar esto primero tenemos que crear una clase personalizada para tal fin. Para esto vamos a heredar de “log4net.Appender.SmtpAppender” para agregar esta nueva caracteristica. De esta forma nace la clase “MyApp.ExchangeAppender” que usaremos siempre que queramos enviar nuestro logs atraves de una cuenta exchange. Aqui tiene la clase que yo utilizo para esto.
using System;
using System.Net;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
namespace MyApp
{
public class ExchangeAppender : log4net.Appender.SmtpAppender
{
protected override void SendEmail(string messageBody)
{
try
{
string sUri;
sUri = “https://miservidor/exchange/” + Username;
sUri = sUri + “/%23%23DavMailSubmissionURI%23%23″;
System.Uri myUri = new System.Uri(sUri);
HttpWebRequest HttpWRequest = (HttpWebRequest)WebRequest.Create(myUri);
string sQuery;
sQuery = “From: ” + From + “n” +
“To: ” + To + “n” +
//”CC: ” + cc + “n” +
“Subject: ” + Subject + “n” +
“Date: ” + DateTime.Now.ToString() + “n” +
“X-Mailer: My DAV mailer” + “n” +
“MIME-Version: 1.0″ + “n” +
“Content-Type: text/plain;” + “n” +
“Charset = “iso-8859-1″” + “n” +
“Content-Transfer-Encoding: 7bit” + “n” + “n” +
messageBody;
// Set the credentials.
// TODO: Replace with the appropriate user credential.
NetworkCredential myCred = new NetworkCredential(Username, Password);
CredentialCache myCredentialCache = new CredentialCache();
myCredentialCache.Add(myUri, “Basic”, myCred);
HttpWRequest.Credentials = myCredentialCache;
// Set the headers.
HttpWRequest.Headers.Set(“Translate”, “f”);
HttpWRequest.ContentType = “message/rfc822″;
HttpWRequest.ContentLength = sQuery.Length;
//Set the request timeout to 5 minutes.
HttpWRequest.Timeout = 300000;
// Set the request method.
HttpWRequest.Method = “PUT”;
// Store the data in a byte array.
byte[] ByteQuery = System.Text.Encoding.ASCII.GetBytes(sQuery);
HttpWRequest.ContentLength = ByteQuery.Length;
Stream QueryStream = HttpWRequest.GetRequestStream();
// write the data to be posted to the Request Stream
QueryStream.Write(ByteQuery, 0, ByteQuery.Length);
QueryStream.Close();
// Send the request and get the response.
HttpWebResponse HttpWResponse =(HttpWebResponse)HttpWRequest.GetResponse();
// Get the Status code.
int iStatCode = (int)HttpWResponse.StatusCode;
string sStatus = iStatCode.ToString();
//log.DebugFormat(“Status Code: {0}”, sStatus);
// Get the request headers.
string sReqHeaders = HttpWRequest.Headers.ToString();
//log.Debug(sReqHeaders);
// Read the response stream.
Stream strm = HttpWResponse.GetResponseStream();
StreamReader sr = new StreamReader(strm);
string sText = sr.ReadToEnd();
// Close the stream.
strm.Close();
// Clean up.
myCred = null;
myCredentialCache = null;
HttpWRequest = null;
HttpWResponse = null;
QueryStream = null;
strm = null;
sr = null;
}
catch (Exception e)
{throw new Exception(e.Message);}
}
}
}
Y aqui tienen la configuracion correspondiente:
<appender name=”ExchangeAppender” type=”MyApp.ExchangeAppender”>
<to value=”xxx@dominio.com” />
<from value=”yyy@dominio.com” />
<subject value=”Asunto” />
<bufferSize value=”1″ />
<port value=”587″ />
<lossy value=”false” />
<authentication value=”Basic” />
<userName value=”usuario_exchange” />
<password value=”clave_exchange” />
<layout type=”log4net.Layout.PatternLayout”>
<conversionPattern value=”%newline%date [%thread] %-5level %logger [%property{NDC}] – %message%newline%newline%newline” />
</layout>
<filter type=”log4net.Filter.LevelRangeFilter”>
<levelMin value=”FATAL”/>
<levelMax value=”FATAL”/>
</filter>
Publicado en Log4net | Etiquetado: ASP.NET 2.0, Exchange, Log4net, web.config | Deja un Comentario »