/// <summary>Retrieves a collection of calendars by role.</summary> /// <param name="roleName">The name of the role.</param> /// <returns>A collection of calendars.</returns> public CalendarCollection GetCalendarByRole(string roleName) { CalendarCollection collection = new CalendarCollection(); string listName; string url = ParseSiteUrl(m_calendarsListURL, out listName); using (SPSite site = new SPSite(url)) { using (SPWeb web = site.OpenWeb()) { SPList list = web.Lists[HttpContext.Current.Server.HtmlDecode(listName)]; SPQuery query = new SPQuery(); query.Query = "<Where><Contains><FieldRef Name='Role'/><Value Type='Text'>" + roleName + "</Value></Contains></Where>"; SPListItemCollection items = list.GetItems(query); if (items.Count > 0) { foreach (SPListItem item in items) { Calendar calendar = CalendarFromListItem(item, true); calendar.IsUserSelected = false; collection.Add(calendar); } } } } return(collection); }
/// <summary>Gets a collection of user calendars.</summary> /// <param name="calendarsIdList">A list of calendars.</param> /// <returns>A <see cref="CalendarCollection"/>.</returns> public CalendarCollection GetUserCalendars(string calendarsIdList) { CalendarCollection collection = new CalendarCollection(); if (calendarsIdList.Length > 0) { string listName; string url = ParseSiteUrl(m_calendarsListURL, out listName); using (SPSite site = new SPSite(url)) { using (SPWeb web = site.OpenWeb()) { SPList list = web.Lists[listName.Replace("%20", " ")]; string[] idslist = calendarsIdList.Split(','); SPQuery query = new SPQuery(); query.Query = "<Where><Or>"; foreach (string tmp in idslist) { query.Query += "<Eq><FieldRef Name='ID'/><Value>" + tmp; query.Query += "</value></Eq>"; } query.Query += "</Or></Where>"; SPListItemCollection items = list.GetItems(query); if (items.Count > 0) { foreach (SPListItem item in items) { collection.Add(CalendarFromListItem(item, false)); } } } } } return(collection); }
public Calendar(bool m_showSlk, bool m_showExchange, string sharepointidlist, string exchangeidlist, MLGCalendar.CalendarCollection m_cals) { ShowSLK = m_showSlk; ShowPersonalExchnage = m_showExchange; SharePointCalendarIdsList = sharepointidlist; ExchangeCalendarIdsList = exchangeidlist; Calendars = m_cals; HtmlTableCell lCell = new HtmlTableCell("td"); HtmlTableCell rCell = new HtmlTableCell("td"); HtmlTableCell mCell = new HtmlTableCell("td"); HtmlTableCell reloadCell = new HtmlTableCell("td"); HtmlTableCell myExchangeButton; HtmlTableCell mySLKButton; HtmlTableCell calendarsMenus; HtmlTableCell dummyTD; HtmlTableRow dummyTR; HtmlTable toolbarTable = new HtmlTable(); dummyTD = new HtmlTableCell("td"); dummyTD.ColSpan = 7; dummyTR = new HtmlTableRow(); toolbarTable.Attributes.Add("class", "ms-menutoolbar"); toolbarTable.Width = "100%"; //Add prev month link prevMonth.Text = "<"; prevMonth.ID = "prevMonth"; prevMonth.CommandName = "ChangeMonth"; nextMonth.Text = ">"; nextMonth.ID = "nextMonth"; nextMonth.CommandName = "ChangeMonth"; prevMonth.CssClass = CssHeadClass; nextMonth.CssClass = CssHeadClass; reloadButton.Text = "Reload"; reloadButton.ID = "reload"; reloadButton.CommandName = "ChangeMonth"; //reloadButton.Attributes.Add("onclick", "Javascript:this.document.forms['aspnetForm'].submit();"); lCell.Attributes.Add("class", "ms-cal-navheader"); lCell.Align = "right"; rCell.Attributes.Add("class", "ms-cal-navheader"); rCell.Align = "left"; mCell.Attributes.Add("class", "ms-cal-navheader"); //ms-cal-navheader //Add next month link lCell.Controls.Add(prevMonth); rCell.Controls.Add(nextMonth); mCell.Controls.Add(monthName); mCell.Align = "center"; mCell.ColSpan = 5; headRow.Cells.Add(lCell); headRow.Cells.Add(mCell); headRow.Cells.Add(rCell); // headRow.bor myExchangeButton = GetMyExchangeButton("My Calendar"); mySLKButton = GetMySlkButton("Assignments"); dummyTR.Cells.Add(myExchangeButton); dummyTR.Cells.Add(mySLKButton); myExchangeButton.Attributes.Add("class", "ms-toolbar"); mySLKButton.Attributes.Add("class", "ms-toolbar"); if (m_cals != null) { calendarsMenus = GetToolbarCalendarMenus(); calendarsMenus.Attributes.Add("class", "ms-toolbar"); calendarsMenus.ColSpan = 4; dummyTR.Cells.Add(calendarsMenus); } reloadCell.Controls.Add(reloadButton); reloadCell.Width = "100%"; reloadCell.Align = "right"; dummyTR.Cells.Add(reloadCell); toolbarTable.Rows.Add(dummyTR); dummyTD.Controls.Add(toolbarTable); toolbarRow.Cells.Add(dummyTD); //toolbarRow.Attributes.Add("class", "ms-toolbar"); //this.Border = 10; //this.Border = 3; this.Rows.Add(toolbarRow); this.Rows.Add(headRow); }