Mercurial > altnet-hispano
diff Agendas/trunk/src/Agendas.Google/GCalendarAdapter.cs @ 158:734d3f0853bf
Manejando configuración de los publicadores con una sección propia en los .config
Agregando la opción de habilitar / deshabilitar un publicador
author | nelopauselli |
---|---|
date | Fri, 05 Aug 2011 16:55:18 -0300 |
parents | 0ea32a748453 |
children |
line wrap: on
line diff
--- 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