Example #1
0
        public override DataSet Clone()
        {
            PlacementSet cln = ((PlacementSet)(base.Clone()));

            cln.InitVars();
            return(cln);
        }
Example #2
0
        /// <summary>
        /// Constructs a well formed Document Object Model for a group of placements on a block order.
        /// </summary>
        /// <param name="BlockOrderId">The block order for which we want a placement document.</param>
        public PlacementDocument(int blockOrderId, PlacementSet placementSet)
        {
            // Create the root element for the document.
            XmlElement rootElement = this.CreateElement("Placements");

            this.AppendChild(rootElement);

            // This list is used to sort the placements.
            ArrayList placementsList = new ArrayList();

            // Sort the placements in the order which they were created.
            DataView dataView = new DataView(placementSet.Placement, null, "placementId", DataViewRowState.CurrentRows);

            // Copy the placements that belong to the currently viewed block order (remember that incomplete rows belonging to
            // other blocks can still hang around in the PlacementSet until committed) into the document.
            foreach (DataRowView dataRowView in dataView)
            {
                PlacementSet.PlacementRow placementRow = (PlacementSet.PlacementRow)dataRowView.Row;
                if (placementRow.BlockOrderId == blockOrderId && !placementRow.IsPlacementIdNull())
                {
                    rootElement.AppendChild(this.CreatePlacementElement(placementRow));
                }
            }

            // The temporary records are placed at the end.  This appears to be the more logical placement for the records in the
            // situation where an incomplete record was left in the viewer.  That is, it will most likely be the most recent record
            // in the list.  But because there's no global identifier, it can't be sorted by the order it was inserted in the
            // global tables.  So an assumption is made that, since it's the most reccent, it should be placed at the end of the
            // list.
            foreach (PlacementSet.PlacementRow placementRow in placementSet.Placement)
            {
                if (placementRow.BlockOrderId == blockOrderId && placementRow.IsPlacementIdNull())
                {
                    rootElement.AppendChild(this.CreatePlacementElement(placementRow));
                }
            }

            // The placeholder is a queue for the document manager to create a new placement.
            this.DocumentElement.AppendChild(this.CreatePlaceholderElement());
        }