//This function takes the data from the project file and loads it into memory. void ParseLine(string L) { string[] data; string[] IDs; int Chans; data = L.Split(','); //Data format - Record Type - Record Start //Record types - An = Animal, Fl = File, Gp = Group, Lb = Label. if (data[0].IndexOf("Fl") != -1) { DateTime TempDate; try { TempDate = ConvertFileToDT(data[1]); //Get the ACQ info. int.TryParse(data[3],out Chans); IDs = new string[Chans]; for (int i = 0; i < Chans; i++) { IDs[i] = data[4+i]; } FileType F = new FileType(IDs, Chans, TempDate, data[2]); Files.Add(F); } catch { Console.WriteLine("FAILURE IN DATE PARSE"); } } else if (data[0].IndexOf("Gp") != -1) { GroupType G = new GroupType(data[1], data[2], data[3]); Groups.Add(G); } else if (data[0].IndexOf("Lb") != -1) { LabelType Lb = new LabelType(data[1], data[2]); Labels.Add(Lb); } else if (data[0].IndexOf("An") != -1) { int CurrentAnimal = FindAnimal(data[1]); switch (data[2]) { case " gp": int.TryParse(data[3], out Animals[CurrentAnimal].Group.IDNum); Animals[CurrentAnimal].Group.Name = data[4]; break; case " wt": WeightType W = new WeightType(data[3], data[4], data[5]); Animals[CurrentAnimal].WeightInfo.Add(W); break; case " sz": SeizureType S; if (data.Length == 8) { //Old way - no severity score S = new SeizureType(data[3], data[4], data[5], data[6], data[7]); } else { //New way, has severity info S = new SeizureType(data[3], data[4], data[5], data[6], data[7], data[8]); } Animals[CurrentAnimal].Sz.Add(S); break; case " ml": MealType M = new MealType(data[3], data[4], data[5]); Animals[CurrentAnimal].Meals.Add(M); break; case " dt": ImportantDateType I = new ImportantDateType(data[3], data[4]); Animals[CurrentAnimal].ImportantDates.Add(I); break; default: Console.WriteLine(data[2] + ": ERROR IN COMPARE"); break; } } }
void ParseLineDuplicate(string L) { string[] data; string[] IDs; bool Pass; //Check if Data Is duplicated; int Chans; data = L.Split(','); //Data format - Record Type - Record Start //Record types - An = Animal, Fl = File, if (data[0].IndexOf("Fl") != -1) { DateTime TempDate; try { TempDate = ConvertFileToDT(data[1]); //Get the ACQ info. int.TryParse(data[3], out Chans); IDs = new string[Chans]; for (int i = 0; i < Chans; i++) { IDs[i] = data[4 + i]; } FileType F = new FileType(IDs, Chans, TempDate, data[2]); Pass=true; foreach (FileType C in Files) { if (C.Compare(F)) Pass = false; } if (Pass) Files.Add(F); } catch { Console.WriteLine("FAILURE IN DATE PARSE"); } } else if (data[0].IndexOf("Gp") != -1) { //Need to make sure group is not duplicated int tempG; int.TryParse(data[3], out tempG); bool pass = true; foreach (GroupType G in Groups) { if (G.IDNum == tempG) pass = false; } if (pass) { GroupType G = new GroupType(data[3], data[4], data[5]); Groups.Add(G); } } else if (data[0].IndexOf("Lb") != -1) { int tempL; int.TryParse(data[3], out tempL); bool pass = true; foreach (LabelType Lb in Labels) { if (Lb.IDNum == tempL) pass = false; } if (pass) { LabelType Lb = new LabelType(data[3], data[4]); Labels.Add(Lb); } } else if (data[0].IndexOf("An") != -1) { int CurrentAnimal = FindAnimal(data[1]); //data[2].Replace(" ", string.Empty); switch (data[2]) { case " wt": WeightType W = new WeightType(data[3], data[4], data[5]); Pass = true; Animals[CurrentAnimal].WeightInfo.Add(W); break; case " sz": SeizureType S = new SeizureType(data[3], data[4], data[5], data[6], data[7]); Pass = true; foreach (SeizureType C in Animals[CurrentAnimal].Sz) { if (C.Compare(S)) Pass = false; } if (Pass) Animals[CurrentAnimal].Sz.Add(S); break; case " ml": MealType M = new MealType(data[3], data[4], data[5]); Pass = true; foreach (MealType C in Animals[CurrentAnimal].Meals) { if (C.Compare(M)) Pass = false; } if (Pass) Animals[CurrentAnimal].Meals.Add(M); break; case " id": ImportantDateType I = new ImportantDateType(data[4], data[3]); Animals[CurrentAnimal].ImportantDates.Add(I); break; case " gp": //If the animal doesn't have a group, assign one, otherwise, ignore. if (Animals[CurrentAnimal].Group.IDNum == 0) { int.TryParse(data[3], out Animals[CurrentAnimal].Group.IDNum); Animals[CurrentAnimal].Group.Name = data[4]; } break; default: Console.WriteLine(data[2] + ": ERROR IN COMPARE"); break; } } }
public void AddWeight(string AID, int Wt, int Pt, DateTime dt) { int An = FindAnimal(AID); WeightType W = new WeightType(dt.ToShortDateString(), Wt.ToString(), Pt.ToString()); Animals[An].WeightInfo.Add(W); }