//get all data columms for a particular machine public static List <MachineData> GetIndividualMachineData(string machineName) { var tempList = new List <MachineData>(); var dt = MachineDataDb.GetMachineData(); foreach (DataRow row in dt.Rows) { var data = new MachineData() { MachineName = row.Field <string>(0), Level = row.Field <string>(1), Rate = float.Parse(row.Field <string>(2)) }; if (data.MachineName == machineName) { tempList.Add(data); } ; } return(tempList); }
//<summary>Get list of levels from the text file database. </summary> //<returns>list<string></string></returns> public static List <string> Levels() { //Handler variables var path = dataPath; var tempList = new List <string>(); var dt = new DataTable(); //Collect data from the database dt = ImportData.GetTextFileData(path); //Use a try .. catch block to trap errors found try { //Iterate through the data rows to find unique machine names foreach (DataRow row in dt.Rows) { //useing an object to hold the data from each row //Intellisense will know valid object field item in the row of data var lineData = new MachineData { MachineName = row.Field <string>(0), Level = row.Field <string>(1) }; if (!Utility.StringFound(tempList, lineData.Level)) { tempList.Add(lineData.Level); } } } catch (Exception) { throw; } //return the list return(tempList); }