Пример #1
0
 public static string GetMarkers()
 {
     if (HttpContext.Current.User.Identity.IsAuthenticated)
     {
         string _serialedMessages = JsonConvert.SerializeObject(UIGTSTracer.GetCurrentTrackersInfo());
         return("{\"Markers\":" + _serialedMessages + "}");
     }
     return("{\"Markers\": []}");
 }
Пример #2
0
 public static string GetTrackerHistory(string trackerId, string selectedDate, int timeInterval)
 {
     if (HttpContext.Current.User.Identity.IsAuthenticated)
     {
         //Date is being passed in as mm/dd/yyyy
         string[] _parseDateString          = selectedDate.Split('/');
         DateTime _startDate                = new DateTime(int.Parse(_parseDateString[2]), int.Parse(_parseDateString[0]), int.Parse(_parseDateString[1]), (timeInterval - 1) * 6, 0, 0);
         DateTime _endDate                  = new DateTime(_startDate.Year, _startDate.Month, _startDate.Day, (timeInterval * 6) - 1, 59, 59);
         GTSLocationMessageHistory _history = UIGTSTracer.GetTrackerInfoByDate(trackerId, _startDate, _endDate);
         string _serialedMessages           = JsonConvert.SerializeObject(_history);
         return("{\"History\":" + _serialedMessages + "}");
     }
     return("{\"History\": []}");
 }
Пример #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            MembershipUser _currentUser = Membership.GetUser();

            List <GTSLocationMessage>         userCurrentTrackerInfo = UIGTSTracer.GetCurrentTrackersInfo();
            List <GTSBizObjects.Events.Event> currentUserEvents      = new GTSBizObjects.Events.Management().GetEventsCurrentUser((Guid)_currentUser.ProviderUserKey);

            int speedEventCount     = 0;
            int idleEventCount      = 0;
            int attentionEventCount = 0;

            List <string> trackersWithSpeedEvent     = new List <string>();
            List <string> trackersWithIdleEvent      = new List <string>();
            List <string> trackersWithAttentionEvent = new List <string>();

            foreach (GTSBizObjects.Events.Event item in currentUserEvents)
            {
                if (item.GetTrackerEventType == (int)GTSBizObjects.Events.Enums.TrackerEventTypes.Speeding)
                {
                    speedEventCount += 1;
                    if (!(trackersWithSpeedEvent.Contains(item.ObjectId)))
                    {
                        trackersWithSpeedEvent.Add(item.ObjectId);
                    }
                }
                if (item.GetTrackerEventType == (int)GTSBizObjects.Events.Enums.TrackerEventTypes.ExcessiveIdle)
                {
                    idleEventCount += 1;
                    if (!(trackersWithIdleEvent.Contains(item.ObjectId)))
                    {
                        trackersWithIdleEvent.Add(item.ObjectId);
                    }
                }
                if (item.GetTrackerEventType == (int)GTSBizObjects.Events.Enums.TrackerEventTypes.LowBattery ||
                    item.GetTrackerEventType == (int)GTSBizObjects.Events.Enums.TrackerEventTypes.GPSAntennaCut ||
                    item.GetTrackerEventType == (int)GTSBizObjects.Events.Enums.TrackerEventTypes.EnterGPSBlindArea)
                {
                    attentionEventCount += 1;
                    if (!(trackersWithAttentionEvent.Contains(item.ObjectId)))
                    {
                        trackersWithAttentionEvent.Add(item.ObjectId);
                    }
                }
            }

            List <DashboardViewModel> dashboardDataList = new List <DashboardViewModel>();

            foreach (GTSLocationMessage item in userCurrentTrackerInfo)
            {
                DashboardViewModel dashboardRecord = new DashboardViewModel();
                dashboardRecord.TrackerName          = item.TrackerDetail.Name;
                dashboardRecord.TrackerId            = item.TrackerID;
                dashboardRecord.DetailsNavigationURL = "MyTrack.aspx?Id=" + item.TrackerID;

                int      timeSlice   = 1;
                TimeSpan slice1Start = new TimeSpan(0, 0, 0);
                TimeSpan slice2Start = new TimeSpan(6, 0, 0);
                TimeSpan slice3Start = new TimeSpan(12, 0, 0);
                TimeSpan slice4Start = new TimeSpan(18, 0, 0);
                TimeSpan now         = DateTime.Now.TimeOfDay;

                if (now >= slice1Start && now < slice2Start)
                {
                    timeSlice = 1;
                }
                else if (now >= slice2Start && now < slice3Start)
                {
                    timeSlice = 2;
                }
                else if (now >= slice3Start && now < slice4Start)
                {
                    timeSlice = 3;
                }
                else
                {
                    timeSlice = 4;
                }

                dashboardRecord.HistoryNavigationURL = "History.aspx?timeSlice=" + timeSlice.ToString() + "&histDate=" + DateTime.Now.Month + "/" + DateTime.Now.Day + "/" + DateTime.Now.Year + "&currTrackerId=" + item.TrackerID;

                dashboardRecord.TrackerMileage = Math.Floor(item.Mileage.HasValue? item.Mileage.Value : 0.0);
                dashboardRecord.TrackerSpeed   = Math.Round(item.Speed, 2).ToString() + " KPH";
                if (trackersWithSpeedEvent.Contains(item.TrackerID))
                {
                    dashboardRecord.TrackerSpeedClass = SPEED_EVENT_CSS_CLASS;
                }
                else
                {
                    dashboardRecord.TrackerSpeedClass = SPEED_NORMAL_CSS_CLASS;
                }

                if (trackersWithAttentionEvent.Contains(item.TrackerID))
                {
                    dashboardRecord.NeedsAttention = true;
                }
                else
                {
                    dashboardRecord.NeedsAttention = false;
                }

                dashboardDataList.Add(dashboardRecord);
            }

            this.txtEventCount.InnerText      = currentUserEvents.Count.ToString();
            this.txtIdleEventCount.InnerText  = trackersWithIdleEvent.Count.ToString();
            this.txtSpeedEventCount.InnerText = trackersWithSpeedEvent.Count.ToString();

            this.trackerList.DataSource = dashboardDataList;
            this.trackerList.DataBind();
        }