Exemple #1
0
        public void LoadTrackers(int id)
        {
            lbTrackers.Items.Clear();
            lbNotTrackers.Items.Clear();

            int selectedFence = Convert.ToInt32(dlFences.SelectedValue);

            var ids      = new List <long>();
            var trackers = TrackerManager.GetByUserId(Membership.GetUser().ProviderUserKey.ToString());

            var trackerFences = TrackerFenceMapManager.GetByFenceId(selectedFence);

            foreach (var item in trackerFences)
            {
                if (item.FencesId == selectedFence)
                {
                    var tracker = TrackerManager.GetById(Convert.ToString(item.TrackerId));
                    if (!String.IsNullOrWhiteSpace(tracker.Id))
                    {
                        lbTrackers.Items.Add(new ListItem(tracker.Name, tracker.Id.ToString()));
                        ids.Add(Convert.ToInt64(item.TrackerId));
                    }
                }
            }

            foreach (var trackr in trackers)
            {
                if (!ids.Contains(Convert.ToInt64(trackr.Id)))
                {
                    lbNotTrackers.Items.Add(new ListItem(trackr.Name, trackr.Id.ToString()));
                }
            }
        }
        public FenceTrackerModel GetTrackersByFenceId(int id)
        {
            var lstFences = new List <FencesModel>();
            var trackers  = TrackerManager.GetByUserId(Membership.GetUser().ProviderUserKey.ToString());

            var trackerFences = TrackerFenceMapManager.GetByFenceId(id);

            var tr = new FenceTrackerModel();

            tr.fenceId    = id;
            tr.TrackersIn = (from x in trackers
                             where trackerFences.Any(t => t.TrackerId == x.Id)
                             select new TrackerModel {
                Id = x.Id, Name = x.Name
            }).ToList();

            tr.TrackersOut = (from x in trackers
                              where !trackerFences.Any(t => t.TrackerId == x.Id)
                              select new TrackerModel {
                Id = x.Id, Name = x.Name
            }).ToList();

            return(tr);
        }