comparison Agendas/trunk/src/Agendas.Google/GooglePublicador.cs @ 184:2a336a6a76b5

Agregando log al track cuando fallan los publicadores
author nelopauselli
date Mon, 08 Aug 2011 22:32:12 -0300
parents 734d3f0853bf
children 2d02adb79322
comparison
equal deleted inserted replaced
183:212c664db5aa 184:2a336a6a76b5
1 using System.Collections.Generic; 1 using System;
2 using System.Collections.Generic;
2 using AltNetHispano.Agendas.Configurations; 3 using AltNetHispano.Agendas.Configurations;
3 using AltNetHispano.Agendas.Domain; 4 using AltNetHispano.Agendas.Domain;
4 using AltNetHispano.Agendas.Google.DetailsEvents; 5 using AltNetHispano.Agendas.Google.DetailsEvents;
5 6
6 namespace AltNetHispano.Agendas.Google 7 namespace AltNetHispano.Agendas.Google
29 { 30 {
30 if (!AgendasConfigurationManager.Publicadores.Google.Enabled) return; 31 if (!AgendasConfigurationManager.Publicadores.Google.Enabled) return;
31 32
32 foreach (var track in tracks) 33 foreach (var track in tracks)
33 { 34 {
34 switch (track.Accion) 35 try
35 { 36 {
36 case Accion.Agendar: 37 switch (track.Accion)
37 PublicarAccionAgendar(track); 38 {
38 break; 39 case Accion.Agendar:
39 case Accion.Cancelar: 40 PublicarAccionAgendar(track);
40 PublicarAccionCancelar(track); 41 break;
41 break; 42 case Accion.Cancelar:
42 } 43 PublicarAccionCancelar(track);
44 break;
45 }
46 }
47 catch (Exception ex)
48 {
49 track.LogAdd(new TrackLog(TrackLogPropietario.Calendario, track.Usuario, ex));
50 }
43 } 51 }
44 } 52 }
45 53
46 private void PublicarAccionCancelar(Track track) 54 private void PublicarAccionCancelar(Track track)
47 { 55 {
48 string message; 56 string message;
49 var result= _adapter.DeleteEvent(track.Evento.Fecha.Value, track.Evento.Fecha.Value.AddHours(2), out message); 57 var result = _adapter.DeleteEvent(track.Evento.Fecha.Value, track.Evento.Fecha.Value.AddHours(2), out message);
50 track.LogAdd(new TrackLog(TrackLogPropietario.Calendario, message, track.Usuario, result)); 58 track.LogAdd(new TrackLog(TrackLogPropietario.Calendario, message, track.Usuario, result));
59
60
51 } 61 }
52 62
53 private void PublicarAccionAgendar(Track track) 63 private void PublicarAccionAgendar(Track track)
54 { 64 {
55 string message; 65 _gEventDetails[track.Evento.Tipo].Generate(track.Evento);
56 _gEventDetails[track.Evento.Tipo].Generate(track.Evento); 66 string message;
57 var result = _adapter.CreateEvent(_gEventDetails[track.Evento.Tipo], out message); 67 var result = _adapter.CreateEvent(_gEventDetails[track.Evento.Tipo], out message);
58 track.LogAdd(new TrackLog(TrackLogPropietario.Calendario, message, track.Usuario, result)); 68 track.LogAdd(new TrackLog(TrackLogPropietario.Calendario, message, track.Usuario, result));
59 } 69 }
60 70
61 public GooglePublicador() 71 public GooglePublicador()
62 : this(new GCalendarAdapter("VAN", GetUserName, GetPassword, GetCalendarId)) 72 : this(new GCalendarAdapter("VAN", GetUserName, GetPassword, GetCalendarId))
63 { 73 {
64 } 74 }
65 75
66 public GooglePublicador(IGCalendarAdapter gCalendarAdapter) 76 public GooglePublicador(IGCalendarAdapter gCalendarAdapter)