private List <OrderCaseData> FillDataList(SPListItemCollection collListItems) { List <OrderCaseData> _rows = new List <OrderCaseData>(); foreach (SPListItem oListItem in collListItems) { OrderCaseData _row = new OrderCaseData(); foreach (PropertyInfo pi in _row.GetProperties()) { string _field = pi.Name; if (pi.CanWrite) { try { if (oListItem[_field] != null) { pi.SetValue(_row, oListItem[_field], null); } else { pi.SetValue(_row, null, null); } } catch { pi.SetValue(_row, null, null); } } } _rows.Add(_row); } return(_rows); }
private List <OrderCaseData> GetDataList(XmlNode items) { XmlDocument docItems = new XmlDocument(); docItems.LoadXml("<?xml version='1.0' ?>" + items.OuterXml); XmlNamespaceManager nsMgr = new XmlNamespaceManager(docItems.NameTable); nsMgr.AddNamespace("s", "uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882"); nsMgr.AddNamespace("dt", "uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"); nsMgr.AddNamespace("rs", "urn:schemas-microsoft-com:rowset"); nsMgr.AddNamespace("z", "#RowsetSchema"); nsMgr.AddNamespace("mha", "http://schemas.microsoft.com/sharepoint/soap/"); XmlNodeList nodelist = docItems.SelectNodes("//mha:listitems/rs:data/z:row", nsMgr); List <OrderCaseData> _rows = new List <OrderCaseData>(); foreach (XmlNode datanode in nodelist) { OrderCaseData _row = new OrderCaseData(); foreach (PropertyInfo pi in _row.GetProperties()) { string _field = "ows_" + pi.Name; string _type = pi.PropertyType.Name; if (pi.CanWrite) { try { if (datanode.Attributes[_field] != null) { switch (_type) { case "Int32": pi.SetValue(_row, int.Parse((string)datanode.Attributes[_field].Value), null); break; case "String": pi.SetValue(_row, (string)datanode.Attributes[_field].Value, null); break; default: pi.SetValue(_row, datanode.Attributes[_field].Value, null); break; } } else { pi.SetValue(_row, null, null); } } catch { pi.SetValue(_row, null, null); } } } _rows.Add(_row); } return(_rows); }