/// <summary>
        /// Validates the Version argument
        /// </summary>
        /// <param name="Version">The Version to validate</param>
        /// <param name="Culture">The culture in which any exception messages should be thrown</param>
        internal static void ValidateVersion(SimSig.Version Version, CultureInfo Culture)
        {
            ResourceManager ExceptionMessageResources = new ResourceManager("GroundFrame.Core.Resources.ExceptionResources", Assembly.GetExecutingAssembly());

            if (Version == null)
            {
                throw new ArgumentException(ExceptionMessageResources.GetString("InvalidSimulationArgument", Culture));
            }
        }
 public IActionResult Get(int id)
 {
     try
     {
         GroundFrame.Core.SimSig.Version Ver = new GroundFrame.Core.SimSig.Version(id, this._SQLConnection);
         return(Ok(Ver));
     }
     catch (Exception Ex)
     {
         _logger.LogError($"An error has occurred: {Ex}");
         return(StatusCode(500, Ex.Message));
     }
 }
Example #3
0
        /// <summary>
        /// Creates the mapped location in the Target Simulation
        /// </summary>
        /// <param name="SQLConnector">The target simulation where the location should be created</param>
        /// <param name="TargetSimulation">A GFSqlConnector object connected to the GroundFrame.SQL database</param>
        /// <param name="Version">The version under which the location node was created</param>
        /// <param name="SimEra">The era for which the location node is valid</param>
        /// <param name="Location">The location against which the location node will be created</param>
        public void CreateLocationNode(ref SimSig.SimulationExtension TargetSimulation, GFSqlConnector SQLConnector, SimSig.Location Location, SimSig.Version Version, SimSig.SimulationEra SimEra)
        {
            //Validate Arguments
            ArgumentValidation.ValidateSQLConnector(SQLConnector, Globals.UserSettings.GetCultureInfo());
            ArgumentValidation.ValidateSimulation(TargetSimulation, Globals.UserSettings.GetCultureInfo());
            ArgumentValidation.ValidateVersion(Version, Globals.UserSettings.GetCultureInfo());
            ArgumentValidation.ValidateLocation(Location, Globals.UserSettings.GetCultureInfo());
            ArgumentValidation.ValidateSimEra(SimEra, Globals.UserSettings.GetCultureInfo());

            //Default Value
            Electrification DefaultElectrification = new Electrification("D");

            //Instantiate Location Node
            SimSig.LocationNode NewLocationNode = new SimSig.LocationNode(TargetSimulation.ID, Location.ID, SimEra.ID, Version, this.Platform, DefaultElectrification, SimSig.SimSigLocationType.Unknown, null, false, this.Line, this.Path, SQLConnector);

            if (TargetSimulation.LocationNodes.Exists(NewLocationNode) == false)
            {
                //Save to GroundFrame.SQL database
                NewLocationNode.SaveToSQLDB();
                //Add location node to MapperLocationNode
                this._LocationNode = NewLocationNode;
                //Add location to the simulation
                TargetSimulation.LocationNodes.Add(NewLocationNode);
            }

            //Dispose
            NewLocationNode.Dispose();
        }