Ejemplo n.º 1
0
        public static VM.MeasTaskDetailStationViewModel Map(SDR.StationDataForMeasurements source)
        {
            if (source == null)
            {
                return(null);
            }

            return(new VM.MeasTaskDetailStationViewModel
            {
                GlobalSID = source.GlobalSID,
                LicenseCloseDate = source.LicenseParameter.CloseDate.ToNull(),
                LicenseDozvilName = source.LicenseParameter.DozvilName,
                LicenseEndDate = source.LicenseParameter.EndDate.ToNull(),
                LicenseIcsmId = source.LicenseParameter.Id.ToNull(),
                LicenseStartDate = source.LicenseParameter.StartDate.ToNull(),
                OwnerAddres = source.Owner.Addres,
                OwnerCode = source.Owner.Code,
                OwnerId = source.Owner.Id,
                OwnerName = source.Owner.OwnerName,
                OwnerOKPO = source.Owner.OKPO,
                OwnerZip = source.Owner.Zip,
                Sectors = source.Sectors,
                SiteAdress = source.Site.Adress,
                SiteLat = source.Site.Lat.ToNull(),
                SiteLon = source.Site.Lon.ToNull(),
                SiteRegion = source.Site.Region,
                Standart = source.Standart,
                StationId = source.IdStation,
                Status = source.Status
            });
        }
Ejemplo n.º 2
0
        private static SDR.StationDataForMeasurements[] PreparedStationDataForMeasurements(DM.Tour tour, DM.Inspection[] inspections)
        {
            var stations = new List <SDR.StationDataForMeasurements>();

            var applications = new Dictionary <int, DM.NfraApplication>();

            inspections.ToList().ForEach(inspection =>
            {
                if (MD.MobStations.TableName.Equals(inspection.StationTableName, StringComparison.OrdinalIgnoreCase))
                {
                    var mobStation = Repository.ReadEntityById <DM.MobStation>(inspection.StationTableId);


                    var application = Repository.ReadFirstEntity <DM.NfraApplication>(source =>
                    {
                        source.SetWhere(MD.NfraApplication.Fields.ObjTable, IMRecordset.Operation.Eq, inspection.StationTableName);
                        source.SetAdditional($"({inspection.StationTableId} 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}]))");
                    });

                    if (application == null)
                    {
                        throw new InvalidOperationException($"Not found record of {MD.NfraApplication.TableName} by ObjId #{inspection.StationTableId} and TableName '{inspection.StationTableName}'");
                    }

                    mobStation.Frequencies = Repository
                                             .GetEntities <DM.MobStationFrequencies>(
                        source => source.SetWhere(MD.MobStationFrequencies.Fields.StationId, IMRecordset.Operation.Eq, mobStation.Id)
                        );

                    if (applications.ContainsKey(application.Id))
                    {
                        applications[application.Id].MobStations.Add(mobStation);
                    }
                    else
                    {
                        application.MobStations = new List <DM.MobStation>();
                        application.MobStations.Add(mobStation);
                        applications.Add(application.Id, application);
                    }
                }
            });

            applications.Values.ToList().ForEach(app =>
            {
                var firstStation = app.MobStations[0];
                var stationData  = new SDR.StationDataForMeasurements
                {
                    Owner = new SDR.OwnerData
                    {
                        Id        = firstStation.OwnerRef.Id,
                        OwnerName = firstStation.OwnerRef.Name,
                        Addres    = firstStation.OwnerRef.Address,
                        Code      = firstStation.OwnerRef.Code,
                        OKPO      = firstStation.OwnerRef.RegistNum,
                        Zip       = firstStation.OwnerRef.PostCode
                    },
                    IdStation = string.IsNullOrEmpty(firstStation.CustTxt13) ? firstStation.Name.TryToInt() : firstStation.CustTxt13.TryToInt(),
                    Site      = new SDR.SiteStationForMeas
                    {
                        Adress = firstStation.PositionRef.Address,
                        Lat    = firstStation.PositionRef.Latitude,
                        Lon    = firstStation.PositionRef.Longitude,
                        Region = firstStation.PositionRef.SubProvince
                    },
                    Sectors = app.MobStations.Select(mobStation =>
                                                     new SDR.SectorStationForMeas
                    {
                        AGL           = mobStation.Agl,
                        IdSector      = mobStation.Id,
                        EIRP          = mobStation.Power,
                        Azimut        = mobStation.Azimut,
                        BW            = mobStation.BW,
                        ClassEmission = mobStation.DesignEmission,
                        MaskBW        = new SDR.MaskElements[] { },
                        Frequencies   = mobStation.Frequencies.Select(
                            freq => new SDR.FrequencyForSectorFormICSM
                        {
                            ChannalNumber = freq.ChannelTxRef.Channel,
                            Frequency     = freq.ChannelTxRef.Freq,
                            Id            = freq.Id,
                            IdPlan        = freq.ChannelTxRef.PlanId
                        }).ToArray()
                    }).ToArray(),
                    Standart         = firstStation.Standart,
                    LicenseParameter = new SDR.PermissionForAssignment
                    {
                        CloseDate  = app.DozvDateCancel,
                        DozvilName = app.DozvNum,
                        EndDate    = app.DozvDateTo,
                        StartDate  = app.DozvDateFrom,
                        Id         = app.Id
                    }
                };

                stations.Add(stationData);
            });

            return(stations.ToArray());
        }