void FileType_DataInit(ClientContextMethod client, Microsoft.SharePoint.Client.FileCollection fileCollection) { foreach (var file in fileCollection) { DataGridItemLb lb = new DataGridItemLb(); PropertyInfo[] propertyes = lb.GetType().GetProperties(); //加载文档创建者 client.LoadMethod(file.Author); //加载文档修改者 client.LoadMethod(file.ModifiedBy); //加载文档版本控制 client.LoadMethod(file.Versions); propertyes[0].SetValue(lb, file.Name, null); propertyes[1].SetValue(lb, file.Author.Title, null); propertyes[2].SetValue(lb, file.ModifiedBy.Title, null); propertyes[3].SetValue(lb, file.TimeCreated.ToString(), null); propertyes[4].SetValue(lb, System.IO.Path.GetExtension(file.ServerRelativeUrl).Replace(".", ""), null); propertyes[5].SetValue(lb, file.UIVersionLabel, null); propertyes[6].SetValue(lb, file.Versions.Count.ToString(), null); propertyes[7].SetValue(lb, file.TimeLastModified.ToString(), null); dataList.Add(lb); this.datagrid.Items.Add(lb); } }
void ListType_DataInit(Microsoft.SharePoint.Client.ListItemCollection collec) { for (int i = 0; i < collec.Count; i++) { int propertyCount = 0; DataGridItemLb lb = new DataGridItemLb(); string ad = string.Empty; PropertyInfo[] propertyes = lb.GetType().GetProperties(); for (int j = 0; j < collec[i].FieldValues.Count; j++) { if (dicIndentList.ContainsValue(collec[i].FieldValues.Keys.ElementAt(j))) { if (collec[i].FieldValues.Values.ElementAt(j) == null) { propertyes[propertyCount].SetValue(lb, string.Empty, null); propertyCount++; } else { propertyes[propertyCount].SetValue(lb, collec[i].FieldValues.Values.ElementAt(j).ToString(), null); propertyCount++; } } } dataList.Add(lb); this.datagrid.Items.Add(lb); } }