private ViewCreationInformation GetViewCreationInfoFromConfig(ShView view) { return(new ViewCreationInformation { Title = view.Title, Query = view.Query, ViewFields = view.ViewFields, RowLimit = view.RowLimit, SetAsDefaultView = view.DefaultView }); }
private void SetupView(ClientContext context, List list, ShView view) { var viewCollection = list.Views; View setupView = null; if (!string.IsNullOrEmpty(view.Title)) { setupView = viewCollection.FirstOrDefault(v => v.Title == view.Title); if (setupView == null) { setupView = viewCollection.Add(GetViewCreationInfoFromConfig(view)); context.ExecuteQuery(); } } else if (!string.IsNullOrEmpty(view.Url)) { context.Load(list, x => x.ParentWebUrl); context.Load(list, x => x.ParentWeb); context.ExecuteQuery(); var serverRelativeUrl = UriUtilities.CombineServerRelativeUri(list.ParentWebUrl, view.Url); list.ParentWeb.CheckOutFile(serverRelativeUrl); setupView = viewCollection.FirstOrDefault(v => v.ServerRelativeUrl == serverRelativeUrl); } if (setupView != null) { if (view.ViewFields.Length > 0) { setupView.ViewFields.RemoveAll(); foreach (var field in view.ViewFields) { setupView.ViewFields.Add(field); } } setupView.JSLink = view.JSLink; setupView.ViewQuery = view.Query; setupView.RowLimit = view.RowLimit; setupView.Update(); if (!string.IsNullOrEmpty(view.Url)) { list.ParentWeb.CheckInFile(setupView.ServerRelativeUrl, CheckinType.MajorCheckIn, "updated by sherpa"); } context.ExecuteQuery(); } }
private void SetupView(ClientContext context, List list, ShView view) { var viewCollection = list.Views; View setupView = null; if (!string.IsNullOrEmpty(view.Title)) { setupView = viewCollection.FirstOrDefault(v => v.Title == view.Title); if (setupView == null) { setupView = viewCollection.Add(GetViewCreationInfoFromConfig(view)); context.ExecuteQuery(); } } else if (!string.IsNullOrEmpty(view.Url)) { context.Load(list, x=>x.ParentWebUrl); context.Load(list, x => x.ParentWeb); context.ExecuteQuery(); var serverRelativeUrl = UriUtilities.CombineServerRelativeUri(list.ParentWebUrl, view.Url); list.ParentWeb.CheckOutFile(serverRelativeUrl); setupView = viewCollection.FirstOrDefault(v => v.ServerRelativeUrl == serverRelativeUrl); } if (setupView != null) { if (view.ViewFields.Length > 0) { setupView.ViewFields.RemoveAll(); foreach (var field in view.ViewFields) { setupView.ViewFields.Add(field); } } setupView.JSLink = view.JSLink; setupView.ViewQuery = view.Query; setupView.RowLimit = view.RowLimit; setupView.Update(); if (!string.IsNullOrEmpty(view.Url)) { list.ParentWeb.CheckInFile(setupView.ServerRelativeUrl, CheckinType.MajorCheckIn, "updated by sherpa"); } context.ExecuteQuery(); } }
private ViewCreationInformation GetViewCreationInfoFromConfig(ShView view) { return new ViewCreationInformation { Title = view.Title, Query = view.Query, ViewFields = view.ViewFields, RowLimit = view.RowLimit, SetAsDefaultView = view.DefaultView }; }