示例#1
0
        private ListItemIdList PerformMappingAndSubmit(XmlDocument doc, string siteUrl, XmlNode mapping)
        {
            ListItemIdList itemIdList = new ListItemIdList();

            Dictionary <int, XmlNode> methodMap;
            XmlNamespaceManager       nsm = GenerateBatch.BuildNamespaceManager(doc);
            ListName listName             = GetListName(mapping);


            XmlElement batch = GenerateBatch.GenerateBatchElement(doc, nsm, mapping, out methodMap);

            if (null == batch)
            {
                return(itemIdList);
            }

            itemIdList = UploadData(siteUrl, listName.ListNameToUse, batch);

            return(itemIdList);
        }
示例#2
0
        private void AssignIds(XmlNode mapping, XPathNavigator outputNav, Dictionary <int, XmlNode> methodMap, XmlNamespaceManager nsm)
        {
            try
            {
                string idPath = GenerateBatch.GetListIdPath(mapping);

                if (idPath != null)
                {
                    XPathNodeIterator newIdResults =
                        outputNav.Select(@"//so:Result[substring-after(@ID, ',') = 'New']
                                               [number(substring-before(@ID, ',')) = number(substring-before(@ID, ','))]
                                               [z:row/@ows_ID]",
                                         SharePointNamespaceManager);

                    XmlNode foundNode;
                    foreach (XPathNavigator result in newIdResults)
                    {
                        string methodId = result.SelectSingleNode("@ID").Value;
                        methodId = methodId.Remove(methodId.IndexOf(','));

                        // Ensured to be safe by the selection XPath
                        int methodIdInt = int.Parse(methodId);

                        if (methodMap.TryGetValue(methodIdInt, out foundNode))
                        {
                            XmlNode idNode = foundNode.SelectSingleNode(idPath, nsm);
                            if (idNode != null && string.IsNullOrEmpty(idNode.InnerText))
                            {
                                idNode.InnerText = result.SelectSingleNode("z:row/@ows_ID", SharePointNamespaceManager).Value;
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }