Ejemplo n.º 1
0
        internal void ProcessDiffs(DataSet ds, XmlReader ssync)
        {
            DataTable tableBefore;
            DataRow   row;
            int       oldRowRecord;
            int       pos = -1;

            int iSsyncDepth = ssync.Depth;

            ssync.Read(); // pass the before node.

            SkipWhitespaces(ssync);

            while (iSsyncDepth < ssync.Depth)
            {
                tableBefore = null;
                string diffId = null;

                oldRowRecord = -1;

                // the diffgramm always contains sql:before and sql:after pairs

                int iTempDepth = ssync.Depth;

                diffId = ssync.GetAttribute(Keywords.DIFFID, Keywords.DFFNS);
                bool hasErrors = ssync.GetAttribute(Keywords.HASERRORS, Keywords.DFFNS) == Keywords.TRUE;
                oldRowRecord = ReadOldRowData(ds, ref tableBefore, ref pos, ssync);
                if (oldRowRecord == -1)
                {
                    continue;
                }

                if (tableBefore == null)
                {
                    throw ExceptionBuilder.DiffgramMissingSQL();
                }

                row = (DataRow)tableBefore.RowDiffId[diffId];
                if (row != null)
                {
                    row._oldRecord = oldRowRecord;
                    tableBefore._recordManager[oldRowRecord] = row;
                }
                else
                {
                    row = tableBefore.NewEmptyRow();
                    tableBefore._recordManager[oldRowRecord] = row;
                    row._oldRecord = oldRowRecord;
                    row._newRecord = oldRowRecord;
                    tableBefore.Rows.DiffInsertAt(row, pos);
                    row.Delete();
                    if (hasErrors)
                    {
                        tableBefore.RowDiffId[diffId] = row;
                    }
                }
            }

            return;
        }
Ejemplo n.º 2
0
        internal void ProcessErrors(ArrayList dt, XmlReader ssync)
        {
            DataTable table;

            int iSsyncDepth = ssync.Depth;

            ssync.Read(); // pass the before node.

            while (iSsyncDepth < ssync.Depth)
            {
                table = GetTable(XmlConvert.DecodeName(ssync.LocalName), ssync.NamespaceURI);
                if (table == null)
                {
                    throw ExceptionBuilder.DiffgramMissingSQL();
                }

                string diffId = ssync.GetAttribute(Keywords.DIFFID, Keywords.DFFNS);

                DataRow row = (DataRow)table.RowDiffId[diffId];
                if (row == null)
                {
                    for (int i = 0; i < dt.Count; i++)
                    {
                        row = (DataRow)((DataTable)dt[i]).RowDiffId[diffId];
                        if (row != null)
                        {
                            table = row.Table;
                            break;
                        }
                    }
                }
                string rowError = ssync.GetAttribute(Keywords.MSD_ERROR, Keywords.DFFNS);
                if (rowError != null)
                {
                    row.RowError = rowError;
                }
                int iRowDepth = ssync.Depth;
                ssync.Read(); // we may be inside a column

                while (iRowDepth < ssync.Depth)
                {
                    if (XmlNodeType.Element == ssync.NodeType)
                    {
                        DataColumn col = table.Columns[XmlConvert.DecodeName(ssync.LocalName), ssync.NamespaceURI];
                        //if (col == null)
                        // throw exception here
                        string colError = ssync.GetAttribute(Keywords.MSD_ERROR, Keywords.DFFNS);
                        row.SetColumnError(col, colError);
                    }
                    ssync.Read();
                }
                while ((ssync.NodeType == XmlNodeType.EndElement) && (iSsyncDepth < ssync.Depth))
                {
                    ssync.Read();
                }
            }

            return;
        }
Ejemplo n.º 3
0
        internal void ProcessDiffs(ArrayList tableList, XmlReader ssync)
        {
            DataTable?tableBefore;
            DataRow?  row;
            int       oldRowRecord;
            int       pos = -1;

            int iSsyncDepth = ssync.Depth;

            ssync.Read(); // pass the before node.

            //SkipWhitespaces(ssync); for given scenario does not require this change, but in fact we should do it.

            while (iSsyncDepth < ssync.Depth)
            {
                tableBefore = null;
                string diffId;

                oldRowRecord = -1;

                // the diffgramm always contains sql:before and sql:after pairs

                diffId = ssync.GetAttribute(Keywords.DIFFID, Keywords.DFFNS) !;
                bool hasErrors = ssync.GetAttribute(Keywords.HASERRORS, Keywords.DFFNS) == Keywords.TRUE;
                oldRowRecord = ReadOldRowData(_dataSet, ref tableBefore, ref pos, ssync);
                if (oldRowRecord == -1)
                {
                    continue;
                }

                if (tableBefore == null)
                {
                    throw ExceptionBuilder.DiffgramMissingSQL();
                }

                row = (DataRow?)tableBefore.RowDiffId[diffId];

                if (row != null)
                {
                    row._oldRecord = oldRowRecord;
                    tableBefore._recordManager[oldRowRecord] = row;
                }
                else
                {
                    row = tableBefore.NewEmptyRow();
                    tableBefore._recordManager[oldRowRecord] = row;
                    row._oldRecord = oldRowRecord;
                    row._newRecord = oldRowRecord;
                    tableBefore.Rows.DiffInsertAt(row, pos);
                    row.Delete();
                    if (hasErrors)
                    {
                        tableBefore.RowDiffId[diffId] = row;
                    }
                }
            }

            return;
        }
        internal void ProcessErrors(ArrayList dt, XmlReader ssync)
        {
            int depth = ssync.Depth;

            ssync.Read();
            while (depth < ssync.Depth)
            {
                DataTable table = this.GetTable(XmlConvert.DecodeName(ssync.LocalName), ssync.NamespaceURI);
                if (table == null)
                {
                    throw ExceptionBuilder.DiffgramMissingSQL();
                }
                string  attribute = ssync.GetAttribute("id", "urn:schemas-microsoft-com:xml-diffgram-v1");
                DataRow row       = (DataRow)table.RowDiffId[attribute];
                if (row == null)
                {
                    for (int i = 0; i < dt.Count; i++)
                    {
                        row = (DataRow)((DataTable)dt[i]).RowDiffId[attribute];
                        if (row != null)
                        {
                            table = row.Table;
                            break;
                        }
                    }
                }
                string str = ssync.GetAttribute("Error", "urn:schemas-microsoft-com:xml-diffgram-v1");
                if (str != null)
                {
                    row.RowError = str;
                }
                int num3 = ssync.Depth;
                ssync.Read();
                while (num3 < ssync.Depth)
                {
                    if (XmlNodeType.Element == ssync.NodeType)
                    {
                        DataColumn column = table.Columns[XmlConvert.DecodeName(ssync.LocalName), ssync.NamespaceURI];
                        string     error  = ssync.GetAttribute("Error", "urn:schemas-microsoft-com:xml-diffgram-v1");
                        row.SetColumnError(column, error);
                    }
                    ssync.Read();
                }
                while ((ssync.NodeType == XmlNodeType.EndElement) && (depth < ssync.Depth))
                {
                    ssync.Read();
                }
            }
        }
Ejemplo n.º 5
0
        internal static void ProcessErrors(DataSet ds, XmlReader ssync)
        {
            DataTable?table;

            int iSsyncDepth = ssync.Depth;

            ssync.Read(); // pass the before node.

            while (iSsyncDepth < ssync.Depth)
            {
                table = ds.Tables.GetTable(XmlConvert.DecodeName(ssync.LocalName), ssync.NamespaceURI);
                if (table == null)
                {
                    throw ExceptionBuilder.DiffgramMissingSQL();
                }
                string  diffId   = ssync.GetAttribute(Keywords.DIFFID, Keywords.DFFNS) !;
                DataRow row      = (DataRow)table.RowDiffId[diffId] !;
                string? rowError = ssync.GetAttribute(Keywords.MSD_ERROR, Keywords.DFFNS);
                if (rowError != null)
                {
                    row.RowError = rowError;
                }
                int iRowDepth = ssync.Depth;
                ssync.Read(); // we may be inside a column
                while (iRowDepth < ssync.Depth)
                {
                    if (XmlNodeType.Element == ssync.NodeType)
                    {
                        DataColumn col = table.Columns[XmlConvert.DecodeName(ssync.LocalName), ssync.NamespaceURI] !;
                        //if (col == null)
                        // throw exception here
                        string colError = ssync.GetAttribute(Keywords.MSD_ERROR, Keywords.DFFNS) !;
                        row.SetColumnError(col, colError);
                    }

                    ssync.Read();
                }
                while ((ssync.NodeType == XmlNodeType.EndElement) && (iSsyncDepth < ssync.Depth))
                {
                    ssync.Read();
                }
            }

            return;
        }
        internal void ProcessDiffs(DataSet ds, XmlReader ssync)
        {
            int pos   = -1;
            int depth = ssync.Depth;

            ssync.Read();
            this.SkipWhitespaces(ssync);
            while (depth < ssync.Depth)
            {
                DataTable table     = null;
                string    attribute = null;
                int       num       = -1;
                int       num1      = ssync.Depth;
                attribute = ssync.GetAttribute("id", "urn:schemas-microsoft-com:xml-diffgram-v1");
                bool flag = ssync.GetAttribute("hasErrors", "urn:schemas-microsoft-com:xml-diffgram-v1") == "true";
                num = this.ReadOldRowData(ds, ref table, ref pos, ssync);
                if (num != -1)
                {
                    if (table == null)
                    {
                        throw ExceptionBuilder.DiffgramMissingSQL();
                    }
                    DataRow row = (DataRow)table.RowDiffId[attribute];
                    if (row != null)
                    {
                        row.oldRecord            = num;
                        table.recordManager[num] = row;
                    }
                    else
                    {
                        row = table.NewEmptyRow();
                        table.recordManager[num] = row;
                        row.oldRecord            = num;
                        row.newRecord            = num;
                        table.Rows.DiffInsertAt(row, pos);
                        row.Delete();
                        if (flag)
                        {
                            table.RowDiffId[attribute] = row;
                        }
                    }
                }
            }
        }