コード例 #1
0
        public HttpResponseMessage GetListOfLocationData(JQueryDTRequestDeviceData model)
        {
            int FixedLength = Convert.ToInt32(model.RecordToDisply);
            int SkipStart   = (Convert.ToInt32(model.CurrentPage) * FixedLength);

            int pages        = (SkipStart + FixedLength) / FixedLength;
            int TotalRecords = 0;
            int?timeframe    = 0;

            //IEnumerable<LocationData> lstLocationData = null;
            IEnumerable <RtlsNotificationData> lstLocationData = null;

            try
            {
                //var objRtlsConfiguration = db.RtlsConfiguration.FirstOrDefault(m => m.SiteId == model.SiteId);
                //var row = db.LocationData.Where(m => m.sn == objRtlsConfiguration.EngageSiteName); // IsDIsplay =m.IsDeviceRegisterInRtls
                lstLocationData = db.RtlsNotificationData;
                TotalRecords    = lstLocationData.Count();
                lstLocationData = db.RtlsNotificationData.OrderByDescending(m => m.NotifyDateTime).ToList().Skip(SkipStart).Take(FixedLength);
                //var _rtlsDataAsPerSite = db.RtlsConfiguration.Where(m => m.SiteId == model.SiteId).FirstOrDefault();
                //timeframe = _rtlsDataAsPerSite.TimeFrame;
            }
            catch (Exception ex)
            {
                log.Error(ex.InnerException.Message);
            }
            return(new HttpResponseMessage()
            {
                Content = new StringContent(JsonConvert.SerializeObject(new
                {
                    CurrentPage = pages,
                    TotalRecords = TotalRecords,
                    RecordToDisply = FixedLength,
                    TimeFrame = timeframe,
                    lstLocationData
                }), Encoding.UTF8, "application/json")
            });
        }
コード例 #2
0
        public HttpResponseMessage AjaxGetListOfMacAddress(JQueryDTRequestDeviceData model)
        {
            int FixedLength        = Convert.ToInt32(model.RecordToDisply);
            int SkipStart          = (Convert.ToInt32(model.CurrentPage) * FixedLength);
            var OmniEngine         = (Convert.ToInt32(DeviceRegisteredInEngine.OmniEngine));
            var EngageEngine       = (Convert.ToInt32(DeviceRegisteredInEngine.EngageEngine));
            int pages              = (SkipStart + FixedLength) / FixedLength;
            int TotalRecords       = 0;
            int TotalOmniRecords   = 0;
            int TotalEngageRecords = 0;

            IEnumerable <RTLSSetUpReturnDto> OmniMaclist = null;
            IEnumerable EngageMaclist = null;

            try
            {
                if (db.RtlsConfiguration.Any(m => m.SiteId == model.SiteId))
                {
                    OmniMaclist = (from dvcAssociate in db.DeviceAssociateSite.Where(m => m.SiteId == model.SiteId && m.DeviceRegisteredInEngineTypeId != 0)
                                   join wifiCred in db.WifiUserLoginCredential.Where(m => m.SiteId == model.SiteId)
                                   on dvcAssociate.DeviceId equals wifiCred.DeviceId into dvc_Cred_Joined
                                   from wifiCred in dvc_Cred_Joined.DefaultIfEmpty()
                                   select new RTLSSetUpReturnDto
                    {
                        Id = dvcAssociate.SiteId,
                        Mac = dvcAssociate.Device.MacAddress,
                        omniUniqueId = dvcAssociate.Device.OmniDeviceMapping.UniqueId,
                        IsTrackByAdmin = dvcAssociate.IsTrackByAdmin,
                        IsEntryNotify = dvcAssociate.IsEntryNotify,
                        IsDisplay = dvcAssociate.IsTrackByRtls,
                        IsCreatedByAdmin = dvcAssociate.IsCreatedByAdmin,
                        Email = wifiCred.WifiUser.UserName,
                        FirstName = wifiCred.WifiUser.FirstName,
                        LastName = wifiCred.WifiUser.LastName,
                        Status = dvcAssociate.status.ToString()
                    });

                    TotalOmniRecords = OmniMaclist.Count();

                    OmniMaclist = OmniMaclist.ToList().Skip(SkipStart).Take(FixedLength);

                    foreach (var item in OmniMaclist)
                    {
                        item.FirstName = CommonHasher.Decrypt(item.FirstName, true);
                        item.LastName  = CommonHasher.Decrypt(item.LastName, true);
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.InnerException.Message);
            }
            return(new HttpResponseMessage()
            {
                Content = new StringContent(JsonConvert.SerializeObject(new
                {
                    CurrentPage = pages,
                    TotalRecords = TotalRecords,
                    TotalOmniRecords = TotalOmniRecords,
                    TotalEngageRecords = TotalEngageRecords,
                    RecordToDisply = FixedLength,
                    OmniMaclist,
                    EngageMaclist
                }), Encoding.UTF8, "application/json")
            });
        }