private void MakeUpdates(IDataSource ds, XmlDocument xml)
{
XmlNodeList updatingRecords = xml.SelectNodes("records/Updated/record");
string id = GetIdColumnName();
foreach (XmlNode node in updatingRecords)
{
record = node;
values = new SortedList(this.Reader.Reader.Fields.Count);
keys = new SortedList();
oldValues = new SortedList();
foreach (RecordField field in this.Reader.Reader.Fields)
{
XmlNode keyNode = node.SelectSingleNode(field.Name);
values[field.Name] = keyNode != null ? keyNode.InnerText : null;
}
confirmation = null;
if (id.IsNotEmpty())
{
XmlNode keyNode = node.SelectSingleNode(id);
string idStr = keyNode != null ? keyNode.InnerText : null;
int idInt;
if (int.TryParse(idStr, out idInt))
{
keys[id] = idInt;
}
else
{
keys[id] = idStr;
}
if (this.UseIdConfirmation && keys[id] != null)
{
confirmation = changingEventArgs.ConfirmationList[keys[id].ToString()];
}
}
BeforeRecordUpdatedEventArgs eBeforeRecordUpdated = new BeforeRecordUpdatedEventArgs(record, keys, values, oldValues, confirmation);
this.OnBeforeRecordUpdated(eBeforeRecordUpdated);
if (eBeforeRecordUpdated.CancelAll)
{
break;
}
if (eBeforeRecordUpdated.Cancel)
{
continue;
}
if (ds !=null)
{
ds.GetView("").Update(keys, values, oldValues, this.UpdateCallback);
}
else
{
this.UpdateCallback(0, null);
}
}
}