# HG changeset patch # User nelopauselli # Date 1312574118 10800 # Node ID 734d3f0853bfbe944f2ea14e917996c39bdf46f8 # Parent f17252543cbf4fff1f8b2b24d246a202d10e00dc Manejando configuración de los publicadores con una sección propia en los .config Agregando la opción de habilitar / deshabilitar un publicador diff -r f17252543cbf -r 734d3f0853bf Agendas/trunk/src/Agendas.Blog/Agendas.Blog.csproj --- a/Agendas/trunk/src/Agendas.Blog/Agendas.Blog.csproj Thu Aug 04 18:45:18 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Blog/Agendas.Blog.csproj Fri Aug 05 16:55:18 2011 -0300 @@ -71,6 +71,10 @@ + + {583304D0-51C7-4808-BE20-6E9A904CA908} + Agendas.Configurations + {A14907DF-02E4-4FA7-BE27-4292AF50AA22} Agendas.Domain diff -r f17252543cbf -r 734d3f0853bf Agendas/trunk/src/Agendas.Blog/Impl/BlogPublicador.cs --- a/Agendas/trunk/src/Agendas.Blog/Impl/BlogPublicador.cs Thu Aug 04 18:45:18 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Blog/Impl/BlogPublicador.cs Fri Aug 05 16:55:18 2011 -0300 @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using AltNetHispano.Agendas.Configurations; using AltNetHispano.Agendas.Domain; namespace Agendas.Blog.Impl @@ -9,6 +10,16 @@ { private readonly IPostWriterFactory _postWriterFactory; + public BlogPublicador() + : this( + new PostWriterFactory( + new PostWriterWebServiceAdapter( + new BlogPublicadorConfig(AgendasConfigurationManager.Publicadores.Blog.Writer.PostWriterServiceUrl, + AgendasConfigurationManager.Publicadores.Blog.Writer.BlogName, + AgendasConfigurationManager.Publicadores.Blog.Writer.BlogWriterMasterKey)))) + { + } + public BlogPublicador(IPostWriterFactory postWriterFactory) { _postWriterFactory = postWriterFactory; @@ -16,6 +27,8 @@ public void Publicar(IEnumerable tracks) { + if (!AgendasConfigurationManager.Publicadores.Blog.Enabled) return; + foreach (var track in tracks) { if (track.Logs.Any(l => l.Propietario == TrackLogPropietario.Blog && l.Successful)) continue; @@ -32,4 +45,4 @@ } } } -} +} \ No newline at end of file diff -r f17252543cbf -r 734d3f0853bf Agendas/trunk/src/Agendas.Configurations.Tests/Agendas.Configurations.Tests.csproj --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Configurations.Tests/Agendas.Configurations.Tests.csproj Fri Aug 05 16:55:18 2011 -0300 @@ -0,0 +1,67 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {BBE36765-6AAB-4689-B2F3-6D18E3F11746} + Library + Properties + Agendas.Configurations.Tests + Agendas.Configurations.Tests + v4.0 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\NUnit.2.5.10.11092\lib\nunit.framework.dll + + + + + + + + + + + + + + + + + {583304D0-51C7-4808-BE20-6E9A904CA908} + Agendas.Configurations + + + + + + + + \ No newline at end of file diff -r f17252543cbf -r 734d3f0853bf Agendas/trunk/src/Agendas.Configurations.Tests/App.config --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Configurations.Tests/App.config Fri Aug 05 16:55:18 2011 -0300 @@ -0,0 +1,20 @@ + + + + +
+ + + + + + + + + + + + + + + \ No newline at end of file diff -r f17252543cbf -r 734d3f0853bf Agendas/trunk/src/Agendas.Configurations.Tests/Properties/AssemblyInfo.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Configurations.Tests/Properties/AssemblyInfo.cs Fri Aug 05 16:55:18 2011 -0300 @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Agendas.Configurations.Tests")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("Agendas.Configurations.Tests")] +[assembly: AssemblyCopyright("Copyright © Microsoft 2011")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("094376cb-d2c5-479e-bce4-b46babd6627d")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff -r f17252543cbf -r 734d3f0853bf Agendas/trunk/src/Agendas.Configurations.Tests/Read_configuration.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Configurations.Tests/Read_configuration.cs Fri Aug 05 16:55:18 2011 -0300 @@ -0,0 +1,71 @@ +using AltNetHispano.Agendas.Configurations; +using NUnit.Framework; + +namespace Agendas.Configurations.Tests +{ + [TestFixture] + public class Read_configuration + { + [Test] + public void Read() + { + var section = AgendasConfigurationManager.Publicadores; + Assert.IsNotNull(section); + } + + [Test] + public void Read_twitter() + { + var publicadores = AgendasConfigurationManager.Publicadores; + Assert.IsNotNull(publicadores); + + Assert.IsNotNull(publicadores.Twitter); + + var twitter = publicadores.Twitter; + Assert.AreEqual(true, twitter.Enabled); + + Assert.IsNotNull(twitter.SignIn); + Assert.AreEqual("consumerKey1", twitter.SignIn.ConsumerKey); + Assert.AreEqual("consumerSecret1", twitter.SignIn.ConsumerSecret); + + Assert.AreEqual("consumerKey2", twitter.SendTwitter.ConsumerKey); + Assert.AreEqual("consumerSecret2", twitter.SendTwitter.ConsumerSecret); + Assert.AreEqual("accessToken2", twitter.SendTwitter.AccessToken); + Assert.AreEqual("accessTokenSecret2", twitter.SendTwitter.AccessTokenSecret); + } + + [Test] + public void Read_blog() + { + var publicadores = AgendasConfigurationManager.Publicadores; + Assert.IsNotNull(publicadores); + + Assert.IsNotNull(publicadores.Blog); + + var blog = publicadores.Blog; + Assert.AreEqual(true, blog.Enabled); + + Assert.IsNotNull(blog.Writer); + Assert.AreEqual("blogName", blog.Writer.BlogName); + Assert.AreEqual("blogWriterMasterKey", blog.Writer.BlogWriterMasterKey); + Assert.AreEqual("postWriterServiceUrl", blog.Writer.PostWriterServiceUrl); + } + + [Test] + public void Read_google() + { + var publicadores = AgendasConfigurationManager.Publicadores; + Assert.IsNotNull(publicadores); + + Assert.IsNotNull(publicadores.Google); + + var google = publicadores.Google; + Assert.AreEqual(true, google.Enabled); + + Assert.IsNotNull(google.Calendar); + Assert.AreEqual("altnethispano.desa@gmail.com", google.Calendar.UserName); + Assert.AreEqual("altnethispano.desa@gmail.com", google.Calendar.CalendarId); + Assert.AreEqual("password", google.Calendar.Password); + } + } +} \ No newline at end of file diff -r f17252543cbf -r 734d3f0853bf Agendas/trunk/src/Agendas.Configurations/Agendas.Configurations.csproj --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Configurations/Agendas.Configurations.csproj Fri Aug 05 16:55:18 2011 -0300 @@ -0,0 +1,73 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {583304D0-51C7-4808-BE20-6E9A904CA908} + Library + Properties + AltNetHispano.Agendas.Configurations + AltNetHispano.Agendas.Configurations + v4.0 + 512 + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff -r f17252543cbf -r 734d3f0853bf Agendas/trunk/src/Agendas.Configurations/BlogConfigurationElement.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Configurations/BlogConfigurationElement.cs Fri Aug 05 16:55:18 2011 -0300 @@ -0,0 +1,19 @@ +using System.Configuration; + +namespace AltNetHispano.Agendas.Configurations +{ + public class BlogConfigurationElement : ConfigurationElement + { + [ConfigurationProperty("writer")] + public BlogWriterConfigurationElement Writer + { + get { return base["writer"] as BlogWriterConfigurationElement; } + } + + [ConfigurationProperty("enabled")] + public bool Enabled + { + get { return (bool) base["enabled"]; } + } + } +} \ No newline at end of file diff -r f17252543cbf -r 734d3f0853bf Agendas/trunk/src/Agendas.Configurations/BlogWriterConfigurationElement.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Configurations/BlogWriterConfigurationElement.cs Fri Aug 05 16:55:18 2011 -0300 @@ -0,0 +1,28 @@ +using System.Configuration; + +namespace AltNetHispano.Agendas.Configurations +{ + public class BlogWriterConfigurationElement : ConfigurationElement + { + [ConfigurationProperty("postWriterServiceUrl")] + public string PostWriterServiceUrl + { + get { return base["postWriterServiceUrl"] as string; } + + } + + [ConfigurationProperty("blogName")] + public string BlogName + { + get { return base["blogName"] as string; } + + } + + [ConfigurationProperty("blogWriterMasterKey")] + public string BlogWriterMasterKey + { + get { return base["blogWriterMasterKey"] as string; } + + } + } +} \ No newline at end of file diff -r f17252543cbf -r 734d3f0853bf Agendas/trunk/src/Agendas.Configurations/CalendarConfigurationElement.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Configurations/CalendarConfigurationElement.cs Fri Aug 05 16:55:18 2011 -0300 @@ -0,0 +1,25 @@ +using System.Configuration; + +namespace AltNetHispano.Agendas.Configurations +{ + public class CalendarConfigurationElement : ConfigurationElement + { + [ConfigurationProperty("userName")] + public string UserName + { + get { return base["userName"] as string; } + } + + [ConfigurationProperty("password")] + public string Password + { + get { return base["password"] as string; } + } + + [ConfigurationProperty("calendarId")] + public string CalendarId + { + get { return base["calendarId"] as string; } + } + } +} \ No newline at end of file diff -r f17252543cbf -r 734d3f0853bf Agendas/trunk/src/Agendas.Configurations/ConfigurationManager.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Configurations/ConfigurationManager.cs Fri Aug 05 16:55:18 2011 -0300 @@ -0,0 +1,18 @@ +using System.Configuration; + +namespace AltNetHispano.Agendas.Configurations +{ + public class AgendasConfigurationManager + { + public static PublicadoresConfigurationSection Publicadores + { + get + { + var config = ConfigurationManager.GetSection("publicadores") as PublicadoresConfigurationSection; + if (config == null) + throw new PublicadoresConfigurationException(); + return config; + } + } + } +} \ No newline at end of file diff -r f17252543cbf -r 734d3f0853bf Agendas/trunk/src/Agendas.Configurations/GoogleConfigurationElement.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Configurations/GoogleConfigurationElement.cs Fri Aug 05 16:55:18 2011 -0300 @@ -0,0 +1,19 @@ +using System.Configuration; + +namespace AltNetHispano.Agendas.Configurations +{ + public class GoogleConfigurationElement : ConfigurationElement + { + [ConfigurationProperty("calendar")] + public CalendarConfigurationElement Calendar + { + get { return base["calendar"] as CalendarConfigurationElement; } + } + + [ConfigurationProperty("enabled")] + public bool Enabled + { + get { return (bool) base["enabled"]; } + } + } +} \ No newline at end of file diff -r f17252543cbf -r 734d3f0853bf Agendas/trunk/src/Agendas.Configurations/Properties/AssemblyInfo.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Configurations/Properties/AssemblyInfo.cs Fri Aug 05 16:55:18 2011 -0300 @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Agendas.Configurations")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("Agendas.Configurations")] +[assembly: AssemblyCopyright("Copyright © Microsoft 2011")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("c404575c-e8c5-45dd-8745-c77436045824")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff -r f17252543cbf -r 734d3f0853bf Agendas/trunk/src/Agendas.Configurations/PublicadoresConfigurationException.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Configurations/PublicadoresConfigurationException.cs Fri Aug 05 16:55:18 2011 -0300 @@ -0,0 +1,11 @@ +using System.Configuration; + +namespace AltNetHispano.Agendas.Configurations +{ + public class PublicadoresConfigurationException : ConfigurationErrorsException + { + public PublicadoresConfigurationException() : base("Falta configurar la sección Publicadores") + { + } + } +} \ No newline at end of file diff -r f17252543cbf -r 734d3f0853bf Agendas/trunk/src/Agendas.Configurations/PublicadoresConfigurationSection.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Configurations/PublicadoresConfigurationSection.cs Fri Aug 05 16:55:18 2011 -0300 @@ -0,0 +1,25 @@ +using System.Configuration; + +namespace AltNetHispano.Agendas.Configurations +{ + public class PublicadoresConfigurationSection : ConfigurationSection + { + [ConfigurationProperty("twitter", IsRequired = true)] + public TwitterConfigurationElement Twitter + { + get { return base["twitter"] as TwitterConfigurationElement; } + } + + [ConfigurationProperty("google")] + public GoogleConfigurationElement Google + { + get { return base["google"] as GoogleConfigurationElement; } + } + + [ConfigurationProperty("blog")] + public BlogConfigurationElement Blog + { + get { return base["blog"] as BlogConfigurationElement; } + } + } +} \ No newline at end of file diff -r f17252543cbf -r 734d3f0853bf Agendas/trunk/src/Agendas.Configurations/TwitterConfigurationElement.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Configurations/TwitterConfigurationElement.cs Fri Aug 05 16:55:18 2011 -0300 @@ -0,0 +1,27 @@ +using System.Configuration; + +namespace AltNetHispano.Agendas.Configurations +{ + public class TwitterConfigurationElement : ConfigurationElement + { + [ConfigurationProperty("signIn")] + public TwitterSignInConfigurationElement SignIn + { + get { return base["signIn"] as TwitterSignInConfigurationElement; } + } + + + [ConfigurationProperty("sendTwitter")] + public TwitterSendTwitterConfigurationElement SendTwitter + { + get { return base["sendTwitter"] as TwitterSendTwitterConfigurationElement; } + } + + [ConfigurationProperty("enabled")] + public bool Enabled + { + get { return (bool) base["enabled"]; } + + } + } +} \ No newline at end of file diff -r f17252543cbf -r 734d3f0853bf Agendas/trunk/src/Agendas.Configurations/TwitterSendTwitterConfigurationElement.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Configurations/TwitterSendTwitterConfigurationElement.cs Fri Aug 05 16:55:18 2011 -0300 @@ -0,0 +1,31 @@ +using System.Configuration; + +namespace AltNetHispano.Agendas.Configurations +{ + public class TwitterSendTwitterConfigurationElement : ConfigurationElement + { + [ConfigurationProperty("consumerKey")] + public string ConsumerKey + { + get { return base["consumerKey"] as string; } + } + + [ConfigurationProperty("consumerSecret")] + public string ConsumerSecret + { + get { return base["consumerSecret"] as string; } + } + + [ConfigurationProperty("accessToken")] + public string AccessToken + { + get { return base["accessToken"] as string; } + } + + [ConfigurationProperty("accessTokenSecret")] + public string AccessTokenSecret + { + get { return base["accessTokenSecret"] as string; } + } + } +} \ No newline at end of file diff -r f17252543cbf -r 734d3f0853bf Agendas/trunk/src/Agendas.Configurations/TwitterSignInConfigurationElement.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Configurations/TwitterSignInConfigurationElement.cs Fri Aug 05 16:55:18 2011 -0300 @@ -0,0 +1,21 @@ +using System.Configuration; + +namespace AltNetHispano.Agendas.Configurations +{ + public class TwitterSignInConfigurationElement : ConfigurationElement + { + [ConfigurationProperty("consumerKey")] + public string ConsumerKey + { + get { return base["consumerKey"] as string; } + + } + + [ConfigurationProperty("consumerSecret")] + public string ConsumerSecret + { + get { return base["consumerSecret"] as string; } + + } + } +} \ No newline at end of file diff -r f17252543cbf -r 734d3f0853bf Agendas/trunk/src/Agendas.Configurations/build.bat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Configurations/build.bat Fri Aug 05 16:55:18 2011 -0300 @@ -0,0 +1,3 @@ +"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools\xsd.exe" "C:\Users\nelo.NELUZ\Desktop\altnethispano\Agendas\trunk\src\Agendas.Configurations\bin\Debug\AltNetHispano.Agendas.Configurations.dll" /type:PublicadoresSection /outputdir:"C:\Users\nelo.NELUZ\Desktop\altnethispano\Agendas\trunk\src\Agendas.Configurations" + +PAUSE \ No newline at end of file diff -r f17252543cbf -r 734d3f0853bf Agendas/trunk/src/Agendas.Factories/AgendaFactory.cs --- a/Agendas/trunk/src/Agendas.Factories/AgendaFactory.cs Thu Aug 04 18:45:18 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Factories/AgendaFactory.cs Fri Aug 05 16:55:18 2011 -0300 @@ -1,7 +1,9 @@ -using Agendas.NHibernate; +using Agendas.Blog.Impl; +using Agendas.NHibernate; using AltNetHispano.Agendas.Domain; using AltNetHispano.Agendas.Domain.Repositories; using AltNetHispano.Agendas.Domain.Services; +using AltNetHispano.Agendas.Google; using AltNetHispano.Agendas.Repositories.NHibernate; using AltNetHispano.Agendas.Twitter; using NHibernate; @@ -15,10 +17,13 @@ public static Agenda GetAgenda() { + var publicadores = + new CompositePublicador(new IPublicador[] {new TwitterPublicador(), new BlogPublicador(), new GooglePublicador()}); + ISessionFactory sessionFactory = NhHelper.GetSessionFactory(); return _agenda ?? (_agenda = - new Agenda(new TwitterPublicador(), new EventoRepository(sessionFactory), + new Agenda(publicadores, new EventoRepository(sessionFactory), new PersonaRepository(sessionFactory), new PatrocinadorRepository(sessionFactory))); } diff -r f17252543cbf -r 734d3f0853bf Agendas/trunk/src/Agendas.Factories/Agendas.Factories.csproj --- a/Agendas/trunk/src/Agendas.Factories/Agendas.Factories.csproj Thu Aug 04 18:45:18 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Factories/Agendas.Factories.csproj Fri Aug 05 16:55:18 2011 -0300 @@ -49,10 +49,18 @@ + + {DDD605FF-EF42-428A-AEB6-F3496A46A82B} + Agendas.Blog + {A14907DF-02E4-4FA7-BE27-4292AF50AA22} Agendas.Domain + + {45804F1F-EB72-4F82-A227-088CAD9B785D} + Agendas.Google + {9519A43A-9D5E-4BFD-9F88-AFFC53C9973A} Agendas.NHibernate diff -r f17252543cbf -r 734d3f0853bf Agendas/trunk/src/Agendas.Google.Test/App.config --- a/Agendas/trunk/src/Agendas.Google.Test/App.config Thu Aug 04 18:45:18 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Google.Test/App.config Fri Aug 05 16:55:18 2011 -0300 @@ -1,8 +1,13 @@ - + + - - - - - + +
+ + + + + + + \ No newline at end of file diff -r f17252543cbf -r 734d3f0853bf Agendas/trunk/src/Agendas.Google.Test/GCalendarTest.cs --- a/Agendas/trunk/src/Agendas.Google.Test/GCalendarTest.cs Thu Aug 04 18:45:18 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Google.Test/GCalendarTest.cs Fri Aug 05 16:55:18 2011 -0300 @@ -1,10 +1,8 @@ using System; -using System.Configuration; using AltNetHispano.Agendas.Domain; using AltNetHispano.Agendas.Google; using AltNetHispano.Agendas.Google.DetailsEvents; using AltNetHispano.Agendas.Tests; -using Moq; using NUnit.Framework; namespace Agendas.Google.Test @@ -17,9 +15,7 @@ [Test] public void CrearEventoGoogleCalendar() { - var gCalendar = new GCalendarAdapter("VAN", ConfigurationManager.AppSettings["userNameGoogleCalendar"], - ConfigurationManager.AppSettings["passwordGoogleCalendar"], - ConfigurationManager.AppSettings["calendarIdGoogleCalendar"]); + var gCalendar = new GCalendarAdapter("VAN"); var ev = Evento.Agendar("Evento Test", null, _fechaEvento, "url", TipoEvento.Cafe); string message; var detail = new CafeGEventDetail(); @@ -32,9 +28,7 @@ [Test] public void EliminarEventoGoogleCalendar() { - var gCalendar = new GCalendarAdapter("VAN", ConfigurationManager.AppSettings["userNameGoogleCalendar"], - ConfigurationManager.AppSettings["passwordGoogleCalendar"], - ConfigurationManager.AppSettings["calendarIdGoogleCalendar"]); + var gCalendar = new GCalendarAdapter("VAN"); string message; var startEvent = new DateTime(_fechaEvento.Year, _fechaEvento.Month, _fechaEvento.Day, 18, 0, 0, DateTimeKind.Utc); diff -r f17252543cbf -r 734d3f0853bf Agendas/trunk/src/Agendas.Google/Agendas.Google.csproj --- a/Agendas/trunk/src/Agendas.Google/Agendas.Google.csproj Thu Aug 04 18:45:18 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Google/Agendas.Google.csproj Fri Aug 05 16:55:18 2011 -0300 @@ -63,6 +63,10 @@ + + {583304D0-51C7-4808-BE20-6E9A904CA908} + Agendas.Configurations + {A14907DF-02E4-4FA7-BE27-4292AF50AA22} Agendas.Domain diff -r f17252543cbf -r 734d3f0853bf Agendas/trunk/src/Agendas.Google/GCalendarAdapter.cs --- a/Agendas/trunk/src/Agendas.Google/GCalendarAdapter.cs Thu Aug 04 18:45:18 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Google/GCalendarAdapter.cs Fri Aug 05 16:55:18 2011 -0300 @@ -1,79 +1,90 @@ using System; +using AltNetHispano.Agendas.Configurations; using Google.GData.Calendar; using Google.GData.Extensions; namespace AltNetHispano.Agendas.Google { - public class GCalendarAdapter : IGCalendarAdapter - { - private readonly CalendarService _service; - private readonly Uri _feedUri; + public class GCalendarAdapter : IGCalendarAdapter + { + private readonly CalendarService _service; + private readonly Uri _feedUri; - public bool CreateEvent(IGEventDetail gEventDetail, out string message) - { - try - { - var entry = new EventEntry - { - Title = { Text = gEventDetail.Title }, - Content = { Content = gEventDetail.Summary } - }; + public bool CreateEvent(IGEventDetail gEventDetail, out string message) + { + try + { + var entry = new EventEntry + { + Title = {Text = gEventDetail.Title}, + Content = {Content = gEventDetail.Summary} + }; - var eventLocation = new Where - { - ValueString = gEventDetail.Location - }; + var eventLocation = new Where + { + ValueString = gEventDetail.Location + }; - entry.Locations.Add(eventLocation); + entry.Locations.Add(eventLocation); - var eventTime = new When(gEventDetail.StartEvent, gEventDetail.EndEvent); - entry.Times.Add(eventTime); + var eventTime = new When(gEventDetail.StartEvent, gEventDetail.EndEvent); + entry.Times.Add(eventTime); - _service.Insert(_feedUri, entry); - message = "Event create successful"; - return true; - } - catch (Exception exception) - { - message = exception.Message; - return false; - } - } + _service.Insert(_feedUri, entry); + message = "Event create successful"; + return true; + } + catch (Exception exception) + { + message = exception.Message; + return false; + } + } - public bool DeleteEvent(DateTime startEvent, DateTime endEvent, out string message) - { - try - { - var myQuery = new EventQuery - { - StartTime = startEvent, - EndTime = endEvent, - Uri = _feedUri - }; + public bool DeleteEvent(DateTime startEvent, DateTime endEvent, out string message) + { + try + { + var myQuery = new EventQuery + { + StartTime = startEvent, + EndTime = endEvent, + Uri = _feedUri + }; - var myResultsFeed = _service.Query(myQuery); - if (myResultsFeed.Entries.Count > 0) - { - myResultsFeed.Entries[0].Delete(); - message = "Event delete successful"; - return true; - } + var myResultsFeed = _service.Query(myQuery); + if (myResultsFeed.Entries.Count > 0) + { + myResultsFeed.Entries[0].Delete(); + message = "Event delete successful"; + return true; + } - message = "Event not found"; - return false; - } - catch (Exception exception) - { - message = exception.Message; - return false; - } - } + message = "Event not found"; + return false; + } + catch (Exception exception) + { + message = exception.Message; + return false; + } + } - public GCalendarAdapter(string applicationName ,string userName, string password, string calendarId) - { - _service = new CalendarService(applicationName); - _service.setUserCredentials(userName, password); - _feedUri = new Uri("https://www.google.com/calendar/feeds/" + calendarId + "/private/full"); - } - } + public GCalendarAdapter(string applicationName) : this(applicationName, + AgendasConfigurationManager.Publicadores.Google.Calendar. + UserName, + AgendasConfigurationManager.Publicadores.Google.Calendar. + Password, + AgendasConfigurationManager.Publicadores.Google.Calendar. + CalendarId) + { + } + + public GCalendarAdapter(string applicationName, string userName, string password, string calendarId) + { + _service = new CalendarService(applicationName); + _service.setUserCredentials(userName, password); + _feedUri = new Uri("https://www.google.com/calendar/feeds/" + calendarId + "/private/full"); + } + } } \ No newline at end of file diff -r f17252543cbf -r 734d3f0853bf Agendas/trunk/src/Agendas.Google/GooglePublicador.cs --- a/Agendas/trunk/src/Agendas.Google/GooglePublicador.cs Thu Aug 04 18:45:18 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Google/GooglePublicador.cs Fri Aug 05 16:55:18 2011 -0300 @@ -1,5 +1,5 @@ using System.Collections.Generic; -using System.Configuration; +using AltNetHispano.Agendas.Configurations; using AltNetHispano.Agendas.Domain; using AltNetHispano.Agendas.Google.DetailsEvents; @@ -12,21 +12,23 @@ private static string GetUserName { - get { return ConfigurationManager.AppSettings["userNameGoogleCalendar"]; } + get { return AgendasConfigurationManager.Publicadores.Google.Calendar.UserName; } } private static string GetPassword { - get { return ConfigurationManager.AppSettings["passwordGoogleCalendar"]; } + get { return AgendasConfigurationManager.Publicadores.Google.Calendar.Password; } } private static string GetCalendarId { - get { return ConfigurationManager.AppSettings["calendarIdGoogleCalendar"]; } + get { return AgendasConfigurationManager.Publicadores.Google.Calendar.CalendarId; } } public void Publicar(IEnumerable tracks) { + if (!AgendasConfigurationManager.Publicadores.Google.Enabled) return; + foreach (var track in tracks) { switch (track.Accion) diff -r f17252543cbf -r 734d3f0853bf Agendas/trunk/src/Agendas.Tests/App.config --- a/Agendas/trunk/src/Agendas.Tests/App.config Thu Aug 04 18:45:18 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Tests/App.config Fri Aug 05 16:55:18 2011 -0300 @@ -1,6 +1,15 @@  + +
+ + + + + + + \ No newline at end of file diff -r f17252543cbf -r 734d3f0853bf Agendas/trunk/src/Agendas.Tests/Blog/PostWriterWebServiceAdapterTests.cs --- a/Agendas/trunk/src/Agendas.Tests/Blog/PostWriterWebServiceAdapterTests.cs Thu Aug 04 18:45:18 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Tests/Blog/PostWriterWebServiceAdapterTests.cs Fri Aug 05 16:55:18 2011 -0300 @@ -1,14 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Configuration; -using System.Linq; -using System.ServiceModel; -using System.Text; -using Agendas.Blog; -using Agendas.Blog.Exceptions; +using System.ServiceModel; using Agendas.Blog.Impl; -using AltNetHispano.Agendas.Domain; -using Moq; using NUnit.Framework; namespace AltNetHispano.Agendas.Tests.Blog diff -r f17252543cbf -r 734d3f0853bf Agendas/trunk/src/Agendas.Twitter.Tests/Agendas.Twitter.Tests.csproj --- a/Agendas/trunk/src/Agendas.Twitter.Tests/Agendas.Twitter.Tests.csproj Thu Aug 04 18:45:18 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Twitter.Tests/Agendas.Twitter.Tests.csproj Fri Aug 05 16:55:18 2011 -0300 @@ -63,7 +63,9 @@ - + + Designer + diff -r f17252543cbf -r 734d3f0853bf Agendas/trunk/src/Agendas.Twitter.Tests/App.config --- a/Agendas/trunk/src/Agendas.Twitter.Tests/App.config Thu Aug 04 18:45:18 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Twitter.Tests/App.config Fri Aug 05 16:55:18 2011 -0300 @@ -1,9 +1,15 @@ - + + - - - - - - + +
+ + + + + + + + + \ No newline at end of file diff -r f17252543cbf -r 734d3f0853bf Agendas/trunk/src/Agendas.Twitter.Tests/Publicador_tests.cs --- a/Agendas/trunk/src/Agendas.Twitter.Tests/Publicador_tests.cs Thu Aug 04 18:45:18 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Twitter.Tests/Publicador_tests.cs Fri Aug 05 16:55:18 2011 -0300 @@ -4,7 +4,6 @@ using AltNetHispano.Agendas.Twitter; using Moq; using NUnit.Framework; -using Twitterizer; namespace Agendas.Twitter.Tests { @@ -15,17 +14,10 @@ public void Proponer_evento() { var adapter = new Mock(); + + string message; string twitt = null; - - var response = new TwitterResponse - { - Result = - RequestResult.Success - }; - - adapter.Setup(a => a.UpdateStatus(It.IsAny(), It.IsAny())) - .Returns(response) - .Callback((tokens, status) => twitt = status); + adapter.Setup(a => a.Update(It.IsAny(), out message)).Returns(true).Callback((status, m) => twitt = status); var publicador = new TwitterPublicador(adapter.Object); @@ -33,7 +25,7 @@ agenda.Proponer("Identity Providers", null, null, TipoEvento.GrupoEstudio); - adapter.Verify(a => a.UpdateStatus(It.IsAny(), It.IsAny()), Times.Once()); + adapter.Verify(a => a.Update(It.IsAny(), out message), Times.Once()); Assert.That(twitt, Is.StringContaining("GrupoEstudio")); } @@ -42,28 +34,21 @@ public void Proponer_y_agendar_evento() { var adapter = new Mock(); + + string message; string twitt = null; - - var response = new TwitterResponse - { - Result = - RequestResult.Success - }; - - adapter.Setup(a => a.UpdateStatus(It.IsAny(), It.IsAny())) - .Returns(response) - .Callback((tokens, status) => twitt = status); + adapter.Setup(a => a.Update(It.IsAny(), out message)).Returns(true).Callback((status, m) => twitt = status); var publicador = new TwitterPublicador(adapter.Object); var agenda = new Agenda(publicador, DefaultEventoRepository, DefaultPersonaRepository, DefaultPatrocinadorRepository); agenda.Proponer("Identity Providers", null, null, TipoEvento.GrupoEstudio); - adapter.Verify(a => a.UpdateStatus(It.IsAny(), It.IsAny()), Times.Once()); + adapter.Verify(a => a.Update(It.IsAny(), out message), Times.Once()); agenda.Agendar("Identity Providers", TestsHelper.GetOrCreatePonente("Nelo Pauselli"), DateTime.Today.AddDays(7), null, TipoEvento.GrupoEstudio); - adapter.Verify(a => a.UpdateStatus(It.IsAny(), It.IsAny()), Times.Exactly(2)); + adapter.Verify(a => a.Update(It.IsAny(), out message), Times.Exactly(2)); Assert.That(twitt, Is.StringContaining("@nelopauselli")); diff -r f17252543cbf -r 734d3f0853bf Agendas/trunk/src/Agendas.Twitter.Tests/Send_twitt_tests.cs --- a/Agendas/trunk/src/Agendas.Twitter.Tests/Send_twitt_tests.cs Thu Aug 04 18:45:18 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Twitter.Tests/Send_twitt_tests.cs Fri Aug 05 16:55:18 2011 -0300 @@ -10,10 +10,10 @@ [Test] public void Send_twitt() { - var p = new TwitterPublicador(); + var p = new TwitterAdapter(); string message; - var r = p.Publicar("Ejecutando los tests. Hora: " + DateTime.Now, out message); + var r = p.Update("Ejecutando los tests. Hora: " + DateTime.Now, out message); Console.WriteLine(message); Assert.IsTrue(r); diff -r f17252543cbf -r 734d3f0853bf Agendas/trunk/src/Agendas.Twitter/Agendas.Twitter.csproj --- a/Agendas/trunk/src/Agendas.Twitter/Agendas.Twitter.csproj Thu Aug 04 18:45:18 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Twitter/Agendas.Twitter.csproj Fri Aug 05 16:55:18 2011 -0300 @@ -60,6 +60,10 @@ + + {583304D0-51C7-4808-BE20-6E9A904CA908} + Agendas.Configurations + {A14907DF-02E4-4FA7-BE27-4292AF50AA22} Agendas.Domain diff -r f17252543cbf -r 734d3f0853bf Agendas/trunk/src/Agendas.Twitter/ITwitterAdapter.cs --- a/Agendas/trunk/src/Agendas.Twitter/ITwitterAdapter.cs Thu Aug 04 18:45:18 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Twitter/ITwitterAdapter.cs Fri Aug 05 16:55:18 2011 -0300 @@ -1,4 +1,5 @@ using System; +using AltNetHispano.Agendas.Configurations; using Twitterizer; namespace AltNetHispano.Agendas.Twitter @@ -7,11 +8,40 @@ { Uri BuildAuthorizationUri(string consumerKey, string consumerSecret, string callbackAddress); string GetAccessToken(string consumerKey, string consumerSecret, string requestToken, string verifier); - TwitterResponse UpdateStatus(OAuthTokens tokens, string status); + bool Update(string status, out string message); } public class TwitterAdapter : ITwitterAdapter { + private static TwitterConfigurationElement _config; + + public TwitterAdapter() + { + _config = AgendasConfigurationManager.Publicadores.Twitter; + } + + private static string ConsumerKey + { + get { return _config.SendTwitter.ConsumerKey; } + } + + private static string ConsumerSecret + { + get { return _config.SendTwitter.ConsumerSecret; } + } + + + private static string AccessToken + { + get { return _config.SendTwitter.AccessToken; } + } + + + private static string AccessTokenSecret + { + get { return _config.SendTwitter.AccessTokenSecret; } + } + public Uri BuildAuthorizationUri(string consumerKey, string consumerSecret, string callbackAddress) { // Obtain a request token @@ -47,9 +77,21 @@ } - public TwitterResponse UpdateStatus(OAuthTokens tokens, string status) + public bool Update(string status, out string message) { - return TwitterStatus.Update(tokens, status); + var tokens = new OAuthTokens + { + ConsumerKey = ConsumerKey, + ConsumerSecret = ConsumerSecret, + AccessToken = AccessToken, + AccessTokenSecret = AccessTokenSecret + }; + + var response = TwitterStatus.Update(tokens, status); + + message = response.ErrorMessage; + return response.Result == RequestResult.Success; + } } } \ No newline at end of file diff -r f17252543cbf -r 734d3f0853bf Agendas/trunk/src/Agendas.Twitter/TwitterPublicador.cs --- a/Agendas/trunk/src/Agendas.Twitter/TwitterPublicador.cs Thu Aug 04 18:45:18 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Twitter/TwitterPublicador.cs Fri Aug 05 16:55:18 2011 -0300 @@ -1,9 +1,8 @@ using System.Collections.Generic; -using System.Configuration; using System.Linq; +using AltNetHispano.Agendas.Configurations; using AltNetHispano.Agendas.Domain; using AltNetHispano.Agendas.Twitter.Writers; -using Twitterizer; namespace AltNetHispano.Agendas.Twitter { @@ -32,30 +31,10 @@ private const int LIMITE_MENSAJE = 140; - private static string ConsumerKey - { - get { return ConfigurationManager.AppSettings["consumerKeyAppTwitt"]; } - } - - private static string ConsumerSecret - { - get { return ConfigurationManager.AppSettings["consumerSecretAppTwitt"]; } - } - - - private static string AccessToken - { - get { return ConfigurationManager.AppSettings["accessTokenAppTwitt"]; } - } - - - private static string AccessTokenSecret - { - get { return ConfigurationManager.AppSettings["accessTokenSecretAppTwitt"]; } - } - public void Publicar(IEnumerable tracks) { + if (!AgendasConfigurationManager.Publicadores.Twitter.Enabled) return; + foreach (var track in tracks) { //Si ya hicimos el twitt de este track, no volvemos a hacerlo @@ -65,7 +44,7 @@ if (!string.IsNullOrWhiteSpace(twitt)) { string message; - bool success = Publicar(twitt, out message); + bool success = _twitterAdapter.Update(twitt, out message); track.LogAdd(new TrackLog(TrackLogPropietario.Twitter, message, track.Usuario, success)); } } @@ -81,21 +60,5 @@ return body.Length > LIMITE_MENSAJE ? body.Substring(0, LIMITE_MENSAJE - 1) : body; } - - public bool Publicar(string status, out string message) - { - var tokens = new OAuthTokens - { - ConsumerKey = ConsumerKey, - ConsumerSecret = ConsumerSecret, - AccessToken = AccessToken, - AccessTokenSecret = AccessTokenSecret - }; - - var response = _twitterAdapter.UpdateStatus(tokens, status); - - message = response.ErrorMessage; - return response.Result == RequestResult.Success; - } } } \ No newline at end of file diff -r f17252543cbf -r 734d3f0853bf Agendas/trunk/src/Agendas.Twitter/oAuthTwitter.cs --- a/Agendas/trunk/src/Agendas.Twitter/oAuthTwitter.cs Thu Aug 04 18:45:18 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Twitter/oAuthTwitter.cs Fri Aug 05 16:55:18 2011 -0300 @@ -1,5 +1,5 @@ using System; -using System.Configuration; +using AltNetHispano.Agendas.Configurations; namespace AltNetHispano.Agendas.Twitter { @@ -19,12 +19,12 @@ private string ConsumerKey { - get { return ConfigurationManager.AppSettings["consumerKeyAppSignIn"]; } + get { return AgendasConfigurationManager.Publicadores.Twitter.SignIn.ConsumerKey; } } private string ConsumerSecret { - get { return ConfigurationManager.AppSettings["consumerSecretAppSignIn"]; } + get { return AgendasConfigurationManager.Publicadores.Twitter.SignIn.ConsumerSecret; } } public Uri AuthorizationLinkGet(string callbackAddress) diff -r f17252543cbf -r 734d3f0853bf Agendas/trunk/src/Agendas.Web/Agendas.Web.csproj --- a/Agendas/trunk/src/Agendas.Web/Agendas.Web.csproj Thu Aug 04 18:45:18 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Web/Agendas.Web.csproj Fri Aug 05 16:55:18 2011 -0300 @@ -56,7 +56,6 @@ - @@ -163,6 +162,10 @@ + + {583304D0-51C7-4808-BE20-6E9A904CA908} + Agendas.Configurations + {A14907DF-02E4-4FA7-BE27-4292AF50AA22} Agendas.Domain diff -r f17252543cbf -r 734d3f0853bf Agendas/trunk/src/Agendas.Web/DataProviders.cs --- a/Agendas/trunk/src/Agendas.Web/DataProviders.cs Thu Aug 04 18:45:18 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Web/DataProviders.cs Fri Aug 05 16:55:18 2011 -0300 @@ -23,6 +23,5 @@ select new SelectListItem {Text = p.Nombre, Value = p.Id.ToString(), Selected = p.Id.Equals(id)}; } - } -} \ No newline at end of file +} diff -r f17252543cbf -r 734d3f0853bf Agendas/trunk/src/Agendas.Web/Web.config --- a/Agendas/trunk/src/Agendas.Web/Web.config Thu Aug 04 18:45:18 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Web/Web.config Fri Aug 05 16:55:18 2011 -0300 @@ -5,23 +5,15 @@ --> + +
+ + - - - - - - - - - - - - @@ -93,4 +85,17 @@ + + + + + + + + + + + + + \ No newline at end of file diff -r f17252543cbf -r 734d3f0853bf Agendas/trunk/src/Agendas.sln --- a/Agendas/trunk/src/Agendas.sln Thu Aug 04 18:45:18 2011 -0300 +++ b/Agendas/trunk/src/Agendas.sln Fri Aug 05 16:55:18 2011 -0300 @@ -34,6 +34,10 @@ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Agendas.Google.Test", "Agendas.Google.Test\Agendas.Google.Test.csproj", "{3257EEC5-8FB7-4AD6-AD4C-F9748A1791B1}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Agendas.Configurations", "Agendas.Configurations\Agendas.Configurations.csproj", "{583304D0-51C7-4808-BE20-6E9A904CA908}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Agendas.Configurations.Tests", "Agendas.Configurations.Tests\Agendas.Configurations.Tests.csproj", "{BBE36765-6AAB-4689-B2F3-6D18E3F11746}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -92,6 +96,14 @@ {3257EEC5-8FB7-4AD6-AD4C-F9748A1791B1}.Debug|Any CPU.Build.0 = Debug|Any CPU {3257EEC5-8FB7-4AD6-AD4C-F9748A1791B1}.Release|Any CPU.ActiveCfg = Release|Any CPU {3257EEC5-8FB7-4AD6-AD4C-F9748A1791B1}.Release|Any CPU.Build.0 = Release|Any CPU + {583304D0-51C7-4808-BE20-6E9A904CA908}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {583304D0-51C7-4808-BE20-6E9A904CA908}.Debug|Any CPU.Build.0 = Debug|Any CPU + {583304D0-51C7-4808-BE20-6E9A904CA908}.Release|Any CPU.ActiveCfg = Release|Any CPU + {583304D0-51C7-4808-BE20-6E9A904CA908}.Release|Any CPU.Build.0 = Release|Any CPU + {BBE36765-6AAB-4689-B2F3-6D18E3F11746}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BBE36765-6AAB-4689-B2F3-6D18E3F11746}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BBE36765-6AAB-4689-B2F3-6D18E3F11746}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BBE36765-6AAB-4689-B2F3-6D18E3F11746}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE