Пример #1
0
        /// <summary>
        /// Executes the get station operator code from internal code valid operation.
        /// </summary>
        /// <param name="accessor">The accessor.</param>
        /// <param name="stationOperatorCodeExpected">The operator code expected.</param>
        private static void ExecuteGetStationOperatorCodeFromInternalCodeValid(LmtDatabaseAccessor accessor, string stationOperatorCodeExpected)
        {
            uint   stationInternalCode       = 7;
            string stationOperatorCodeResult = string.Empty;

            stationOperatorCodeResult = accessor.GetStationOperatorCodeFromInternalCode(stationInternalCode);

            Assert.AreEqual(stationOperatorCodeExpected, stationOperatorCodeResult);
        }
Пример #2
0
        /// <summary>
        /// Performs the get station list from LMT data base.
        /// </summary>
        /// <param name="missionCode">The mission code.</param>
        /// <param name="elementId">Identifier for the element.</param>
        /// <param name="elementData">Information describing the element.</param>
        /// <param name="result">[in, out] The result.</param>
        protected virtual void PerformGetStationListFromLMTDataBase(string missionCode, string elementId, AvailableElementData elementData, ref RealTimeRetrieveStationListResult result)
        {
            if (result == null)
            {
                result            = new RealTimeRetrieveStationListResult();
                result.ResultCode = RealTimeServiceErrorEnum.RequestAccepted;
            }

            if (elementData.PisBaselineData != null)
            {
                if (!string.IsNullOrEmpty(elementData.PisBaselineData.CurrentVersionLmtOut))
                {
                    string lmtVersion = elementData.PisBaselineData.CurrentVersionLmtOut;

                    using (var remoteDataStore = _remoteDataStoreFactory.GetRemoteDataStoreInstance() as RemoteDataStoreProxy)
                    {
                        if (remoteDataStore != null)
                        {
                            if (remoteDataStore.checkIfDataPackageExists("LMT", lmtVersion))
                            {
                                var openPackageResult = remoteDataStore.openLocalDataPackage(
                                    "LMT",
                                    lmtVersion,
                                    string.Empty);

                                if (openPackageResult.Status == OpenDataPackageStatusEnum.COMPLETED)
                                {
                                    string lmtDatabaseFilePath = FindLmtDatabaseFilePath(openPackageResult.LocalPackagePath);
                                    if (!string.IsNullOrEmpty(lmtDatabaseFilePath))
                                    {
                                        using (var lmtDatabaseAccessor = new LmtDatabaseAccessor(lmtDatabaseFilePath, _platformType))
                                        {
                                            result.ResultCode  = RealTimeServiceErrorEnum.RequestAccepted;
                                            result.StationList = new List <string>();

                                            if (string.IsNullOrEmpty(missionCode))
                                            {
                                                foreach (var station in lmtDatabaseAccessor.GetStationList())
                                                {
                                                    if (!result.StationList.Contains(station.OperatorCode))
                                                    {
                                                        result.StationList.Add(station.OperatorCode);
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                uint?missionId = lmtDatabaseAccessor.GetMissionInternalCodeFromOperatorCode(missionCode);
                                                if (missionId != null)
                                                {
                                                    List <uint> missionRoute = lmtDatabaseAccessor.GetMissionRoute((uint)missionId);
                                                    foreach (uint stationId in missionRoute)
                                                    {
                                                        result.StationList.Add(lmtDatabaseAccessor.GetStationOperatorCodeFromInternalCode(stationId));
                                                    }
                                                }
                                                else
                                                {
                                                    result.ResultCode = RealTimeServiceErrorEnum.ErrorInvalidMissionCode;
                                                }
                                            }

                                            if (result.ResultCode == RealTimeServiceErrorEnum.RequestAccepted &&
                                                result.StationList.Count == 0)
                                            {
                                                result.ResultCode = RealTimeServiceErrorEnum.InfoNoDataForElement;
                                            }
                                        }
                                    }
                                    else
                                    {
                                        result.ResultCode = RealTimeServiceErrorEnum.ErrorRemoteDatastoreUnavailable;
                                        LogManager.WriteLog(TraceType.ERROR, string.Format(CultureInfo.CurrentCulture, Logs.ERROR_RETRIEVESTATIONLIST_LMT_DB_NOT_FOUND, lmtVersion, elementId), "PIS.Ground.RealTime.RealTimeService.RetrieveStationList", null, EventIdEnum.RealTime);
                                    }
                                }
                                else
                                {
                                    result.ResultCode = RealTimeServiceErrorEnum.ErrorRemoteDatastoreUnavailable;
                                    LogManager.WriteLog(TraceType.ERROR, string.Format(CultureInfo.CurrentCulture, Logs.ERROR_RETRIEVESTATIONLIST_CANT_OPEN_PACKAGE, lmtVersion, elementId), "PIS.Ground.RealTime.RealTimeService.RetrieveStationList", null, EventIdEnum.RealTime);
                                }
                            }
                            else
                            {
                                result.ResultCode = RealTimeServiceErrorEnum.ErrorRemoteDatastoreUnavailable;
                                LogManager.WriteLog(TraceType.ERROR, string.Format(CultureInfo.CurrentCulture, Logs.ERROR_RETRIEVESTATIONLIST_UNKNOWN_EMBEDDED_LMT, lmtVersion), "PIS.Ground.RealTime.RealTimeService.RetrieveStationList", null, EventIdEnum.RealTime);
                            }
                        }
                        else
                        {
                            result.ResultCode = RealTimeServiceErrorEnum.ErrorRemoteDatastoreUnavailable;
                            LogManager.WriteLog(TraceType.ERROR, string.Format(CultureInfo.CurrentCulture, Logs.ERROR_UNKNOWN), "PIS.Ground.RealTime.RealTimeService.RetrieveStationList", null, EventIdEnum.RealTime);
                        }
                    }
                }
                else
                {
                    result.ResultCode = RealTimeServiceErrorEnum.InfoNoDataForElement;
                }
            }
        }