/// <summary>
        /// Gets a Nullable Byte value from a SqlDataReader
        /// </summary>
        /// <param name="DataReader"></param>
        /// <param name="FieldName"></param>
        /// <returns></returns>
        public static byte GetNullableByte(this SqlDataReader DataReader, string FieldName)
        {
            //Validate Arguments
            ArgumentValidation.ValidateSqlDataReader(DataReader, new System.Globalization.CultureInfo("en-GB"));

            int Ordinal = DataReader.GetOrdinal(FieldName);

            return(DataReader.IsDBNull(Ordinal) ? Convert.ToByte(0) : DataReader.GetByte(Ordinal));
        }
        /// <summary>
        /// Gets a Nullable Int32 value from a SqlDataReader
        /// </summary>
        /// <param name="DataReader"></param>
        /// <param name="FieldName"></param>
        /// <returns></returns>
        public static Int32 GetNullableInt32(this SqlDataReader DataReader, string FieldName)
        {
            //Validate Arguments
            ArgumentValidation.ValidateSqlDataReader(DataReader, new System.Globalization.CultureInfo("en-GB"));

            int Ordinal = DataReader.GetOrdinal(FieldName);

            return(DataReader.IsDBNull(Ordinal) ? 0 : DataReader.GetInt32(Ordinal));
        }
Ejemplo n.º 3
0
        /// <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();
        }
Ejemplo n.º 4
0
        /// <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);
        }
Ejemplo n.º 5
0
        /// <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);
        }
Ejemplo n.º 6
0
        /// <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());
        }
Ejemplo n.º 7
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>
 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();
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Instantiates a UserSettingCollection from a JSON file.
        /// </summary>
        /// <param name="JSON">A JSON string representing a collection of user settings</param>
        public UserSettingCollection(string JSON)
        {
            this._Culture = new CultureInfo("en-GB");

            //Validate arguments
            ArgumentValidation.ValidateJSON(JSON, _Culture);

            //Try deserializing the string
            try
            {
                //Deserialize the JSON string
                this._UserSettings = JsonConvert.DeserializeObject <List <UserSetting> >(JSON);
            }
            catch (Exception Ex)
            {
                throw new ApplicationException(ExceptionHelper.GetStaticException("ParseUserSettingsJSONError", null, this._Culture), Ex);
            }
        }