Mercurial > altnet-hispano
comparison Agendas/trunk/src/Agendas.Blog/Impl/PostWriterWebServiceAdapter.cs @ 105:1d820f17fc75
ajustes y correcciones en el publicador de blogs
agregado de numeroOrden y urlWiki en metodo Publicar de Agenda y Evento (con test)
author | jorge.rowies |
---|---|
date | Mon, 06 Jun 2011 09:12:52 -0300 |
parents | 3027c64344bd |
children |
comparison
equal
deleted
inserted
replaced
104:c5034884c7d7 | 105:1d820f17fc75 |
---|---|
7 | 7 |
8 namespace Agendas.Blog.Impl | 8 namespace Agendas.Blog.Impl |
9 { | 9 { |
10 public class PostWriterWebServiceAdapter : IPostWriterWebService | 10 public class PostWriterWebServiceAdapter : IPostWriterWebService |
11 { | 11 { |
12 private readonly BlogPublicadorConfig _config; | |
12 private readonly PostWriterWebServiceSoapClient _service; | 13 private readonly PostWriterWebServiceSoapClient _service; |
13 | 14 |
14 public PostWriterWebServiceAdapter() | 15 public PostWriterWebServiceAdapter(BlogPublicadorConfig config) |
15 { | 16 { |
16 var postWriterUrl = System.Configuration.ConfigurationManager.AppSettings["PublicadorBlog.PostWriterServiceUrl"]; | 17 _config = config; |
17 if (string.IsNullOrEmpty(postWriterUrl)) | 18 _service = new PortalSitefinity.PostWriterWebServiceSoapClient(new BasicHttpBinding(), |
18 throw new PostWriterServiceUrlNotFoundException(); | 19 new EndpointAddress(config.PostWriterServiceUrl)); |
19 | |
20 _service = new PortalSitefinity.PostWriterWebServiceSoapClient(new BasicHttpBinding(), new EndpointAddress(postWriterUrl)); | |
21 } | 20 } |
22 | 21 |
23 private static string buildToken(string key, DateTime time) | 22 private static string buildToken(string key, DateTime time) |
24 { | 23 { |
25 var aux = key + time.ToString(CultureInfo.InvariantCulture); | 24 var aux = key + time.ToString(CultureInfo.InvariantCulture); |
36 } | 35 } |
37 | 36 |
38 public void WriteBlogPost(string postTitle, string postHtmlContent, string postAuthor, bool setPublicationDate) | 37 public void WriteBlogPost(string postTitle, string postHtmlContent, string postAuthor, bool setPublicationDate) |
39 { | 38 { |
40 var securityToken = getSecurityToken(); | 39 var securityToken = getSecurityToken(); |
41 var blogName = System.Configuration.ConfigurationManager.AppSettings["PublicadorBlog.BlogName"]; | 40 _service.WriteBlogPost(securityToken, _config.BlogName, postTitle, postHtmlContent, postAuthor, setPublicationDate); |
42 if (string.IsNullOrEmpty(blogName)) | |
43 throw new BlogNameNotFoundException(); | |
44 | |
45 _service.WriteBlogPost(securityToken, blogName, postTitle, postHtmlContent, postAuthor, setPublicationDate); | |
46 } | 41 } |
47 | 42 |
48 private static string getSecurityToken() | 43 private string getSecurityToken() |
49 { | 44 { |
50 var masterKey = System.Configuration.ConfigurationManager.AppSettings["PublicadorBlog.BlogWriterMasterKey"]; | |
51 if (string.IsNullOrEmpty(masterKey)) | |
52 throw new BlogWriterMasterKeyNotFoundException(); | |
53 | |
54 var now = DateTime.UtcNow; | 45 var now = DateTime.UtcNow; |
55 now = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, 0, 0); | 46 now = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, 0, 0); |
56 | 47 |
57 return buildToken(masterKey, now); | 48 return buildToken(_config.BlogWriterMasterKey, now); |
58 } | 49 } |
59 } | 50 } |
60 } | 51 } |