Mercurial > altnet-hispano
changeset 130:0ea32a748453
Se termina el publicador via el calendario de google, además se realizan las pruebas unitarias.
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Google.Test/Agendas.Google.Test.csproj Sun Jul 10 18:50:11 2011 -0400 @@ -0,0 +1,89 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProductVersion>8.0.30703</ProductVersion> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{3257EEC5-8FB7-4AD6-AD4C-F9748A1791B1}</ProjectGuid> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>Agendas.Google.Test</RootNamespace> + <AssemblyName>Agendas.Google.Test</AssemblyName> + <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> + <FileAlignment>512</FileAlignment> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <ItemGroup> + <Reference Include="Moq"> + <HintPath>..\packages\Moq.4.0.10827\lib\NET40\Moq.dll</HintPath> + </Reference> + <Reference Include="nunit.framework, Version=2.5.10.11092, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL"> + <SpecificVersion>False</SpecificVersion> + <HintPath>..\packages\NUnit.2.5.10.11092\lib\nunit.framework.dll</HintPath> + </Reference> + <Reference Include="nunit.mocks, Version=2.5.10.11092, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL"> + <SpecificVersion>False</SpecificVersion> + <HintPath>..\packages\NUnit.2.5.10.11092\lib\nunit.mocks.dll</HintPath> + </Reference> + <Reference Include="pnunit.framework, Version=1.0.4109.34242, Culture=neutral, processorArchitecture=MSIL"> + <SpecificVersion>False</SpecificVersion> + <HintPath>..\packages\NUnit.2.5.10.11092\lib\pnunit.framework.dll</HintPath> + </Reference> + <Reference Include="System" /> + <Reference Include="System.Configuration" /> + <Reference Include="System.Core" /> + <Reference Include="System.Xml.Linq" /> + <Reference Include="System.Data.DataSetExtensions" /> + <Reference Include="Microsoft.CSharp" /> + <Reference Include="System.Data" /> + <Reference Include="System.Xml" /> + </ItemGroup> + <ItemGroup> + <Compile Include="GCalendarTest.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + <Compile Include="PublicadorTest.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="App.config" /> + <None Include="packages.config" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\Agendas.Domain\Agendas.Domain.csproj"> + <Project>{A14907DF-02E4-4FA7-BE27-4292AF50AA22}</Project> + <Name>Agendas.Domain</Name> + </ProjectReference> + <ProjectReference Include="..\Agendas.Google\Agendas.Google.csproj"> + <Project>{45804F1F-EB72-4F82-A227-088CAD9B785D}</Project> + <Name>Agendas.Google</Name> + </ProjectReference> + <ProjectReference Include="..\Agendas.Tests\Agendas.Tests.csproj"> + <Project>{29AC1253-D455-4958-9AAA-DA879C3889A4}</Project> + <Name>Agendas.Tests</Name> + </ProjectReference> + </ItemGroup> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. + Other similar extension points exist, see Microsoft.Common.targets. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> + --> +</Project> \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Google.Test/App.config Sun Jul 10 18:50:11 2011 -0400 @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="utf-8" ?> +<configuration> + <appSettings> + <add key="userNameGoogleCalendar" value="altnethispano.desa@gmail.com" /> + <add key="passwordGoogleCalendar" value="fA&Ec3wU3est" /> + <add key="calendarIdGoogleCalendar" value="altnethispano.desa@gmail.com" /> + </appSettings> +</configuration> \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Google.Test/GCalendarTest.cs Sun Jul 10 18:50:11 2011 -0400 @@ -0,0 +1,49 @@ +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 +{ + [TestFixture] + public class GCalendarTest : TestBase + { + private readonly DateTime _fechaEvento = new DateTime(2011, 07, 16); + + [Test] + public void CrearEventoGoogleCalendar() + { + var gCalendar = new GCalendarAdapter("VAN", ConfigurationManager.AppSettings["userNameGoogleCalendar"], + ConfigurationManager.AppSettings["passwordGoogleCalendar"], + ConfigurationManager.AppSettings["calendarIdGoogleCalendar"]); + var ev = Evento.Agendar("Evento Test", null, _fechaEvento, "url", TipoEvento.Cafe); + string message; + var detail = new CafeGEventDetail(); + detail.Generate(ev); + var result = gCalendar.CreateEvent(detail, out message); + + Assert.AreEqual(true, result); + Assert.AreEqual(message, "Event create successful"); + } + [Test] + public void EliminarEventoGoogleCalendar() + { + var gCalendar = new GCalendarAdapter("VAN", ConfigurationManager.AppSettings["userNameGoogleCalendar"], + ConfigurationManager.AppSettings["passwordGoogleCalendar"], + ConfigurationManager.AppSettings["calendarIdGoogleCalendar"]); + string message; + var startEvent = new DateTime(_fechaEvento.Year, _fechaEvento.Month, _fechaEvento.Day, 18, 0, 0, + DateTimeKind.Utc); + var endEvent = new DateTime(_fechaEvento.Year, _fechaEvento.Month, _fechaEvento.Day, 20, 0, 0, + DateTimeKind.Utc); + var result = gCalendar.DeleteEvent(startEvent, endEvent, out message); + + Assert.AreEqual(true, result); + Assert.AreEqual(message, "Event delete successful"); + } + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Google.Test/Properties/AssemblyInfo.cs Sun Jul 10 18:50:11 2011 -0400 @@ -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.Google.Test")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("Agendas.Google.Test")] +[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("9994c0cd-3860-491f-8ad3-a638e7b7cafa")] + +// 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")]
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Google.Test/PublicadorTest.cs Sun Jul 10 18:50:11 2011 -0400 @@ -0,0 +1,139 @@ +using System; +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 +{ + [TestFixture] + public class PublicadorTest : TestBase + { + /// <summary> + /// Validar que solamente se creen eventos cuando la acción sea Accion.Agendar + /// </summary> + [Test] + public void CuandoPublicarEventoDadoAccionAgendarEntoncesEventoCreado() + { + + } + + /// <summary> + /// Validar que se halla creado IGEventDetail según detalles y tipo de evento (VAN, Café, Grupo estudio) + /// - Summary correcto, según tipo + /// - Summary con fecha en cultura es-ES + /// - Fecha de inicio y termino en Utc. + /// - Location + /// - Titulo según tipo + /// </summary> + [Test] + public void CuandoPublicarEventoDadoTipoVanEntoncesDetalleCorrecto() + { + var adapter = new Mock<IGCalendarAdapter>(); + var detail = new VanGEventDetail(); + + var publicador = new GooglePublicador(adapter.Object); + var agenda = new Agenda(publicador, DefaultEventoRepository, DefaultPersonaRepository); + agenda.Proponer("Agile Patterns", null, null, TipoEvento.Van); + agenda.Agendar("Agile Patterns", "Alejandro Labra", new DateTime(2011, 07, 09), "https://groups.google.com/d/topic/altnet-hispano/arYEMsPiAtY/discussion", TipoEvento.Van); + + var ev = DefaultEventoRepository.GetActivos()[0]; + detail.Generate(ev); + + Assert.AreEqual("http://snipr.com/virtualaltnet", detail.Location); + Assert.AreEqual("VAN sobre Agile Patterns", detail.Title); + + Assert.AreEqual(DateTimeKind.Utc, detail.StartEvent.Kind); + Assert.AreEqual(18, detail.StartEvent.Hour); + Assert.AreEqual(ev.Fecha.Value.Day, detail.StartEvent.Day); + Assert.AreEqual(ev.Fecha.Value.Month, detail.StartEvent.Month); + Assert.AreEqual(ev.Fecha.Value.Year, detail.StartEvent.Year); + + Assert.AreEqual(DateTimeKind.Utc, detail.EndEvent.Kind); + Assert.AreEqual(20, detail.EndEvent.Hour); + Assert.AreEqual(ev.Fecha.Value.Day, detail.EndEvent.Day); + Assert.AreEqual(ev.Fecha.Value.Month, detail.EndEvent.Month); + Assert.AreEqual(ev.Fecha.Value.Year, detail.EndEvent.Year); + + Assert.AreEqual("La comunidad ALT.NET Hispano (http://altnethispano.org) realizará una VAN sobre Agile Patterns, con Alejandro Labra." + + "\n\rFecha: sábado, 09 de julio de 2011 a las 18:00 hrs. Hora Internacional (GMT/UTC), con una duración aproximada de 2 horas." + + "\n\rPueden plantear sus comentarios e inquietudes sobre el tema de la reunión en: https://groups.google.com/d/topic/altnet-hispano/arYEMsPiAtY/discussion" + + "\n\rPara mayor información sobre cómo atender la reunión consulten: http://tinyurl.com/van-hispano" + + "\n\rPueden vincular el Google Calendar al suyo (http://screenr.com/nr7)", detail.Summary); + } + + [Test] + public void CuandoPublicarEventoTipoCafeEntoncesDetalleCorrecto() + { + var adapter = new Mock<IGCalendarAdapter>(); + var detail = new CafeGEventDetail(); + + var publicador = new GooglePublicador(adapter.Object); + var agenda = new Agenda(publicador, DefaultEventoRepository, DefaultPersonaRepository); + agenda.Proponer("Agile Patterns", null, null, TipoEvento.Cafe); + agenda.Agendar("Agile Patterns", null, new DateTime(2011, 07, 09), "https://groups.google.com/d/topic/altnet-hispano/arYEMsPiAtY/discussion", TipoEvento.Cafe); + + var ev = DefaultEventoRepository.GetActivos()[0]; + detail.Generate(ev); + + Assert.AreEqual("http://snipr.com/virtualaltnet", detail.Location); + Assert.AreEqual("Alt.Net Café Agile Patterns", detail.Title); + + Assert.AreEqual(DateTimeKind.Utc, detail.StartEvent.Kind); + Assert.AreEqual(18, detail.StartEvent.Hour); + Assert.AreEqual(ev.Fecha.Value.Day, detail.StartEvent.Day); + Assert.AreEqual(ev.Fecha.Value.Month, detail.StartEvent.Month); + Assert.AreEqual(ev.Fecha.Value.Year, detail.StartEvent.Year); + + Assert.AreEqual(DateTimeKind.Utc, detail.EndEvent.Kind); + Assert.AreEqual(20, detail.EndEvent.Hour); + Assert.AreEqual(ev.Fecha.Value.Day, detail.EndEvent.Day); + Assert.AreEqual(ev.Fecha.Value.Month, detail.EndEvent.Month); + Assert.AreEqual(ev.Fecha.Value.Year, detail.EndEvent.Year); + + Assert.AreEqual("La comunidad ALT.NET Hispano (http://altnethispano.org) realizará un Alt.Net Cafe virtual con el tema Agile Patterns." + + "\n\rFecha: sábado, 09 de julio de 2011 a las 18:00 hrs. Hora Internacional (GMT/UTC), con una duración aproximada de 2 horas." + + "\n\rPueden plantear sus comentarios e inquietudes sobre el tema de la reunión en: https://groups.google.com/d/topic/altnet-hispano/arYEMsPiAtY/discussion" + + "\n\rPara mayor información sobre cómo atender la reunión consulten: http://tinyurl.com/van-hispano" + + "\n\rPueden vincular el Google Calendar al suyo (http://screenr.com/nr7)", detail.Summary); + } + + [Test] + public void CuandoPublicarEventoTipoEstudioEntoncesDetalleCorrecto() + { + var adapter = new Mock<IGCalendarAdapter>(); + var detail = new EstudioGEventDetail(); + + var publicador = new GooglePublicador(adapter.Object); + var agenda = new Agenda(publicador, DefaultEventoRepository, DefaultPersonaRepository); + agenda.Proponer("Agile Patterns", null, null, TipoEvento.GrupoEstudio); + agenda.Agendar("Agile Patterns", null, new DateTime(2011, 07, 09), "https://groups.google.com/d/topic/altnet-hispano/arYEMsPiAtY/discussion", TipoEvento.GrupoEstudio); + + var ev = DefaultEventoRepository.GetActivos()[0]; + detail.Generate(ev); + + Assert.AreEqual("http://snipr.com/virtualaltnet", detail.Location); + Assert.AreEqual("Grupo de Estudio Agile Patterns", detail.Title); + + Assert.AreEqual(DateTimeKind.Utc, detail.StartEvent.Kind); + Assert.AreEqual(18, detail.StartEvent.Hour); + Assert.AreEqual(ev.Fecha.Value.Day, detail.StartEvent.Day); + Assert.AreEqual(ev.Fecha.Value.Month, detail.StartEvent.Month); + Assert.AreEqual(ev.Fecha.Value.Year, detail.StartEvent.Year); + + Assert.AreEqual(DateTimeKind.Utc, detail.EndEvent.Kind); + Assert.AreEqual(20, detail.EndEvent.Hour); + Assert.AreEqual(ev.Fecha.Value.Day, detail.EndEvent.Day); + Assert.AreEqual(ev.Fecha.Value.Month, detail.EndEvent.Month); + Assert.AreEqual(ev.Fecha.Value.Year, detail.EndEvent.Year); + + Assert.AreEqual("La comunidad ALT.NET Hispano (http://altnethispano.org) realizará un grupo de estudio sobre tema Agile Patterns." + + "\n\rFecha: sábado, 09 de julio de 2011 a las 18:00 hrs. Hora Internacional (GMT/UTC), con una duración aproximada de 2 horas." + + "\n\rPueden plantear sus comentarios e inquietudes sobre el tema de la reunión en: https://groups.google.com/d/topic/altnet-hispano/arYEMsPiAtY/discussion" + + "\n\rPara mayor información sobre cómo atender la reunión consulten: http://tinyurl.com/van-hispano" + + "\n\rPueden vincular el Google Calendar al suyo (http://screenr.com/nr7)", detail.Summary); + } + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Google.Test/packages.config Sun Jul 10 18:50:11 2011 -0400 @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<packages> + <package id="Moq" version="4.0.10827" /> + <package id="NUnit" version="2.5.10.11092" /> +</packages> \ No newline at end of file
--- a/Agendas/trunk/src/Agendas.Google/Agendas.Google.csproj Sun Jul 10 18:08:00 2011 -0400 +++ b/Agendas/trunk/src/Agendas.Google/Agendas.Google.csproj Sun Jul 10 18:50:11 2011 -0400 @@ -44,6 +44,7 @@ <HintPath>..\packages\Google.GData.Extensions.1.8.0.0\lib\Google.GData.Extensions.dll</HintPath> </Reference> <Reference Include="System" /> + <Reference Include="System.Configuration" /> <Reference Include="System.Core" /> <Reference Include="System.Xml.Linq" /> <Reference Include="System.Data.DataSetExtensions" /> @@ -52,9 +53,13 @@ <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> + <Compile Include="DetailsEvents\CafeGEventDetail.cs" /> + <Compile Include="DetailsEvents\EstudioGEventDetail.cs" /> + <Compile Include="DetailsEvents\VanGEventDetail.cs" /> <Compile Include="GCalendarAdapter.cs" /> <Compile Include="GooglePublicador.cs" /> <Compile Include="IGCalendarAdapter.cs" /> + <Compile Include="IGEventDetail.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> </ItemGroup> <ItemGroup> @@ -66,6 +71,7 @@ <ItemGroup> <None Include="packages.config" /> </ItemGroup> + <ItemGroup /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Google/DetailsEvents/CafeGEventDetail.cs Sun Jul 10 18:50:11 2011 -0400 @@ -0,0 +1,38 @@ +using System; +using System.Globalization; +using AltNetHispano.Agendas.Domain; + +namespace AltNetHispano.Agendas.Google.DetailsEvents +{ + public class CafeGEventDetail : IGEventDetail + { + private const string TextoCafe = + "La comunidad ALT.NET Hispano (http://altnethispano.org) realizará un Alt.Net Cafe virtual con el tema [NOMBRE]" + + "\n\rFecha: [FECHA] a las 18:00 hrs. Hora Internacional (GMT/UTC), con una duración aproximada de 2 horas." + + "\n\rPueden plantear sus comentarios e inquietudes sobre el tema de la reunión en: [URL_DISCUCION]" + + "\n\rPara mayor información sobre cómo atender la reunión consulten: http://tinyurl.com/van-hispano" + + "\n\rPueden vincular el Google Calendar al suyo (http://screenr.com/nr7)"; + + public string Title { get; private set; } + public string Location { get; private set; } + public string Summary { get; private set; } + public DateTime StartEvent { get; private set; } + public DateTime EndEvent { get; private set; } + + public void Generate(Evento evento) + { + Title = "Alt.Net Café " + evento.Titulo; + Location = "http://snipr.com/virtualaltnet"; + if (evento.Fecha != null) + StartEvent = new DateTime(evento.Fecha.Value.Year, evento.Fecha.Value.Month, evento.Fecha.Value.Day, + 18, 0, 0, DateTimeKind.Utc); + EndEvent = StartEvent.AddHours(2); + + var cultureInfo = new CultureInfo("es-ES", false).DateTimeFormat; + + Summary = TextoCafe.Replace("[NOMBRE]", evento.Titulo). + Replace("[FECHA]", StartEvent.ToString("D", cultureInfo)). + Replace("[URL_DISCUCION]", evento.UrlInvitacion); + } + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Google/DetailsEvents/EstudioGEventDetail.cs Sun Jul 10 18:50:11 2011 -0400 @@ -0,0 +1,38 @@ +using System; +using System.Globalization; +using AltNetHispano.Agendas.Domain; + +namespace AltNetHispano.Agendas.Google.DetailsEvents +{ + public class EstudioGEventDetail : IGEventDetail + { + private const string TextoEstudio = + "La comunidad ALT.NET Hispano (http://altnethispano.org) realizará un grupo de estudio sobre [NOMBRE]" + + "\n\rFecha: [FECHA] a las 18:00 hrs. Hora Internacional (GMT/UTC), con una duración aproximada de 2 horas." + + "\n\rPueden plantear sus comentarios e inquietudes sobre el tema de la reunión en: [URL_DISCUCION]" + + "\n\rPara mayor información sobre cómo atender la reunión consulten: http://tinyurl.com/van-hispano" + + "\n\rPueden vincular el Google Calendar al suyo (http://screenr.com/nr7)"; + + public string Title { get; private set; } + public string Location { get; private set; } + public string Summary { get; private set; } + public DateTime StartEvent { get; private set; } + public DateTime EndEvent { get; private set; } + + public void Generate(Evento evento) + { + Title = "Grupo de Estudio " + evento.Titulo; + Location = "http://snipr.com/virtualaltnet"; + if (evento.Fecha != null) + StartEvent = new DateTime(evento.Fecha.Value.Year, evento.Fecha.Value.Month, evento.Fecha.Value.Day, + 18, 0, 0, DateTimeKind.Utc); + EndEvent = StartEvent.AddHours(2); + + var cultureInfo = new CultureInfo("es-ES", false).DateTimeFormat; + + Summary = TextoEstudio.Replace("[NOMBRE]", evento.Titulo). + Replace("[FECHA]", StartEvent.ToString("D", cultureInfo)). + Replace("[URL_DISCUCION]", evento.UrlInvitacion); + } + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Google/DetailsEvents/VanGEventDetail.cs Sun Jul 10 18:50:11 2011 -0400 @@ -0,0 +1,40 @@ +using System; +using System.Globalization; +using AltNetHispano.Agendas.Domain; + +namespace AltNetHispano.Agendas.Google.DetailsEvents +{ + public class VanGEventDetail : IGEventDetail + { + private const string TextoVan = + "La comunidad ALT.NET Hispano (http://altnethispano.org) realizará una VAN sobre [NOMBRE], con [NOMBRE_EXPOSITOR]." + + "\n\rFecha: [FECHA] a las 18:00 hrs. Hora Internacional (GMT/UTC), con una duración aproximada de 2 horas." + + "\n\rPueden plantear sus comentarios e inquietudes sobre el tema de la reunión en: [URL_DISCUCION]" + + "\n\rPara mayor información sobre cómo atender la reunión consulten: http://tinyurl.com/van-hispano" + + "\n\rPueden vincular el Google Calendar al suyo (http://screenr.com/nr7)"; + + + public string Title { get; private set; } + public string Location { get; private set; } + public string Summary { get; private set; } + public DateTime StartEvent { get; private set; } + public DateTime EndEvent { get; private set; } + + public void Generate(Evento evento) + { + Title = "VAN sobre " + evento.Titulo; + Location = "http://snipr.com/virtualaltnet"; + if (evento.Fecha != null) + StartEvent = new DateTime(evento.Fecha.Value.Year, evento.Fecha.Value.Month, evento.Fecha.Value.Day, + 18, 0, 0, DateTimeKind.Utc); + EndEvent = StartEvent.AddHours(2); + + var cultureInfo = new CultureInfo( "es-ES", false ).DateTimeFormat; + + Summary = TextoVan.Replace("[NOMBRE]", evento.Titulo). + Replace("[NOMBRE_EXPOSITOR]", evento.Ponente.Nombre). + Replace("[FECHA]", StartEvent.ToString("D", cultureInfo)). + Replace("[URL_DISCUCION]", evento.UrlInvitacion); + } + } +}
--- a/Agendas/trunk/src/Agendas.Google/GCalendarAdapter.cs Sun Jul 10 18:08:00 2011 -0400 +++ b/Agendas/trunk/src/Agendas.Google/GCalendarAdapter.cs Sun Jul 10 18:50:11 2011 -0400 @@ -9,39 +9,64 @@ private readonly CalendarService _service; private readonly Uri _feedUri; - public void CreateEvent(string title, DateTime startEvent, DateTime endEvent, string location, string summary) + public bool CreateEvent(IGEventDetail gEventDetail, out string message) { - var entry = new EventEntry - { - Title = { Text = title }, - Content = { Content = summary } - }; + 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 = location - }; + entry.Locations.Add(eventLocation); + + var eventTime = new When(gEventDetail.StartEvent, gEventDetail.EndEvent); + entry.Times.Add(eventTime); - entry.Locations.Add(eventLocation); - - var eventTime = new When(startEvent, endEvent); - entry.Times.Add(eventTime); - - _service.Insert(_feedUri, entry); + _service.Insert(_feedUri, entry); + message = "Event create successful"; + return true; + } + catch (Exception exception) + { + message = exception.Message; + return false; + } } - public void DeleteEvent(DateTime startEvent, DateTime endEvent) + public bool DeleteEvent(DateTime startEvent, DateTime endEvent, out string message) { - var myQuery = new EventQuery - { - StartTime = startEvent, - EndTime = endEvent, - Uri = _feedUri - }; + 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(); + 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; + } } public GCalendarAdapter(string applicationName ,string userName, string password, string calendarId)
--- a/Agendas/trunk/src/Agendas.Google/GooglePublicador.cs Sun Jul 10 18:08:00 2011 -0400 +++ b/Agendas/trunk/src/Agendas.Google/GooglePublicador.cs Sun Jul 10 18:50:11 2011 -0400 @@ -1,14 +1,62 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; +using System.Configuration; using AltNetHispano.Agendas.Domain; +using AltNetHispano.Agendas.Google.DetailsEvents; namespace AltNetHispano.Agendas.Google { public class GooglePublicador : IPublicador { - public void Publicar(IEnumerable<Track> tracks) + private readonly IGCalendarAdapter _adapter; + private readonly IDictionary<TipoEvento, IGEventDetail> _gEventDetails; + + private static string GetUserName + { + get { return ConfigurationManager.AppSettings["userNameGoogleCalendar"]; } + } + + private static string GetPassword + { + get { return ConfigurationManager.AppSettings["passwordGoogleCalendar"]; } + } + + private static string GetCalendarId + { + get { return ConfigurationManager.AppSettings["calendarIdGoogleCalendar"]; } + } + + public void Publicar(IEnumerable<Track> tracks) { - throw new NotImplementedException(); + foreach (var track in tracks) + { + if (track.Accion == Accion.Agendar) + PublicarAccionAgendar(track); + } } + + private void PublicarAccionAgendar(Track track) + { + string message; + _gEventDetails[track.Evento.Tipo].Generate(track.Evento); + var result = _adapter.CreateEvent(_gEventDetails[track.Evento.Tipo], out message); + track.LogAdd(new TrackLog(TrackLogPropietario.Calendario, message, track.Usuario, result)); + } + + public GooglePublicador() + : this(new GCalendarAdapter("VAN", GetUserName, GetPassword, GetCalendarId)) + { + } + + public GooglePublicador(IGCalendarAdapter gCalendarAdapter) + { + _adapter = gCalendarAdapter; + + _gEventDetails = new Dictionary<TipoEvento, IGEventDetail> + { + {TipoEvento.Van, new VanGEventDetail()}, + {TipoEvento.Cafe, new CafeGEventDetail()}, + {TipoEvento.GrupoEstudio, new EstudioGEventDetail()} + }; + } } } \ No newline at end of file
--- a/Agendas/trunk/src/Agendas.Google/IGCalendarAdapter.cs Sun Jul 10 18:08:00 2011 -0400 +++ b/Agendas/trunk/src/Agendas.Google/IGCalendarAdapter.cs Sun Jul 10 18:50:11 2011 -0400 @@ -10,18 +10,16 @@ /// <summary> /// Method to insert new calendar event /// </summary> - /// <param name="title">Title of the Event</param> - /// <param name="startEvent">Date and Time of event start</param> - /// <param name="endEvent">Date and Time of event end</param> - /// <param name="location">Place of the event</param> - /// <param name="summary">Description of the event</param> - void CreateEvent(string title, DateTime startEvent, DateTime endEvent, String location, String summary); + /// <param name="gEventDetail">Detail of the event</param> + /// <param name="message">Detail of the execution of the method</param> + bool CreateEvent(IGEventDetail gEventDetail, out string message); /// <summary> /// Method to delete calendar event, searching by /// start and end date and time the event. /// </summary> /// <param name="startEvent">Date and Time of event start to search</param> /// <param name="endEvent">Date and Time of event end to search</param> - void DeleteEvent(DateTime startEvent, DateTime endEvent); + /// <param name="message">Detail of the execution of the method</param> + bool DeleteEvent(DateTime startEvent, DateTime endEvent, out string message); } } \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Google/IGEventDetail.cs Sun Jul 10 18:50:11 2011 -0400 @@ -0,0 +1,35 @@ +using System; +using AltNetHispano.Agendas.Domain; + +namespace AltNetHispano.Agendas.Google +{ + public interface IGEventDetail + { + /// <summary> + /// Title of the Event + /// </summary> + string Title { get; } + /// <summary> + /// Place of the event + /// </summary> + string Location { get; } + /// <summary> + /// Description of the event + /// </summary> + string Summary { get; } + /// <summary> + /// Date and Time of event start + /// </summary> + DateTime StartEvent { get; } + /// <summary> + /// Date and Time of event end + /// </summary> + DateTime EndEvent { get; } + + /// <summary> + /// Setting the details of the properties depending on the event. + /// </summary> + /// <param name="evento"></param> + void Generate(Evento evento); + } +} \ No newline at end of file
--- a/Agendas/trunk/src/Agendas.sln Sun Jul 10 18:08:00 2011 -0400 +++ b/Agendas/trunk/src/Agendas.sln Sun Jul 10 18:50:11 2011 -0400 @@ -32,6 +32,8 @@ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Agendas.Twitter.Tests", "Agendas.Twitter.Tests\Agendas.Twitter.Tests.csproj", "{462D86DD-7F4D-4596-B18B-2DD92C7FD73F}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Agendas.Google.Test", "Agendas.Google.Test\Agendas.Google.Test.csproj", "{3257EEC5-8FB7-4AD6-AD4C-F9748A1791B1}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -86,6 +88,10 @@ {462D86DD-7F4D-4596-B18B-2DD92C7FD73F}.Debug|Any CPU.Build.0 = Debug|Any CPU {462D86DD-7F4D-4596-B18B-2DD92C7FD73F}.Release|Any CPU.ActiveCfg = Release|Any CPU {462D86DD-7F4D-4596-B18B-2DD92C7FD73F}.Release|Any CPU.Build.0 = Release|Any CPU + {3257EEC5-8FB7-4AD6-AD4C-F9748A1791B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {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 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE
--- a/Agendas/trunk/src/install packages.bat Sun Jul 10 18:08:00 2011 -0400 +++ b/Agendas/trunk/src/install packages.bat Sun Jul 10 18:50:11 2011 -0400 @@ -5,5 +5,6 @@ ..\tools\nuget i Agendas.Twitter\packages.config -o packages ..\tools\nuget i Agendas.Twitter.Tests\packages.config -o packages ..\tools\nuget i Agendas.Google\packages.config -o packages +..\tools\nuget i Agendas.Google.Test\packages.config -o packages PAUSE \ No newline at end of file