private void GetFeed() { // Connexion ThreadStart threadHotmail = () => { var googleCalendar = new CalendarInfo(); CalendarData data = googleCalendar.GetFeedOfCalendar(Widget.Settings.FeedURL, Widget.Settings.Username, Widget.Settings.Password); this.Dispatcher.Invoke((Action) delegate { if (data != null) { Title.Text = data.Title; if (!string.IsNullOrEmpty(data.Location)) { Location.Visibility = Visibility.Visible; Location.Text = data.Location; } else { Location.Visibility = Visibility.Collapsed; } if (!string.IsNullOrEmpty(data.Description)) { Description.Visibility = Visibility.Visible; Description.Text = data.Description; } else { Description.Visibility = Visibility.Collapsed; } string beginTime = data.BeginTime.ToShortTimeString(); //by default show only the time if (!IsCalendar(data.BeginTime)) { beginTime = data.BeginTime.ToShortDateString() + " " + beginTime; //but if it's not today show date string too } string endTime = data.EndTime.ToShortTimeString(); if (!IsCalendar(data.EndTime)) { endTime = data.EndTime.ToShortDateString() + " " + endTime; } Time.Text = beginTime + " - " + endTime; } // Récupération liste évènements à faire dans la journée (les 3 premiers) //googleCalendar.getFeedOnDay(); }); }; var thread = new Thread(threadHotmail); //thread.SetApartmentState(ApartmentState.STA); thread.Start(); }
static void Main(string[] args) { Console.WriteLine("Please enter a calendar year."); string yearString = Console.ReadLine(); int year; if (Int32.TryParse(yearString, out year)) { CalendarData calendarData = new CalendarData(year); File.WriteAllText("calendar_" + yearString + ".html", calendarData.ReturnPreHTML() + calendarData.CreateSaintDays() + "</body></html>"); } else { Console.WriteLine("Please enter a year greater than 0."); Console.ReadLine(); } }
public CalendarData GetFeedOfCalendar(String feedUrl, String user, String pass) { var myService = new CalendarService("Newgen_Calendar"); myService.setUserCredentials(user, pass); var myQuery = new EventQuery(feedUrl); myQuery.StartTime = DateTime.Now; myQuery.EndTime = DateTime.Today.AddDays(2); // we search two days after EventFeed calFeed = myService.Query(myQuery); // now populate the calendar if (calFeed.Entries.Count > 0) { var entry = (EventEntry)calFeed.Entries[0]; var result = new CalendarData(); // Title result.Title = entry.Title.Text; if (entry.Locations.Count > 0 && !string.IsNullOrEmpty(entry.Locations[0].ValueString)) { result.Location = entry.Locations[0].ValueString; } else if (entry.Content != null) { result.Description = entry.Content.Content; } if (entry.Times.Count > 0) { result.BeginTime = entry.Times[0].StartTime; result.EndTime = entry.Times[0].EndTime; } return(result); } return(null); }