Ejemplo n.º 1
0
 private static IQueryable <BroadcastStations> SelectStringFields(RadioDevice primary, IQueryable <BroadcastStations> records)
 {
     if (primary != null && records != null)
     {
         if (!string.IsNullOrWhiteSpace(primary.NumSvid))
         {
             records = records.Where(x => x.NUM_SVID.Contains(primary.NumSvid));
         }
         if (!string.IsNullOrWhiteSpace(primary.Lat))
         {
             records = records.Where(x => x.LAT.Contains(primary.Lat));
         }
         if (!string.IsNullOrWhiteSpace(primary.Long))
         {
             records = records.Where(x => x.LONG.Contains(primary.Long));
         }
         if (!string.IsNullOrWhiteSpace(primary.Mac))
         {
             records = records.Where(x => x.MAC.Contains(primary.Mac));
         }
         if (!string.IsNullOrWhiteSpace(primary.ZavNum))
         {
             records = records.Where(x => x.ZAV_NUM.Contains(primary.ZavNum));
         }
         if (!string.IsNullOrWhiteSpace(primary.Ids))
         {
             records = records.Where(x => x.IDS.Contains(primary.Ids));
         }
     }
     return(records);
 }
Ejemplo n.º 2
0
        public ActionResult BrowseData()
        {
            var requestForm = Request?.Form;
            var allRecords  = RadioDevice.SearchRadioDevice(requestForm);

            return(View(allRecords));
        }
Ejemplo n.º 3
0
        private IQueryable <BroadcastStations> SelectByPrimaryCriteria(RadioDevice primary, IQueryable <BroadcastStations> records)
        {
            if (primary != null && records != null)
            {
                if (primary.Region.HasValue)
                {
                    records = records.Where(x => x.REGION == primary.Region);
                }
                if (Criteria != null)
                {
                    if (!Criteria.IsPrimaryIdResNull)
                    {
                        records = records.Where(x => x.ID_RES == primary.IdRes);
                    }
                }

                if (primary.UpdateDate.HasValue)
                {
                    records = records.Where(x => x.UPDATE_DATE >= primary.UpdateDate.Value.Date || x.UPDATE_DATE <= primary.UpdateDate.Value.Date.AddDays(1));
                }
                if (primary.DateSvid.HasValue)
                {
                    records = records.Where(x => x.DATE_SVID >= primary.DateSvid.Value.Date || x.DATE_SVID <= primary.DateSvid.Value.Date.AddDays(1));
                }
                if (primary.DelDate.HasValue)
                {
                    records = records.Where(x => x.DEL_DATE >= primary.DelDate.Value.Date || x.DEL_DATE <= primary.DelDate.Value.Date.AddDays(1));
                }
                if (primary.SrokSvid.HasValue)
                {
                    records = records.Where(x => x.SROK_SVID >= primary.SrokSvid.Value.Date || x.SROK_SVID <= primary.SrokSvid.Value.Date.AddDays(1));
                }
            }
            return(records);
        }
Ejemplo n.º 4
0
        public ActionResult DeleteAllRecords()
        {
            // ReSharper disable UnusedVariable
            var result = RadioDevice.DeleteAllRecords();

            // ReSharper restore UnusedVariable
            return(RedirectToAction("BrowseData", "RadioDevice"));
        }
Ejemplo n.º 5
0
        public ActionResult RecordPopup(string id)
        {
            var radioDevice = new RadioDevice();

            radioDevice.Boot(id);
            var view = View(radioDevice);

            return(view);
        }
        public ActionResult DeleteAllRecords()
        {
            // ReSharper disable UnusedVariable
            var result = RadioDevice.DeleteAllRecords();
            // ReSharper restore UnusedVariable
            var redirectToIndex = RedirectToAction("Index", "CramData");

            return(redirectToIndex);
        }
Ejemplo n.º 7
0
        public List <RadioDevice> FetchRecords()
        {
            var allRecords = new List <RadioDevice>();

            if (Repository?.BroadcastStations != null)
            {
                IQueryable <BroadcastStations> records = Repository.BroadcastStations;

                if (Criteria != null)
                {
                    var primary      = Criteria.PrimarySelectionCriteria;
                    var secondary    = Criteria.SecondarySelectionCriteria;
                    var useSecondary = Criteria.LetUseSecondary;

                    records = SelectStringFields(primary, records);
                    records = useSecondary
                        ? SelectByPrimaryAndSecondaryCriteria(primary, secondary, records)
                        : SelectByPrimaryCriteria(primary, records);
                }

                var selectedRecords = records?.ToArray();

                if (selectedRecords != null)
                {
                    foreach (var repositoryRecord in selectedRecords)
                    {
                        RadioDevice record = null;
                        if (repositoryRecord != null)
                        {
                            record = new RadioDevice
                            {
                                DateSvid   = repositoryRecord.DATE_SVID,
                                DelDate    = repositoryRecord.DEL_DATE,
                                IdRes      = repositoryRecord.ID_RES,
                                Ids        = repositoryRecord.IDS,
                                Lat        = repositoryRecord.LAT,
                                Long       = repositoryRecord.LONG,
                                Mac        = repositoryRecord.MAC,
                                NumSvid    = repositoryRecord.NUM_SVID,
                                Region     = repositoryRecord.REGION,
                                SrokSvid   = repositoryRecord.SROK_SVID,
                                UpdateDate = repositoryRecord.UPDATE_DATE,
                                ZavNum     = repositoryRecord.ZAV_NUM
                            };
                        }

                        if (record != null)
                        {
                            allRecords.Add(record);
                        }
                    }
                }
            }
            return(allRecords);
        }
Ejemplo n.º 8
0
        public RadioDevice GetRecord(long id)
        {
            RadioDevice device = null;

            var repository = Repository?.BroadcastStations;

            if (repository != null)
            {
                var stationRecord = repository.FirstOrDefault(r => r.ID_RES == id);

                if (stationRecord != null)
                {
                    device = new RadioDevice
                    {
                        DateSvid   = stationRecord.DATE_SVID,
                        DelDate    = stationRecord.DATE_SVID,
                        IdRes      = stationRecord.ID_RES,
                        Ids        = stationRecord.IDS,
                        Lat        = stationRecord.LAT,
                        Long       = stationRecord.LONG,
                        Mac        = stationRecord.MAC,
                        NumSvid    = stationRecord.NUM_SVID,
                        Region     = stationRecord.REGION,
                        SrokSvid   = stationRecord.SROK_SVID,
                        UpdateDate = stationRecord.UPDATE_DATE,
                        ZavNum     = stationRecord.ZAV_NUM
                    };
                }
                var signals = new List <RadioDevice.DeviceSignal>();
                if (stationRecord?.StationFrequencies != null)
                {
                    var frequenciesRecords = stationRecord.StationFrequencies;
                    foreach (var frequencyRecord in frequenciesRecords)
                    {
                        if (frequencyRecord != null)
                        {
                            var signal = new RadioDevice.DeviceSignal
                            {
                                Res = frequencyRecord.RES,
                                IdF = frequencyRecord.ID_F,
                                Rn  = frequencyRecord.RN,
                                Tn  = frequencyRecord.TN
                            };
                            signals.Add(signal);
                        }
                    }
                }
                if (device != null)
                {
                    device.RadioSignals = signals.ToArray();
                }
            }
            return(device);
        }
Ejemplo n.º 9
0
        private static BroadcastStations SingleRadioDeviceToBroadcastStations(RadioDevice device)
        {
            BroadcastStations station = null;

            if (device != null)
            {
                station = new BroadcastStations
                {
                    DATE_SVID   = device.DateSvid,
                    DEL_DATE    = device.DelDate,
                    IDS         = device.Ids,
                    ID_RES      = device.IdRes,
                    LAT         = device.Lat,
                    LONG        = device.Long,
                    MAC         = device.Mac,
                    NUM_SVID    = device.NumSvid,
                    REGION      = device.Region,
                    SROK_SVID   = device.SrokSvid,
                    UPDATE_DATE = device.UpdateDate,
                    ZAV_NUM     = device.ZavNum
                };

                var broadcastFrequencies = new EntitySet <StationFrequencies>();
                var radioSignals         = device.RadioSignals;
                var length = radioSignals?.Length;
                if (length > 0)
                {
                    foreach (var signal in radioSignals)
                    {
                        if (signal != null)
                        {
                            var frequrency = new StationFrequencies
                            {
                                RN = signal.Rn,
                                TN = signal.Tn
                            };
                            broadcastFrequencies.Add(frequrency);
                        }
                    }
                }

                station.StationFrequencies = broadcastFrequencies;
            }
            return(station);
        }
Ejemplo n.º 10
0
        public IDevice GetDevice(DpConstants.Devices deviceType)
        {
            IDevice device = null;

            switch (deviceType)
            {
                case DpConstants.Devices.Television:
                    device = new TelevisionDevice();
                    break;
                case DpConstants.Devices.Radio:
                    device = new RadioDevice();
                    break;
                default:
                    device = new RadioDevice();
                    break;
            }

            return device;
        }
Ejemplo n.º 11
0
        public IDevice GetDevice(DpConstants.Devices deviceType)
        {
            IDevice device = null;

            switch (deviceType)
            {
            case DpConstants.Devices.Television:
                device = new TelevisionDevice();
                break;

            case DpConstants.Devices.Radio:
                device = new RadioDevice();
                break;

            default:
                device = new RadioDevice();
                break;
            }

            return(device);
        }
Ejemplo n.º 12
0
 public SelectionCriteria()
 {
     PrimarySelectionCriteria   = new RadioDevice();
     SecondarySelectionCriteria = new RadioDevice();
 }