本文整理汇总了C#中SPList.GetView方法的典型用法代码示例。如果您正苦于以下问题:C# SPList.GetView方法的具体用法?C# SPList.GetView怎么用?C# SPList.GetView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SPList
的用法示例。
在下文中一共展示了SPList.GetView方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create
public SPView Create(SPList list)
{
SPView view = list.GetView(Name);
IEnumerable<SPField> viewFields = GetViewFields(list);
if (view == null)
{
StringCollection strViewFields = new StringCollection();
strViewFields.AddRange(viewFields.Select(vf => vf.InternalName).ToArray());
view = list.Views.Add(Name, strViewFields, Query, RowLimit, Paged, IsDefault, ViewType, IsPersonal);
}
else
{
view.ViewFields.DeleteAll();
foreach (SPField viewField in viewFields)
{
view.ViewFields.Add(viewField);
}
view.Hidden = Hidden;
view.Scope = Scope;
view.Query = Query;
view.RowLimit = RowLimit;
view.Paged = Paged;
view.DefaultView = IsDefault;
view.Update();
}
return view;
}
示例2: AddCalendarOverlay
private static void AddCalendarOverlay(SPList targetList, string viewName, string overlayViewName, string owaUrl, string exchangeUrl, SPList overlayList, string overlayName, string overlayDescription, CalendarOverlayColor color, bool alwaysShow, bool clearExisting)
{
var isSharePointOverlay = overlayList != null;
var overlayViewId = string.IsNullOrEmpty(overlayViewName) ? overlayList.DefaultView.ID : overlayList.Views[overlayViewName].ID;
var linkUrl = isSharePointOverlay ? overlayList.GetView(overlayViewId).Url : owaUrl;
var targetView = targetList.DefaultView;
if (!string.IsNullOrEmpty(viewName))
{
targetView = targetList.Views[viewName];
}
var xml = new XmlDocument();
XmlElement aggregationElement = null;
var count = 0;
if (string.IsNullOrEmpty(targetView.CalendarSettings) || clearExisting)
{
xml.AppendChild(xml.CreateElement("AggregationCalendars"));
aggregationElement = xml.CreateElement("AggregationCalendar");
if (xml.DocumentElement != null)
{
xml.DocumentElement.AppendChild(aggregationElement);
}
}
else
{
xml.LoadXml(targetView.CalendarSettings);
var calendars = xml.SelectNodes("/AggregationCalendars/AggregationCalendar");
if (calendars != null)
{
count = calendars.Count;
}
aggregationElement =
xml.SelectSingleNode(
string.Format("/AggregationCalendars/AggregationCalendar[@CalendarUrl='{0}']", linkUrl)) as XmlElement;
if (aggregationElement == null)
{
if (count >= 10)
{
throw new SPException(
string.Format(
"10 calendar ovarlays already exist for the calendar {0}.",
targetList.RootFolder.ServerRelativeUrl));
}
aggregationElement = xml.CreateElement("AggregationCalendar");
if (xml.DocumentElement != null)
{
xml.DocumentElement.AppendChild(aggregationElement);
}
}
}
if (!aggregationElement.HasAttribute("Id"))
{
aggregationElement.SetAttribute("Id", Guid.NewGuid().ToString("B", CultureInfo.InvariantCulture));
}
aggregationElement.SetAttribute("Type", isSharePointOverlay ? "SharePoint" : "Exchange");
aggregationElement.SetAttribute("Name", !string.IsNullOrEmpty(overlayName) ? overlayName : (overlayList == null ? string.Empty : overlayList.Title));
aggregationElement.SetAttribute("Description", !string.IsNullOrEmpty(overlayDescription) ? overlayDescription : (overlayList == null ? string.Empty : overlayList.Description));
aggregationElement.SetAttribute("Color", ((int)color).ToString(CultureInfo.InvariantCulture));
aggregationElement.SetAttribute("AlwaysShow", alwaysShow.ToString());
aggregationElement.SetAttribute("CalendarUrl", linkUrl);
var settingsElement = aggregationElement.SelectSingleNode("./Settings") as XmlElement;
if (settingsElement == null)
{
settingsElement = xml.CreateElement("Settings");
aggregationElement.AppendChild(settingsElement);
}
if (isSharePointOverlay)
{
settingsElement.SetAttribute("WebUrl", overlayList.ParentWeb.Site.MakeFullUrl(overlayList.ParentWebUrl));
settingsElement.SetAttribute("ListId", overlayList.ID.ToString("B", CultureInfo.InvariantCulture));
settingsElement.SetAttribute("ViewId", overlayViewId.ToString("B", CultureInfo.InvariantCulture));
settingsElement.SetAttribute("ListFormUrl", overlayList.Forms[PAGETYPE.PAGE_DISPLAYFORM].ServerRelativeUrl);
}
else
{
settingsElement.SetAttribute("ServiceUrl", exchangeUrl);
}
targetView.CalendarSettings = xml.OuterXml;
targetView.Update();
}