GetNestedParentRow() приватный Метод

private GetNestedParentRow ( DataRowVersion version ) : DataRow
version DataRowVersion
Результат DataRow
Пример #1
0
        private void GenerateRow(DataRow row) {
            DataRowState state = row.RowState;
            if ((state == DataRowState.Unchanged ) || (state  == DataRowState.Added)) {
                return;
            }
            if (!fBefore) {
                _xmlw.WriteStartElement( Keywords.DFF, Keywords.SQL_BEFORE, Keywords.DFFNS);
                fBefore = true;
            }

            DataTable table = row.Table;
            int colCount = table.Columns.Count;
            string rowIDString = table.TableName+row.rowID.ToString(CultureInfo.InvariantCulture);
            string parentId = null;
            if ( (state == DataRowState.Deleted )  && (row.Table.NestedParentRelations.Length != 0)){
                DataRow parentRow = row.GetNestedParentRow(DataRowVersion.Original);
                if (parentRow != null) {
                    parentId = parentRow.Table.TableName+parentRow.rowID.ToString(CultureInfo.InvariantCulture);
                }
            }


            string tablePrefix = (table.Namespace.Length != 0) ? table.Prefix : String.Empty;

            // read value if the TextOnly column (if any)
            object val = (table.XmlText == null ? DBNull.Value : row[table.XmlText, DataRowVersion.Original]);

                    //old row
            _xmlw.WriteStartElement( tablePrefix, row.Table.EncodedTableName, row.Table.Namespace);

            _xmlw.WriteAttributeString( Keywords.DFF, Keywords.DIFFID, Keywords.DFFNS, rowIDString);

            if ( (state == DataRowState.Deleted ) && XmlDataTreeWriter.RowHasErrors(row))
                _xmlw.WriteAttributeString( Keywords.DFF, Keywords.HASERRORS, Keywords.DFFNS, Keywords.TRUE);

            if (parentId != null)
                _xmlw.WriteAttributeString( Keywords.DFF, Keywords.DIFFPID, Keywords.DFFNS, parentId);

            _xmlw.WriteAttributeString( Keywords.MSD, Keywords.ROWORDER, Keywords.MSDNS, rowsOrder[row].ToString());
            for (int colNum = 0; colNum < colCount; ++colNum) {
                if ((row.Table.Columns[colNum].ColumnMapping == MappingType.Attribute) ||
                    (row.Table.Columns[colNum].ColumnMapping == MappingType.Hidden))
                GenerateColumn(row,  row.Table.Columns[colNum], DataRowVersion.Original);
            }
            for (int colNum = 0; colNum < colCount; ++colNum) {
                if ((row.Table.Columns[colNum].ColumnMapping == MappingType.Element) ||
                    (row.Table.Columns[colNum].ColumnMapping == MappingType.SimpleContent))
                GenerateColumn(row,  row.Table.Columns[colNum], DataRowVersion.Original);
            }
            _xmlw.WriteEndElement();  //old row
        }
 private void GenerateRow(DataRow row)
 {
     DataRowState rowState = row.RowState;
     switch (rowState)
     {
         case DataRowState.Unchanged:
         case DataRowState.Added:
             return;
     }
     if (!this.fBefore)
     {
         this._xmlw.WriteStartElement("diffgr", "before", "urn:schemas-microsoft-com:xml-diffgram-v1");
         this.fBefore = true;
     }
     DataTable table = row.Table;
     int count = table.Columns.Count;
     string str3 = table.TableName + row.rowID.ToString(CultureInfo.InvariantCulture);
     string str = null;
     if ((rowState == DataRowState.Deleted) && (row.Table.NestedParentRelations.Length != 0))
     {
         DataRow nestedParentRow = row.GetNestedParentRow(DataRowVersion.Original);
         if (nestedParentRow != null)
         {
             str = nestedParentRow.Table.TableName + nestedParentRow.rowID.ToString(CultureInfo.InvariantCulture);
         }
     }
     string prefix = (table.Namespace.Length != 0) ? table.Prefix : string.Empty;
     if (table.XmlText != null)
     {
         object obj1 = row[table.XmlText, DataRowVersion.Original];
     }
     this._xmlw.WriteStartElement(prefix, row.Table.EncodedTableName, row.Table.Namespace);
     this._xmlw.WriteAttributeString("diffgr", "id", "urn:schemas-microsoft-com:xml-diffgram-v1", str3);
     if ((rowState == DataRowState.Deleted) && XmlDataTreeWriter.RowHasErrors(row))
     {
         this._xmlw.WriteAttributeString("diffgr", "hasErrors", "urn:schemas-microsoft-com:xml-diffgram-v1", "true");
     }
     if (str != null)
     {
         this._xmlw.WriteAttributeString("diffgr", "parentId", "urn:schemas-microsoft-com:xml-diffgram-v1", str);
     }
     this._xmlw.WriteAttributeString("msdata", "rowOrder", "urn:schemas-microsoft-com:xml-msdata", this.rowsOrder[row].ToString());
     for (int i = 0; i < count; i++)
     {
         if ((row.Table.Columns[i].ColumnMapping == MappingType.Attribute) || (row.Table.Columns[i].ColumnMapping == MappingType.Hidden))
         {
             this.GenerateColumn(row, row.Table.Columns[i], DataRowVersion.Original);
         }
     }
     for (int j = 0; j < count; j++)
     {
         if ((row.Table.Columns[j].ColumnMapping == MappingType.Element) || (row.Table.Columns[j].ColumnMapping == MappingType.SimpleContent))
         {
             this.GenerateColumn(row, row.Table.Columns[j], DataRowVersion.Original);
         }
     }
     this._xmlw.WriteEndElement();
 }
        private void GenerateRow(DataRow row)
        {
            DataRowState rowState = row.RowState;

            switch (rowState)
            {
            case DataRowState.Unchanged:
            case DataRowState.Added:
                return;
            }
            if (!this.fBefore)
            {
                this._xmlw.WriteStartElement("diffgr", "before", "urn:schemas-microsoft-com:xml-diffgram-v1");
                this.fBefore = true;
            }
            DataTable table = row.Table;
            int       count = table.Columns.Count;
            string    str3  = table.TableName + row.rowID.ToString(CultureInfo.InvariantCulture);
            string    str   = null;

            if ((rowState == DataRowState.Deleted) && (row.Table.NestedParentRelations.Length != 0))
            {
                DataRow nestedParentRow = row.GetNestedParentRow(DataRowVersion.Original);
                if (nestedParentRow != null)
                {
                    str = nestedParentRow.Table.TableName + nestedParentRow.rowID.ToString(CultureInfo.InvariantCulture);
                }
            }
            string prefix = (table.Namespace.Length != 0) ? table.Prefix : string.Empty;

            if (table.XmlText != null)
            {
                object obj1 = row[table.XmlText, DataRowVersion.Original];
            }
            this._xmlw.WriteStartElement(prefix, row.Table.EncodedTableName, row.Table.Namespace);
            this._xmlw.WriteAttributeString("diffgr", "id", "urn:schemas-microsoft-com:xml-diffgram-v1", str3);
            if ((rowState == DataRowState.Deleted) && XmlDataTreeWriter.RowHasErrors(row))
            {
                this._xmlw.WriteAttributeString("diffgr", "hasErrors", "urn:schemas-microsoft-com:xml-diffgram-v1", "true");
            }
            if (str != null)
            {
                this._xmlw.WriteAttributeString("diffgr", "parentId", "urn:schemas-microsoft-com:xml-diffgram-v1", str);
            }
            this._xmlw.WriteAttributeString("msdata", "rowOrder", "urn:schemas-microsoft-com:xml-msdata", this.rowsOrder[row].ToString());
            for (int i = 0; i < count; i++)
            {
                if ((row.Table.Columns[i].ColumnMapping == MappingType.Attribute) || (row.Table.Columns[i].ColumnMapping == MappingType.Hidden))
                {
                    this.GenerateColumn(row, row.Table.Columns[i], DataRowVersion.Original);
                }
            }
            for (int j = 0; j < count; j++)
            {
                if ((row.Table.Columns[j].ColumnMapping == MappingType.Element) || (row.Table.Columns[j].ColumnMapping == MappingType.SimpleContent))
                {
                    this.GenerateColumn(row, row.Table.Columns[j], DataRowVersion.Original);
                }
            }
            this._xmlw.WriteEndElement();
        }