/// <summary> /// Validates the SqlDataReader argument /// </summary> /// <param name="SQLConnector">The GFSqlConnector object to validate</param> /// <param name="Culture">The culture in which any exception messages should be thrown</param> internal static void ValidateSQLConnector(GFSqlConnector SQLConnector, CultureInfo Culture) { ResourceManager ExceptionMessageResources = new ResourceManager("GroundFrame.Core.Resources.ExceptionResources", Assembly.GetExecutingAssembly()); if (SQLConnector == null) { throw new ArgumentException(ExceptionMessageResources.GetString("InvalidSQLConnectorArgument", Culture)); } }
/// <summary> /// Instantiates a UserSettingCollection object the supplied GroundFrame.SQL Connection /// </summary> /// <param name="SQLConnector">A SQL Connector the GroundFrame.SQL database</param> public UserSettingCollection(GFSqlConnector SQLConnector) { this._Culture = new CultureInfo("en-GB"); //Validate Arguments ArgumentValidation.ValidateSQLConnector(SQLConnector, this._Culture); //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.GetAllUserSettingsFromSQLDB(); }
/// <summary> /// Instantiates a user setting from a SqlDataReader object /// </summary> /// <param name="DataReader">The SqlDataReader object to parse into the UserSetting object</param> /// <param name="SQLConnector">A GFSqlConnector to the GroundFrame.SQL database</param> /// <param name="Culture">The culture in which user would receive any exception messages. Defaults to en-GB</param> public UserSetting(SqlDataReader DataReader, GFSqlConnector SQLConnector, string Culture) { //Set the culture this._Culture = new CultureInfo(string.IsNullOrEmpty(Culture) ? "en-GB" : Culture); //Validate Arguments ArgumentValidation.ValidateSqlDataReader(DataReader, this._Culture); ArgumentValidation.ValidateSQLConnector(SQLConnector, this._Culture); this._SQLConnector = new GFSqlConnector(SQLConnector); //Parse DataReader this.ParseSqlDataReader(DataReader); }
/// <summary> /// Instantiates a user setting from the supplied arguments /// </summary> /// <param name="Key">The setting key</param> /// <param name="Description">The setting description</param> /// <param name="Value">The setting value</param> /// <param name="DataTypeName">The data type of the setting expressed as a .net full name (e.g. "system.string")</param> /// <param name="SQLConnector">A GFSqlConnector object representing a connection to the GroundFrame.SQL database</param> public UserSetting(string Key, string Description, string Value, string DataTypeName, GFSqlConnector SQLConnector) { //Set the culture this._Culture = new CultureInfo("en-GB"); //Validate Arguments ArgumentValidation.ValidateSQLConnector(SQLConnector, this._Culture); this._SQLConnector = new GFSqlConnector(SQLConnector); //Instantiate copy of the SQLConnector to stop conflicts in the connection this._Key = Key; this._Description = Description; //Set the values this.SetValues(DataTypeName, Value); }
/// <summary> /// Instatiates a new GFSqlConnector as a copy of the supplied one. Stops conflicts between connectors on sub query execution /// </summary> /// <param name="SQLConnector"></param> internal GFSqlConnector(GFSqlConnector SQLConnector) { //Validate argument ArgumentValidation.ValidateSQLConnector(SQLConnector, Globals.UserSettings.GetCultureInfo()); this._ApplicationAPIKey = SQLConnector.ApplicationAPIKey; this._ApplicationUserAPIKey = SQLConnector.ApplicationUserAPIKey; this._SQLServer = SQLConnector.SQLServer; this._DBName = SQLConnector.DBName; this._IsTest = SQLConnector.IsTest; this._TestDataID = SQLConnector.TestDataID; this._Timeout = SQLConnector.Timeout; this._Connection = new SqlConnection(this.BuildSQLConnectionString()); }
/// <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(); }
/// <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> public void CreateLocation(ref GroundFrame.Core.SimSig.Simulation TargetSimulation, GFSqlConnector SQLConnector) { //Validate Arguments ArgumentValidation.ValidateSQLConnector(SQLConnector, Globals.UserSettings.GetCultureInfo()); ArgumentValidation.ValidateSimulation(TargetSimulation, Globals.UserSettings.GetCultureInfo()); //Instantiate Location GroundFrame.Core.SimSig.Location NewLocation = new SimSig.Location(TargetSimulation, this.Name, null, this.SimSigCode, this.IsEntryPoint, SimSig.SimSigLocationType.Unknown, SQLConnector); //Save to GroundFrame.SQL database NewLocation.SaveToSQLDB(); //Add location to MapperLocation this._Location = NewLocation; //Dispose NewLocation.Dispose(); }