本文整理汇总了C#中Google.GData.Calendar.CalendarService类的典型用法代码示例。如果您正苦于以下问题:C# CalendarService类的具体用法?C# CalendarService怎么用?C# CalendarService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CalendarService类属于Google.GData.Calendar命名空间,在下文中一共展示了CalendarService类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Delete
public bool Delete(Task task)
{
ErrorMessage = String.Empty;
CalendarService service = new CalendarService("googleCalendar");
service.setUserCredentials(task.AccountInfo.Username, task.AccountInfo.Password);
Log.InfoFormat("Fetching google account : [{0}]", task.AccountInfo.ToString());
string queryUri = String.Format(CultureInfo.InvariantCulture,
"http://www.google.com/calendar/feeds/{0}/private/full",
service.Credentials.Username);
Log.DebugFormat("Query='{0}'", queryUri);
EventQuery eventQuery = new EventQuery(queryUri);
try
{
EventFeed eventFeed = service.Query(eventQuery);
foreach (EventEntry eventEntry in eventFeed.Entries.Cast<EventEntry>())
{
if (eventEntry.Times.Count > 0)
{
if (eventEntry.EventId == task.Id)
{
Log.InfoFormat("Deleting : [{0}]-[{1}]", eventEntry.EventId, eventEntry.Title);
eventEntry.Delete();
return true;
}
}
}
}
catch (Exception exception)
{
Log.ErrorFormat(exception.Message);
Log.ErrorFormat(exception.ToString());
ErrorMessage = exception.Message;
}
return false;
}
示例2: Insert
public bool Insert(Task task)
{
EventEntry eventEntry = new EventEntry
{
Title = {Text = task.Head},
Content = {Content = task.Description,},
Locations = {new Where("", "", task.Location)},
Times = {new When(task.StartDate, task.StopDate)},
};
Log.InfoFormat("Inserting new entry to google : [{0}]", task.ToString());
CalendarService service = new CalendarService("googleCalendarInsert");
service.setUserCredentials(task.AccountInfo.Username, task.AccountInfo.Password);
Uri postUri = new Uri("https://www.google.com/calendar/feeds/default/private/full");
ErrorMessage = String.Empty;
try
{
EventEntry createdEntry = service.Insert(postUri, eventEntry);
return createdEntry != null;
}
catch (Exception exception)
{
Log.ErrorFormat(exception.Message);
Log.ErrorFormat(exception.ToString());
ErrorMessage = exception.Message;
}
return false;
}
示例3: getService
private CalendarService getService()
{
// Create a CalenderService and authenticate
CalendarService googleCalendarService = new CalendarService("rpcwc-rpcwcorg-2");
googleCalendarService.setUserCredentials("[email protected]", "Vert1go");
return googleCalendarService;
}
示例4: GoogleCalendar
public GoogleCalendar()
{
this.userName = GoogleUsername;
this.userPassword = GooglePassword;
calendarService = new CalendarService("webcsm");
calendarService.setUserCredentials(userName, userPassword);
}
示例5: BookThemAllSample
public BookThemAllSample(string domain, string admin, string password)
{
apps = new AppsService(domain, admin, password);
calendar = new CalendarService("BookThemAll");
calendar.setUserCredentials(admin, password);
this.admin = admin;
}
示例6: CalendarManager
public CalendarManager(string email, string password)
{
_userID = email;
_password = password;
_myService = new CalendarService("Bruce's Application");
_myService.setUserCredentials(_userID, _password);
}
示例7: googlecalendarSMSreminder
public void googlecalendarSMSreminder(string sendstring)
{
CalendarService service = new CalendarService("exampleCo-exampleApp-1");
service.setUserCredentials(UserName.Text, Password.Text);
EventEntry entry = new EventEntry();
// Set the title and content of the entry.
entry.Title.Text = sendstring;
entry.Content.Content = "Nadpis Test SMS.";
// Set a location for the event.
Where eventLocation = new Where();
eventLocation.ValueString = "Test sms";
entry.Locations.Add(eventLocation);
When eventTime = new When(DateTime.Now.AddMinutes(3), DateTime.Now.AddHours(1));
entry.Times.Add(eventTime);
//Add SMS Reminder
Reminder fiftyMinReminder = new Reminder();
fiftyMinReminder.Minutes = 1;
fiftyMinReminder.Method = Reminder.ReminderMethod.sms;
entry.Reminders.Add(fiftyMinReminder);
Uri postUri = new Uri("http://www.google.com/calendar/feeds/default/private/full");
// Send the request and receive the response:
AtomEntry insertedEntry = service.Insert(postUri, entry);
}
示例8: GetCalendarEvents
public static List<CalendarEvent> GetCalendarEvents(Calendar calendar)
{
List<CalendarEvent> eventList = new List<CalendarEvent>();
EventQuery query = new EventQuery();
CalendarService service = new CalendarService("GoogleCalendarReminder");
service.SetAuthenticationToken(GetAuthToken());
//service.setUserCredentials(Account.Default.Username
// , SecureStringUtility.SecureStringToString(Account.Default.Password));
query.Uri = new Uri(calendar.CalendarUri);
query.SingleEvents = true;
query.StartTime = DateTime.Now;
query.EndTime = DateTime.Today.AddDays(Settings.Default.DayRange);
EventFeed calFeed;
try
{
calFeed = service.Query(query) as EventFeed;
}
catch (Exception)
{
return null;
}
// now populate the calendar
while (calFeed != null && calFeed.Entries.Count > 0)
{
foreach (EventEntry entry in calFeed.Entries)
{
eventList.Add(new CalendarEvent(entry)
{
Color = calendar.Color
});
}
// just query the same query again.
if (calFeed.NextChunk != null)
{
query.Uri = new Uri(calFeed.NextChunk);
try
{
calFeed = service.Query(query) as EventFeed;
}
catch (Exception ex)
{
return null;
}
}
else
{
calFeed = null;
}
}
return eventList;
}
示例9: ClassInit
public static void ClassInit( TestContext context )
{
_creds = GooCalCreds.CreateAndValidate();
_calendarPurge = (CalendarPurge)CalendarPurgeFactory.Create( _creds );
_service = _calendarPurge.GoogleCalendarService;
DeleteAllEvents();
}
示例10: Authenticate
public void Authenticate(string account, string password)
{
_calendarService = new Google.GData.Calendar.CalendarService("");
_calendarService.setUserCredentials(account, password);
_calendarUri = new Uri(string.Format("https://www.google.com/calendar/feeds/{0}/private/full", account));
_isAuthenticated = true;
}
示例11: GetPostableEvents
public PostableEvents GetPostableEvents(string calendarId)
{
var result = new PostableEvents();
var service = new CalendarService("WascherCom.Auto.CalendarToBlog");
if (!string.IsNullOrWhiteSpace(UserId))
{
service.setUserCredentials(UserId, Password);
}
var query = new EventQuery
{
Uri = new Uri(string.Format(GOOGLE_URI, calendarId)),
StartTime = StartDate.AddDays(-DaysForPastEvents),
EndTime = StartDate.AddDays(DaysForCurrentEvents + DaysForFutureEvents)
};
var eventFeed = service.Query(query);
if (eventFeed == null || eventFeed.Entries.Count == 0)
{
return result;
}
foreach (EventEntry entry in eventFeed.Entries)
{
foreach (var time in entry.Times)
{
var calEvent = new CalendarEvent
{
Title = entry.Title.Text,
Description = string.Empty,
StartDateTime = time.StartTime,
EndDateTime = time.EndTime,
IsAllDay = time.AllDay
};
if (calEvent.StartDateTime < StartDate)
{
result.PastEvents.Add(calEvent);
}
else if (calEvent.StartDateTime > StartDate.AddDays(DaysForCurrentEvents))
{
result.FutureEvents.Add(calEvent);
}
else
{
result.CurrentEvents.Add(calEvent);
}
Console.WriteLine(string.Format("{0}: {1} All Day: {2}", entry.Title.Text, time.StartTime, time.AllDay));
}
}
return result;
}
示例12: AuthenticateV2
public void AuthenticateV2()
{
// create an OAuth factory to use
log.Debug("Authenticating to calendar service using 2-legged OAuth");
GOAuthRequestFactory requestFactory = new GOAuthRequestFactory("cl", "MyApp");
requestFactory.ConsumerKey = ConfigurationManager.AppSettings["consumerKey"];
requestFactory.ConsumerSecret = ConfigurationManager.AppSettings["consumerSecret"];
service = new CalendarService("MyApp");
service.RequestFactory = requestFactory;
}
示例13: Init
public bool Init(string user, string password)
{
service = new CalendarService("GTrello");
service.setUserCredentials(user, password);
if (!LoadMapping())
{
return false;
}
return CollectEntries();
}
示例14: SetProxy
private void SetProxy(CalendarService service)
{
var f = (GDataRequestFactory) service.RequestFactory;
IWebProxy iProxy = WebRequest.DefaultWebProxy;
var myProxy = new WebProxy(iProxy.GetProxy(new Uri(GOOGLE_CALENDAR_URI)))
{
Credentials = CredentialCache.DefaultCredentials,
UseDefaultCredentials = true
};
f.Proxy = myProxy;
}
示例15: PrintAllEvents
/// <summary>
/// Prints the titles of all events on the specified calendar.
/// </summary>
/// <param name="service">The authenticated CalendarService object.</param>
static void PrintAllEvents(CalendarService service)
{
EventQuery myQuery = new EventQuery(feedUri);
EventFeed myResultsFeed = service.Query(myQuery) as EventFeed;
Console.WriteLine("All events on your calendar:");
Console.WriteLine();
for (int i = 0; i < myResultsFeed.Entries.Count; i++)
{
Console.WriteLine(myResultsFeed.Entries[i].Title.Text);
}
Console.WriteLine();
}