private static DataTable GetParentLines(DataTable table) { Hashtable parentlist = new Hashtable(); DataView view = new DataView(table); DataTable distinctvalues = view.ToTable(true, "ParentTrackElement"); while (distinctvalues.Rows.Count > 0) { DataRow row = distinctvalues.Rows[0]; if (row["ParentTrackElement"] != System.DBNull.Value) { DataRow datarow = table.Select("EquipmentID = " + (double)row["ParentTrackElement"])[0]; eLine line = new eLine(); line.id = (string)datarow["Sector"]; line.description = (string)datarow["Description"]; _model.infrastructure.trackGroups.line.Add(line); functionalLocation loc = new functionalLocation(); loc.sectorID = line.id; loc.name = line.description; datarow.Delete(); } row.Delete(); } return(table); }
private static void GetTracks(DataTable table) { foreach (DataRow row in table.Rows) { if (row.RowState != DataRowState.Deleted && !(bool)row["removed"])// && (string)row["ElementUsage"] != "C" && (string)row["ElementUsage"] != "F" && (string)row["ElementUsage"] != "A") { eTrack track = new eTrack() { id = (row["Serial Number"] as string) ?? null, description = (row["Description"] as string) ?? null }; track.trackTopology.trackBegin.pos = (decimal)(((row["StartMiles"] as double?) ?? 0) + ((row["StartYards"] as double?) ?? 0) / 1760); track.trackTopology.trackEnd.pos = (decimal)(((row["EndMiles"] as double?) ?? 0) + ((row["EndYards"] as double?) ?? 0) / 1760); if ((string)row["Type"] == "UR") { track.mainDir = tExtendedDirection.up; } else if ((string)row["Type"] == "DR") { track.mainDir = tExtendedDirection.down; } else { track.mainDir = tExtendedDirection.none; } if (row["Road"] is DBNull) { track.type = "connectingTrack"; } else if ((string)row["Road"] == "MAIN") { track.type = "mainTrack"; } else if ((string)row["Road"] == "BAY") { track.type = "stationTrack"; } else { track.type = "sidingTrack"; } if ((string)row["ElementUsage"] != "C" && (string)row["ElementUsage"] != "A") { track.trackDescr = new List <string>(); track.trackDescr.Add("Closed/Abandoned"); } if (row["ParentTrackElement"] != System.DBNull.Value) { eLine line = _model.infrastructure.trackGroups.line.Find(x => x.id == (string)row["Sector"]); line.trackRef.Add(new tTrackRefInGroup() { @ref = track.id }); } track = GetTrackCoords(track, row["EquipmentID"].ToString()); _model.infrastructure.tracks.Add(track); } } }