diff 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
line wrap: on
line diff
--- a/Agendas/trunk/src/Agendas.Blog/Impl/PostWriterWebServiceAdapter.cs	Sun Jun 05 13:22:36 2011 -0300
+++ b/Agendas/trunk/src/Agendas.Blog/Impl/PostWriterWebServiceAdapter.cs	Mon Jun 06 09:12:52 2011 -0300
@@ -9,15 +9,14 @@
 {
   public class PostWriterWebServiceAdapter : IPostWriterWebService
   {
+    private readonly BlogPublicadorConfig _config;
     private readonly PostWriterWebServiceSoapClient _service;
 
-    public PostWriterWebServiceAdapter()
+    public PostWriterWebServiceAdapter(BlogPublicadorConfig config)
     {
-      var postWriterUrl = System.Configuration.ConfigurationManager.AppSettings["PublicadorBlog.PostWriterServiceUrl"];
-      if (string.IsNullOrEmpty(postWriterUrl))
-        throw new PostWriterServiceUrlNotFoundException();
-
-      _service = new PortalSitefinity.PostWriterWebServiceSoapClient(new BasicHttpBinding(), new EndpointAddress(postWriterUrl));
+      _config = config;
+      _service = new PortalSitefinity.PostWriterWebServiceSoapClient(new BasicHttpBinding(),
+                                                                     new EndpointAddress(config.PostWriterServiceUrl));
     }
 
     private static string buildToken(string key, DateTime time)
@@ -38,23 +37,15 @@
     public void WriteBlogPost(string postTitle, string postHtmlContent, string postAuthor, bool setPublicationDate)
     {
       var securityToken = getSecurityToken();
-      var blogName = System.Configuration.ConfigurationManager.AppSettings["PublicadorBlog.BlogName"];
-      if (string.IsNullOrEmpty(blogName))
-        throw new BlogNameNotFoundException();
-
-      _service.WriteBlogPost(securityToken, blogName, postTitle, postHtmlContent, postAuthor, setPublicationDate);
+      _service.WriteBlogPost(securityToken, _config.BlogName, postTitle, postHtmlContent, postAuthor, setPublicationDate);
     }
 
-    private static string getSecurityToken()
+    private string getSecurityToken()
     {
-      var masterKey = System.Configuration.ConfigurationManager.AppSettings["PublicadorBlog.BlogWriterMasterKey"];
-      if (string.IsNullOrEmpty(masterKey))
-        throw new BlogWriterMasterKeyNotFoundException();
-
       var now = DateTime.UtcNow;
       now = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, 0, 0);
 
-      return buildToken(masterKey, now);
+      return buildToken(_config.BlogWriterMasterKey, now);
     }
   }
 }
\ No newline at end of file