GetChildRows() публичный Метод

Gets the child rows of this using the specified .
public GetChildRows ( DataRelation relation ) : System.Data.DataRow[]
relation DataRelation
Результат System.Data.DataRow[]
Пример #1
0
        public DualDraw(DataRow data)
        {
            DataRow[] parts = data.GetChildRows("Module_Module");

            _lower = (IDrawExecuter)BaseModule.GetModule(parts[0]);
            _upper = (IDrawExecuter)BaseModule.GetModule(parts[1]);
        }
Пример #2
0
        internal override object Eval(DataRow row, DataRowVersion version)
        {
            if (_childTable == null)
            {
                throw ExprException.AggregateUnbound(ToString());
            }

            DataRow[] rows;

            if (_local)
            {
                rows = new DataRow[_childTable.Rows.Count];
                _childTable.Rows.CopyTo(rows, 0);
            }
            else
            {
                if (row == null)
                {
                    throw ExprException.EvalNoContext();
                }
                if (_relation == null)
                {
                    throw ExprException.AggregateUnbound(ToString());
                }
                rows = row.GetChildRows(_relation, version);
            }

            int[] records;
            if (version == DataRowVersion.Proposed)
            {
                version = DataRowVersion.Default;
            }

            List <int> recordList = new List <int>();

            for (int i = 0; i < rows.Length; i++)
            {
                if (rows[i].RowState == DataRowState.Deleted)
                {
                    if (DataRowAction.Rollback != rows[i]._action)
                    {
                        continue;
                    }
                    Debug.Assert(DataRowVersion.Original == version, "wrong version");
                    version = DataRowVersion.Original;
                }
                else if ((DataRowAction.Rollback == rows[i]._action) && (rows[i].RowState == DataRowState.Added))
                {
                    continue;
                }
                if (version == DataRowVersion.Original && rows[i]._oldRecord == -1)
                {
                    continue;
                }
                recordList.Add(rows[i].GetRecordFromVersion(version));
            }
            records = recordList.ToArray();

            return(_column.GetAggregateValue(records, _type));
        }
Пример #3
0
 /// <summary>
 /// 递归添加子节点
 /// </summary>
 /// <param name="cRow"></param>
 private void BuildSubTree(DataRow cRow)
 {
     var i = 0;
     _stringBuilder.Append(",\"children\":[");
     foreach (var iRow in cRow.GetChildRows("NodeRelation"))
     {
         if (i != 0)
         {
             _stringBuilder.Append(",");
         }
         var text = iRow["AreaName"].ToString().Trim();
         var no = iRow["AreaId"].ToString().Trim();
         var href = Request.QueryString["menu"] + "?AreaId=" + no;
         //_stringBuilder.Append("{\"data\":{\"title\": \"" + text + "\",\"attr\": { \"href\": \"" + href + "\", \"target\": \"center\" }},\"attr\": { \"id\": \"" + no + "\" }");
         if (iRow.GetChildRows("NodeRelation").Length <= 0)
         {
             _stringBuilder.Append("{\"data\":{\"title\": \"" + text +
                                   "\",\"icon\": \"jstree-iconla\",\"attr\": { \"href\": \"" + href +
                                   "\", \"target\": \"center\" }},\"attr\": { \"id\": \"" + no + "\" }");
         }
         else
         {
             _stringBuilder.Append("{\"data\":{\"title\": \"" + text + "\",\"attr\": { \"href\": \"" + href +
                                   "\", \"target\": \"center\" }},\"attr\": { \"id\": \"" + no + "\" }");
         }
         i++;
         BuildSubTree(iRow);
         _stringBuilder.Append("}");
     }
     _stringBuilder.Append("]");
 }
Пример #4
0
 public ADOTabularFunction(DataRow dr)
 {
     _caption = dr["FUNCTION_NAME"].ToString();
     _desc = dr["DESCRIPTION"].ToString();
     _group = dr["INTERFACE_NAME"].ToString();
     _paramColl = new ADOTabularParameterCollection(dr.GetChildRows("rowsetTablePARAMETERINFO"));
 }
Пример #5
0
 private void RecursivelyPopulate(DataRow dbRow, TreeNode node)
 {
     foreach (DataRow childRow in dbRow.GetChildRows("NodeRelation")) {
         TreeNode childNode = CreateNode(childRow["folderName"].ToString(), true);
         childNode.Tag = childRow["generatedID"].ToString();
         node.Nodes.Add(childNode);
         RecursivelyPopulate(childRow, childNode);
     }
 }
Пример #6
0
 private static void RecursivelyPopulate(DataRow dbRow, TreeNode node)
 {
     foreach (DataRow childRow in dbRow.GetChildRows("NodeRelation"))
     {
         TreeNode childNode = CreateNode(childRow["Text"].ToString(), true, childRow["ID"].ToString());
         node.Nodes.Add(childNode);
         RecursivelyPopulate(childRow, childNode);
     }
 }
Пример #7
0
        public OpenDoorOnCollide(DataRow data)
            : this(EntityBuilder.Instance.CurrentArea.AreaID)
        {
            DataRow props = data.GetChildRows("object_properties")[0];

            try
            {
                _needsMaster = bool.Parse(XMLParser.ValueOfProperty(props, "master"));
            }
            catch (PropertyNotFoundException e)
            { }
        }
Пример #8
0
 public void PopulateTree(DataRow dr, TreeNode node)
 {
     foreach (DataRow row in dr.GetChildRows("rsParentChild"))
     {
         TreeNode child = new TreeNode(row["CompanyName"].ToString());
         child.Tag = row;
         node.Nodes.Add(child);
         //Recursively build the tree
         PopulateTree(row, child);
     }
     return;
 }
Пример #9
0
        internal override object Eval(DataRow row, DataRowVersion version)
        {
#if DEBUG
            if (CompModSwitches.AggregateNode.TraceVerbose)
            {
                Debug.WriteLine("Eval " + this.ToString() + ", version " + version.ToString());
            }
#endif
            if (table == null)
            {
                throw ExprException.AggregateUnbound(this.ToString());
            }

            DataRow[] rows;

            if (local)
            {
                rows = new DataRow[table.Rows.Count];
                table.Rows.CopyTo(rows, 0);
            }
            else
            {
                if (row == null)
                {
                    throw ExprException.EvalNoContext();
                }
                if (relation == null)
                {
                    throw ExprException.AggregateUnbound(this.ToString());
                }
                rows = row.GetChildRows(relation, version);
            }
#if DEBUG
            if (CompModSwitches.AggregateNode.TraceVerbose)
            {
                Debug.WriteLine("Eval " + this.ToString() + ", # of Rows: " + rows.Length.ToString());
            }
#endif

            int[] records;

            if (version == DataRowVersion.Proposed)
            {
                version = DataRowVersion.Default;
            }

            records = new int[rows.Length];
            for (int i = 0; i < rows.Length; i++)
            {
                records[i] = rows[i].GetRecordFromVersion(version);
            }
            return(column.GetAggregateValue(records, type));
        }
 /// <summary>
 /// 递归添加子节点
 /// </summary>
 /// <param name="cRow"></param>
 private void BuildSubTree(DataRow cRow)
 {
     var i = 0;
     _stringBuilder.Append(",\"children\":[");
     foreach (var iRow in cRow.GetChildRows("NodeRelation"))
     {
         if (i != 0)
         {
             _stringBuilder.Append(",");
         }
         var text = iRow["AreaName"].ToString().Trim();
         var no = iRow["AreaId"].ToString().Trim();
         var href = Request.QueryString["menu"] + "?AreaId=" + no;
         //_stringBuilder.Append("{\"data\":{\"title\": \"" + text + "\",\"attr\": { \"href\": \"" + href + "\", \"target\": \"center\" }},\"attr\": { \"id\": \"" + no + "\" }");
         if (iRow.GetChildRows("NodeRelation").Length <= 0)
         {
             _stringBuilder.Append("{\"data\":{\"title\": \"" + text +
                                   "\",\"icon\": \"jstree-iconla\",\"attr\": { \"href\": \"" + href +
                                   "\", \"target\": \"center\" }},\"attr\": { \"id\": \"" + no + "\" }");
         }
         else
         {
             _stringBuilder.Append("{\"data\":{\"title\": \"" + text + "\",\"attr\": { \"href\": \"" + href +
                                   "\", \"target\": \"center\" }},\"attr\": { \"id\": \"" + no + "\" }");
         }
         i++;
         BuildSubTree(iRow);
         _stringBuilder.Append("}");
     }
     List<SqlParameter> parameters = new List<SqlParameter>();
     var parameter = new SqlParameter("@AreaId", DbType.AnsiString) { Value = cRow["AreaId"] };
     parameters.Add(parameter);
     var dt = new OrgOrganize().GetList(" AreaId=@AreaId and OrgType=5 and Status=1 ", parameters).Tables[0];
     if (dt.Rows.Count > 0)
     {
         var k = 0;
         for (int j = 0; j < dt.Rows.Count; j++)
         {
             if (i != 0 || k != 0)
             {
                 _stringBuilder.Append(",");
             }
             var text = dt.Rows[j]["OrgName"].ToString().Trim();
             var no = dt.Rows[j]["OrgId"].ToString().Trim();
             var href = Request.QueryString["menu"] + "?OId=" + no;
             _stringBuilder.Append("{\"data\":{\"title\": \"" + text + "\",\"icon\": \"jstree-iconWS\",\"attr\": { \"href\": \"" + href + "\", \"target\": \"center\" }},\"attr\": { \"id\": \"" + no + "\" }");
             k++;
             _stringBuilder.Append("}");
         }
     }
     _stringBuilder.Append("]");
 }
Пример #11
0
        internal override object Eval(DataRow row, DataRowVersion version)
        {
            DataRow[] childRows;
            if (this.childTable == null)
            {
                throw ExprException.AggregateUnbound(this.ToString());
            }
            if (this.local)
            {
                childRows = new DataRow[this.childTable.Rows.Count];
                this.childTable.Rows.CopyTo(childRows, 0);
            }
            else
            {
                if (row == null)
                {
                    throw ExprException.EvalNoContext();
                }
                if (this.relation == null)
                {
                    throw ExprException.AggregateUnbound(this.ToString());
                }
                childRows = row.GetChildRows(this.relation, version);
            }
            if (version == DataRowVersion.Proposed)
            {
                version = DataRowVersion.Default;
            }
            List <int> list = new List <int>();

            for (int i = 0; i < childRows.Length; i++)
            {
                if (childRows[i].RowState == DataRowState.Deleted)
                {
                    if (DataRowAction.Rollback != childRows[i]._action)
                    {
                        continue;
                    }
                    version = DataRowVersion.Original;
                }
                else if ((DataRowAction.Rollback == childRows[i]._action) && (childRows[i].RowState == DataRowState.Added))
                {
                    continue;
                }
                if ((version != DataRowVersion.Original) || (childRows[i].oldRecord != -1))
                {
                    list.Add(childRows[i].GetRecordFromVersion(version));
                }
            }
            int[] records = list.ToArray();
            return(this.column.GetAggregateValue(records, this.type));
        }
Пример #12
0
        private void DeleteParameters(string ruleId)
        {
            View ruleView      = GetView(GetConfigViewName());
            View parameterView = GetView("Parameter");

            System.Data.DataRow row = ruleView.GetDataRow(ruleId);

            foreach (System.Data.DataRow parameterRow in row.GetChildRows("Parameters"))
            {
                string parameterId = parameterRow["ID"].ToString();
                parameterView.Delete(parameterId, null, null, null);
            }
        }
Пример #13
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TileSet" /> class.
        /// </summary>
        /// <param name="data">Data referes to a 'tilest' row atop of a .tmx file.</param>
        /// <exception cref="System.Exception">Faulty property in tiletype with ID  + type.ID + .</exception>
        public TileSet(DataRow data)
        {
            _firstID = int.Parse(data["firstgid"].ToString());
            _name = data["name"].ToString();
            TileDimensions = new Point(int.Parse(data["tilewidth"].ToString()), int.Parse(data["tileheight"].ToString()));
            Image = Game1.Instance.Content.Load<Texture2D>("tileset/" + data.GetChildRows("tileset_properties")[0].GetChildRows("properties_property")[0]["value"].ToString());
            //Image = Game1.Instance.Content.Load<Texture2D>("tileset/dg_dungeon32");
            RowsColls = new Point(
                int.Parse(data.GetChildRows("tileset_image")[0]["height"].ToString()) / TileDimensions.Y,
                                int.Parse(data.GetChildRows("tileset_image")[0]["width"].ToString()) / TileDimensions.X);

            _types = new List<TileType>();

            foreach (DataRow typeData in data.GetChildRows("tileset_tile"))
            {
                TileType type = new TileType();
                type.ID = int.Parse(typeData["id"].ToString());

                foreach (DataRow propData in typeData.GetChildRows("tile_properties")[0].GetChildRows("properties_property"))
                {
                    if (propData["name"].ToString().Equals("Modifier"))
                    {
                        type.SpeedModifier = int.Parse(propData["value"].ToString());
                        continue;
                    }
                    if (propData["name"].ToString().Equals("Type"))
                    {
                        type.Type = propData["value"].ToString();
                        continue;
                    }

                    throw new Exception("Faulty property in tiletype with ID " + type.ID + ".");
                }

                _types.Add(type);
            }
        }
Пример #14
0
        public AnimatedDrawer(DataRow data)
            : this(Game1.Instance.Content.Load<Texture2D>("sprite/"+data["Texture"].ToString()))
        {
            foreach (DataRow animData in data.GetChildRows("Module_Animation"))
            {
                this.AddAnimation(ReadAnimation(animData));
            }

            this.SetCurrentAnimation("default");

            try
            {
                this.IsLight = bool.Parse(data["IsLight"].ToString());
            }
            catch { }
        }
        private void getChildRows(DataRow datarow, TreeNode treenode)
        {
            DataRow[] ChildRows = datarow.GetChildRows("ChildRows");
            foreach (DataRow Childrow in ChildRows)
            {
                TreeNode childTreeNode = new TreeNode();
                childTreeNode.Text = Childrow["Name"].ToString();
             //   childTreeNode.NavigateUrl = Childrow["NavigateUrl"].ToString();
                treenode.ChildNodes.Add(childTreeNode);
                if (Childrow.GetChildRows("ChildRows").Length > 0)
                {
                    getChildRows(Childrow, childTreeNode);
                }

            }

        }
Пример #16
0
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="name"></param>
        public BaseLogger(string name, DataRow rowLogger)
        {
            this.IsOutputConsole = false;
            this.Name = name;
            if (rowLogger != null)
            {
                if (rowLogger.Table.Columns.Contains("OutputConsole"))
                {
                    this.IsOutputConsole = bool.Parse(rowLogger["OutputConsole"].ToString());
                }

                if (rowLogger.Table.Columns.Contains("Type"))
                {
                    this.Type = rowLogger["Type"].ToString();
                }
                else
                {
                    this.Type = "Text";
                }

                DataRow[] rows = rowLogger.GetChildRows("Logger_Property");
                foreach (DataRow rowProperty in rows)
                {
                    PropertyInfo propertyInfo = this.GetType().GetProperty(rowProperty["Name"].ToString());
                    if (propertyInfo != null)
                    {
                        object value ;
                        if (rowProperty["Name"].ToString().ToLower().Equals("databasetype"))
                        {
                            value = Enum.Parse(propertyInfo.PropertyType, rowProperty["Property_Text"].ToString());
                        }
                        else
                        {
                            value = Convert.ChangeType(rowProperty["Property_Text"], propertyInfo.PropertyType);

                        }
                        propertyInfo.SetValue(this, value, null);
                    }
                }
            }
        }
Пример #17
0
        public Int32 addEvent(DataRow dr, DataTable dt)
        {
            if (dt != null)
            {
                DataRelationCollection relations = dt.ChildRelations;
                if (relations.Count > 0)
                {
                    DataRelation relationAddress = relations[0];
                    DataRow[] rowsAddress = dr.GetChildRows(relationAddress);
                    foreach (DataRow mRow in rowsAddress)
                    {
                        try
                        {
                            mevent = new cc_event();
                            mevent.mCtr_Event = mRow[gf_main.CTRLEVENT].ToString();
                            mevent.mCtrl_Line = mRow[gf_main.CTRLLINE].ToString();

                            mEventCollection.Add(mevent);
                        }
                        catch (FormatException)
                        {
                        }
                    }
                }
                else
                {
                    try
                    {
                        mevent = new cc_event();
                        mevent.mCtr_Event = dr[gf_main.CTRLTYPE].ToString();
                        mevent.mCtrl_Line = dr[gf_main.CTRLLINE].ToString();

                        mEventCollection.Add(mevent);
                    }
                    catch (FormatException)
                    {
                    }
                }
            }
            return 0;
        }
 public static void TransformTableWithSpace(ref DataTable source, DataTable dest, DataRelation rel, DataRow parentRow)
 {
     if (parentRow == null)
     {
         foreach (DataRow row in source.Rows)
         {
             if (!row.HasErrors && (Utils.CIntDef(row["AREA_PARENT_ID"]) <= 0))
             {
                 row["AREA_NAME"] = (Utils.CIntDef(row["AREA_RANK"]) <= 1 ? "" : Duplicate("------", Utils.CIntDef(row["AREA_RANK"]))) + row["AREA_NAME"];
                 dest.Rows.Add(row.ItemArray);
                 row.RowError = "dirty";
                 if (Utils.CStrDef(row["AREA_NAME"]) != "------- Root -------")
                     TransformTableWithSpace(ref source, dest, rel, row);
             }
         }
     }
     else
     {
         DataRow[] children = parentRow.GetChildRows(rel);
         if (!parentRow.HasErrors)
         {
             parentRow["AREA_NAME"] = (Utils.CIntDef(parentRow["AREA_RANK"]) <= 1 ? "" : Duplicate("------", Utils.CIntDef(parentRow["AREA_RANK"]))) + parentRow["AREA_NAME"];
             dest.Rows.Add(parentRow.ItemArray);
             parentRow.RowError = "dirty";
         }
         if (children != null && children.Length > 0)
         {
             foreach (DataRow child in children)
             {
                 if (!child.HasErrors)
                 {
                     child["AREA_NAME"] = (Utils.CIntDef(child["AREA_RANK"]) <= 1 ? "" : Duplicate("------", Utils.CIntDef(child["AREA_RANK"]))) + child["AREA_NAME"];
                     dest.Rows.Add(child.ItemArray);
                     child.RowError = "dirty";
                     TransformTableWithSpace(ref source, dest, rel, child);
                 }
             }
         }
     }
 }
Пример #19
0
        /// <summary>
        /// Searches a propertie structure for a specified propertie.
        /// </summary>
        /// <param name="data">The data.</param>
        /// <param name="propertyName">Name of the property.</param>
        /// <returns></returns>
        public static string ValueOfProperty(DataRow data, string propertyName)
        {
            foreach (DataRow property in data.GetChildRows("properties_property"))
            {
                if (property["name"].ToString().Equals(propertyName))
                {
                    if (property["name"].ToString().Equals("master"))
                    {
                        if (property["value"].ToString().Equals("1"))
                            return "true";
                        if (property["value"].ToString().Equals("0"))
                            return "false";
                    }
                    return property["value"].ToString();
                }
            }

            throw new PropertyNotFoundException(propertyName);
        }
Пример #20
0
        internal void XmlDataRowWriter(DataRow row, string encodedTableName)
        {
            object obj2;
            string prefix = (row.Table.Namespace.Length == 0) ? "" : row.Table.Prefix;

            this._xmlw.WriteStartElement(prefix, encodedTableName, row.Table.Namespace);
            if (this.isDiffgram)
            {
                this._xmlw.WriteAttributeString("diffgr", "id", "urn:schemas-microsoft-com:xml-diffgram-v1", row.Table.TableName + row.rowID.ToString(CultureInfo.InvariantCulture));
                this._xmlw.WriteAttributeString("msdata", "rowOrder", "urn:schemas-microsoft-com:xml-msdata", this.rowsOrder[row].ToString());
                if (row.RowState == DataRowState.Added)
                {
                    this._xmlw.WriteAttributeString("diffgr", "hasChanges", "urn:schemas-microsoft-com:xml-diffgram-v1", "inserted");
                }
                if (row.RowState == DataRowState.Modified)
                {
                    this._xmlw.WriteAttributeString("diffgr", "hasChanges", "urn:schemas-microsoft-com:xml-diffgram-v1", "modified");
                }
                if (RowHasErrors(row))
                {
                    this._xmlw.WriteAttributeString("diffgr", "hasErrors", "urn:schemas-microsoft-com:xml-diffgram-v1", "true");
                }
            }
            foreach (DataColumn column2 in row.Table.Columns)
            {
                if (column2.columnMapping == MappingType.Attribute)
                {
                    obj2 = row[column2];
                    string str3 = (column2.Namespace.Length == 0) ? "" : column2.Prefix;
                    if ((obj2 != DBNull.Value) && (!column2.ImplementsINullable || !DataStorage.IsObjectSqlNull(obj2)))
                    {
                        XmlTreeGen.ValidateColumnMapping(column2.DataType);
                        this._xmlw.WriteAttributeString(str3, column2.EncodedColumnName, column2.Namespace, column2.ConvertObjectToXml(obj2));
                    }
                }
                if (this.isDiffgram && (column2.columnMapping == MappingType.Hidden))
                {
                    obj2 = row[column2];
                    if ((obj2 != DBNull.Value) && (!column2.ImplementsINullable || !DataStorage.IsObjectSqlNull(obj2)))
                    {
                        XmlTreeGen.ValidateColumnMapping(column2.DataType);
                        this._xmlw.WriteAttributeString("msdata", "hidden" + column2.EncodedColumnName, "urn:schemas-microsoft-com:xml-msdata", column2.ConvertObjectToXml(obj2));
                    }
                }
            }
            foreach (DataColumn column in row.Table.Columns)
            {
                if (column.columnMapping != MappingType.Hidden)
                {
                    obj2 = row[column];
                    string str2 = (column.Namespace.Length == 0) ? "" : column.Prefix;
                    bool   flag = true;
                    if (((obj2 == DBNull.Value) || (column.ImplementsINullable && DataStorage.IsObjectSqlNull(obj2))) && (column.ColumnMapping == MappingType.SimpleContent))
                    {
                        this._xmlw.WriteAttributeString("xsi", "nil", "http://www.w3.org/2001/XMLSchema-instance", "true");
                    }
                    if (((obj2 != DBNull.Value) && (!column.ImplementsINullable || !DataStorage.IsObjectSqlNull(obj2))) && (column.columnMapping != MappingType.Attribute))
                    {
                        if ((column.columnMapping != MappingType.SimpleContent) && ((!column.IsCustomType || !column.IsValueCustomTypeInstance(obj2)) || typeof(IXmlSerializable).IsAssignableFrom(obj2.GetType())))
                        {
                            this._xmlw.WriteStartElement(str2, column.EncodedColumnName, column.Namespace);
                            flag = false;
                        }
                        Type type = obj2.GetType();
                        if (!column.IsCustomType)
                        {
                            if (((type == typeof(char)) || (type == typeof(string))) && PreserveSpace(obj2))
                            {
                                this._xmlw.WriteAttributeString("xml", "space", "http://www.w3.org/XML/1998/namespace", "preserve");
                            }
                            this._xmlw.WriteString(column.ConvertObjectToXml(obj2));
                        }
                        else if (column.IsValueCustomTypeInstance(obj2))
                        {
                            if (!flag && (type != column.DataType))
                            {
                                this._xmlw.WriteAttributeString("msdata", "InstanceType", "urn:schemas-microsoft-com:xml-msdata", DataStorage.GetQualifiedName(type));
                            }
                            if (!flag)
                            {
                                column.ConvertObjectToXml(obj2, this._xmlw, null);
                            }
                            else
                            {
                                if (obj2.GetType() != column.DataType)
                                {
                                    throw ExceptionBuilder.PolymorphismNotSupported(type.AssemblyQualifiedName);
                                }
                                XmlRootAttribute xmlAttrib = new XmlRootAttribute(column.EncodedColumnName)
                                {
                                    Namespace = column.Namespace
                                };
                                column.ConvertObjectToXml(obj2, this._xmlw, xmlAttrib);
                            }
                        }
                        else
                        {
                            if (((type == typeof(Type)) || (type == typeof(Guid))) || ((type == typeof(char)) || DataStorage.IsSqlType(type)))
                            {
                                this._xmlw.WriteAttributeString("msdata", "InstanceType", "urn:schemas-microsoft-com:xml-msdata", type.FullName);
                            }
                            else if (obj2 is Type)
                            {
                                this._xmlw.WriteAttributeString("msdata", "InstanceType", "urn:schemas-microsoft-com:xml-msdata", "Type");
                            }
                            else
                            {
                                string str = "xs:" + XmlTreeGen.XmlDataTypeName(type);
                                this._xmlw.WriteAttributeString("xsi", "type", "http://www.w3.org/2001/XMLSchema-instance", str);
                                this._xmlw.WriteAttributeString("xmlns:xs", "http://www.w3.org/2001/XMLSchema");
                            }
                            if (!DataStorage.IsSqlType(type))
                            {
                                this._xmlw.WriteString(column.ConvertObjectToXml(obj2));
                            }
                            else
                            {
                                column.ConvertObjectToXml(obj2, this._xmlw, null);
                            }
                        }
                        if ((column.columnMapping != MappingType.SimpleContent) && !flag)
                        {
                            this._xmlw.WriteEndElement();
                        }
                    }
                }
            }
            if (this._ds != null)
            {
                foreach (DataRelation relation in this.GetNestedChildRelations(row))
                {
                    foreach (DataRow row2 in row.GetChildRows(relation))
                    {
                        this.XmlDataRowWriter(row2, relation.ChildTable.EncodedTableName);
                    }
                }
            }
            this._xmlw.WriteEndElement();
        }
Пример #21
0
        private void ResolveSubTree(DataRow dataRow, TreeNode treeNode)
        {
            DataRow[] rows = dataRow.GetChildRows("TreeRelation");
            if (rows.Length > 0)
            {
                treeNode.Expanded = true;
                foreach (DataRow row in rows)
                {
                    TreeNode node = new TreeNode();
                    node.Text = row["Text"].ToString();
                    treeNode.Nodes.Add(node);

                    ResolveSubTree(row, node);
                }
            }
        }
Пример #22
0
        internal void  XmlDataRowWriter(DataRow row, String encodedTableName) {

            object value;
            string prefix = (row.Table.Namespace.Length == 0) ? "" : row.Table.Prefix;

            _xmlw.WriteStartElement(prefix, encodedTableName, row.Table.Namespace);

            if (isDiffgram)  {
                _xmlw.WriteAttributeString( Keywords.DFF, Keywords.DIFFID, Keywords.DFFNS, row.Table.TableName+row.rowID.ToString(CultureInfo.InvariantCulture));

                _xmlw.WriteAttributeString( Keywords.MSD, Keywords.ROWORDER, Keywords.MSDNS, rowsOrder[row].ToString());

                if (row.RowState == DataRowState.Added) {
                    _xmlw.WriteAttributeString( Keywords.DFF, Keywords.HASCHANGES, Keywords.DFFNS, Keywords.INSERTED);
                }
                if (row.RowState == DataRowState.Modified) {
                    _xmlw.WriteAttributeString( Keywords.DFF, Keywords.HASCHANGES, Keywords.DFFNS, Keywords.MODIFIED);
                }

                if (RowHasErrors(row)) {
                    _xmlw.WriteAttributeString( Keywords.DFF, Keywords.HASERRORS, Keywords.DFFNS, Keywords.TRUE);
                }
            }




            //write the attribute columns first, if any
            foreach( DataColumn col in row.Table.Columns )
            {
                if (col.columnMapping == MappingType.Attribute)
                {
                    value = row[col];
                    string colPrefix = (col.Namespace.Length == 0) ? "" : col.Prefix;

                    if  ((value != DBNull.Value) && (!col.ImplementsINullable || !DataStorage.IsObjectSqlNull(value))){
		        XmlTreeGen.ValidateColumnMapping(col.DataType);
                        _xmlw.WriteAttributeString(colPrefix, col.EncodedColumnName, col.Namespace, col.ConvertObjectToXml(value));
                    }
                }

                if (!isDiffgram)
                    continue;

                if (col.columnMapping == MappingType.Hidden)
                {
                    value = row[col];

                    if  ((value != DBNull.Value) && (!col.ImplementsINullable || !DataStorage.IsObjectSqlNull(value))){
		        XmlTreeGen.ValidateColumnMapping(col.DataType);
                        _xmlw.WriteAttributeString(Keywords.MSD, "hidden"+col.EncodedColumnName, Keywords.MSDNS, col.ConvertObjectToXml(value));
                    }
                }
            } //end foreach

            foreach( DataColumn col in row.Table.Columns  )
            {
                if (col.columnMapping != MappingType.Hidden)
                {
                    value = row[col];
                    string colPrefix = (col.Namespace.Length == 0) ? "" : col.Prefix;
                    bool startElementSkipped = true;

                    if (((value == DBNull.Value) || (col.ImplementsINullable && DataStorage.IsObjectSqlNull(value))) && (col.ColumnMapping == MappingType.SimpleContent))
                        _xmlw.WriteAttributeString(Keywords.XSI, Keywords.XSI_NIL, Keywords.XSINS, Keywords.TRUE);
                    // basically this is a continue; if it is null we write xsi:nil='true'
                    // below, the check is if it is not null
                    if  (((value != DBNull.Value) && (!col.ImplementsINullable || !DataStorage.IsObjectSqlNull(value)))&&(col.columnMapping != MappingType.Attribute)){
                        if (col.columnMapping != MappingType.SimpleContent) {
                            // again, if we need to use XmlSerializer, do not write start Element (see above for more info)
                            if (!col.IsCustomType || !col.IsValueCustomTypeInstance(value) ||(typeof(IXmlSerializable).IsAssignableFrom(value.GetType()))) {
                                _xmlw.WriteStartElement(colPrefix, col.EncodedColumnName, col.Namespace);
                                startElementSkipped = false;
                            }
                        }

                        Type valuesType = value.GetType();
                        if (!col.IsCustomType) { // if column's type is built in type: CLR and SQLTypes : ie storage supported types
                            if(valuesType == typeof(char) || valuesType == typeof(string)) {
                                if (PreserveSpace(value)) {
                                    _xmlw.WriteAttributeString(Keywords.XML, Keywords.SPACE, Keywords.XML_XMLNS, Keywords.PRESERVE);
                                }
                            }
                            _xmlw.WriteString(col.ConvertObjectToXml(value));
                        }
                        else { // Columns type is CDT

                            if (col.IsValueCustomTypeInstance(value) /*&& !(value is Type) && valuesType != typeof(Type)*/)  {// value is also CDT
                                // if SkippedElement, ie does not implement IXMLSerializable: so No Polymorphism Support.
                                if (!startElementSkipped && valuesType != col.DataType) { // for polymorphism.
                                    _xmlw.WriteAttributeString(Keywords.MSD, Keywords.MSD_INSTANCETYPE, Keywords.MSDNS, DataStorage.GetQualifiedName(valuesType));
                                }
                                if (!startElementSkipped) { // make sure XmlRootAttribute is passed null as this type implement IXmlSerializable
                                    col.ConvertObjectToXml(value, _xmlw, null); // pass XmlRootAttribute as null, it also means: No XmlSerializer
                                }
                                else{ // startElement is skipped: this guy does not implement IXmlSerializable, need to go via XmlSerializer
                                    if (value.GetType() != col.DataType) { // throw if polymorphism; not supported
                                        throw ExceptionBuilder.PolymorphismNotSupported(valuesType.AssemblyQualifiedName);
                                    }
                                    // therefore we are skipping the start element, but by passing XmlRootAttribute with the same name as
                                    // we open the start element (column's name), XmlSerializer will open and close it for us
                                    XmlRootAttribute xmlAttrib = new XmlRootAttribute(col.EncodedColumnName);
                                    xmlAttrib.Namespace = col.Namespace;
                                    col.ConvertObjectToXml(value, _xmlw, xmlAttrib);
                                }
                            }
                            else { // this is case that column type is object and value is CLR or SQLTypes
                                if (valuesType == typeof(Type) || valuesType == typeof(Guid)|| valuesType == typeof(Char) ||
                                    DataStorage.IsSqlType(valuesType)) { // if unmapped type or SQL type write msdata:Datatype=typeofinstance
                                    _xmlw.WriteAttributeString(Keywords.MSD, Keywords.MSD_INSTANCETYPE, Keywords.MSDNS, valuesType.FullName);
                                }
                                else if (value is Type) {
                                    _xmlw.WriteAttributeString(Keywords.MSD, Keywords.MSD_INSTANCETYPE, Keywords.MSDNS, Keywords.TYPEINSTANCE);
                                }
                                else {
                                    string xsdTypeName = Keywords.XSD_PREFIXCOLON+ XmlTreeGen.XmlDataTypeName(valuesType);
                                    _xmlw.WriteAttributeString(Keywords.XSI, Keywords.TYPE, Keywords.XSINS, xsdTypeName);
                                    _xmlw.WriteAttributeString (Keywords.XMLNS_XSD, Keywords.XSDNS);
                                }
                                if (!DataStorage.IsSqlType(valuesType)) {
                                    _xmlw.WriteString(col.ConvertObjectToXml(value));
                                }
                                else {
                                    col.ConvertObjectToXml(value, _xmlw, null);
                                }
                            }
                        }
                        if (col.columnMapping != MappingType.SimpleContent && !startElementSkipped)
                            _xmlw.WriteEndElement();
                    }
                }
            } //end foreach

            if (_ds != null)
                foreach( DataRelation dr in GetNestedChildRelations(row) ) {
                    foreach( DataRow r in row.GetChildRows(dr) ) {
                        XmlDataRowWriter(r,dr.ChildTable.EncodedTableName);
                    }
                }

            _xmlw.WriteEndElement();
        }
Пример #23
0
		public DataRow GetReferencedRow (DataRow row)
		{
			// Verify the column reference is valid 
			GetColumn (row);

			switch (refTable) {
			case ReferencedTable.Self:
			default:
				return row;

			case ReferencedTable.Parent:
				return row.GetParentRow (GetRelation (row));

			case ReferencedTable.Child:
				return row.GetChildRows (GetRelation (row)) [0];
			}
		}
Пример #24
0
        internal virtual void Evaluate(DataRow row, DataRowVersion version)
        {
#if DEBUG
            if (CompModSwitches.DataExpression.TraceVerbose)
            {
                Debug.WriteLine("Evaluate expression column Queue, version = " + version.ToString() + " for table " + owner.TableName);
            }
#endif
            Debug.Assert(columns != null, "Invalid dependensy list");
            Debug.Assert(row != null, "Invalid argument to Evaluate, row");
            for (int i = 0; i < columnCount; i++)
            {
                DataColumn col = columns[i];
                Debug.Assert(col.Computed, "Only computed columns should be in the queue.");

#if DEBUG
                if (CompModSwitches.DataExpression.TraceVerbose)
                {
                    Debug.WriteLine("Evaluate column " + col.ColumnName + " = " + col.DataExpression.ToString());
                }
#endif

                if (col.Table == null)
                {
                    continue;
                }

                if (col.Table != owner)
                {
                    // first if the column belongs to an other table we need to recalc it for each row in the foreing table

#if DEBUG
                    if (CompModSwitches.DataExpression.TraceVerbose)
                    {
                        Debug.WriteLine("the column belong to a different table %%%%%%%");
                    }
#endif
                    // we need to update all foreign table - NOPE, only those who are valid parents. ALTHOUGH we're skipping old parents right now... confirm.
                    DataRowVersion foreignVer = (version == DataRowVersion.Proposed) ? DataRowVersion.Default : version;

                    int parentRelationCount = owner.ParentRelations.Count;
                    for (int j = 0; j < parentRelationCount; j++)
                    {
                        DataRelation relation = owner.ParentRelations[j];
                        if (relation.ParentTable != col.Table)
                        {
                            continue;
                        }
                        DataRow parentRow = row.GetParentRow(relation, version);
                        if (parentRow != null)
                        {
                            col[parentRow.GetRecordFromVersion(foreignVer)] = col.DataExpression.Evaluate(parentRow, foreignVer);
                        }
                    }

                    int childRelationCount = owner.ChildRelations.Count;
                    for (int j = 0; j < childRelationCount; j++)
                    {
                        DataRelation relation = owner.ChildRelations[j];
                        if (relation.ChildTable != col.Table)
                        {
                            continue;
                        }
                        DataRow[] childRows = row.GetChildRows(relation, version);
                        for (int k = 0; k < childRows.Length; k++)
                        {
                            if (childRows[k] != null)
                            {
                                col[childRows[k].GetRecordFromVersion(foreignVer)] = col.DataExpression.Evaluate(childRows[k], foreignVer);
                            }
                        }
                    }
                }
                else if (col.DataExpression.HasLocalAggregate())
                {
                    // if column expression references a local Table aggregate we need to recalc it for the each row in the local table

                    DataRowVersion aggVersion = (version == DataRowVersion.Proposed) ? DataRowVersion.Default : version;
#if DEBUG
                    if (CompModSwitches.DataExpression.TraceVerbose)
                    {
                        Debug.WriteLine("it has local aggregate.");
                    }
#endif
                    bool   isConst = col.DataExpression.IsTableAggregate();
                    object val     = null;

                    if (isConst)
                    {
                        val = col.DataExpression.Evaluate(row, aggVersion);
                    }

                    DataRow[] rows = new DataRow[col.Table.Rows.Count];
                    col.Table.Rows.CopyTo(rows, 0);

                    for (int j = 0; j < rows.Length; j++)
                    {
                        if (!isConst)
                        {
                            val = col.DataExpression.Evaluate(rows[j], aggVersion);
                        }
                        col[rows[j].GetRecordFromVersion(aggVersion)] = val;
                    }
                }
                else
                {
                    col[row.GetRecordFromVersion(version)] = col.DataExpression.Evaluate(row, version);
                }
            }
        }
Пример #25
0
		public DataRow[] GetProductsInCategory(DataRow rowParent)
		{
			DataRelation relCategoryProduct = rowParent.Table.DataSet.Relations[0];
			return rowParent.GetChildRows(relCategoryProduct);
		}
Пример #26
0
	private void Copy(DataRow leaf)
	{
		_resultDt.ImportRow(leaf);

		DataRow[] childs = leaf.GetChildRows("r1");

		foreach (DataRow child in childs)
		{
			DataRow[] subChilds = child.GetChildRows("r1");

			if (subChilds.Length > 0)
				Copy(child);
			else
				_resultDt.ImportRow(child);
		}
	}
Пример #27
0
        private void SetNewRecordWorker(DataRow row, int proposedRecord, DataRowAction action, bool isInMerge, bool suppressEnsurePropertyChanged,
            int position, bool fireEvent, out Exception deferredException) {

            // this is the event workhorse... it will throw the changing/changed events
            // and update the indexes. Used by change, add, delete, revert.

            // order of execution is as follows
            //
            // 1) set temp record
            // 2) Check constraints for non-expression columns
            // 3) Raise RowChanging/RowDeleting with temp record
            // 4) set the new record in storage
            // 5) Update indexes with recordStateChanges - this will fire ListChanged & PropertyChanged events on associated views
            // 6) Evaluate all Expressions (exceptions are deferred)- this will fire ListChanged & PropertyChanged events on associated views
            // 7) Raise RowChanged/ RowDeleted
            // 8) Check constraints for expression columns

            Debug.Assert(row != null, "Row can't be null.");
            deferredException = null;
            
            if (row.tempRecord != proposedRecord) {
                // $HACK: for performance reasons, EndUpdate calls SetNewRecord with tempRecord == proposedRecord
                if (!inDataLoad) {
                    row.CheckInTable();
                    CheckNotModifying(row);
                }
                if (proposedRecord == row.newRecord) {
                    if (isInMerge) {
                        Debug.Assert(fireEvent, "SetNewRecord is called with wrong parameter");
                        RaiseRowChanged(null, row, action);
                    }
                    return;
                }

                Debug.Assert(!row.inChangingEvent, "How can this row be in an infinite loop?");

                row.tempRecord = proposedRecord;
            }
            DataRowChangeEventArgs drcevent = null;

            try {
                row._action = action;
                drcevent = RaiseRowChanging(null, row, action, fireEvent);
            }
            catch {
                row.tempRecord = -1;
                throw;
            }
            finally {
                row._action = DataRowAction.Nothing;
            }

            row.tempRecord = -1;

            int currentRecord = row.newRecord;

            // if we're deleting, then the oldRecord value will change, so need to track that if it's distinct from the newRecord.
            int secondRecord = (proposedRecord != -1 ?
                                proposedRecord :
                                (row.RowState != DataRowState.Unchanged ?
                                 row.oldRecord :
                                 -1));

            if (action == DataRowAction.Add) { //if we come here from insert we do insert the row to collection
                if (position == -1)
                    Rows.ArrayAdd(row);
                else
                    Rows.ArrayInsert(row, position);
            }

            List<DataRow> cachedRows = null;
            if ((action == DataRowAction.Delete || action == DataRowAction.Change)
                && dependentColumns != null && dependentColumns.Count > 0) {
                // if there are expression columns, need to cache related rows for deletes and updates (key changes)
                // before indexes are modified.
                cachedRows = new List<DataRow>();
                for (int j = 0; j < ParentRelations.Count; j++) {
                    DataRelation relation = ParentRelations[j];
                    if (relation.ChildTable != row.Table) {
                        continue;
                    }
                    cachedRows.InsertRange(cachedRows.Count, row.GetParentRows(relation));
                }

                for (int j = 0; j < ChildRelations.Count; j++) {
                    DataRelation relation = ChildRelations[j];
                    if (relation.ParentTable != row.Table) {
                        continue;
                    }
                    cachedRows.InsertRange(cachedRows.Count, row.GetChildRows(relation));
                }
            }

            // Dev10 Bug 688779: DataRowView.PropertyChanged are not raised on RejectChanges
            // if the newRecord is changing, the propertychanged event should be allowed to triggered for ListChangedType.Changed or .Moved
            // unless the specific condition is known that no data has changed, like DataRow.SetModified()
            if (!suppressEnsurePropertyChanged && !row.HasPropertyChanged && (row.newRecord != proposedRecord)
                && (-1 != proposedRecord) // explictly not fixing Dev10 Bug 692044: DataRowView.PropertyChanged are not raised on DataTable.Delete when mixing current and original records in RowStateFilter
                && (-1 != row.newRecord)) // explictly not fixing parts of Dev10 Bug 697909: when mixing current and original records in RowStateFilter
            {
                // DataRow will believe multiple edits occured and
                // DataView.ListChanged event w/ ListChangedType.ItemChanged will raise DataRowView.PropertyChanged event and
                // PropertyChangedEventArgs.PropertyName will now be empty string so
                // WPF will refresh the entire row
                row.LastChangedColumn = null;
                row.LastChangedColumn = null;
            }

                // Check whether we need to update indexes
                if (LiveIndexes.Count != 0) {

                    // Dev10 bug #463087: DataTable internal index is currupted: '5'
                    if ((-1 == currentRecord) && (-1 != proposedRecord) && (-1 != row.oldRecord) && (proposedRecord != row.oldRecord)) {
                        // the transition from DataRowState.Deleted -> DataRowState.Modified
                        // with same orginal record but new current record
                        // needs to raise an ItemChanged or ItemMoved instead of ItemAdded in the ListChanged event.
                        // for indexes/views listening for both DataViewRowState.Deleted | DataViewRowState.ModifiedCurrent
                        currentRecord = row.oldRecord;
                    }

                    DataViewRowState currentRecordStatePre = row.GetRecordState(currentRecord);
                    DataViewRowState secondRecordStatePre = row.GetRecordState(secondRecord);

                    row.newRecord = proposedRecord;
                    if (proposedRecord != -1)
                        this.recordManager[proposedRecord] = row;

                    DataViewRowState currentRecordStatePost = row.GetRecordState(currentRecord);
                    DataViewRowState secondRecordStatePost = row.GetRecordState(secondRecord);

                    // may raise DataView.ListChanged event
                    RecordStateChanged(currentRecord, currentRecordStatePre, currentRecordStatePost,
                        secondRecord, secondRecordStatePre, secondRecordStatePost);
                }
                else {
                    row.newRecord = proposedRecord;
                    if (proposedRecord != -1)
                        this.recordManager[proposedRecord] = row;
                }

                // Dev10 Bug 461199 - reset the last changed column here, after all
                // DataViews have raised their DataRowView.PropertyChanged event
                row.ResetLastChangedColumn();

                // SQLBU 278737: Record manager corruption when reentrant write operations
                // free the 'currentRecord' only after all the indexes have been updated.
                // Corruption! { if (currentRecord != row.oldRecord) { FreeRecord(ref currentRecord); } }
                // RecordStateChanged raises ListChanged event at which time user may do work
                if (-1 != currentRecord) {
                    if (currentRecord != row.oldRecord)
                    {
                        if ((currentRecord != row.tempRecord) &&   // Delete, AcceptChanges, BeginEdit
                            (currentRecord != row.newRecord) &&    // RejectChanges & SetAdded
                            (row == recordManager[currentRecord])) // AcceptChanges, NewRow
                        {
                            FreeRecord(ref currentRecord);
                        }
                    }
                }

            if (row.RowState == DataRowState.Detached && row.rowID != -1) {
                RemoveRow(row, false);
            }

            if (dependentColumns != null && dependentColumns.Count > 0) {
                try {
                    EvaluateExpressions(row, action, cachedRows);
                }
                catch (Exception exc) {
                    // For DataRows being added, throwing of exception from expression evaluation is
                    // deferred until after the row has been completely added.
                    if (action != DataRowAction.Add) {
                        throw exc;
                    }
                    else {
                        deferredException = exc;
                    }
                }
            }

            try {
                if (fireEvent) {
                    RaiseRowChanged(drcevent, row, action);
                }
            }
            catch (Exception e) {
                // 
                if (!Common.ADP.IsCatchableExceptionType(e)) {
                    throw;
                }
                ExceptionBuilder.TraceExceptionWithoutRethrow(e);
                // ignore the exception
            }
        }
Пример #28
0
		// Método de apoio ao MergeDatasets que tem como função identificar e copiar para um DataSet as 
		// linhas "filhas" daquela passada como argumento
		private void getChildRows(DataRow row, DataSet dstDs, DataSet ds)
		{
			foreach (DataRelation rel in row.Table.ChildRelations)
			{
				if (row.GetChildRows(rel).Length > 0)
				{
					ds.Tables.Add(rel.ChildTable.Clone());
					foreach (DataRow childRow in row.GetChildRows(rel))
					{
						string filter2 = ConcorrenciaRule.Current.buildFilter(ds.Tables[rel.ChildTable.TableName], childRow, false);
						if (ds.Tables[rel.ChildTable.TableName].Select(filter2).Length == 0)
						{
							ds.Tables[rel.ChildTable.TableName].ImportRow(childRow);
						}
						getChildRows(childRow, dstDs, ds);
					}
				}
			}
		}
Пример #29
0
        private void ReadEntityLayer(ref Area area, DataRow data)
        {
            EntityLayer entLayer = new EntityLayer();

            foreach (DataRow objectData in data.GetChildRows("objectgroup_object"))
            {
                entLayer.AddEntity(EntityBuilder.Instance.CreateEntity(area.TileSets, objectData));
            }

            area.AddEntityLayer(entLayer);
        }
Пример #30
0
 private void ReadRoamZones(DataRow data)
 {
     foreach (DataRow objectData in data.GetChildRows("objectgroup_object"))
     {
         EntityBuilder.Instance.DepositZone(
             int.Parse(XMLParser.ValueOfProperty(objectData.GetChildRows("object_properties")[0], "ID")),
             ZoneFactory.ProduceZone(objectData));
     }
 }
Пример #31
0
		public DataRow[] GetReferencedRows (DataRow row)
		{
			// Verify the column reference is valid 
			GetColumn (row);

			switch (refTable) {
			case ReferencedTable.Self:
			default:
				DataRow[] rows = row.Table.NewRowArray(row.Table.Rows.Count);
				row.Table.Rows.CopyTo (rows, 0);
				return rows;
				
			case ReferencedTable.Parent:
				return row.GetParentRows (GetRelation (row));

			case ReferencedTable.Child:
				return row.GetChildRows (GetRelation (row));
			}
		}
Пример #32
0
        private EntityObject CreateObject(DataRow row, Type entityType, DataSet dataset)
        {
            var entityObject = (EntityObject)entityType.GetConstructor(new Type[] { }).Invoke(null);
            foreach (DataColumn column in row.Table.Columns) {
                var columnName = column.ColumnName.ToUpper(); // Informix在创建表的时候会自动把Column的名字改成小写,这里就取不到属性了。
                var property = entityType.GetProperty(columnName);
                if (property != null && row[columnName] != DBNull.Value){
                    entityObject.SetValue(columnName, row[columnName]);
                }
            }
            var entityKey = new EntityKey();
            entityKey.EntityContainerName = AssemblyName;
            entityKey.EntitySetName = row.Table.TableName;
            entityKey.EntityKeyValues = new EntityKeyMember[row.Table.PrimaryKey.Length];
            for (int i = 0; i < row.Table.PrimaryKey.Length; i++) {
                var primaryKey = row.Table.PrimaryKey[i];
                entityKey.EntityKeyValues[i] = new EntityKeyMember() { Key = primaryKey.ColumnName, Value = row[primaryKey.ColumnName] };
            }
            entityObject.EntityKey = entityKey;

            foreach (DataRelation relation in dataset.Relations) {
                if (relation.ParentTable.Equals(row.Table)) {
                    var navigationProperty = entityType.GetProperty(relation.ChildTable.TableName);
                    if (navigationProperty != null) {
                        var list = (IList)navigationProperty.PropertyType.GetConstructor(new Type[] { }).Invoke(null);
                        var childEntityType = GetEntityType(relation.ChildTable.TableName);
                        var childRows = row.GetChildRows(relation);
                        foreach (var childRow in childRows) {
                            var childObject = CreateObject(childRow, childEntityType, dataset);
                            var childNavigationProperty = childEntityType.GetProperty(relation.ParentTable.TableName);
                            if (childNavigationProperty != null)
                            {
                                childNavigationProperty.SetValue(childObject, entityObject, null);
                            }
                            list.Add(childObject);
                        }
                        navigationProperty.SetValue(entityObject, list, null);
                    }
                }
            }
            return entityObject;
        }
Пример #33
0
        private Animation ReadAnimation(DataRow data)
        {
            Animation res = new Animation(data["Name"].ToString());

            foreach (DataRow frameData in data.GetChildRows("Animation_Frame"))
            {
                DataRow recData = frameData.GetChildRows("Frame_Rectangle")[0];
                res.AddFrame(new Rectangle(
                    int.Parse(recData["X"].ToString()),
                    int.Parse(recData["Y"].ToString()),
                    int.Parse(recData["width"].ToString()),
                    int.Parse(recData["height"].ToString())));
            }

            return res;
        }
Пример #34
0
		//apaga / marca como apagada, as linhas descendentes daquela passada como argumento e remove-as da estrutura que mantem as linhas alteradas em memoria
		private void removeChildRows(DataRow dr, ArrayList changedrows)
		{
			changedRows el = new changedRows();
			ArrayList rows = new ArrayList();
			foreach (DataRelation rel in dr.Table.ChildRelations)
			{
				foreach (DataRow row in dr.GetChildRows(rel))
				{
					if (row.Table.ChildRelations.Count > 0)
						removeChildRows(row, changedrows);

					rows.Clear();
					//verificar se a row está no arraylist com as linhas alteradas
					if (row.RowState == DataRowState.Added || row.RowState == DataRowState.Deleted || row.RowState == DataRowState.Modified)
					{
						el = getChangedRowsElement(changedrows, row.Table.TableName);
						el.rowsAdd.Remove(row);
						el.rowsMod.Remove(row);
						el.rowsDel.Remove(row);
					}
					row.Table.Rows.Remove(row);
				}
			}
		}
Пример #35
0
            protected override bool DrawBackground(Graphics g, Rectangle bounds, int rowNum,
                                                   Brush backBrush, System.Data.DataRow dr)
            {
                Brush background = backBrush;
                bool  bSelAll    = false,
                      bSel       = (((SolidBrush)backBrush).Color != Owner.SelectionBackColor) ? false : true;

                if (bSel == false)
                {// вообще-то не выделена, но иногда надо выделить
                    switch (this.TableInd)
                    {
                    case NSI.BD_DIND:
                        if (MainF.drEasyEdit == dr)
                        {    // режим быстрого ввода
                            background = this.SelBackBrush;
                            bSelAll    = true;
                        }
                        else
                        {     // возможны и другие цвета
                            if ((null != this.AltSolidBrush) || (null != this.AltSolidBrushSpec))
                            { // If have alternating brush, row is odd and not selected...
                                if (System.DBNull.Value != dr["READYZ"])
                                {
                                    NSI.READINESS nState = (NSI.READINESS)dr["READYZ"];
                                    if (nState == NSI.READINESS.FULL_READY)
                                    {
                                        background = this.AltSolidBrush;                             // Then use alternating brush.
                                    }
                                    else
                                    {
                                        if (this.AltSolidBrushSpec != null)
                                        {
                                            //if ((int)dr["COND"] == (int)NSI.SPECCOND.PARTY_SET)
                                            //    background = this.AltSolidBrushSpec;                         // Then use alternating brush.
                                            if ((((int)dr["COND"] & (int)NSI.SPECCOND.DATE_SET_EXACT) > 0) &&
                                                (this.MappingName == "DVR"))
                                            {
                                                background = this.AltSolidBrushSpec;                             // Then use alternating brush.
                                            }
                                        }
                                    }
                                }
                                if (this.MappingName == "KOLM")
                                {
                                    background = this.AltSolidBrushSpec;                             // Then use alternating brush.
                                }
                            }
                        }
                        break;

                    case NSI.BD_DOUTD:
                        if (null != this.AltSolidBrush)
                        {
                            //if (( (xF.xCDoc.nTypOp == AppC.TYPOP_PRMK)||(xF.xCDoc.nTypOp == AppC.TYPOP_MARK))


                            if ((xF.xCDoc.xDocP.nTypD == AppC.TYPD_OPR) &&
                                (this.MappingName == "SNM"))
                            {
                                if (((int)dr["STATE"] & (int)AppC.OPR_STATE.OPR_TRANSFERED) > 0)
                                {
                                    background = this.AltSolidBrush;
                                }
                            }
                            else
                            {
                                if (dr.GetChildRows(NSI.REL2BRK).Length > 0)
                                {
                                    //if (this.MappingName == "KOLE")
                                    background = this.AltSolidBrush;                    // Для строк с браком
                                }
                            }
                        }
                        if (null != this.AltSolidBrushSpec)
                        {
                            if (((int)dr["NPODDZ"] < 0) &&
                                (this.MappingName == "KOLE"))
                            {
                                background = this.AltSolidBrushSpec;
                            }
                        }
                        break;
                    }



                    //if (this.TableInd == NSI.BD_DIND)
                    //{// колонка для заявок
                    //    if (MainF.drEasyEdit == dr)
                    //    {// режим быстрого ввода
                    //        background = this.SelBackBrush;
                    //        bSelAll = true;
                    //    }
                    //    else
                    //    {// возможны и другие цвета
                    //        if ((null != this.AltSolidBrush) || (null != this.AltSolidBrushSpec))
                    //        {                                                                   // If have alternating brush, row is odd and not selected...
                    //            if ((bSel == false) && (System.DBNull.Value != dr["READYZ"]))
                    //            {
                    //                NSI.READINESS nState = (NSI.READINESS)dr["READYZ"];
                    //                if (nState == NSI.READINESS.FULL_READY)
                    //                    background = this.AltSolidBrush;                         // Then use alternating brush.
                    //                else
                    //                {
                    //                    if (this.AltSolidBrushSpec != null)
                    //                    {
                    //                        if (((System.DBNull.Value != dr["NP"]) && ((int)dr["NP"] > 0)))
                    //                            background = this.AltSolidBrushSpec;                         // Then use alternating brush.
                    //                    }
                    //                }
                    //            }
                    //        }
                    //    }
                    //}
                }

                g.FillRectangle(background, bounds);
                return(bSelAll);
            }
Пример #36
0
        internal void EvaluateDependentExpressions(List<DataColumn> columns, DataRow row, DataRowVersion version, List<DataRow> cachedRows) {
            if (columns == null)
                return;
            //Expression evaluation is done first over same table expressions.
            int count = columns.Count;
            for(int i = 0; i < count; i++) {
                if (columns[i].Table == this) {// if this column is in my table
                    DataColumn dc = columns[i];
                    if (dc.DataExpression != null && dc.DataExpression.HasLocalAggregate()) {
                    // if column expression references a local Table aggregate we need to recalc it for the each row in the local table
                        DataRowVersion expressionVersion  = (version == DataRowVersion.Proposed) ? DataRowVersion.Default : version;
                        bool isConst = dc.DataExpression.IsTableAggregate(); //is expression constant for entire table?
                        object newValue = null;
                        if (isConst) {  //if new value, just compute once
                            newValue = dc.DataExpression.Evaluate(row, expressionVersion);
                        }
                        for (int j = 0; j < Rows.Count; j++) { //evaluate for all rows in the table
                            DataRow dr = Rows[j];
                            if (dr.RowState == DataRowState.Deleted) {
                                continue;
                            }
                            else if (expressionVersion == DataRowVersion.Original && (dr.oldRecord == -1 || dr.oldRecord == dr.newRecord)) {
                                continue;
                            }

                            if (!isConst) {
                                newValue = dc.DataExpression.Evaluate(dr, expressionVersion);
                            }
                            SilentlySetValue(dr, dc, expressionVersion, newValue);
                        }
                    }
                    else {
                        if (row.RowState == DataRowState.Deleted) {
                            continue;
                        }
                        else if (version == DataRowVersion.Original && (row.oldRecord == -1 || row.oldRecord == row.newRecord)) {
                            continue;
                        }
                        SilentlySetValue(row, dc, version, dc.DataExpression == null ? dc.DefaultValue : dc.DataExpression.Evaluate(row, version));
                    }
                }
            }
            // now do expression evaluation for expression columns other tables.
            count = columns.Count;
            for(int i = 0; i < count; i++) {
                DataColumn dc = columns[i];
                // if this column is NOT in my table or it is in the table and is not a local aggregate (self refs)
                if (dc.Table != this || (dc.DataExpression != null && !dc.DataExpression.HasLocalAggregate())) {
                    DataRowVersion foreignVer = (version == DataRowVersion.Proposed) ? DataRowVersion.Default : version;

                    // first - evaluate expressions for cachedRows (deletes & updates)
                    if (cachedRows != null) {
                        foreach (DataRow cachedRow in cachedRows) {
                            if (cachedRow.Table != dc.Table)
                                continue;
                             // don't update original version if child row doesn't have an oldRecord.
                            if (foreignVer == DataRowVersion.Original && cachedRow.newRecord == cachedRow.oldRecord)
                                 continue;
                            if (cachedRow != null && ((cachedRow.RowState != DataRowState.Deleted) && (version != DataRowVersion.Original || cachedRow.oldRecord != -1))) {// if deleted GetRecordFromVersion will throw
                                object newValue = dc.DataExpression.Evaluate(cachedRow, foreignVer);
                                SilentlySetValue(cachedRow, dc, foreignVer, newValue);
                            }
                        }
                    }

                    // next check parent relations
                    for (int j = 0; j < ParentRelations.Count; j++) {
                        DataRelation relation = ParentRelations[j];
                        if (relation.ParentTable != dc.Table)
                            continue;
                        foreach (DataRow parentRow in row.GetParentRows(relation, version)) {
                            if (cachedRows != null && cachedRows.Contains(parentRow))
                                continue;
                             // don't update original version if child row doesn't have an oldRecord.
                            if (foreignVer == DataRowVersion.Original && parentRow.newRecord == parentRow.oldRecord)
                                 continue;
                            if (parentRow != null && ((parentRow.RowState != DataRowState.Deleted) && (version != DataRowVersion.Original || parentRow.oldRecord != -1))) {// if deleted GetRecordFromVersion will throw
                                object newValue = dc.DataExpression.Evaluate(parentRow, foreignVer);
                                SilentlySetValue(parentRow, dc, foreignVer, newValue);
                            }
                        }
                    }
                    // next check child relations
                    for (int j = 0; j < ChildRelations.Count; j++) {
                        DataRelation relation = ChildRelations[j];
                        if (relation.ChildTable != dc.Table)
                            continue;
                        foreach (DataRow childRow in row.GetChildRows(relation, version)) {
                            // don't update original version if child row doesn't have an oldRecord.
                            if (cachedRows != null && cachedRows.Contains(childRow))
                                continue;
                            if (foreignVer == DataRowVersion.Original && childRow.newRecord == childRow.oldRecord)
                                continue;
                            if (childRow != null && ((childRow.RowState != DataRowState.Deleted) && (version != DataRowVersion.Original || childRow.oldRecord != -1))) { // if deleted GetRecordFromVersion will throw
                                object newValue = dc.DataExpression.Evaluate(childRow, foreignVer);
                                SilentlySetValue(childRow, dc, foreignVer, newValue);
                            }
                        }
                    }
                }
            }
        }
Пример #37
0
        // Move regions that are marked in ROM as nested children of row/rowElement as last children in XML fragment
        private void FixNestedChildren(DataRow row, XmlElement rowElement)
        {
            foreach (DataRelation dr in GetNestedChildRelations(row))
            {
                foreach (DataRow r in row.GetChildRows(dr))
                {
                    XmlElement childElem = r.Element;
                    // childElem can be null when we create XML from DataSet (XmlDataDocument( DataSet ) is called) and we insert rowElem of the parentRow before
                    // we insert the rowElem of children rows.
                    if (childElem != null)
                    {
#if DEBUG
                        bool fIsChildConnected = IsConnected(childElem);
#endif
                        if (childElem.ParentNode != rowElement)
                        {
                            childElem.ParentNode.RemoveChild(childElem);
                            rowElement.AppendChild(childElem);
                        }
#if DEBUG
                        // We should not have changed the connected/disconnected state of the node (since the row state did not change)
                        Debug.Assert(fIsChildConnected == IsConnected(childElem));
                        Debug.Assert(IsRowLive(r) ? IsConnected(childElem) : !IsConnected(childElem));
#endif
                    }
                }
            }
        }