本文整理汇总了C#中Google.GData.Calendar.CalendarService.Insert方法的典型用法代码示例。如果您正苦于以下问题:C# CalendarService.Insert方法的具体用法?C# CalendarService.Insert怎么用?C# CalendarService.Insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Google.GData.Calendar.CalendarService
的用法示例。
在下文中一共展示了CalendarService.Insert方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: createNewCalendar
private void createNewCalendar(CalendarService service)
{
CalendarEntry calendar = new CalendarEntry();
calendar.Title.Text = textBox1.Text;//"Little League Schedule";
calendar.Summary.Text = "This calendar contains the practice schedule and game times.";
calendar.TimeZone = "America/Los_Angeles";
calendar.Hidden = false;
calendar.Color = "#2952A3";
calendar.Location = new Where("", "", "Oakland");
Uri postUri = new Uri("https://www.google.com/calendar/feeds/default/owncalendars/full");
CalendarEntry createdCalendar = (CalendarEntry)service.Insert(postUri, calendar);
refreshCalendar();
}
示例2: AddAccessControl
/// <summary>
/// Shares a calendar with the specified user. Note that this method
/// will not run by default.
/// </summary>
/// <param name="service">The authenticated CalendarService object.</param>
/// <param name="aclFeedUri">the ACL feed URI of the calendar being shared.</param>
/// <param name="userEmail">The email address of the user with whom to share.</param>
/// <param name="role">The role of the user with whom to share.</param>
/// <returns>The AclEntry returned by the server.</returns>
static AclEntry AddAccessControl(CalendarService service, string aclFeedUri,
string userEmail, AclRole role)
{
AclEntry entry = new AclEntry();
entry.Scope = new AclScope();
entry.Scope.Type = AclScope.SCOPE_USER;
entry.Scope.Value = userEmail;
entry.Role = role;
Uri aclUri =
new Uri("http://www.google.com/calendar/feeds/[email protected]/acl/full");
AclEntry insertedEntry = service.Insert(aclUri, entry);
Console.WriteLine("Added user {0}", insertedEntry.Scope.Value);
return insertedEntry;
}
示例3: 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);
}
}
示例4: 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 "";
}
}
示例5: CalendarOwnCalendarsTest
/////////////////////////////////////////////////////////////////////////////
/// <summary>
/// Test to check creating/updating/deleting a secondary calendar.
/// </summary>
[Test] public void CalendarOwnCalendarsTest()
{
Tracing.TraceMsg("Enterting CalendarOwnCalendarsTest");
CalendarService service = new CalendarService(this.ApplicationName);
if (this.defaultOwnCalendarsUri != null)
{
if (this.userName != null)
{
service.Credentials = new GDataCredentials(this.userName, this.passWord);
}
service.RequestFactory = this.factory;
CalendarEntry newCalendar = new CalendarEntry();
newCalendar.Title.Text = "new calendar" + Guid.NewGuid().ToString();
newCalendar.Summary.Text = "some unique summary" + Guid.NewGuid().ToString();
newCalendar.TimeZone = "America/Los_Angeles";
newCalendar.Hidden = false;
newCalendar.Selected = true;
newCalendar.Color = "#2952A3";
newCalendar.Location = new Where("", "", "Test City");
Uri postUri = new Uri(this.defaultOwnCalendarsUri);
CalendarEntry createdCalendar = (CalendarEntry) service.Insert(postUri, newCalendar);
Assert.IsNotNull(createdCalendar, "created calendar should be returned.");
Assert.AreEqual(newCalendar.Title.Text, createdCalendar.Title.Text, "Titles should be equal");
Assert.AreEqual(newCalendar.Summary.Text, createdCalendar.Summary.Text, "Summaries should be equal");
Assert.AreEqual(newCalendar.TimeZone, createdCalendar.TimeZone, "Timezone should be equal");
Assert.AreEqual(newCalendar.Hidden, createdCalendar.Hidden, "Hidden property should be equal");
Assert.AreEqual(newCalendar.Color, createdCalendar.Color, "Color property should be equal");
Assert.AreEqual(newCalendar.Location.ValueString, createdCalendar.Location.ValueString, "Where should be equal");
createdCalendar.Title.Text = "renamed calendar" + Guid.NewGuid().ToString();
createdCalendar.Hidden = true;
CalendarEntry updatedCalendar = (CalendarEntry) createdCalendar.Update();
Assert.AreEqual(createdCalendar.Title.Text, updatedCalendar.Title.Text, "entry should have been updated");
updatedCalendar.Delete();
CalendarQuery query = new CalendarQuery();
query.Uri = postUri;
CalendarFeed calendarList = service.Query(query);
foreach (CalendarEntry entry in calendarList.Entries)
{
Assert.IsTrue(entry.Title.Text != updatedCalendar.Title.Text, "Calendar should have been removed");
}
service.Credentials = null;
}
}
示例6: CalendarACL2Test
/////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
/// <summary>Tests the ACL extensions, this time getting the feed from the entry</summary>
//////////////////////////////////////////////////////////////////////
[Test] public void CalendarACL2Test()
{
Tracing.TraceMsg("Entering CalendarACL2Test");
CalendarQuery query = new CalendarQuery();
CalendarService service = new CalendarService(this.ApplicationName);
if (this.defaultCalendarUri != null)
{
if (this.userName != null)
{
service.Credentials = new GDataCredentials(this.userName, this.passWord);
}
service.RequestFactory = this.factory;
query.Uri = new Uri(this.defaultOwnCalendarsUri);
CalendarFeed calFeed = service.Query(query);
if (calFeed != null && calFeed.Entries != null && calFeed.Entries[0] != null)
{
AtomLink link = calFeed.Entries[0].Links.FindService(AclNameTable.LINK_REL_ACCESS_CONTROL_LIST, null);
AclEntry aclEntry = new AclEntry();
aclEntry.Scope = new AclScope();
aclEntry.Scope.Type = AclScope.SCOPE_USER;
aclEntry.Scope.Value = "[email protected]";
aclEntry.Role = AclRole.ACL_CALENDAR_READ;
Uri aclUri = null;
if (link != null)
{
aclUri = new Uri(link.HRef.ToString());
}
else
{
throw new Exception("ACL link was null.");
}
AclEntry insertedEntry = service.Insert(aclUri, aclEntry);
insertedEntry.Delete();
}
}
}
示例7: generateBtn_Click
// TODO: dynamically generate study time based on credit hours of each class
private void generateBtn_Click(object sender, EventArgs e)
{
timeSlots.Clear();
String report = "";
if (username == "" || password == "" || calendarUrl == "")
{
MessageBox.Show("Please add Google login and password information.");
}
else
{
foreach (ClassGroupBox g in groupBoxList)
{
firstDayOfClass = assignClassStartDay(g.getDays()[0], startOfSemester);
String recursionString = "DTSTART;TZID=US/Eastern:" + startOfSemester.Year
+ startOfSemester.Month.ToString("00") + firstDayOfClass.ToString()
+ "T" + g.getStartHour() + g.getStartMin()
+ "00" + "\r\nDTEND;TZID=US/Eastern:" + startOfSemester.Year
+ startOfSemester.Month.ToString("00") + startOfSemester.Day.ToString("00")
+ "T" + g.getEndHour() + g.getEndMin() + "00"
+ "\r\n" + "RRULE:FREQ=WEEKLY;BYDAY=" + buildDayString(g.getDays()) + ";UNTIL="
+ endOfSemester.Year + endOfSemester.Month.ToString("00")
+ endOfSemester.Day.ToString("00") + "\r\n";
Recurrence recurrence = new Recurrence();
recurrence.Value = recursionString;
Console.Out.WriteLine(recursionString);
CalendarService service = new CalendarService("ggco-purdueScheduler-0.01");
Uri postUri = new Uri("https://www.google.com/calendar/feeds/" + calendarUrl + "/private/full");
service.setUserCredentials(username, password);
EventEntry calendarEntry = new EventEntry();
calendarEntry.Title.Text = g.getCourseName();
calendarEntry.Recurrence = recurrence;
report += buildDayReport(g);
try
{
AtomEntry insertedEntry = service.Insert(postUri, calendarEntry);
resultLbl.Text = "SUCCESS";
resultLbl.ForeColor = Color.White;
resultLbl.BackColor = Color.Green;
}
catch
{
resultLbl.Text = "FAILURE";
resultLbl.ForeColor = Color.White;
resultLbl.BackColor = Color.Red;
}
//// BASELINE - used to ensure no overlap in a given day
//DateTime start = new DateTime(DateTime.Now.Year, DateTime.Now.Month,
// DateTime.Now.Day, int.Parse(g.getStartHour()), int.Parse(g.getStartMin()), 0);
//DateTime end = new DateTime(DateTime.Now.Year, DateTime.Now.Month,
// DateTime.Now.Day, int.Parse(g.getEndHour()), int.Parse(g.getEndMin()), 0);
//if (groupBoxList.Count == 0)
//{
// timeSlots.Add(new TimeSlot(start, end));
//}
//else
//{
// foreach (TimeSlot t in timeSlots)
// {
// if (start <= t.getStartTime() && end > t.getStartTime())
// {
// MessageBox.Show("Classes overlap - one ends after another starts.");
// }
// else if (start >= t.getStartTime() && start < t.getEndTime())
// {
// MessageBox.Show("Classes overlap - one starts before another ends.");
// }
// else
// {
// MessageBox.Show("No errors");
// }
// }
// timeSlots.Add(new TimeSlot(start, end));
//}
}
}
reportRichTxt.Text = report;
}
示例8: googlecalendarSMSreminder
public void googlecalendarSMSreminder(string sendstring)
{
CalendarService service = new CalendarService("exampleCo-exampleApp-1");
service.setUserCredentials("[email protected]", "joneson55");
EventEntry entry = new EventEntry();
// Set the title and content of the entry.
entry.Title.Text = sendstring;
entry.Content.Content = "Lockerz Login Page Check.";
// Set a location for the event.
Where eventLocation = new Where();
eventLocation.ValueString = "Lockerz Login";
entry.Locations.Add(eventLocation);
When eventTime = new When(DateTime.Now.AddMinutes(3), DateTime.Now.AddHours(1));
entry.Times.Add(eventTime);
if (checkBox1.Checked == true) //Reminder ON/OFF
{
//Add SMS Reminder
Reminder fiftyMinReminder = new Reminder();
fiftyMinReminder.Minutes = 1;
fiftyMinReminder.Method = Reminder.ReminderMethod.sms;
entry.Reminders.Add(fiftyMinReminder);
}
else
{
}
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);
}
示例9: AddMenuButton
//.........这里部分代码省略.........
Dictionary<string, Calendar> courseCalendar = new Dictionary<string, Calendar>();
string condition = "RefCourseID in (";
foreach (string key in selectedSource)
{
if (condition != "RefCourseID in (")
condition += ",";
condition += "'" + key + "'";
}
condition += ")";
foreach (Calendar cal in accessHelper.Select<Calendar>(condition))
{
if (!courseCalendar.ContainsKey(cal.RefCourseID))
courseCalendar.Add(cal.RefCourseID, cal);
}
bkw.ReportProgress(5);
CalendarService myService = new CalendarService("ischool.CourseCalendar");
myService.setUserCredentials(googleAcc, googlePWD);
bkw.ReportProgress(20);
foreach (K12.Data.CourseRecord course in K12.Data.Course.SelectByIDs(courseAttend.Keys))
{
Calendar targetCal = null;
try
{
if (!courseCalendar.ContainsKey(course.ID))
{
#region 建立新Calender
string[] colorLists = new string[]{"#A32929","#B1365F","#7A367A","#5229A3","#29527A","#2952A3","#1B887A",
"#28754E","#0D7813","#528800","#88880E","#AB8B00","#BE6D00","#B1440E",
"#865A5A","#705770","#4E5D6C","#5A6986","#4A716C","#6E6E41","#8D6F47"};
CalendarEntry newCal = new CalendarEntry();
newCal.Title.Text = course.Name;
newCal.Summary.Text = "科目:" + course.Subject
+ "\n學年度:" + course.SchoolYear
+ "\n學期:" + course.Semester
+ "\n學分數:" + course.Credit;
newCal.TimeZone = "Asia/Taipei";
//targetCalender.Hidden = false;
newCal.Color = colorLists[new Random(DateTime.Now.Millisecond).Next(0, colorLists.Length)];
Uri postUri = new Uri("http://www.google.com/calendar/feeds/default/owncalendars/full");
newCal = (CalendarEntry)myService.Insert(postUri, newCal);
#endregion
String calendarURI = newCal.Id.Uri.ToString();
String calendarID = calendarURI.Substring(calendarURI.LastIndexOf("/") + 1);
targetCal = new Calendar() { RefCourseID = course.ID, GoogleCalanderID = calendarID };
targetCal.Save();
courseCalendar.Add(course.ID, targetCal);
}
else
{
targetCal = courseCalendar[course.ID];
}
}
catch { hasFaild = true; }
if (targetCal != null)
{
List<string> aclList = new List<string>(targetCal.ACLList.Split("%".ToCharArray(), StringSplitOptions.RemoveEmptyEntries));
foreach (var student in K12.Data.Student.SelectByIDs(courseAttend[course.ID]))
{
try
{
if (student.SALoginName != "" && !aclList.Contains(student.SALoginName))
{
#region 新增分享
AclEntry entry = new AclEntry();
entry.Scope = new AclScope();
entry.Scope.Type = AclScope.SCOPE_USER;
entry.Scope.Value = student.SALoginName;
entry.Role = AclRole.ACL_CALENDAR_READ;
try
{
AclEntry insertedEntry = myService.Insert(new Uri("https://www.google.com/calendar/feeds/" + targetCal.GoogleCalanderID + "/acl/full"), entry);
}
catch (GDataRequestException gex)
{
if (!gex.InnerException.Message.Contains("(409)"))
throw;
}
#endregion
aclList.Add(student.SALoginName);
targetCal.ACLList += (targetCal.ACLList == "" ? "" : "%") + student.SALoginName;
}
}
catch
{
hasFaild = true;
}
syncedSections++;
int p = syncedSections * 80 / count + 20;
if (p > 100) p = 100;
if (p < 0) p = 0;
bkw.ReportProgress(p);
}
}
}
courseCalendar.Values.SaveAll();
};
bkw.RunWorkerAsync();
};
}
示例10: Main
static void Main(string[] args)
{
string username = Properties.Settings.Default.username;
string password = Properties.Settings.Default.password;
Uri calendarUri = Properties.Settings.Default.calendarUri;
Division divisionExclusion = Properties.Settings.Default.divisionExclusion;
// Filter by division
List<Contest> contests = getContests().Where((contest) => (contest.Division ^ divisionExclusion) > 0).ToList();
CalendarService service = new CalendarService("codeforces-export");
service.setUserCredentials(username, password);
foreach (Contest contest in contests)
{
// Check if this contest already exists, update then
EventQuery q = new EventQuery();
q.Uri = calendarUri;
q.StartTime = contest.Start;
q.EndTime = contest.End;
EventFeed feed = service.Query(q);
EventEntry eventEntry;
bool contestExists;
if (feed.Entries.Count == 1)
{
eventEntry = (EventEntry)feed.Entries[0];
contestExists = true;
}
else
{
// No such contest, create new
eventEntry = new EventEntry();
contestExists = false;
}
eventEntry.Title.Text = contest.Title;
eventEntry.Content.Content = contest.Title + " (";
if (contest.Division == Division.Both)
eventEntry.Content.Content += "Both divs.";
else if (contest.Division == Division.First)
eventEntry.Content.Content += "Div. 1";
else
eventEntry.Content.Content += "Div. 2";
eventEntry.Content.Content += ")";
eventEntry.Times.Add(new When(contest.Start, contest.End));
if (contestExists)
{
eventEntry.Update();
Console.WriteLine("Updated " + eventEntry.Content.Content + " event");
}
else
{
service.Insert(calendarUri, eventEntry);
Console.WriteLine("Added " + eventEntry.Content.Content + " event");
}
}
}
示例11: CreateEvent
/// <summary>
/// Helper method to create either single-instance or recurring events.
/// For simplicity, some values that might normally be passed as parameters
/// (such as author name, email, etc.) are hard-coded.
/// </summary>
/// <param name="service">The authenticated CalendarService object.</param>
/// <param name="entryTitle">Title of the event to create.</param>
/// <param name="recurData">Recurrence value for the event, or null for
/// single-instance events.</param>
/// <returns>The newly-created EventEntry on the calendar.</returns>
static EventEntry CreateEvent(CalendarService service, String entryTitle,
String recurData)
{
EventEntry entry = new EventEntry();
// Set the title and content of the entry.
entry.Title.Text = entryTitle;
entry.Content.Content = "Meet for a quick lesson.";
// Set a location for the event.
Where eventLocation = new Where();
eventLocation.ValueString = "South Tennis Courts";
entry.Locations.Add(eventLocation);
// If a recurrence was requested, add it. Otherwise, set the
// time (the current date and time) and duration (30 minutes)
// of the event.
if (recurData == null) {
When eventTime = new When();
eventTime.StartTime = DateTime.Now;
eventTime.EndTime = eventTime.StartTime.AddMinutes(30);
entry.Times.Add(eventTime);
} else {
Recurrence recurrence = new Recurrence();
recurrence.Value = recurData;
entry.Recurrence = recurrence;
}
// Send the request and receive the response:
Uri postUri = new Uri(feedUri);
AtomEntry insertedEntry = service.Insert(postUri, entry);
return (EventEntry)insertedEntry;
}
示例12: 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;
}
示例13: CreateReminder
private void CreateReminder(CalendarService calendarService, String reminderText, DateTime reminderTime)
{
EventEntry newEvent = new EventEntry();
newEvent.Title.Text = reminderText;
newEvent.Content.Content = reminderText + " (Reminder added by RemGen from " + Environment.MachineName + " by " + Environment.UserName + " " + Environment.UserDomainName + ")";
//Where eventLocation = new Where();
//eventLocation.ValueString = "Test event location 2";
//newEvent.Locations.Add(eventLocation);
When eventTime = new When(reminderTime, reminderTime);
newEvent.Times.Add(eventTime);
Reminder reminder = new Reminder();
reminder.Method = Reminder.ReminderMethod.sms;
reminder.AbsoluteTime = reminderTime;
newEvent.Reminders.Add(reminder);
Uri postUri = new Uri(calendarApiUri);
try
{
AtomEntry insertedEntry = calendarService.Insert(postUri, newEvent);
MessageBox.Show("Reminder added successfully");
}
catch (Exception ex)
{
MessageBox.Show("Failed to create event" + Environment.NewLine + Environment.NewLine + ex.ToString(), "RemGen");
}
}
示例14: AddMenuButton
//.........这里部分代码省略.........
break;
}
}
}
}
}
bkw.ReportProgress(5);
CalendarService myService = new CalendarService("ischool.CourseCalendar");
myService.setUserCredentials(googleAcc, googlePWD);
bkw.ReportProgress(20);
List<Section> syncedSections = new List<Section>();
foreach (K12.Data.CourseRecord course in K12.Data.Course.SelectByIDs(syncCourses))
{
//CalendarEntry targetCalender = null;
Calendar targetCal = null;
try
{
if (!calendars.ContainsKey(course.ID))
{
#region 建立新Calender
string[] colorLists = new string[]{"#A32929","#B1365F","#7A367A","#5229A3","#29527A","#2952A3","#1B887A",
"#28754E","#0D7813","#528800","#88880E","#AB8B00","#BE6D00","#B1440E",
"#865A5A","#705770","#4E5D6C","#5A6986","#4A716C","#6E6E41","#8D6F47"};
CalendarEntry newCal = new CalendarEntry();
newCal.Title.Text = course.Name;
newCal.Summary.Text = "科目:" + course.Subject
+ "\n學年度:" + course.SchoolYear
+ "\n學期:" + course.Semester
+ "\n學分數:" + course.Credit;
newCal.TimeZone = "Asia/Taipei";
//targetCalender.Hidden = false;
newCal.Color = colorLists[new Random(DateTime.Now.Millisecond).Next(0, colorLists.Length)];
Uri postUri = new Uri("http://www.google.com/calendar/feeds/default/owncalendars/full");
newCal = (CalendarEntry)myService.Insert(postUri, newCal);
#endregion
String calendarURI = newCal.Id.Uri.ToString();
String calendarID = calendarURI.Substring(calendarURI.LastIndexOf("/") + 1);
targetCal = new Calendar() { RefCourseID = course.ID, GoogleCalanderID = calendarID };
targetCal.Save();
}
else
{
targetCal = calendars[course.ID];
}
}
catch
{
hasFaild = true;
}
if (targetCal != null)
{
try
{
#region ACL
if (courseAttend.ContainsKey(course.ID))
{
List<string> aclList = new List<string>(targetCal.ACLList.Split("%".ToCharArray(), StringSplitOptions.RemoveEmptyEntries));
for (int i = 0; i < aclList.Count; i++)
{
aclList[i] = aclList[i].ToLower();
}
List<string> attentAccounts = new List<string>();
foreach (string sid in courseAttend[course.ID])
{
if (studentLoginAccount[sid] != "")
attentAccounts.Add(studentLoginAccount[sid]);
示例15: addACLShared
private static void addACLShared(string calID, string acc)
{
#region 新增分享
CalendarService myService = new CalendarService("ischool.CourseCalendar");
myService.setUserCredentials(googleAcc, googlePWD);
AclEntry entry = new AclEntry();
entry.Scope = new AclScope();
entry.Scope.Type = AclScope.SCOPE_USER;
entry.Scope.Value = acc;
entry.Role = AclRole.ACL_CALENDAR_READ;
try
{
AclEntry insertedEntry = myService.Insert(new Uri("https://www.google.com/calendar/feeds/" + calID + "/acl/full"), entry);
}
catch (GDataRequestException gex)
{
if (!gex.InnerException.Message.Contains("(409)"))
throw;
}
#endregion
}