DataRow[] unitRows =
taskUnitDb.Select("GeoID=" + rootNode.ObjEntity.ObjID + " and NavigateID=" +
rootNode.ObjEntity.NavigateID + " and UnitID=" + unitID +
" and OrganizationID=" + rootNode.ObjEntity.OrgID + " and WorkID =" + AppGlobal.WorkID);
//去掉重复单元
var distinctRows = unitRows.AsEnumerable().Cast<DataRow>()
.Select(row => new
{
GeoID = row.Field<int>("GeoID"),
NavigateID = row.Field<int>("NavigateID"),
UnitID = row.Field<int>("UnitID"),
OrganizationID = rootNode.ObjEntity.OrgID,
WorkID = AppGlobal.WorkID,
UnitName = row.Field<string>("UnitName"),
UnitEnumType = row.Field<string>("UnitEnumType")
})
.Distinct().ToList();
foreach (var dr in distinctRows)
{
string id = dr.UnitID + "";
string name = dr.UnitName;
OfEntityObjectType objType =
(OfEntityObjectType)Enum.Parse(typeof(OfEntityObjectType), dr.UnitEnumType);
// 绑定单元(计算单元、开发单元、评估单元)
childNode = CreateAbstractNode(rootNode.ObjEntity.ObjID, name, objType, rootNode);
childNode.ObjEntity.UnitID = id;
childNode.ObjEntity.UnitName = name;
childNode.ObjEntity.NodeEnumType = NodeEnumType.Unit;
childNode.ObjEntity.Wells = Well.GetWellsInUnit(int.Parse(id));
if (childNode != null)
rootNode.Nodes.Add(childNode);
}
注意项目需要添加System.Data.DataSetExtensions引用