コード例 #1
0
 private static DM.Inspection[] FindInspections(DM.Tour tour)
 {
     return(Repository.GetEntities <DM.Inspection>(source =>
     {
         source.SetWhere(MD.Inspection.Fields.TourId, IMRecordset.Operation.Eq, tour.Id);
     }));
 }
コード例 #2
0
        private static SDR.MeasDtParam PreparedDetectedParam(DM.Tour tour)
        {
            var detectedParam = new SDR.MeasDtParam()
            {
                TypeMeasurements = SDR.MeasurementType.MonitoringStations
            };

            return(detectedParam);
        }
コード例 #3
0
        private static bool ValidateTour(DM.Tour tour)
        {
            var  messages = new StringBuilder();
            bool result   = true;

            if (!tour.IsNewState)
            {
                messages.AppendLine($"Incorrect the status of the tour #{tour.Id}");
                result = false;
            }

            if (tour.StartDate.IsNull())
            {
                messages.AppendLine($"Undefined a start date of the tour #{tour.Id}");
                result = false;
            }

            if (tour.StopDate.IsNull())
            {
                messages.AppendLine($"Undefined a stop date of the tour #{tour.Id}");
                result = false;
            }

            if (tour.MeasTaskId != IM.NullI)
            {
                messages.AppendLine($"For the tour #{tour.Id} the meas task already creted with Id #{tour.MeasTaskId}");
                result = false;
            }

            if (string.IsNullOrEmpty(tour.MeasTaskName))
            {
                messages.AppendLine($"Undefined a meas task name of the tour #{tour.Id}");
                result = false;
            }

            if (string.IsNullOrEmpty(tour.SensorName))
            {
                messages.AppendLine($"Undefined a sensor name of the tour #{tour.Id}");
                result = false;
            }

            if (string.IsNullOrEmpty(tour.SensorEquipTechId))
            {
                messages.AppendLine($"Undefined a sensor equipment tech ID of the tour #{tour.Id}");
                result = false;
            }

            if (!result)
            {
                Logger.WriteWarning(PluginMetadata.Processes.CreateMeasTask, messages.ToString(), true);
            }

            return(result);
        }
コード例 #4
0
        private static SDR.MeasStation[] PreparedStations(DM.Tour tour)
        {
            var stations = new List <SDR.MeasStation>();

            var constraint = new AAC.DataConstraintGroup()
            {
                Type        = AAC.DataConstraintType.Group,
                Operation   = AAC.DataConstraintGroupOperation.And,
                Constraints = new AAC.DataConstraintExpression[]
                {
                    new AAC.DataConstraintExpression
                    {
                        Type        = AAC.DataConstraintType.Expression,
                        Operation   = AAC.DataConstraintOperation.Eq,
                        LeftOperand = new AAC.DataConstraintColumnOperand {
                            Type = AAC.DataConstraintOperandType.Column, Alias = "Sensor", ColumnName = "Name"
                        },
                        RightOperand = new AAC.DataConstraintValueOperand {
                            Type = AAC.DataConstraintOperandType.Value, DataType = AAC.CommonDataType.String, StringValue = tour.SensorName
                        }
                    },
                    new AAC.DataConstraintExpression
                    {
                        Type        = AAC.DataConstraintType.Expression,
                        Operation   = AAC.DataConstraintOperation.Eq,
                        LeftOperand = new AAC.DataConstraintColumnOperand {
                            Type = AAC.DataConstraintOperandType.Column, Alias = "Sensor", ColumnName = "Equipment.TechId"
                        },
                        RightOperand = new AAC.DataConstraintValueOperand {
                            Type = AAC.DataConstraintOperandType.Value, DataType = AAC.CommonDataType.String, StringValue = tour.SensorEquipTechId
                        }
                    }
                }
            };
            var result = WCF.SdrnsControllerWcfClient.GetSensors(constraint);

            result = result.Where(u => u.Name == tour.SensorName && u.Equipment.TechId == tour.SensorEquipTechId).ToArray();

            if (result.Length > 0)
            {
                stations.AddRange(
                    result.Select(sensor => new SDR.MeasStation
                {
                    StationId = new SDR.MeasStationIdentifier
                    {
                        Value = sensor.Id.Value
                    }
                })
                    );
            }
            return(stations.ToArray());
        }
コード例 #5
0
        private static SDR.MeasTask PreparedMeasTaskInfo(DM.Tour tour, DM.Inspection[] inspections)
        {
            var measTask = new SDR.MeasTask()
            {
                Name              = tour.MeasTaskName,
                ExecutionMode     = SDR.MeasTaskExecutionMode.Manual,
                DateCreated       = DateTime.Now,
                CreatedBy         = IM.ConnectedUser(),
                MeasDtParam       = PreparedDetectedParam(tour),
                MeasTimeParamList = new SDR.MeasTimeParamList()
                {
                    PerStart = tour.StartDate, PerStop = tour.StopDate
                },
                Stations = PreparedStations(tour), // new SDR.MeasStation[] { } ,
                StationsForMeasurements = PreparedStationDataForMeasurements(tour, inspections),
            };

            return(measTask);
        }
コード例 #6
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());
        }