public virtual void removeActivity(Activity activity) { if (activity.getDay().getnDay() > DateTimeExtension.marsToday) { this.actList.Remove(activity); } }
//add activity public virtual void assignActivity(Activity activity) { //if (activity.getDay().getnDay() > DateTimeExtension.marsToday) { actList.Add(activity); } }
public static void addActivity(XDocument doc, Activity activity, string activityPlanFile) { int ID = activity.getMyType().getID(); XElement act = activity.generateXmlElement(); doc.Descendants("ActType").Where(x => x.Attribute("ID").Value == ID.ToString()).Single().Descendants("ActivityList").FirstOrDefault().Add(act); doc.Save(activityPlanFile); }
//, int nDay, int start, int end, int X, int Y) public static void deleteActivity(XDocument doc, Activity activity, string activityPlanFile) { int nDay = activity.getDay().getnDay(); int start = activity.getTimeSlot().getStart(); int end = activity.getTimeSlot().getEnd(); int X = activity.getLocation().getCoordX(); int Y = activity.getLocation().getCoordY(); // On peut ajouter les autres critères s'il existe plusieur activité en même temps même location doc.Descendants("Activity").Where(x => x.Descendants("nDay").FirstOrDefault().Value == nDay.ToString() && x.Descendants("start").FirstOrDefault().Value == start.ToString() && x.Descendants("X").FirstOrDefault().Value == X.ToString() && x.Descendants("Y").FirstOrDefault().Value == Y.ToString()).Single().Remove(); doc.Save(activityPlanFile); }
public static void importPlan(XDocument doc, List<ActType> actTypeList, Mission mission) { foreach (XElement activity in doc.Descendants("Activity")) { int idType = Int32.Parse(activity.Parent.Parent.Attribute("ID").Value); ActType actType = actTypeList[idType - 1]; int d = Int32.Parse(activity.Element("Day").Element("nDay").Value); Day day = new Day(d); Day checkDay = mission.checkDayList(day); if (checkDay == null) { mission.addDay(day); } else { day = checkDay; } int timeslotBegin = Int32.Parse(activity.Element("timeSlot").Element("start").Value); int timeslotEnd = Int32.Parse(activity.Element("timeSlot").Element("end").Value); TimeSlot timeSlot = new TimeSlot(timeslotBegin, timeslotEnd); string locName = activity.Element("Location").Element("Name").Value; int x = Int32.Parse(activity.Descendants("X").FirstOrDefault().Value); int y = Int32.Parse(activity.Descendants("Y").FirstOrDefault().Value); Location location = new Location(locName, new Position(x, y)); Location checkLocation = mission.checkLocationList(location); if (checkLocation == null) { mission.addLocation(location); } else { location = checkLocation; } List<Astronaut> astrList = new List<Astronaut>(); foreach (XElement astronaut in activity.Descendants("Astronaut")) { string astroName = astronaut.Element("Name").Value; Astronaut member = new Astronaut(astroName); Astronaut checkMember = mission.checkAstronaut(member); if (checkMember == null) { mission.addAstronaut(member); } else { member = checkMember; } astrList.Add(member); } string Desc = activity.Element("Desc").Value; Activity act = new Activity(actType, day, timeSlot, location, astrList, Desc); act.update(); } }