private void LoadingTabRawData() { gvRawData.Rows.Clear(); if (tabs.SelectedTab == tpRawData) { SPLoader.LoadRawData(tvSite.SelectedNode, gvRawData); } tsProgressBar.Value = 0; }
private void LoadSiteCollections() { // Prepare root node TreeNode rootNode = tvSite.Nodes[0]; rootNode.Nodes.Clear(); // Add site collections from Global list foreach (SiteAuth sc in Globals.SiteCollections.Where(s => s.IsLoaded)) { SPLoader.LoadSite(rootNode, sc, this); } // Ensure recent sites are in sync this.LoadRecentSites(); // Expand root node rootNode.Expand(); }
public static void LoadRawData(TreeNode selectedNode, DataGridView gvRawData) { try { SPClient.List list = selectedNode.Tag as SPClient.List; if (list != null) { // Reset the grid gvRawData.Columns.Clear(); gvRawData.Rows.Clear(); // Get list data SPClient.CamlQuery query = new SPClient.CamlQuery(); query.ViewXml = "<View Scope='RecursiveAll'><RowLimit>5000</RowLimit></View>"; SPClient.ClientContext ctx = SPLoader.GetClientContext(selectedNode); SPClient.ListItemCollection items = list.GetItems(query); ctx.Load(items); ctx.Load(list.Fields); ctx.ExecuteQuery(); // Add columns foreach (SPClient.Field field in list.Fields) { DataGridViewColumn column = new DataGridViewTextBoxColumn(); column.Name = field.InternalName; column.HeaderText = field.Title; column.DataPropertyName = field.InternalName; column.ReadOnly = true; column.Tag = field; column.ToolTipText = string.Format("InternalName: {0}\nStaticName: {1}\nTypeAsString: {2}\nType: {3}", field.InternalName, field.StaticName, field.TypeAsString, field.GetType()); if (field.Hidden) { DataGridViewCellStyle style = new DataGridViewCellStyle(); style.ForeColor = Color.Gray; column.HeaderCell.Style = style; } gvRawData.Columns.Add(column); } int total = items.Count; int current = 0; // Add rows foreach (SPClient.ListItem item in items) { DataGridViewRow row = gvRawData.Rows[gvRawData.Rows.Add()]; foreach (DataGridViewColumn column in gvRawData.Columns) { if (item.FieldValues.ContainsKey(column.Name) && item.FieldValues[column.Name] != null) { SPClient.Field field = (SPClient.Field)column.Tag; switch (field.TypeAsString) { case "Lookup": if (string.IsNullOrEmpty(((SPClient.FieldLookup)field).LookupList)) { row.Cells[column.Name].Value = item.FieldValues[column.Name].ToString(); } else { row.Cells[column.Name].Value = string.Format("{0};#{1}", ((SPClient.FieldLookupValue)item.FieldValues[column.Name]).LookupId, ((SPClient.FieldLookupValue)item.FieldValues[column.Name]).LookupValue); } break; case "URL": row.Cells[column.Name].Value = ((SPClient.FieldUrlValue)item.FieldValues[column.Name]).Url; break; case "User": row.Cells[column.Name].Value = string.Format("{0};#{1}", ((SPClient.FieldUserValue)item.FieldValues[column.Name]).LookupId, ((SPClient.FieldUserValue)item.FieldValues[column.Name]).LookupValue); break; default: row.Cells[column.Name].Value = item.FieldValues[column.Name].ToString(); break; } } } // Update progress current++; ItemLoaded(null, new ItemLoadedEventArgs() { TotalItem = total, CurrentItem = current }); } } } catch (Exception ex) { MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void LoadNodes(LoadType loadType, TreeNode node) { // Initiate treeview load tvSite.BeginUpdate(); // Clear Loading... node node.Nodes.Clear(); // Load node contents switch (loadType) { case LoadType.SiteFields: SPLoader.LoadSiteColumns(node, ((SPClient.Site)node.Parent.Tag).RootWeb.AvailableFields, this, loadType); break; case LoadType.SiteContentTypes: SPLoader.LoadContentTypes(node, ((SPClient.Site)node.Parent.Tag).RootWeb.AvailableContentTypes, this, loadType); break; case LoadType.SiteFeatures: SPLoader.LoadFeatures(node, ((SPClient.Site)node.Parent.Tag).Features, this, loadType); break; case LoadType.SiteEventReceivers: // Not supported in SP2010 CSOM break; case LoadType.SiteRecycleBin: SPLoader.LoadRecycleBin(node, ((SPClient.Site)node.Parent.Tag).RecycleBin, this, loadType); break; case LoadType.SiteWebTemplates: // Not supported in SP2010 CSOM break; case LoadType.WebSubWebs: SPLoader.LoadSubWebs(node, ((SPClient.Web)node.Parent.Tag).GetSubwebsForCurrentUser(null), this); break; case LoadType.WebFields: SPLoader.LoadSiteColumns(node, ((SPClient.Web)node.Parent.Tag).Fields, this, loadType); break; case LoadType.WebContentTypes: SPLoader.LoadContentTypes(node, ((SPClient.Web)node.Parent.Tag).ContentTypes, this, loadType); break; case LoadType.WebLists: SPLoader.LoadLists(node, ((SPClient.Web)node.Parent.Tag).Lists, this); break; case LoadType.WebFeatures: SPLoader.LoadFeatures(node, ((SPClient.Web)node.Parent.Tag).Features, this, loadType); break; case LoadType.WebUsers: SPLoader.LoadSiteUsers(node, ((SPClient.Web)node.Parent.Tag).SiteUserInfoList, this); break; case LoadType.WebGroups: SPLoader.LoadSiteGroups(node, ((SPClient.Web)node.Parent.Tag).SiteGroups, this); break; case LoadType.WebRecycleBin: // Not supported in SP2010 CSOM break; case LoadType.GroupUsers: SPLoader.LoadUsers(node, ((SPClient.Group)node.Tag).Users, this, loadType); break; case LoadType.WebWorkflowAssociations: SPLoader.LoadWorkflowAssociations(node, ((SPClient.Web)node.Parent.Tag).WorkflowAssociations, this, loadType); break; case LoadType.WebWorkflowTemplates: SPLoader.LoadWorkflowTemplates(node, ((SPClient.Web)node.Parent.Tag).WorkflowTemplates, this, loadType); break; case LoadType.WebEventReceivers: // Not supported in SP2010 CSOM break; case LoadType.WebProperties: SPLoader.LoadProperties(node, ((SPClient.Web)node.Parent.Tag).AllProperties, this, loadType); break; case LoadType.WebListTemplates: SPLoader.LoadListTemplates(node, ((SPClient.Web)node.Parent.Tag).ListTemplates, this, loadType); break; case LoadType.WebPushNotificationSubscribers: // Not supported in SP2010 CSOM break; case LoadType.WebRoleAssignments: SPLoader.LoadRoleAssignments(node, ((SPClient.Web)node.Parent.Tag).RoleAssignments, this, loadType); break; case LoadType.WebRoleDefinitions: SPLoader.LoadRoleDefinitions(node, ((SPClient.Web)node.Parent.Tag).RoleDefinitions, this, loadType); break; case LoadType.WebTemplates: SPLoader.LoadWebTemplates(node, ((SPClient.Web)node.Parent.Tag).GetAvailableWebTemplates(((SPClient.Web)node.Parent.Tag).Language, true), this, loadType); break; case LoadType.Folder: SPLoader.LoadSubFolders(node, ((SPClient.Folder)node.Tag), this); break; case LoadType.FolderProperties: // Not supported in SP2010 CSOM break; case LoadType.ListFields: SPLoader.LoadSiteColumns(node, ((SPClient.List)node.Parent.Tag).Fields, this, loadType); break; case LoadType.ListContentTypes: SPLoader.LoadContentTypes(node, ((SPClient.List)node.Parent.Tag).ContentTypes, this, loadType); break; case LoadType.ListViews: SPLoader.LoadViews(node, ((SPClient.List)node.Parent.Tag).Views, this); break; case LoadType.ListWorkflowAssociations: SPLoader.LoadWorkflowAssociations(node, ((SPClient.List)node.Parent.Tag).WorkflowAssociations, this, loadType); break; case LoadType.ListEventReceivers: // Not supported in SP2010 CSOM break; case LoadType.ListRoleAssignments: SPLoader.LoadRoleAssignments(node, ((SPClient.List)node.Parent.Tag).RoleAssignments, this, loadType); break; default: break; } // End treeview load tvSite.EndUpdate(); tsProgressBar.Value = 0; }