private void OnEndTagClose(object sender, HtmlParserCloseTagEventArgs e) { if (_currentElementRecord != null) { ElementNode element = _currentElementRecord.Element; ReadOnlyCollection <ElementNode> children = ElementNode.EmptyCollection; if (_currentElementRecord.Children.Count > 0) { children = new ReadOnlyCollection <ElementNode>(_currentElementRecord.Children); } ReadOnlyCollection <AttributeNode> startTagAttributes = AttributeNode.EmptyCollection; if (_currentElementRecord.StartTagAttributes.Count > 0) { startTagAttributes = new ReadOnlyCollection <AttributeNode>(_currentElementRecord.StartTagAttributes); } ReadOnlyCollection <AttributeNode> endTagAttributes = AttributeNode.EmptyCollection; if (_currentElementRecord.EndTagAttributes.Count > 0) { endTagAttributes = new ReadOnlyCollection <AttributeNode>(_currentElementRecord.EndTagAttributes); } element.EndTag.Complete(endTagAttributes, e.CloseAngleBracket, e.IsClosed, false, false); element.CompleteElement(e.CloseAngleBracket, true, children, startTagAttributes, endTagAttributes); _currentElementRecord = null; } CloseOrphanedEndTag(e.CloseAngleBracket, e.IsClosed); }
private void OnEndTagOpen(object sender, HtmlParserOpenTagEventArgs e) { // Current element must already be on the stack. It is not null // only when we are processing start tag. Debug.Assert(_currentElementRecord == null); // e.Token contains NameToken describing element prefix:name range. // </ precedes the range immediately. Note that token may contain invalid/empty // range if element name is missing such as in </{ws} or </>. We will ignore // malformed end tags. if (e.NameToken != null && e.NameToken.QualifiedName.Length > 0) { // close at name.start-1 (skip < of the tag, end exclusive) // subtract </ _currentElementRecord = CloseElements(e.NameToken.QualifiedName, e.NameToken.QualifiedName.Start - 2, new string[0]); if (_currentElementRecord != null) { _currentElementRecord.Element.OpenEndTag(e.OpenAngleBracketPosition, e.NameToken, _tree.Text.Length); } else { var dummyElement = new ElementNode(_tree.RootNode, e.OpenAngleBracketPosition, e.NameToken, _tree.Text.Length); _orphanedEndTagRecord = new ElementRecord(dummyElement); _orphanedEndTagRecord.Element.OpenEndTag(e.OpenAngleBracketPosition, e.NameToken, _tree.Text.Length); } } }
private void OnStartTagOpen(object sender, HtmlParserOpenTagEventArgs e) { Debug.Assert(_currentElementRecord == null); // e.NameToken describes element prefix:name range. // < precedes the range immediately. // Artifacts are not allowed in element names. string[] containerNames; // Close any elements on the stack that must be closed either by implicit // closure or by the fact that they are inside the element that is being closed. if (e.NameToken != null && e.NameToken.IsNameWellFormed() && _tree.HtmlClosureProvider.IsImplicitlyClosed(_tree.Text, e.NameToken, out containerNames)) { // close at name.start-1 (skip < of the tag, end exclusive) CloseElements(e.NameToken.QualifiedName, e.NameToken.QualifiedName.Start - 1, containerNames); } // Parent is the element on top of the stack or the root node if stack is empty var parentRecord = _elementStack.Count > 0 ? _elementStack.Peek() : _rootNodeRecord; ElementNode element = new ElementNode(parentRecord.Element, e.OpenAngleBracketPosition, e.NameToken, _tree.Text.Length); parentRecord.Children.Add(element); _currentElementRecord = new ElementRecord(element); }
private void OnParseBegin(object sender, HtmlParserRangeEventArgs e) { _startTime = DateTime.UtcNow; _rootNodeRecord = new ElementRecord(new RootNode(_tree)); _currentElementRecord = null; _orphanedEndTagRecord = null; _elementStack = new Stack<ElementRecord>(16); _elementStack.Push(_rootNodeRecord); }
public override void Modify(ElementRecord record) { DbCommand command = this.Provider.GetStoredProcedure("spInsertUpdateElement"); this.MapParameterIn(command, "@PA_USER_LOGIN_ID", "dev"); this.MapParametersIn(command, record, true); this.Execute(command); this.MapParametersOut(command, record); }
private void UpdateValueAndIndexArrays(ElementRecord elementRecord, ref TextRecord textRecord, PhpArray values, PhpArray indices, bool middle) { // if we have no valid data in the middle, just end if (middle && textRecord == null) { return; } if (!middle && elementRecord.State == ElementState.Interior) { UpdateValueAndIndexArrays(elementRecord, ref textRecord, values, indices, true); } if (values != null) { PhpArray arrayRecord = new PhpArray(); arrayRecord.Add("tag", elementRecord.ElementName); arrayRecord.Add("level", elementRecord.Level); if (elementRecord.State == ElementState.Beginning) { arrayRecord.Add("type", middle ? "open" : "complete"); } else { arrayRecord.Add("type", middle ? "cdata" : "close"); } if (textRecord != null) { arrayRecord.Add("value", textRecord.Text); } if (elementRecord.State == ElementState.Beginning && elementRecord.Attributes.Count != 0) { arrayRecord.Add("attributes", elementRecord.Attributes); } var value_idx = values.Add(arrayRecord) - 1; if (indices != null) { var elementIndices = indices[elementRecord.ElementName].AsArray(); if (elementIndices == null) { indices[elementRecord.ElementName] = elementIndices = new PhpArray(); } // add the max index (last inserted value) elementIndices.Add(value_idx); } } textRecord = null; }
private void OnParseBegin(object sender, HtmlParserRangeEventArgs e) { _startTime = DateTime.UtcNow; _rootNodeRecord = new ElementRecord(new RootNode(_tree)); _currentElementRecord = null; _orphanedEndTagRecord = null; _elementStack = new Stack <ElementRecord>(16); _elementStack.Push(_rootNodeRecord); }
private void OnStartTagClose(object sender, HtmlParserCloseTagEventArgs e) { // e.Token contain Token with range for > or /> if well formed // or IsGhost is set to true otherwise Debug.Assert(_currentElementRecord != null); // Close start tag of the current element and push element // on the stack if element is not self-closing (or self-closed via />). ElementNode currentElement = _currentElementRecord.Element; ReadOnlyCollection <AttributeNode> attributes = AttributeNode.EmptyCollection; if (_currentElementRecord.StartTagAttributes.Count > 0) { attributes = new ReadOnlyCollection <AttributeNode>(_currentElementRecord.StartTagAttributes); } if (currentElement.StartTag.NameToken == null || currentElement.Name.Equals("!doctype", StringComparison.OrdinalIgnoreCase)) { currentElement.StartTag.Complete(attributes, e.CloseAngleBracket, e.IsClosed, e.IsShorthand, true); currentElement.CompleteElement(e.CloseAngleBracket, e.IsClosed, ElementNode.EmptyCollection, attributes, AttributeNode.EmptyCollection); } else { // Check if element is self-closing by calling URI info provider for a given namespace. bool selfClosing = false; NameToken nameToken = currentElement.StartTag.NameToken; if (nameToken != null) { selfClosing = _tree.HtmlClosureProvider.IsSelfClosing(_tree.Text, nameToken.PrefixRange, nameToken.NameRange); } currentElement.StartTag.Complete(attributes, e.CloseAngleBracket, e.IsClosed, e.IsShorthand, selfClosing); currentElement.CompleteElement(e.CloseAngleBracket, e.IsClosed, ElementNode.EmptyCollection, attributes, AttributeNode.EmptyCollection); if (!selfClosing && !e.IsShorthand) { _elementStack.Push(_currentElementRecord); } } _currentElementRecord = null; }
internal static GroupInfoRecord Read(BinaryReader r) { var record = new GroupInfoRecord(); var elementCount = r.ReadUInt32(); record.elements = new List <ElementRecord>((int)elementCount); for (UInt32 elementIndex = 0; elementIndex < elementCount; ++elementIndex) { var element = new ElementRecord(); element.Read(r); record.elements.Add(element); } return(record); }
private void CloseOrphanedEndTag(ITextRange closeAngleBracket, bool isClosed) { if (_orphanedEndTagRecord != null) { ReadOnlyCollection <AttributeNode> endTagAttributes = AttributeNode.EmptyCollection; if (_orphanedEndTagRecord.EndTagAttributes.Count > 0) { endTagAttributes = new ReadOnlyCollection <AttributeNode>(_orphanedEndTagRecord.EndTagAttributes); } _orphanedEndTagRecord.Element.EndTag.Complete(endTagAttributes, closeAngleBracket, isClosed, false, false); ElementRecord currentElementRecord = _elementStack.Peek(); currentElementRecord.Element.AddOrphanedEndTag(_orphanedEndTagRecord.Element.EndTag); _orphanedEndTagRecord = null; } }
private void OnParseEnd(object sender, HtmlParserRangeEventArgs e) { // Collect all orphaned end tags since they belong to the currently // CloseOrphanedEndTag(new TextRange(e.Range.End, 0), false); // Close all element that are still on the stack while (_elementStack.Count > 0) { ElementRecord elementRecord = _elementStack.Pop(); ElementNode element = elementRecord.Element; ReadOnlyCollection <ElementNode> children = ElementNode.EmptyCollection; if (elementRecord.Children.Count > 0) { children = new ReadOnlyCollection <ElementNode>(elementRecord.Children); } ReadOnlyCollection <AttributeNode> startTagAttributes = AttributeNode.EmptyCollection; if (elementRecord.StartTagAttributes.Count > 0) { startTagAttributes = new ReadOnlyCollection <AttributeNode>(elementRecord.StartTagAttributes); } ReadOnlyCollection <AttributeNode> endTagAttributes = AttributeNode.EmptyCollection; if (elementRecord.EndTagAttributes.Count > 0) { endTagAttributes = new ReadOnlyCollection <AttributeNode>(elementRecord.EndTagAttributes); } element.CompleteElement(TextRange.FromBounds(e.Range.End, e.Range.End), false, children, startTagAttributes, endTagAttributes); } _tree.RootNode = _rootNodeRecord.Element as RootNode; _rootNodeRecord = null; _tree.CommentCollection.Sort(); var parser = sender as HtmlParser; _tree.DocType = parser.DocType; TreeBuildingTime = DateTime.UtcNow - _startTime; }
private void ParseStep(XmlReader reader, Stack <ElementRecord> elementStack, ref TextRecord textChunk, PhpArray values, PhpArray indices) { string elementName; bool emptyElement; ElementRecord currentElementRecord = null; switch (reader.NodeType) { case XmlNodeType.Element: elementName = reader.Name; emptyElement = reader.IsEmptyElement; PhpArray attributeArray = new PhpArray(); if (_processNamespaces && elementName.IndexOf(":") >= 0) { string localName = elementName.Substring(elementName.IndexOf(":") + 1); elementName = reader.NamespaceURI + _namespaceSeparator + localName; } if (reader.MoveToFirstAttribute()) { do { if (_processNamespaces && reader.Name.StartsWith("xmlns:")) { string namespaceID = reader.Name.Substring(6); string namespaceUri = reader.Value; if (_startNamespaceDeclHandler.Callback != null) { _startNamespaceDeclHandler.Invoke(this, namespaceID, namespaceUri); } continue; } attributeArray.Add(_enableCaseFolding ? reader.Name.ToUpperInvariant() : reader.Name, reader.Value); }while (reader.MoveToNextAttribute()); } // update current top of stack if (elementStack.Count != 0) { currentElementRecord = elementStack.Peek(); UpdateValueAndIndexArrays(currentElementRecord, ref textChunk, values, indices, true); if (currentElementRecord.State == ElementState.Beginning) { currentElementRecord.State = ElementState.Interior; } } // push the element into the stack (needed for parse_into_struct) elementStack.Push( new ElementRecord() { ElementName = elementName, Level = reader.Depth, State = ElementState.Beginning, Attributes = (PhpArray)attributeArray.DeepCopy() }); if (_startElementHandler.Callback != null) { _startElementHandler.Invoke(this, _enableCaseFolding ? elementName.ToUpperInvariant() : elementName, attributeArray); } else if (_defaultHandler.Callback != null) { _defaultHandler.Invoke(this, ""); } if (emptyElement) { goto case XmlNodeType.EndElement; // and end the element immediately (<element/>, XmlNodeType.EndElement will not be called) } break; case XmlNodeType.EndElement: elementName = reader.Name; if (_processNamespaces && elementName.IndexOf(":") >= 0) { string localName = elementName.Substring(elementName.IndexOf(":") + 1); elementName = reader.NamespaceURI + _namespaceSeparator + localName; } // pop the top element record currentElementRecord = elementStack.Pop(); UpdateValueAndIndexArrays(currentElementRecord, ref textChunk, values, indices, false); if (_endElementHandler.Callback != null) { _endElementHandler.Invoke(this, _enableCaseFolding ? elementName.ToUpperInvariant() : elementName); } else if (_defaultHandler.Callback != null) { _defaultHandler.Invoke(this, ""); } break; case XmlNodeType.Whitespace: case XmlNodeType.Text: case XmlNodeType.CDATA: if (textChunk == null) { textChunk = new TextRecord() { Text = reader.Value }; } else { textChunk.Text += reader.Value; } if (_characterDataHandler.Callback != null) { _characterDataHandler.Invoke(this, reader.Value); } else if (_defaultHandler.Callback != null) { _defaultHandler.Invoke(this, reader.Value); } break; case XmlNodeType.ProcessingInstruction: if (_processingInstructionHandler.Callback != null) { _processingInstructionHandler.Invoke(this, reader.Name, reader.Value); } else if (_defaultHandler.Callback != null) { _defaultHandler.Invoke(this, string.Empty); } break; } }
private void OnParseEnd(object sender, HtmlParserRangeEventArgs e) { // Collect all orphaned end tags since they belong to the currently // CloseOrphanedEndTag(new TextRange(e.Range.End, 0), false); // Close all element that are still on the stack while (_elementStack.Count > 0) { ElementRecord elementRecord = _elementStack.Pop(); ElementNode element = elementRecord.Element; ReadOnlyCollection<ElementNode> children = ElementNode.EmptyCollection; if (elementRecord.Children.Count > 0) { children = new ReadOnlyCollection<ElementNode>(elementRecord.Children); } ReadOnlyCollection<AttributeNode> startTagAttributes = AttributeNode.EmptyCollection; if (elementRecord.StartTagAttributes.Count > 0) { startTagAttributes = new ReadOnlyCollection<AttributeNode>(elementRecord.StartTagAttributes); } ReadOnlyCollection<AttributeNode> endTagAttributes = AttributeNode.EmptyCollection; if (elementRecord.EndTagAttributes.Count > 0) { endTagAttributes = new ReadOnlyCollection<AttributeNode>(elementRecord.EndTagAttributes); } element.CompleteElement(TextRange.FromBounds(e.Range.End, e.Range.End), false, children, startTagAttributes, endTagAttributes); } _tree.RootNode = _rootNodeRecord.Element as RootNode; _rootNodeRecord = null; _tree.CommentCollection.Sort(); var parser = sender as HtmlParser; _tree.DocType = parser.DocType; TreeBuildingTime = DateTime.UtcNow - _startTime; }
private ElementRecord CloseElements(ITextRange nameRange, int position, string[] containerNames) { ElementRecord last = null; int count = 0; bool foundSameElement = false; bool foundContainer = false; bool testImplicitClosureWalkingUp = (containerNames.Length > 0); bool foundImplicitlyClosedElement = false; string name = _tree.Text.GetText(nameRange); // Dev12 764293: Match end tags regardless of parsing mode, and let validation ensure the casing. // var comparison = Parser.ParsingMode == ParsingMode.Html ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal; var comparison = StringComparison.OrdinalIgnoreCase; // Walk up the stack looking for element name but stop at possible container // so we don't close outer <li> by inner <li> in <ol><li><ol><li> and rather // stop at the nearest <ol> which is a 'hard' container for <li>. foreach (var elementRecord in _elementStack) { ITextRange qualifiedNameRange = elementRecord.Element.QualifiedNameRange; string qualifiedName = _tree.Text.GetText(qualifiedNameRange); if (String.Compare(qualifiedName, name, comparison) == 0) { foundSameElement = true; count++; // Ensure we close the element with the same name break; } foreach (var containerName in containerNames) { if (String.Compare(qualifiedName, containerName, comparison) == 0) { foundContainer = true; break; } } if (foundContainer) { break; } if (testImplicitClosureWalkingUp && !foundImplicitlyClosedElement) { string[] containerNamesCurrentElement; if (!String.IsNullOrEmpty(qualifiedName) && _tree.HtmlClosureProvider.IsImplicitlyClosed(_tree.Text, qualifiedNameRange, out containerNamesCurrentElement)) { foundImplicitlyClosedElement = true; } } count++; } if (foundSameElement || (foundImplicitlyClosedElement && foundContainer)) { for (int i = 0; i < count; i++) { last = _elementStack.Pop(); ElementNode element = last.Element; ReadOnlyCollection <ElementNode> children = ElementNode.EmptyCollection; if (last.Children.Count > 0) { children = new ReadOnlyCollection <ElementNode>(last.Children); } ReadOnlyCollection <AttributeNode> startTagAttributes = AttributeNode.EmptyCollection; if (last.StartTagAttributes.Count > 0) { startTagAttributes = new ReadOnlyCollection <AttributeNode>(last.StartTagAttributes); } ReadOnlyCollection <AttributeNode> endTagAttributes = AttributeNode.EmptyCollection; if (last.EndTagAttributes.Count > 0) { endTagAttributes = new ReadOnlyCollection <AttributeNode>(last.EndTagAttributes); } element.CompleteElement(TextRange.FromBounds(position, position), true, children, startTagAttributes, endTagAttributes); } } return(last); }
private void CloseOrphanedEndTag(ITextRange closeAngleBracket, bool isClosed) { if (_orphanedEndTagRecord != null) { ReadOnlyCollection<AttributeNode> endTagAttributes = AttributeNode.EmptyCollection; if (_orphanedEndTagRecord.EndTagAttributes.Count > 0) { endTagAttributes = new ReadOnlyCollection<AttributeNode>(_orphanedEndTagRecord.EndTagAttributes); } _orphanedEndTagRecord.Element.EndTag.Complete(endTagAttributes, closeAngleBracket, isClosed, false, false); ElementRecord currentElementRecord = _elementStack.Peek(); currentElementRecord.Element.AddOrphanedEndTag(_orphanedEndTagRecord.Element.EndTag); _orphanedEndTagRecord = null; } }
private void OnEndTagClose(object sender, HtmlParserCloseTagEventArgs e) { if (_currentElementRecord != null) { ElementNode element = _currentElementRecord.Element; ReadOnlyCollection<ElementNode> children = ElementNode.EmptyCollection; if (_currentElementRecord.Children.Count > 0) { children = new ReadOnlyCollection<ElementNode>(_currentElementRecord.Children); } ReadOnlyCollection<AttributeNode> startTagAttributes = AttributeNode.EmptyCollection; if (_currentElementRecord.StartTagAttributes.Count > 0) { startTagAttributes = new ReadOnlyCollection<AttributeNode>(_currentElementRecord.StartTagAttributes); } ReadOnlyCollection<AttributeNode> endTagAttributes = AttributeNode.EmptyCollection; if (_currentElementRecord.EndTagAttributes.Count > 0) { endTagAttributes = new ReadOnlyCollection<AttributeNode>(_currentElementRecord.EndTagAttributes); } element.EndTag.Complete(endTagAttributes, e.CloseAngleBracket, e.IsClosed, false, false); element.CompleteElement(e.CloseAngleBracket, true, children, startTagAttributes, endTagAttributes); _currentElementRecord = null; } CloseOrphanedEndTag(e.CloseAngleBracket, e.IsClosed); }
private void OnEndTagOpen(object sender, HtmlParserOpenTagEventArgs e) { // Current element must already be on the stack. It is not null // only when we are processing start tag. Debug.Assert(_currentElementRecord == null); // e.Token contains NameToken describing element prefix:name range. // </ precedes the range immediately. Note that token may contain invalid/empty // range if element name is missing such as in </{ws} or </>. We will ignore // malformed end tags. if (e.NameToken != null && e.NameToken.QualifiedName.Length > 0) { // close at name.start-1 (skip < of the tag, end exclusive) // subtract </ _currentElementRecord = CloseElements(e.NameToken.QualifiedName, e.NameToken.QualifiedName.Start - 2, new string[0]); if (_currentElementRecord != null) { _currentElementRecord.Element.OpenEndTag(e.OpenAngleBracketPosition, e.NameToken, _tree.Text.Length); } else { var dummyElement = new ElementNode(_tree.RootNode, e.OpenAngleBracketPosition, e.NameToken, _tree.Text.Length); _orphanedEndTagRecord = new ElementRecord(dummyElement); _orphanedEndTagRecord.Element.OpenEndTag(e.OpenAngleBracketPosition, e.NameToken, _tree.Text.Length); } } }
private void OnStartTagClose(object sender, HtmlParserCloseTagEventArgs e) { // e.Token contain Token with range for > or /> if well formed // or IsGhost is set to true otherwise Debug.Assert(_currentElementRecord != null); // Close start tag of the current element and push element // on the stack if element is not self-closing (or self-closed via />). ElementNode currentElement = _currentElementRecord.Element; ReadOnlyCollection<AttributeNode> attributes = AttributeNode.EmptyCollection; if (_currentElementRecord.StartTagAttributes.Count > 0) { attributes = new ReadOnlyCollection<AttributeNode>(_currentElementRecord.StartTagAttributes); } if (currentElement.StartTag.NameToken == null || currentElement.Name.Equals("!doctype", StringComparison.OrdinalIgnoreCase)) { currentElement.StartTag.Complete(attributes, e.CloseAngleBracket, e.IsClosed, e.IsShorthand, true); currentElement.CompleteElement(e.CloseAngleBracket, e.IsClosed, ElementNode.EmptyCollection, attributes, AttributeNode.EmptyCollection); } else { // Check if element is self-closing by calling URI info provider for a given namespace. bool selfClosing = false; NameToken nameToken = currentElement.StartTag.NameToken; if (nameToken != null) { selfClosing = _tree.HtmlClosureProvider.IsSelfClosing(_tree.Text, nameToken.PrefixRange, nameToken.NameRange); } currentElement.StartTag.Complete(attributes, e.CloseAngleBracket, e.IsClosed, e.IsShorthand, selfClosing); currentElement.CompleteElement(e.CloseAngleBracket, e.IsClosed, ElementNode.EmptyCollection, attributes, AttributeNode.EmptyCollection); if (!selfClosing && !e.IsShorthand) _elementStack.Push(_currentElementRecord); } _currentElementRecord = null; }
private void UpdateValueAndIndexArrays(ElementRecord elementRecord, ref TextRecord textRecord, PhpArray values, PhpArray indices, bool middle) { // if we have no valid data in the middle, just end if (middle && textRecord == null) return; if (!middle && elementRecord.State == ElementState.Interior) UpdateValueAndIndexArrays(elementRecord, ref textRecord, values, indices, true); if (values != null) { PhpArray arrayRecord = new PhpArray(); arrayRecord.Add("tag", elementRecord.ElementName); arrayRecord.Add("level", elementRecord.Level); if (elementRecord.State == ElementState.Beginning) arrayRecord.Add("type", middle ? "open" : "complete"); else arrayRecord.Add("type", middle ? "cdata" : "close"); if (textRecord != null) arrayRecord.Add("value", textRecord.Text); if (elementRecord.State == ElementState.Beginning && elementRecord.Attributes.Count != 0) arrayRecord.Add("attributes", elementRecord.Attributes); values.Add(arrayRecord); if (indices != null) { PhpArray elementIndices; if (!indices.ContainsKey(elementRecord.ElementName)) { elementIndices = new PhpArray(); indices.Add(elementRecord.ElementName, elementIndices); } else elementIndices = (PhpArray)indices[elementRecord.ElementName]; // add the max index (last inserted value) elementIndices.Add(values.MaxIntegerKey); } } textRecord = null; }
public string CreateDonationProduct(string personName, string surname, string email, string phone, string price, string productId) { var addressId = "11"; var sellingCompanyId = "1"; var organisationId = "1"; var person = new PersonRecord() { FirstName = personName, Surname = surname, HomeAddId = addressId }; this.Provider.DataProvider.Contact.Person.Create(person); var addedPerson = this.Provider.DataProvider.Contact.Person.FetchAll().OrderByDescending(x => x.AddDate).FirstOrDefault(); var role = new PersonRoleRecord() { PersonId = addedPerson.Id, Email = email, Phone = phone, SelcoSpId = sellingCompanyId, OrgId = organisationId, AddId = addressId }; this.Provider.DataProvider.Contact.Role.Create(role); var addedRole = this.Provider.DataProvider.Contact.Role.FetchAll().OrderByDescending(x => x.AddDate).FirstOrDefault(); var booking = new BookingRecord() { ProleId = addedRole.Id, InvOrgId = addedRole.OrgId, SelcoSpId = addedRole.SelcoSpId, PaymentMethd = "05-Cash", CurrencyType = "GBP", NetTotal = Convert.ToInt32(price), PersonId = addedRole.PersonId }; this.Provider.DataProvider.Learning.Booking.Create(booking); var addedBooking = this.Provider.DataProvider.Learning.Booking.FetchAll().OrderByDescending(x => x.AddDate).FirstOrDefault(); var donationProduct = this.Provider.DataProvider.Learning.Product.FetchById(productId); var delegateRecord = new DelegateRecord() { BookId = addedBooking.Id, OrgId = addedBooking.OrgId, PersonId = addedBooking.PersonId, ProleId = addedBooking.ProleId, ProductId = donationProduct.Id, Quantity = 1 }; this.Provider.DataProvider.Learning.Learner.Create(delegateRecord); var addedDelegate = this.Provider.DataProvider.Learning.Learner.FetchAll().OrderByDescending(x => x.AddDate).FirstOrDefault(); var element = new ElementRecord() { BookId = addedBooking.Id, PaymentMethd = "01-Invoice", ProdId = donationProduct.Id, SelcoSpId = sellingCompanyId, Type = 29, Price = Convert.ToInt32(price), Description = donationProduct.Descrip, CostCode = donationProduct.CostCode, Qty = 1, UntPrice = Convert.ToInt32(price), PlId = "1", DelId = addedDelegate.Id }; this.Provider.DataProvider.Learning.Element.Create(element); return("/learning/donationbooking?id=" + addedBooking.Id); }
private void OnStartTagOpen(object sender, HtmlParserOpenTagEventArgs e) { Debug.Assert(_currentElementRecord == null); // e.NameToken describes element prefix:name range. // < precedes the range immediately. // Artifacts are not allowed in element names. string[] containerNames; // Close any elements on the stack that must be closed either by implicit // closure or by the fact that they are inside the element that is being closed. if (e.NameToken != null && e.NameToken.IsNameWellFormed() && _tree.HtmlClosureProvider.IsImplicitlyClosed(_tree.Text, e.NameToken, out containerNames)) { // close at name.start-1 (skip < of the tag, end exclusive) CloseElements(e.NameToken.QualifiedName, e.NameToken.QualifiedName.Start - 1, containerNames); } // Parent is the element on top of the stack or the root node if stack is empty var parentRecord = _elementStack.Count > 0 ? _elementStack.Peek() : _rootNodeRecord; ElementNode element = new ElementNode(parentRecord.Element, e.OpenAngleBracketPosition, e.NameToken, _tree.Text.Length); parentRecord.Children.Add(element); _currentElementRecord = new ElementRecord(element); }