protected void spGridView_Sorting(object sender, GridViewSortEventArgs e) { if (this.SortExpression == e.SortExpression) { this.SortAscending = !this.SortAscending; } else { this.SortAscending = true; } this.SortExpression = e.SortExpression; var options = new ItemsRetrievingOptions() { ViewName = this.View.Name, SortingInfo = new ItemsRetrievingOptions.SortingOptions { FieldName = this.SortExpression, Ascending = this.SortAscending }, Folder = this.folderPath.Value }; this.CurrentItems = new UiItemCollection(this.context, this.List, options); this.spGridView.DataSource = this.CurrentItems; this.BuildGridView(this.List, this.View); this.spGridView.DataBind(); this.CheckButtons(); }
public ItemCollection([NotNull] SpContext context, [NotNull] BaseList list, [NotNull] ItemsRetrievingOptions options) : base(context, list, options) { Assert.ArgumentNotNull(context, "context"); Assert.ArgumentNotNull(list, "list"); Assert.ArgumentNotNull(options, "options"); }
/// <summary> /// Initializes a new instance of the <see cref="ItemsRetrievingOptionsParser"/> class. /// </summary> /// <param name="list">The target SharePoint list.</param> /// <param name="options">Indicates which list items should be retrived from the target SharePoint list.</param> public ItemsRetrievingOptionsParser([NotNull] BaseList list, [NotNull] ItemsRetrievingOptions options) { Assert.ArgumentNotNull(list, "list"); Assert.ArgumentNotNull(options, "options"); this.list = list; this.options = options; }
/// <summary> /// Initializes a new instance of the <see cref="ItemCollection"/> class. /// </summary> /// <param name="context">The context.</param> /// <param name="list">The list.</param> /// <param name="options">The options.</param> public ItemCollection([NotNull] SpContext context, [NotNull] BaseList list, [NotNull] ItemsRetrievingOptions options) { Assert.ArgumentNotNull(context, "context"); Assert.ArgumentNotNull(list, "list"); Assert.ArgumentNotNull(options, "options"); this.Context = context; this.List = list; this.Options = options; this.PageIndex = 1; this.PagingQueryCollection = new Dictionary <int, string>(); this.PagingQueryCollection.Add(1, string.Empty); }
protected ObjectModel.Entities.Collections.ItemCollection GetSubItems([NotNull] BaseList list, [NotNull] IntegrationConfigData integrationConfigData) { Assert.ArgumentNotNull(list, "list"); Assert.ArgumentNotNull(integrationConfigData, "integrationConfigData"); var itemsOptions = new ItemsRetrievingOptions { Folder = integrationConfigData.Folder, ViewName = integrationConfigData.View, ItemLimit = integrationConfigData.ItemLimit }; return(list.GetItems(itemsOptions)); }
public override EntityProperties Update() { EntityProperties returnProperties = null; if (this.NewStream != null) { new DocumentItemConnector(this.Context, this).UploadStream(this.NewStream); this.NewStream.Close(); this.NewStream = null; } if (IsNew) { var itemsRetrievingOptions = new ItemsRetrievingOptions() { Folder = this.Folder, WherePart = String.Format("<Eq><FieldRef Name=\"{0}\"/><Value Type=\"Text\">{1}</Value></Eq>", "FileLeafRef", this["ows_FileLeafRef"]) }; ItemCollection item = this.List.GetItems(itemsRetrievingOptions); if (item.Count == 1) { this.Properties["ows_ID"] = ((DocumentItem)item[0]).Properties["ows_ID"]; this.Properties["ows_FileLeafRef"] = ((DocumentItem)item[0]).Properties["ows_FileLeafRef"]; this.Properties["ows_FileRef"] = ((DocumentItem)item[0]).Properties["ows_FileRef"]; this.Properties["ows_FileDirRef"] = ((DocumentItem)item[0]).Properties["ows_FileDirRef"]; foreach (var propertie in ((DocumentItem)item[0]).Properties) { if (this.Properties[propertie.Key] == null) { this.Properties[propertie.Key] = propertie.Value; } } } else { Log.Error("Can't reload item from Sharepoint.", this); throw new NullReferenceException("Can't reload item from Sharepoint."); } } if (!IsNew) { returnProperties = base.Update(); } return(returnProperties); }
/// <summary> /// This methom calling if data was changed. /// </summary> public void Rebind() { var options = new ItemsRetrievingOptions() { ViewName = this.View.Name, Folder = this.folderPath.Value, SortingInfo = new ItemsRetrievingOptions.SortingOptions { Ascending = this.SortAscending, FieldName = this.SortExpression } }; this.CurrentItems = new UiItemCollection(this.context, this.List, options); this.spGridView.DataSource = this.CurrentItems; this.BuildGridView(this.List, this.View); this.spGridView.DataBind(); this.CheckButtons(); }
protected void spViewsList_IndexChanged(object sender, EventArgs e) { this.folderPath.Value = string.Empty; this.SortAscending = true; this.SortExpression = string.Empty; this.LabelSharepointSite.Text = this.GetBreadcrumbValue(string.Empty); this.spGridView.AutoGenerateColumns = false; BaseList spList = BaseList.GetList(this.Web, this.ListName, this.context); View spView = View.GetView(spList, this.spViewsList.SelectedValue, this.context); var options = new ItemsRetrievingOptions { ViewName = spView.Name }; this.CurrentItems = new UiItemCollection(this.context, spList, options); this.spGridView.DataSource = this.CurrentItems; this.BuildGridView(spList, spView); this.spGridView.DataBind(); this.CheckButtons(); }
public EntityValues GetItems([NotNull] BaseList list, [NotNull] ItemsRetrievingOptions options) { Assert.ArgumentNotNull(list, "list"); Assert.ArgumentNotNull(options, "options"); var optionsParser = new ItemsRetrievingOptionsParser(list, options); XmlNode itemsNode = this.ListWebService.GetListItems( optionsParser.GetListName(), optionsParser.GetViewName(), optionsParser.GetQuery(), optionsParser.GetViewFields(), optionsParser.GetRowLimit(), optionsParser.GetQueryOptions(), optionsParser.GetWebID()); var items = new EntityValues(); XmlNode valuesNode = itemsNode.ChildNodes[1]; if (valuesNode.Attributes["ListItemCollectionPositionNext"] != null) { items.Properties.Add("ListItemCollectionPositionNext", new EntityPropertyValue(valuesNode.Attributes["ListItemCollectionPositionNext"].Value)); } foreach (XmlNode itemNode in valuesNode.ChildNodes) { if (itemNode.Name == "z:row") { var item = new EntityValues { Properties = XmlUtils.LoadProperties(itemNode) }; items.Add("Items", item); } } return(items); }
public static BaseItem GetItem([NotNull] string uniqueID, [NotNull] SpContext context, string viewName = null) { Assert.ArgumentNotNull(uniqueID, "uniqueID"); Assert.ArgumentNotNull(context, "context"); string[] values = StringUtil.Split(uniqueID, '|', true); string webUrl = values[0]; string listName = values[1]; string id = values[2]; string folder = values[3]; string wherePart = string.Format("<Eq><FieldRef Name=\"{0}\"/><Value Type=\"Integer\">{1}</Value></Eq>", "ID", id); var itemsRetrievingOptions = new ItemsRetrievingOptions { WherePart = wherePart, ViewName = viewName }; if (!string.IsNullOrEmpty(folder)) { itemsRetrievingOptions.Folder = folder; } BaseList list = BaseList.GetList(webUrl, listName, context); ItemCollection items = list.GetItems(itemsRetrievingOptions); if (items.Count == 1) { return(items[0]); } if (items.Count > 1) { throw new Exception("More than document has been found by ID"); } throw new Exception("Document can't be found"); }
public ItemCollection GetItems([NotNull] ItemsRetrievingOptions options) { Assert.ArgumentNotNull(options, "options"); var optionIn = options.Clone(); string folder = string.Empty; if (!string.IsNullOrEmpty(this.Folder)) { folder = StringUtil.EnsurePostfix('/', this.Folder) + this.Title; } else { folder = this.Title; } optionIn.Folder = StringUtil.EnsurePostfix('/', folder) + optionIn.Folder; var itemCollection = new ItemCollection(this.Context, this.List, optionIn); options.CopyFrom(optionIn); return(itemCollection); }
protected override void OnLoad(EventArgs e) { this.Initialize(); base.OnLoad(e); if (!this.CheckCredentialsOnSharepointServer()) { return; } if (List == null) { this.menubarDiv.Visible = false; this.controlButtonsDiv.Visible = false; this.dataDiv.Visible = false; this.labelErrorMessageDiv.Visible = true; this.labelErrorMessage.Text = string.IsNullOrEmpty(this.ListName) ? UIMessages.PleaseSelectASharePointListFromTheSPIFControlProperties : UIMessages.ConnectionToSharePointServerFailedPleaseCheckYourSharePointServerConfigurationDetails; return; } if (!IsPostBack) { this.SortExpression = string.Empty; this.SortAscending = true; string selectedView = null; var views = new List <View>(); foreach (View view in List.Views) { if (!view.Hidden && !MainUtil.GetBool(view["RequiresClientIntegration"], false) && view.Type == "HTML") { views.Add(view); if (list["DefaultViewUrl"] == view.Url) { selectedView = view.Name; } } } this.spViewsList.DataSource = views; this.spViewsList.DataTextField = "DisplayName"; this.spViewsList.DataValueField = "Name"; this.spViewsList.DataBind(); this.spViewsList.SelectedValue = selectedView; this.AttemptNumber = 0; } string folderPathValue = this.folderPath.Value; if ((this.FolderPath_Old != folderPathValue) || (this.CurrentItems == null)) { var itemsOptions = new ItemsRetrievingOptions { Folder = folderPathValue, SortingInfo = new ItemsRetrievingOptions.SortingOptions { FieldName = this.SortExpression, Ascending = this.SortAscending }, ViewName = this.View.Name }; this.CurrentItems = new UiItemCollection(this.context, this.List, itemsOptions); this.FolderPath_Old = folderPathValue; } if (!this.IsPostBack && this.CurrentItems.Count == 0 && !this.ShowIfEmpty) { this.Visible = false; } this.spGridView.DataSource = this.CurrentItems; this.BuildGridView(this.List, this.View); if (this.spViewsList.UniqueID != this.Request.Form[System.Web.UI.Page.postEventSourceID]) { this.spGridView.DataBind(); } this.CheckButtons(); this.LabelSharepointSite.Text = this.GetBreadcrumbValue(folderPathValue); }
public virtual ItemCollection GetItems([NotNull] ItemsRetrievingOptions options) { Assert.ArgumentNotNull(options, "options"); return(new ItemCollection(this.Context, this, options)); }
public MyItemCollection([NotNull] SpContext context, [NotNull] BaseList list, [NotNull] ItemsRetrievingOptions options) : base(context, list, options) { this.Items = new List <BaseItem>(); }