Mercurial > altnet-hispano
changeset 125:34b2f85aecab
Se crea adaptador para conectar con Google Calendar, además de crear funcionalidad para insertar y eliminar un evento en el calendario de google.
Se agregan package de nuget para el trabajo con Google Calendar.
author | alabra |
---|---|
date | Tue, 28 Jun 2011 23:32:52 -0400 |
parents | 35498fb9b59b |
children | 6012f2becf97 |
files | Agendas/trunk/src/Agendas.Google/Agendas.Google.csproj Agendas/trunk/src/Agendas.Google/GCalendarAdapter.cs Agendas/trunk/src/Agendas.Google/IGCalendarAdapter.cs Agendas/trunk/src/Agendas.Google/packages.config |
diffstat | 4 files changed, 105 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/Agendas/trunk/src/Agendas.Google/Agendas.Google.csproj Tue Jun 28 20:53:52 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Google/Agendas.Google.csproj Tue Jun 28 23:32:52 2011 -0400 @@ -31,6 +31,18 @@ <WarningLevel>4</WarningLevel> </PropertyGroup> <ItemGroup> + <Reference Include="Google.GData.AccessControl, Version=1.8.0.0, Culture=neutral, PublicKeyToken=b4b8eb9a7afc8328, processorArchitecture=MSIL"> + <HintPath>..\packages\Google.GData.AccessControl.1.8.0.0\lib\Google.GData.AccessControl.dll</HintPath> + </Reference> + <Reference Include="Google.GData.Calendar, Version=1.8.0.0, Culture=neutral, PublicKeyToken=aa6748391206b888, processorArchitecture=MSIL"> + <HintPath>..\packages\Google.GData.Calendar.1.8.0.0\lib\Google.GData.Calendar.dll</HintPath> + </Reference> + <Reference Include="Google.GData.Client, Version=1.8.0.0, Culture=neutral, PublicKeyToken=04a59ca9b0273830, processorArchitecture=MSIL"> + <HintPath>..\packages\Google.GData.Client.1.8.0.0\lib\Google.GData.Client.dll</HintPath> + </Reference> + <Reference Include="Google.GData.Extensions, Version=1.8.0.0, Culture=neutral, PublicKeyToken=0b4c5df2ebf20876, processorArchitecture=MSIL"> + <HintPath>..\packages\Google.GData.Extensions.1.8.0.0\lib\Google.GData.Extensions.dll</HintPath> + </Reference> <Reference Include="System" /> <Reference Include="System.Core" /> <Reference Include="System.Xml.Linq" /> @@ -40,7 +52,9 @@ <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> + <Compile Include="GCalendarAdapter.cs" /> <Compile Include="GooglePublicador.cs" /> + <Compile Include="IGCalendarAdapter.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> </ItemGroup> <ItemGroup> @@ -49,6 +63,9 @@ <Name>Agendas.Domain</Name> </ProjectReference> </ItemGroup> + <ItemGroup> + <None Include="packages.config" /> + </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/GCalendarAdapter.cs Tue Jun 28 23:32:52 2011 -0400 @@ -0,0 +1,54 @@ +using System; +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 void CreateEvent(string title, DateTime startEvent, DateTime endEvent, string location, string summary) + { + var entry = new EventEntry + { + Title = { Text = title }, + Content = { Content = summary } + }; + + var eventLocation = new Where + { + ValueString = location + }; + + entry.Locations.Add(eventLocation); + + var eventTime = new When(startEvent, endEvent); + entry.Times.Add(eventTime); + + _service.Insert(_feedUri, entry); + } + + public void DeleteEvent(DateTime startEvent, DateTime endEvent) + { + var myQuery = new EventQuery + { + StartTime = startEvent, + EndTime = endEvent, + Uri = _feedUri + }; + + var myResultsFeed = _service.Query(myQuery); + if (myResultsFeed.Entries.Count > 0) + myResultsFeed.Entries[0].Delete(); + } + + 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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Google/IGCalendarAdapter.cs Tue Jun 28 23:32:52 2011 -0400 @@ -0,0 +1,27 @@ +using System; + +namespace AltNetHispano.Agendas.Google +{ + /// <summary> + /// Adapter connect to GCalendar + /// </summary> + public interface IGCalendarAdapter + { + /// <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); + /// <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); + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Google/packages.config Tue Jun 28 23:32:52 2011 -0400 @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="utf-8"?> +<packages> + <package id="Google.GData.AccessControl" version="1.8.0.0" /> + <package id="Google.GData.Client" version="1.8.0.0" /> + <package id="Google.GData.Calendar" version="1.8.0.0" /> + <package id="Google.GData.Extensions" version="1.8.0.0" /> +</packages> \ No newline at end of file