Hi,
I have a RadScheduler and I trying to save the new appointment or the changes to a Calendar List. I use the code below to get all the item in the calendar but I have expend 2 days try to find out what is the event that is triggering when the user press the button save.
With the code I was able to fill my calendar. I only need to know what event to use where I can put all the logic to write to the Calendar List. Thanks!!
Note. I am working with ASP.NET
private SPCalendarItemCollection GetCalendarItems()
{
// Create a new collection for the calendar items
// This is an item with a start and end date.
SPCalendarItemCollection items = new SPCalendarItemCollection();
SPWeb oWeb = SPControl.GetContextWeb(Context);
SPList oCalendarList = oWeb.Lists["Calendar"];
SPView oView = oCalendarList.Views["Calendar"];
SPQuery query = new SPQuery();
query.Query = "<OrderBy><FieldRef Name='ID' /></OrderBy>";
query.Query = "<Where><Eq><FieldRef Name='fRecurrence' /><Value Type='Recurrence'>0</Value></Eq></Where><OrderBy><FieldRef Name='ID' /></OrderBy>";
//For Team members (not for recurrent events)
foreach (SPListItem listItem in oCalendarList.GetItems(query))
{
SPCalendarItem calItem = new SPCalendarItem();
calItem.ItemID = listItem["ID"].ToString();
calItem.Title = listItem["Title"].ToString();
calItem.CalendarType = Convert.ToInt32(SPCalendarType.Gregorian);
calItem.StartDate = (DateTime)listItem["Start Time"];
calItem.ItemID = listItem.ID.ToString();
if (listItem["End Time"] != null)
{
calItem.hasEndDate = true;
calItem.EndDate = (DateTime)listItem["End Time"];
}
else
calItem.hasEndDate = false;
if (listItem["Description"] != null)
calItem.Description = listItem["Description"].ToString();
if (listItem["Location"] != null)
calItem.Location = listItem["Location"].ToString();
calItem.IsRecurrence = Convert.ToBoolean(listItem["Recurrence"]);
items.Add(calItem);
}
//Only for Reccurent events (like weekley meetings)
SPQuery queryRecurrence = new SPQuery();
queryRecurrence.ExpandRecurrence = true;
queryRecurrence.Query = "<Where>" +
"<And>" +
"<Eq>" +
"<FieldRef Name='fRecurrence' />" +
"<Value Type='Recurrence'>1</Value>" +
"</Eq>" +
"<DateRangesOverlap>" +
"<FieldRef Name='EventDate' />" +
"<FieldRef Name='EndDate' />" +
"<FieldRef Name='RecurrenceID' />" +
"<Value Type='DateTime'>" +
"<Month />" +
"</Value>" +
"</DateRangesOverlap>" +
"</And>" +
"</Where>" +
"<ViewFields>" +
"<FieldRef Name='Title' />" +
"<FieldRef Name='EventDate' />" +
"FieldRef Name='EndDate' />" +
"<FieldRef Name='fRecurrence' />" +
"<FieldRef Name='Absentee' />" +
"</ViewFields>";
// Look forward from the beginning of the current month
queryRecurrence.CalendarDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
// Returns all items (including recurrence instances) that
// would appear in the calendar view for the current month
SPListItemCollection calendarItems = oCalendarList.GetItems(queryRecurrence);
foreach (SPListItem listItem in oCalendarList.GetItems(queryRecurrence))
{
SPCalendarItem calItem = new SPCalendarItem();
calItem.ItemID = listItem["ID"].ToString();
calItem.Title = listItem["Title"].ToString();
calItem.CalendarType = Convert.ToInt32(SPCalendarType.Gregorian);
calItem.StartDate = (DateTime)listItem["Start Time"];
calItem.ItemID = listItem.ID.ToString();
if (listItem["End Time"] != null)
{
calItem.hasEndDate = true;
calItem.EndDate = (DateTime)listItem["End Time"];
}
else
calItem.hasEndDate = false;
if (listItem["Description"] != null)
calItem.Description = listItem["Description"].ToString();
if (listItem["Location"] != null)
calItem.Location = listItem["Location"].ToString();
items.Add(calItem);
}
// return the collection
return items;
}
I have a RadScheduler and I trying to save the new appointment or the changes to a Calendar List. I use the code below to get all the item in the calendar but I have expend 2 days try to find out what is the event that is triggering when the user press the button save.
With the code I was able to fill my calendar. I only need to know what event to use where I can put all the logic to write to the Calendar List. Thanks!!
Note. I am working with ASP.NET
private SPCalendarItemCollection GetCalendarItems()
{
// Create a new collection for the calendar items
// This is an item with a start and end date.
SPCalendarItemCollection items = new SPCalendarItemCollection();
SPWeb oWeb = SPControl.GetContextWeb(Context);
SPList oCalendarList = oWeb.Lists["Calendar"];
SPView oView = oCalendarList.Views["Calendar"];
SPQuery query = new SPQuery();
query.Query = "<OrderBy><FieldRef Name='ID' /></OrderBy>";
query.Query = "<Where><Eq><FieldRef Name='fRecurrence' /><Value Type='Recurrence'>0</Value></Eq></Where><OrderBy><FieldRef Name='ID' /></OrderBy>";
//For Team members (not for recurrent events)
foreach (SPListItem listItem in oCalendarList.GetItems(query))
{
SPCalendarItem calItem = new SPCalendarItem();
calItem.ItemID = listItem["ID"].ToString();
calItem.Title = listItem["Title"].ToString();
calItem.CalendarType = Convert.ToInt32(SPCalendarType.Gregorian);
calItem.StartDate = (DateTime)listItem["Start Time"];
calItem.ItemID = listItem.ID.ToString();
if (listItem["End Time"] != null)
{
calItem.hasEndDate = true;
calItem.EndDate = (DateTime)listItem["End Time"];
}
else
calItem.hasEndDate = false;
if (listItem["Description"] != null)
calItem.Description = listItem["Description"].ToString();
if (listItem["Location"] != null)
calItem.Location = listItem["Location"].ToString();
calItem.IsRecurrence = Convert.ToBoolean(listItem["Recurrence"]);
items.Add(calItem);
}
//Only for Reccurent events (like weekley meetings)
SPQuery queryRecurrence = new SPQuery();
queryRecurrence.ExpandRecurrence = true;
queryRecurrence.Query = "<Where>" +
"<And>" +
"<Eq>" +
"<FieldRef Name='fRecurrence' />" +
"<Value Type='Recurrence'>1</Value>" +
"</Eq>" +
"<DateRangesOverlap>" +
"<FieldRef Name='EventDate' />" +
"<FieldRef Name='EndDate' />" +
"<FieldRef Name='RecurrenceID' />" +
"<Value Type='DateTime'>" +
"<Month />" +
"</Value>" +
"</DateRangesOverlap>" +
"</And>" +
"</Where>" +
"<ViewFields>" +
"<FieldRef Name='Title' />" +
"<FieldRef Name='EventDate' />" +
"FieldRef Name='EndDate' />" +
"<FieldRef Name='fRecurrence' />" +
"<FieldRef Name='Absentee' />" +
"</ViewFields>";
// Look forward from the beginning of the current month
queryRecurrence.CalendarDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
// Returns all items (including recurrence instances) that
// would appear in the calendar view for the current month
SPListItemCollection calendarItems = oCalendarList.GetItems(queryRecurrence);
foreach (SPListItem listItem in oCalendarList.GetItems(queryRecurrence))
{
SPCalendarItem calItem = new SPCalendarItem();
calItem.ItemID = listItem["ID"].ToString();
calItem.Title = listItem["Title"].ToString();
calItem.CalendarType = Convert.ToInt32(SPCalendarType.Gregorian);
calItem.StartDate = (DateTime)listItem["Start Time"];
calItem.ItemID = listItem.ID.ToString();
if (listItem["End Time"] != null)
{
calItem.hasEndDate = true;
calItem.EndDate = (DateTime)listItem["End Time"];
}
else
calItem.hasEndDate = false;
if (listItem["Description"] != null)
calItem.Description = listItem["Description"].ToString();
if (listItem["Location"] != null)
calItem.Location = listItem["Location"].ToString();
items.Add(calItem);
}
// return the collection
return items;
}