private XmlElement GetBatchSingleItemXml(T item, WebServiceListCommand command) { var fieldMap = ProvideItemFieldMap(item); var xmlDoc = new XmlDocument(); var batchElement = xmlDoc.CreateElement("Batch"); batchElement.SetAttribute("OnError", "Continue"); batchElement.SetAttribute("ListVersion", "1"); batchElement.SetAttribute("ViewName", ""); batchElement.InnerXml = GetMethodString(fieldMap, command, 1); return(batchElement); }
private static string GetMethodString(Dictionary <string, string> fieldMap, WebServiceListCommand command, int commandId) { var method = new StringBuilder(); method.AppendFormat(@"<Method ID=""{0}"" Cmd=""{1}"">", commandId, command); // ID for 'new' items is 'New' if (command == WebServiceListCommand.New) { if (fieldMap.ContainsKey("ID")) { fieldMap["ID"] = "New"; } else { fieldMap.Add("ID", "New"); } } foreach (var key in fieldMap.Keys) { method.AppendFormat(GetFieldNameString(key, fieldMap[key])); } method.AppendFormat(@"</Method>"); return(method.ToString()); }