Esempio n. 1
0
        private static bool CheckStationApplicationCurrentState(DM.Tour tour, DTO.Station station)
        {
            using (var applicationsReader = Repository.ReadEntities <DM.NfraApplication>(source =>
            {
                source.SetWhere(MD.NfraApplication.Fields.ObjTable, IMRecordset.Operation.Eq, station.TableName);
                source.SetAdditional($"({station.TableId} in ([{MD.NfraApplication.Fields.ObjId1}], [{MD.NfraApplication.Fields.ObjId2}], [{MD.NfraApplication.Fields.ObjId3}], [{MD.NfraApplication.Fields.ObjId4}], [{MD.NfraApplication.Fields.ObjId5}], [{MD.NfraApplication.Fields.ObjId6}]))");
            }))
            {
                while (applicationsReader.Read())
                {
                    var application = applicationsReader.GetEntity();

                    var dateFrom   = application.DozvDateFrom;   // applicationRs.GetT(MD.NfraApplication.Fields.DozvDateFrom);
                    var dateTo     = application.DozvDateTo;     // applicationRs.GetT(MD.NfraApplication.Fields.DozvDateTo);
                    var dateCancel = application.DozvDateCancel; // applicationRs.GetT(MD.NfraApplication.Fields.DozvDateCancel);

                    if (!dateFrom.IsNull() && !dateTo.IsNull())
                    {
                        if (!dateCancel.IsNull() && dateCancel < dateTo)
                        {
                            dateTo = dateCancel;
                        }
                        if (dateFrom <= tour.StartDate && tour.StopDate <= dateTo)
                        {
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
Esempio n. 2
0
        private static List <DTO.Station> FindStations(DM.Tour tour)
        {
            var result = new List <DTO.Station>();

            var polygon = new MDC.LocationPolygon(tour.LocationList);

            if (polygon.Count <= 0)
            {
                throw new InvalidOperationException("Location list is empty");
            }
            var polygonRect = polygon.GetRect();

            using (var allStationsReader = Repository.ReadEntities <DM.AllStation>(source =>
            {
                source.SetAdditional($"([{MD.AllStations.Fields.Standart}] in ('{tour.RadioTechList.Replace(",", "','")}'))");
                source.SetWhere(MD.AllStations.Fields.Latitude, IMRecordset.Operation.Ge, polygonRect.Min.Lat);
                source.SetWhere(MD.AllStations.Fields.Latitude, IMRecordset.Operation.Le, polygonRect.Max.Lat);
                source.SetWhere(MD.AllStations.Fields.Longitude, IMRecordset.Operation.Ge, polygonRect.Min.Lon);
                source.SetWhere(MD.AllStations.Fields.Longitude, IMRecordset.Operation.Le, polygonRect.Max.Lon);
            }))
            {
                while (allStationsReader.Read())
                {
                    var allStation = allStationsReader.GetEntity();

                    var checkLocation = new MDC.Location(allStation.Longitude, allStation.Latitude);
                    if (checkLocation.CheckHitting(polygon))
                    {
                        var station = new DTO.Station
                        {
                            Id        = allStation.Id,
                            TableName = allStation.TableName,
                            TableId   = allStation.TableId,
                        };

                        if (CheckStationApplicationCurrentState(tour, station))
                        {
                            result.Add(station);
                        }
                    }
                }
            }

            return(result);
        }