/// <summary> /// Instantiates a new Location Test object /// </summary> public PathEdge() { //Set up the Data Connection var config = new ConfigurationBuilder().AddJsonFile("xunit.config.json").Build(); string SQLServer = config["gfSqlServer"]; string DBName = config["gfDbName"]; this._SQLConnection = new GFSqlConnector("testappAPIKEY", "testadminuserAPIKEY", SQLServer, DBName, true); //Need to log in as admin //Create a Test Simulation and save to DB this._TestSimulation = new Core.SimSig.Simulation("Test PathEdge Sim Name", "Test PathEdge Sim Desc", null, "TestPESimCode", this._SQLConnection); this._TestSimulation.SaveToSQLDB(); this._TestVersion = new Core.SimSig.Version("Test PathEdge Version", "Test LocCode Version", 4.15M, this._SQLConnection); this._TestVersion.SaveToSQLDB(); this._TestLocation1 = new Core.SimSig.Location(this._TestSimulation, "Test PathEdge Loc Name 1", null, "TestPECode1", false, Core.SimSig.SimSigLocationType.Station, this._SQLConnection); this._TestLocation1.SaveToSQLDB(); this._TestLocationNode1 = new Core.SimSig.LocationNode(this._TestSimulation.ID, this._TestLocation1.SimSigCode, this._TestSimulation.GetSimulationEras().Find(x => x.Type == EraType.Template).ID, this._TestVersion, null, new Core.Electrification(0), SimSigLocationType.Station, null, false, null, null, this._SQLConnection); this._TestLocationNode1.SaveToSQLDB(); this._TestLocation2 = new Core.SimSig.Location(this._TestSimulation, "Test PathEdge Loc Name 2", null, "TestPECode2", false, Core.SimSig.SimSigLocationType.Station, this._SQLConnection); this._TestLocation2.SaveToSQLDB(); this._TestLocationNode2 = new Core.SimSig.LocationNode(this._TestSimulation.ID, this._TestLocation2.SimSigCode, this._TestSimulation.GetSimulationEras().Find(x => x.Type == EraType.Template).ID, this._TestVersion, null, new Core.Electrification(0), SimSigLocationType.Station, null, false, null, null, this._SQLConnection); this._TestLocationNode2.SaveToSQLDB(); this._TestSimulationExt = new SimulationExtension(this._TestSimulation.ID, this._SQLConnection); this._TestSimulationExt.Locations.Add(this._TestLocation1); this._TestSimulationExt.Locations.Add(this._TestLocation2); this._TestSimulationExt.LocationNodes.Add(this._TestLocationNode1); this._TestSimulationExt.LocationNodes.Add(this._TestLocationNode2); }
/// <summary> /// Instantiates a Simulation Era object for the supplied arguements /// </summary> /// <param name="Simulation">The simulation to which the era belongs</param> /// <param name="Type">The era type</param> /// <param name="Name">The era name</param> /// <param name="Description">The era decription</param> /// <param name="SQLConnector">A GFSqlConnector object representing a connection to the GroundFrame.SQL database</param> public SimulationEra(Simulation Simulation, EraType Type, string Name, string Description, GFSqlConnector SQLConnector) { //Load Resources this.LoadResource(); if (Simulation == null) { throw new ArgumentNullException(this._ExceptionMessageResources.GetString("InvalidSimulationArgument", Globals.UserSettings.GetCultureInfo())); } //Check the parent simulation is saved to the GroundFrame.SQL Database if (Simulation.ID == 0) { throw new ArgumentException(this._ExceptionMessageResources.GetString("InvalidSimulationNotSavedToDBArgument", Globals.UserSettings.GetCultureInfo())); } if (string.IsNullOrEmpty(Name)) { throw new ArgumentException(this._ExceptionMessageResources.GetString("InvalidSecondsArgument", Globals.UserSettings.GetCultureInfo())); } if (SQLConnector == null) { throw new ArgumentException(this._ExceptionMessageResources.GetString("InvalidSQLConnectorArgument", Globals.UserSettings.GetCultureInfo())); } this._SQLConnector = new GFSqlConnector(SQLConnector); //Create a new connection object to prevent connection / command conflicts this._ID = 0; this._SimID = Simulation.ID; this.Name = Name; this.Description = Description; this.Type = Type; this.SaveToSQLDB(); }
public Versions(ILogger <GroundFrame.Core.SimSig.Version> logger) { _logger = logger; string SQLServer = @"(localdb)\MSSQLLocalDB";; string DBName = "GroundFrame.sql"; this._SQLConnection = new GFSqlConnector("testappAPIKEY", "testuserAPIKEY", SQLServer, DBName); }
/// <summary> /// Instantiates a new Version object from the supplied Version Number. /// </summary> /// <param name="VersionNumber">The version number to get from the GroundFrame.SQL database</param> /// <param name="SQLConnector">A Connector to the GroundFrame.SQL Database</param> public Version(decimal VersionNumber, GFSqlConnector SQLConnector) { //Validate Arguments ArgumentValidation.ValidateSQLConnector(SQLConnector, Globals.UserSettings.GetCultureInfo()); ArgumentValidation.ValidateVersionNumber(VersionNumber, Globals.UserSettings.GetCultureInfo()); this._SQLConnector = new GFSqlConnector(SQLConnector); //Creates a copy of the object to prevent conflict with connectios, commands and readers this.GetVersionFromSQLDBByVersionNumber(VersionNumber); }
/// <summary> /// Instantiates a new Location Node object from the GroundFrame.SQL database /// </summary> /// <param name="ID">The ID of the location record to be retreived</param> /// <param name="SQLConnector">The GFSqlConnector to the GroundFrame.SQL database</param> /// <param name="LoadPathEdges">A flag to indicate whether the Path Edges should be loaded from the GroundFrame.SQL database</param> public LocationNode(int ID, GFSqlConnector SQLConnector, bool LoadPathEdges) { //Validate Arguments ArgumentValidation.ValidateSQLConnector(SQLConnector, Globals.UserSettings.GetCultureInfo()); this._ID = ID; this._SQLConnector = new GFSqlConnector(SQLConnector); //Instantiates a copy of the SQLConnector object so prevent conflicts on Connections, Commands and DataReaders this.GetLocationNodeFromSQLDBByID(LoadPathEdges); }
/// <summary> /// Instantiates a new Simulation object from the GroundFrame.SQL database /// </summary> /// <param name="ID">The ID of the Simulation record to be retreived</param> /// <param name="SQLConnector">The GFSqlConnector to the GroundFrame.SQL database</param> public Simulation(int ID, GFSqlConnector SQLConnector) { //Validate arguments ArgumentValidation.ValidateSQLConnector(SQLConnector, Globals.UserSettings.GetCultureInfo()); this._ID = ID; this._SQLConnector = new GFSqlConnector(SQLConnector); //Instantiates a copy of the SQLConnector object so prevent conflicts on Connections, Commands and DataReaders this.GetSimulationFromSQLDBByID(); }
/// <summary> /// Instantiates a new Simulation Test object /// </summary> public Version() { //Set up the Data Connection var config = new ConfigurationBuilder().AddJsonFile("xunit.config.json").Build(); string SQLServer = config["gfSqlServer"]; string DBName = config["gfDbName"]; this._SQLConnection = new GFSqlConnector("testappAPIKEY", "testadminuserAPIKEY", SQLServer, DBName, true); }
/// <summary> /// Instatiates a Version object from a SqlDataReader object /// </summary> /// <param name="DataReader">The source SqlDataReader</param> /// <param name="SQLConnector">A Connector to the GroundFrame.SQL Database</param> internal Version(SqlDataReader DataReader, GFSqlConnector SQLConnector) { //Validate Arguments ArgumentValidation.ValidateSQLConnector(SQLConnector, Globals.UserSettings.GetCultureInfo()); ArgumentValidation.ValidateSqlDataReader(DataReader, Globals.UserSettings.GetCultureInfo()); this._SQLConnector = new GFSqlConnector(SQLConnector); //Creates a copy of the object to prevent conflict with connectios, commands and readers this.ParseSqlDataReader(DataReader); }
/// <summary> /// Instantiates a new PathEdge object from the supplied values /// </summary> /// <param name="FromLocation">The start location node of the path</param> /// <param name="ToLocation">The end location node of the path</param> /// <param name="SQLConnector">A conector to the GroundFrame.SQL database</param> public PathEdge(LocationNode FromLocation, LocationNode ToLocation, GFSqlConnector SQLConnector) { //Validate Arguments ArgumentValidation.ValidateSQLConnector(SQLConnector, Globals.UserSettings.GetCultureInfo()); this._FromLocation = FromLocation; this._ToLocation = ToLocation; this._SQLConnector = new GFSqlConnector(SQLConnector); this.PathDirection = SimSigPathDirection.None; this.PathElectrification = new Electrification(0); }
/// <summary> /// Instantiates a VersionCollection object the supplied GroundFrame.SQL Connection /// </summary> /// <param name="SQLConnector">A GFSqlConnector to the GroundFrame.SQL database </param> public UserSettingCollection(GFSqlConnector SQLConnector) { //Validate Arguments ArgumentValidation.ValidateSQLConnector(SQLConnector, Globals.UserSettings.GetCultureInfo()); //Set the SQL Connector this._SQLConnector = new GFSqlConnector(SQLConnector); //Instantiated as a new copy of the SQLConnector to stop conflict issues with open connections, commands and DataReaders //Get the simulations this.GetAllVersionsFromSQLDB(); }
/// <summary> /// Instantiates a new Simulation Extension from the GroundFrame.SQL database /// </summary> /// <param name="ID">The ID of the GroundFrame.SQL database simulation record</param> /// <param name="SQLConnector">The GFSqlConnector to the GroundFrame.SQL database</param> public SimulationExtension(int ID, GFSqlConnector SQLConnector) : base(ID, SQLConnector) { //Validate Arguments ArgumentValidation.ValidateSQLConnector(SQLConnector, Globals.UserSettings.GetCultureInfo()); this._SQLConnector = new GFSqlConnector(SQLConnector); //Load the data this.LoadSimErasFromSQLDB(); this._Locations = new LocationCollection(this, SQLConnector); this._LocationNodes = new LocationNodeCollection(this, SQLConnector); }
/// <summary> /// Instantiates a new Simulation Test object /// </summary> public SimulationCollection() { //Set up the Data Connection var config = new ConfigurationBuilder().AddJsonFile("xunit.config.json").Build(); string SQLServer = config["gfSqlServer"]; string DBName = config["gfDbName"]; this._SQLConnection = new GFSqlConnector("testappAPIKEY", "testuserAPIKEY", SQLServer, DBName, true); //Generate some test data in the database this._SQLConnection.GenerateTestData(); }
public SeedSimulationFromWTT(string Key, string AppUserAPIKey, string APIKey, string Environment, string JSON) { //Set private variables this._Key = Key; this._JSON = JSON; this._Environment = Environment; this._SQLConnector = Globals.GetGFSqlConnector(APIKey, AppUserAPIKey, Environment); ///Initialise the response this._Responses = new List <QueuerResponse>(); this._Responses.Add(new QueuerResponse(this._Key, this._Environment, QueuerResponseStatus.Queued, "Process Queued", null)); }
/// <summary> /// Instantiates a PathEdgeCollection for the supplied start location /// </summary> /// <param name="FromLocation">The LocationNode object to which the path collection starts</param> /// <param name="SQLConnector">A GFSqlConnector to the GroundFrame.SQL database</param> public PathEdgeCollection(LocationNode FromLocation, GFSqlConnector SQLConnector) { CultureInfo culture = Globals.UserSettings.GetCultureInfo(); ArgumentValidation.ValidateSQLConnector(SQLConnector, culture); this._FromLocationNode = FromLocation; //Set the SQL Connector this._SQLConnector = new GFSqlConnector(SQLConnector); //Instantiated as a new copy of the SQLConnector to stop conflict issues with open connections, commands and DataReaders //Get the locations this.GetAllPathEdgesFromLocation(); }
/// <summary> /// Instantiates a new PathEdge object from the supplied SqlDataReader /// </summary> /// <param name="FromLocation">The start location node of the path</param> /// <param name="DataReader">The SqlDataReader object to parse into this path edge object</param> /// <param name="SQLConnector">A conector to the GroundFrame.SQL database</param> public PathEdge(LocationNode FromLocation, SqlDataReader DataReader, GFSqlConnector SQLConnector) { //Validate Arguments ArgumentValidation.ValidateSqlDataReader(DataReader, Globals.UserSettings.GetCultureInfo()); ArgumentValidation.ValidateSQLConnector(SQLConnector, Globals.UserSettings.GetCultureInfo()); this._FromLocation = FromLocation; this._SQLConnector = new GFSqlConnector(SQLConnector); //Parse the DataReader object this.ParseDataReader(DataReader); }
/// <summary> /// Instantiates a new Simulation object from the supplied SqlDataReader object /// </summary> /// <param name="DataReader">A SqlDataReader object representing a Simulation</param> /// <param name="SQLConnector">The GFSqlConnector to the GroundFrame.SQL database</param> public Simulation(SqlDataReader DataReader, GFSqlConnector SQLConnector) { CultureInfo culture = Globals.UserSettings.GetCultureInfo(); //Validate arguments ArgumentValidation.ValidateSqlDataReader(DataReader, culture); ArgumentValidation.ValidateSQLConnector(SQLConnector, culture); //Instantiate a new GFSqlConnector object from the supplied connector. Stops issues with shared connections / commands and readers etc. this._SQLConnector = new GFSqlConnector(SQLConnector); //Parse Reader this.ParseSqlDataReader(DataReader); }
/// <summary> /// Instantiates a new SeedSimulationFromWTT object from the supplied object. /// </summary> /// <param name="AppUserAPIKey">The application user API key who queued the process</param> /// <param name="AppAPIKey">The API Key of the application which queued the process</param> /// <param name="Environment">The environment where the task is being executed. This should be proided by the running application</param> /// <param name="JSON">The JSON containing the configuration for the task (see documentation)</param> /// <param name="Authenticated">A flag to indicate whether the user was authenticated at the point of queuing the process</param> internal SeedSimulationFromWTT(string AppUserAPIKey, string AppAPIKey, string Environment, string JSON, bool Authenticated) { //Set private variables this._JSON = JSON; this._Authenticated = Authenticated; this._SQLConnector = Globals.GetGFSqlConnector(AppAPIKey, AppUserAPIKey, Environment); this._Config = Globals.GetConfig(Environment); //Initialise the response this._Responses = new ExtendedList <QueuerResponse> { new QueuerResponse(QueuerResponseStatus.Queued, "Process Queued", null) }; }
/// <summary> /// Instantiates a new Location Node object from the supplied SqlDataReader object /// </summary> /// <param name="DataReader">A SqlDataReader object representing a location node</param> /// <param name="SQLConnector">A GFSqlConnector to the GroundFrame.SQL database</param> /// <param name="LoadPathEdges">A flag to indicate whether the path edges should be loaded for this location node</param> public LocationNode(SqlDataReader DataReader, GFSqlConnector SQLConnector, bool LoadPathEdges) { CultureInfo Culture = Globals.UserSettings.GetCultureInfo(); //Validate Arguments ArgumentValidation.ValidateSqlDataReader(DataReader, Culture); ArgumentValidation.ValidateSQLConnector(SQLConnector, Culture); //Instantiate a new GFSqlConnector object from the supplied connector. Stops issues with shared connections / commands and readers etc. this._SQLConnector = new GFSqlConnector(SQLConnector); //Parse Reader this.ParseSqlDataReader(DataReader, LoadPathEdges); }
/// <summary> /// Instantiates a LocationNodeCollection for the supplied Simulation from the supplied GroundFrame.SQL Connection /// </summary> /// <param name="Simulation">The simulation for which you want to inititate the LocationCOllection</param> /// <param name="SQLConnector">A GFSqlConnector to the GroundFrame.SQL database</param> public LocationNodeCollection(Simulation Simulation, GFSqlConnector SQLConnector) { CultureInfo culture = Globals.UserSettings.GetCultureInfo(); ArgumentValidation.ValidateSimulation(Simulation, culture); ArgumentValidation.ValidateSQLConnector(SQLConnector, culture); this._SimID = Simulation.ID; //Set the SQL Connector this._SQLConnector = new GFSqlConnector(SQLConnector); //Instantiated as a new copy of the SQLConnector to stop conflict issues with open connections, commands and DataReaders //Get the locations this.GetAllLocationNodesBySimFromSQLDB(); }
/// <summary> /// Instantiates a new Location Test object /// </summary> public Location() { //Set up the Data Connection var config = new ConfigurationBuilder().AddJsonFile("xunit.config.json").Build(); string SQLServer = config["gfSqlServer"]; string DBName = config["gfDbName"]; this._SQLConnection = new GFSqlConnector("testappAPIKEY", "testadminuserAPIKEY", SQLServer, DBName, true); //Need to log in as admin //Create a Test Simulation and save to DB this._TestSimulation = new Core.SimSig.Simulation("Test Location Sim Name", "Test Location Sim Desc", null, "Test Location Sim Code", this._SQLConnection); this._TestSimulation.SaveToSQLDB(); }
/// <summary> /// Instantiates a new Version object the supplied values /// </summary> /// <param name="Name">The name of the verison</param> /// <param name="Description">A description of the version</param> /// <param name="Version">The version number. This must be greater the latest version stored in the GroundFrame.SQL database</param> /// <param name="SQLConnector">A Connector to the GroundFrame.SQL Database</param> public Version(string Name, string Description, Decimal Version, GFSqlConnector SQLConnector) { CultureInfo culture = Globals.UserSettings.GetCultureInfo(); //Validate Arguments ArgumentValidation.ValidateName(Name, culture); ArgumentValidation.ValidateSQLConnector(SQLConnector, culture); this._SQLConnector = new GFSqlConnector(SQLConnector); //Creates a copy of the object to prevent conflict with connectios, commands and readers this.Name = Name; this.Description = Description; this.VersionFrom = Version; this.VersionTo = null; this.Status = VersionStatus.Development; }
/// <summary> /// Instantiates a new Simulation object from the supplied arguements /// </summary> /// <param name="Name">The simulation name. This cannot be altered once set</param> /// <param name="Description">A description of the simulation</param> /// <param name="SimSigWikiLink">The URL to the simulation manula on the SimSig wiki</param> /// <param name="SimSigCode">The SimSig code for the simulation. This cannot be altered once set</param> /// <param name="SQLConnector">The GFSqlConnector to the GroundFrame.SQL database</param> public Simulation(string Name, string Description, string SimSigWikiLink, string SimSigCode, GFSqlConnector SQLConnector) { CultureInfo culture = Globals.UserSettings.GetCultureInfo(); //Validate arguments ArgumentValidation.ValidateName(Name, culture); ArgumentValidation.ValidateSimSigCode(SimSigCode, culture); ArgumentValidation.ValidateSQLConnector(SQLConnector, culture); this._ID = 0; this._Name = Name; this.Description = Description; this.SimSigWikiLink = SimSigWikiLink; this._SimSigCode = SimSigCode; this._SQLConnector = new GFSqlConnector(SQLConnector); //Instantiates a new copy of the SQLConnector object to stop conflicts between Connections, Commands and Readers }
/// <summary> /// Instantiates a new Location node object from the supplied arguments /// </summary> /// <param name="SimulationID">The GroundFrame.SQL database id of the simulation</param> /// <param name="LocationID">The GroundFrame.SQL database id of the location</param> /// <param name="EraID">The GroundFrame.SQL database id of the simulation era</param> /// <param name="Version">The version of SimSig this created under</param> /// <param name="Platform">The platform</param> /// <param name="Electrification">The valid electrification options for this location node</param> /// <param name="LocationType">The location type of for this location node</param> /// <param name="Length">A length object representing the length for this location node</param> /// <param name="FreightOnly">Flag to indicate whether the location is freight only</param> /// <param name="Line">The line code</param> /// <param name="Path">The path code</param> /// <param name="SQLConnector">The GFSqlConnector to the GroundFrame.SQL database</param> public LocationNode(int SimulationID, int LocationID, int EraID, Version Version, string Platform, Electrification Electrification, SimSigLocationType LocationType, Length Length, bool FreightOnly, string Line, string Path, GFSqlConnector SQLConnector) { CultureInfo Culture = Globals.UserSettings.GetCultureInfo(); //Check Arguments ArgumentValidation.ValidateSQLConnector(SQLConnector, Culture); this._SQLConnector = new GFSqlConnector(SQLConnector); ArgumentValidation.ValidateVersion(Version, Culture); if (SimulationID == 0) { throw new ArgumentException(ExceptionHelper.GetStaticException("CreateLocationNodeUnsavedSimError", null, Culture)); } this._SimID = SimulationID; //Load simulation into a SimSig Simulation object //TODO: Find a way of not loading the extension data from the Database. This is silly. using SimulationExtension LocNodeSimulation = new SimulationExtension(this.SimID, this._SQLConnector); //Validate locations and eras if (LocNodeSimulation.Locations.Any(x => x.ID == LocationID) == false) { throw new ArgumentException(ExceptionHelper.GetStaticException("CreateLocationNodeInvalidLocationError", null, Culture)); } if (LocNodeSimulation.GetSimulationEras().Any(x => x.ID == EraID) == false) { throw new ArgumentException(ExceptionHelper.GetStaticException("CreateLocationNodeInvalidSimEraError", null, Culture)); } //Set Properties this._LocationID = LocationID; this._LocationSimSigCode = LocNodeSimulation.Locations.Find(x => x.ID == this._LocationID).SimSigCode; this._EraID = EraID; this._Version = Version; this.Platform = Platform; this.Electrification = Electrification; this.LocationType = LocationType; this.Length = Length; this.FreightOnly = FreightOnly; this.Line = Line; this.Path = Path; }
/// <summary> /// Instantiates a new Location Test object /// </summary> public LocationNode() { //Set up the Data Connection var config = new ConfigurationBuilder().AddJsonFile("xunit.config.json").Build(); string SQLServer = config["gfSqlServer"]; string DBName = config["gfDbName"]; this._SQLConnection = new GFSqlConnector("testappAPIKEY", "testadminuserAPIKEY", SQLServer, DBName, true); //Need to log in as admin //Create a Test Simulation and save to DB this._TestSimulation = new Core.SimSig.Simulation("Test LocationNode Sim Name", "Test LocationNode Sim Desc", null, "TestLocationNodeSimCode", this._SQLConnection); this._TestSimulation.SaveToSQLDB(); this._TestLocation = new Core.SimSig.Location(this._TestSimulation, "Test LocNode Loc Name", null, "TestLocNodeCode", false, Core.SimSig.SimSigLocationType.Station, this._SQLConnection); this._TestLocation.SaveToSQLDB(); this._TestSimulationExt = new SimulationExtension(this._TestLocation.ID, this._SQLConnection); this._TestSimulationExt.Locations.Add(this._TestLocation); this._TestVersion = new Core.SimSig.Version("Test LocNode Version", "Test LocCode Version", 4.15M, this._SQLConnection); this._TestVersion.SaveToSQLDB(); }
/// <summary> /// Instantiates a new Location object from the supplied arguements /// </summary> /// <param name="Simulation">The location to which the location belongs</param> /// <param name="Name">The location name</param> /// <param name="TIPLOC">The TIPLOC code for the location.</param> /// <param name="SimSigCode">The SimSig code for the location.</param> /// <param name="EntryPoint">Indicates whether the location is an entry point for the location</param> /// <param name="LocationType">Indicates the type of location</param> /// <param name="SQLConnector">The GFSqlConnector to the GroundFrame.SQL database</param> public Location(Simulation Simulation, string Name, string TIPLOC, string SimSigCode, bool EntryPoint, SimSigLocationType LocationType, GFSqlConnector SQLConnector) { CultureInfo Culture = Globals.UserSettings.GetCultureInfo(); //Check Arguments ArgumentValidation.ValidateName(Name, Culture); ArgumentValidation.ValidateSimSigCode(SimSigCode, Culture, 16); ArgumentValidation.ValidateSQLConnector(SQLConnector, Culture); ArgumentValidation.ValidateSimulation(Simulation, Culture); if (Simulation.ID == 0) { throw new ArgumentException(ExceptionHelper.GetStaticException("CreateLocationUnsavedSimError", null, Culture)); } this._ID = 0; this._SimID = Simulation.ID; this._Name = Name; this.SimSigCode = SimSigCode; this._SQLConnector = new GFSqlConnector(SQLConnector); //Instantiates a new copy of the SQLConnector object to stop conflicts between Connections, Commands and Readers this.TIPLOC = TIPLOC; this.EntryPoint = EntryPoint; this.LocationType = LocationType; }