Mercurial > altnet-hispano
view Agendas/trunk/src/Agendas.Blog/Impl/PostWriterWebServiceAdapter.cs @ 185:2d02adb79322
Se agrega fecha de termino de un Evento y se incluye la hora a la fecha de inicio.
Se modifica la propiedad Fecha del Evento, renombrandola FechaInicio.
En el ModelView se agrega propiedades Duración y Hora del Evento cuando es Modificado, Nuevo y Agendado.
Las fechas ingresadas son creadas en sistema UTC
Queda pendiente Agregar duración a Google Calendar.
author | alabra |
---|---|
date | Tue, 09 Aug 2011 01:04:27 -0400 |
parents | 1d820f17fc75 |
children |
line wrap: on
line source
using System; using System.Globalization; using System.Security.Cryptography; using System.ServiceModel; using Agendas.Blog.Exceptions; using Agendas.Blog.PortalSitefinity; namespace Agendas.Blog.Impl { public class PostWriterWebServiceAdapter : IPostWriterWebService { private readonly BlogPublicadorConfig _config; private readonly PostWriterWebServiceSoapClient _service; public PostWriterWebServiceAdapter(BlogPublicadorConfig config) { _config = config; _service = new PortalSitefinity.PostWriterWebServiceSoapClient(new BasicHttpBinding(), new EndpointAddress(config.PostWriterServiceUrl)); } private static string buildToken(string key, DateTime time) { var aux = key + time.ToString(CultureInfo.InvariantCulture); var enc = System.Text.Encoding.ASCII.GetEncoder(); var data = new byte[aux.Length]; enc.GetBytes(aux.ToCharArray(), 0, aux.Length, data, 0, true); var md5 = new MD5CryptoServiceProvider(); var result = md5.ComputeHash(data); return BitConverter.ToString(result).Replace("-", "").ToLower(); } public void WriteBlogPost(string postTitle, string postHtmlContent, string postAuthor, bool setPublicationDate) { var securityToken = getSecurityToken(); _service.WriteBlogPost(securityToken, _config.BlogName, postTitle, postHtmlContent, postAuthor, setPublicationDate); } private string getSecurityToken() { var now = DateTime.UtcNow; now = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, 0, 0); return buildToken(_config.BlogWriterMasterKey, now); } } }