private void InstallListsViews(SPList list, int parentMessageId, XmlNode nodeView, string name) { if (list == null) { throw new ArgumentNullException(nameof(list)); } if (nodeView == null) { throw new ArgumentNullException(nameof(nodeView)); } var fields = new StringCollection(); fields.AddRange(nodeView.SelectSingleNode(Fields).InnerText.Split(SeparatorComma)); var query = ApplicationInstallerHelpers.getChildNodeText(nodeView, Query); var projectedFields = ApplicationInstallerHelpers.getChildNodeText(nodeView, ProjectedFields); var joins = ApplicationInstallerHelpers.getChildNodeText(nodeView, Joins); uint rowLimit; uint.TryParse(ApplicationInstallerHelpers.getAttribute(nodeView, RowLimit), out rowLimit); bool isDefault; bool.TryParse(ApplicationInstallerHelpers.getAttribute(nodeView, MakeDefault), out isDefault); list.Views.Add(name, fields, query, joins, projectedFields, rowLimit, false, isDefault, SPViewCollection.SPViewType.Html, false); addMessage(0, name, string.Empty, parentMessageId); }
private void InstallListsViews(SPList list, int parentMessageId, XmlNode nodeView, string name, SPView view) { if (list == null) { throw new ArgumentNullException(nameof(list)); } if (nodeView == null) { throw new ArgumentNullException(nameof(nodeView)); } if (view == null) { throw new ArgumentNullException(nameof(view)); } var fields = nodeView.SelectSingleNode(Fields).InnerText.Split(SeparatorComma); var query = ApplicationInstallerHelpers.getChildNodeText(nodeView, Query); var projectedFields = ApplicationInstallerHelpers.getChildNodeText(nodeView, ProjectedFields); var joins = ApplicationInstallerHelpers.getChildNodeText(nodeView, Joins); uint iRowLimit = 0; uint.TryParse(ApplicationInstallerHelpers.getAttribute(nodeView, RowLimit), out iRowLimit); var bDefault = false; bool.TryParse(ApplicationInstallerHelpers.getAttribute(nodeView, MakeDefault), out bDefault); view.ViewFields.DeleteAll(); foreach (var sField in fields) { SPField oField = null; try { oField = list.Fields.GetFieldByInternalName(sField); } catch (Exception ex) { Trace.WriteLine(ex.ToString()); } if (oField != null) { view.ViewFields.Add(oField); } } view.Query = query; view.ProjectedFields = projectedFields; view.Joins = joins; view.RowLimit = iRowLimit; view.DefaultView = bDefault; view.Update(); addMessage(ErrorLevels.Upgrade, name, "View exists and will overwrite", parentMessageId); }