本文整理汇总了C#中Google.GData.Calendar.CalendarService.setUserCredentials方法的典型用法代码示例。如果您正苦于以下问题:C# CalendarService.setUserCredentials方法的具体用法?C# CalendarService.setUserCredentials怎么用?C# CalendarService.setUserCredentials使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Google.GData.Calendar.CalendarService
的用法示例。
在下文中一共展示了CalendarService.setUserCredentials方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: CalendarManager
public CalendarManager(string email, string password)
{
_userID = email;
_password = password;
_myService = new CalendarService("Bruce's Application");
_myService.setUserCredentials(_userID, _password);
}
示例4: 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);
}
示例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: GoogleCalendar
public GoogleCalendar()
{
this.userName = GoogleUsername;
this.userPassword = GooglePassword;
calendarService = new CalendarService("webcsm");
calendarService.setUserCredentials(userName, userPassword);
}
示例7: 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;
}
示例8: 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;
}
示例9: Init
public bool Init(string user, string password)
{
service = new CalendarService("GTrello");
service.setUserCredentials(user, password);
if (!LoadMapping())
{
return false;
}
return CollectEntries();
}
示例10: checkPw
// Validates a username/pass by attempting to login to calendar
public static bool checkPw(string username, string password)
{
GDataGAuthRequestFactory authFactory = new GDataGAuthRequestFactory("cl", "Seadragon");
authFactory.AccountType = "HOSTED";
CalendarService client = new CalendarService(authFactory.ApplicationName);
client.RequestFactory = authFactory;
client.setUserCredentials(username + "@" + DOMAIN, password);
try
{
client.QueryClientLoginToken(); // Authenticate the user immediately
}
catch (WebException) // Invalid login
{
return false;
}
return true;
}
示例11: export
public static void export(string email, string password, List<LeadTask> tasks)
{
CalendarService myService = new CalendarService("exportToGCalendar");
myService.setUserCredentials(email, password);
foreach (LeadTask task in tasks) {
EventEntry entry = new EventEntry();
// Set the title and content of the entry.
entry.Title.Text = task.text;
entry.Content.Content = task.details;
When eventTime = new When((DateTime)task.start_date, (DateTime)task.end_date);
entry.Times.Add(eventTime);
Uri postUri = new Uri("https://www.google.com/calendar/feeds/default/private/full");
// Send the request and receive the response:
Google.GData.Client.AtomEntry insertedEntry = myService.Insert(postUri, entry);
}
}
示例12: Delete
public async Task Delete(Guid userId, string eventId)
{
try
{
var item = _iSysUserService.GetById(userId);
if (string.IsNullOrEmpty(item.GoogleUserName) || string.IsNullOrEmpty(item.GooglePassword)) return;
var myService = new CalendarService(item.GoogleUserName);
myService.setUserCredentials(item.GoogleUserName, item.GooglePassword);
var calendar =
myService.Get("https://www.google.com/calendar/feeds/default/private/full/" + eventId);
foreach (var item1 in calendar.Feed.Entries)
{
item1.Delete();
}
}
catch
{
}
}
示例13: Insert
public async Task<string> Insert(Guid userId, string title, string content, DateTime start, DateTime end)
{
try
{
//同步到Google日历
var item = _iSysUserService.GetById(userId);
if (string.IsNullOrEmpty(item.GoogleUserName) || string.IsNullOrEmpty(item.GooglePassword)) return "";
var myService = new CalendarService(item.GoogleUserName);
myService.setUserCredentials(item.GoogleUserName, item.GooglePassword);
// Set the title and content of the entry.
var entry = new EventEntry
{
Title = { Text = "云集 " + title },
Content = { Content = content }
};
//计划时间
var eventTime = new When(start, end);
//判断是否为全天计划
if (start.Date != end.Date)
eventTime.AllDay = true;
entry.Times.Add(eventTime);
var postUri = new Uri("https://www.google.com/calendar/feeds/default/private/full");
// Send the request and receive the response:
var eventEntry = myService.Insert(postUri, entry);
return eventEntry.EventId;
}
catch
{
return "";
}
}
示例14: Main
static void Main(string[] args)
{
//
// TODO: Add code to start application here
//
if (args.Length != 1 && args.Length != 3)
{
Console.WriteLine("Not enough parameters. Usage is Sample <uri> <username> <password>");
return;
}
string calendarURI = args[0];
string userName = args.Length == 3 ? args[1] : null;
string passWord = args.Length == 3 ? args[2] : null;
EventQuery query = new EventQuery();
CalendarService service = new CalendarService(ApplicationName);
if (userName != null)
{
service.setUserCredentials(userName, passWord);
}
query.Uri = new Uri(calendarURI);
EventFeed calFeed = service.Query(query) as EventFeed;
Console.WriteLine("");
Console.WriteLine("Query Feed Test " + query.Uri);
Console.WriteLine("Post URI is: " + calFeed.Post);
foreach (EventEntry feedEntry in calFeed.Entries)
{
DumpEventEntry(feedEntry);
}
}
示例15: Main
static void Main(string[] args)
{
//
// TODO: Add code to start application here
//
if (args.Length < 3)
{
Console.WriteLine("Not enough parameters. Usage is Sample <uri> <username> <password>");
return;
}
string calendarURI = args[0];
string userName = args[1];
string passWord = args[2];
EventQuery query = new EventQuery();
CalendarService service = new CalendarService(ApplicationName);
if (userName != null)
{
service.setUserCredentials(userName, passWord);
}
query.Uri = new Uri(calendarURI);
EventFeed calFeed = service.Query(query);
EventEntry insertedEntry = InsertEvent(calFeed, "Conference www2006",
"Frank Mantek", DateTime.Now,
DateTime.Now.AddDays(1),
true,
"Edinburgh");
if (insertedEntry != null)
{
DumpEventEntry(insertedEntry);
}
}