Exemple #1
0
        protected virtual void OnBeforeRecordInserted(BeforeRecordInsertedEventArgs e)
        {
            BeforeRecordInsertedEventHandler handler = (BeforeRecordInsertedEventHandler)Events[EventBeforeRecordInserted];

            if (handler != null)
            {
                handler(this, e);
            }
        }
Exemple #2
0
        private void MakeInsertes(IDataSource ds, XmlDocument xml)
        {
            XmlNodeList insertingRecords = xml.SelectNodes("records/Created/record");
            string      id = GetIdColumnName();

            foreach (XmlNode node in insertingRecords)
            {
                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 (!string.IsNullOrEmpty(id))
                {
                    XmlNode keyNode = node.SelectSingleNode(id);
                    if (this.UseIdConfirmation && keyNode != null && !string.IsNullOrEmpty(keyNode.InnerText))
                    {
                        confirmation = changingEventArgs.ConfirmationList[keyNode.InnerText];
                    }
                }

                BeforeRecordInsertedEventArgs eBeforeRecordInserted = new BeforeRecordInsertedEventArgs(record, keys, values, confirmation);
                this.OnBeforeRecordInserted(eBeforeRecordInserted);
                if (eBeforeRecordInserted.CancelAll)
                {
                    break;
                }
                if (eBeforeRecordInserted.Cancel)
                {
                    continue;
                }
                if (ds != null)
                {
                    ds.GetView("").Insert(values, InsertCallback);
                }
                else
                {
                    this.InsertCallback(0, null);
                }
            }

            if (insertingRecords.Count > 0)
            {
                needRetrieve = true;
            }
        }