public static void AddFL(FallLocation fl) { //add to DATALayer Report report = FlToReport(fl); bl.AddReport(report); //add fitt gouplist string key = CreateKey(fl.Date); bool isAdded = false; foreach (var item in FallLocationData) { if (item.GruopId.Equals(key)) { item.FallsLocationlist.Add(fl); isAdded = true; break; } } if (!isAdded) { FallsLocationGroup flg = new FallsLocationGroup(key); flg.FallsLocationlist.Add(fl); FallLocationData.Add(flg); } if (DataChanged != null) { DataChanged.Invoke(); } ; }
//TODO need to add to SQL internal static void AddAFL(AccurateFallLocation afl) { string key = CreateKey(afl.Date); bool isAdded = false; List <Report> r = new List <Report>(); double[] latLog = bl.GetCoordinate(afl.Adress); DateTime enteredDate = DateTime.Parse(afl.Date); Drop d1 = new Drop { Drop_Id = afl.ID, Drop_Adress = afl.Adress, Drop_time = enteredDate, Reports_list = r, Real_lat = latLog[0], Real_log = latLog[1], Estimeated_lat = latLog[0], Estimeated_log = latLog[1], }; bl.AddDrop(d1); foreach (var item in FallLocationData) { if (item.GruopId.Equals(key)) { item.AccurateFallLocation = afl; isAdded = true; break; } } if (!isAdded) { FallsLocationGroup flg = new FallsLocationGroup(key) { AccurateFallLocation = afl }; FallLocationData.Add(flg); } if (DataChanged != null) { DataChanged.Invoke(); } ; }
public static ref ObservableCollection <FallsLocationGroup> GetData(Action <bool> callback) { lock (_getDataLock) { bool isSucceded = false; if (FallLocationData == null) { Task task = new Task(() => { try { FallLocationData = new ObservableCollection <FallsLocationGroup>(); //getting the falls from the Data Source and orderong it into list Dictionary <string, ObservableCollection <FallLocation> > locationData = new Dictionary <string, ObservableCollection <FallLocation> >(); string key; //TODO: get data of FallsAs a List as a List from SQL List <FallLocation> fallLocations = getDummyList(); //sort the FallLocations to the fit list fallLocations.ForEach(x => { key = CreateKey(x.Date); if (!locationData.ContainsKey(key)) { ObservableCollection <FallLocation> oc = new ObservableCollection <FallLocation> { x }; locationData.Add(key, oc); } else { locationData[key].Add(x); } }); //setting it into the map foreach (var item in locationData) { FallsLocationGroup flg = new FallsLocationGroup(item.Key); foreach (var item1 in item.Value) { if (item1 is AccurateFallLocation) { flg.AccurateFallLocation = new AccurateFallLocation((AccurateFallLocation)item1); } else { flg.FallsLocationlist.Add(item1); } } FallLocationData.Add(flg); } //getting the accurate falls from the Data Source and orderong it into list //TODO: get AccurateLocation From SQL; //TODO: add accurateFalls isSucceded = true; } catch (Exception e) { isSucceded = false; } }); task.Start(); while (task.Status == TaskStatus.Running) { Thread.Sleep(100); } callback(isSucceded); return(ref FallLocationData); } else { callback(isSucceded); return(ref FallLocationData); } } }