コード例 #1
0
ファイル: Rekvirent.cs プロジェクト: hafsjold/snvrepos
        private List <RekvirentData> FillDataList(SPListItemCollection collListItems)
        {
            List <RekvirentData> _rows = new List <RekvirentData>();

            foreach (SPListItem oListItem in collListItems)
            {
                RekvirentData _row = new RekvirentData();
                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);
        }
コード例 #2
0
ファイル: Rekvirent.cs プロジェクト: hafsjold/snvrepos
        private List <RekvirentData> 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 <RekvirentData> _rows = new List <RekvirentData>();

            foreach (XmlNode datanode in nodelist)
            {
                RekvirentData _row = new RekvirentData();
                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);
        }