/// <summary>
        /// Deletes a 'Enumeration' from the database
        /// This method calls the DataBridgeManager to execute the delete using the
        /// procedure 'Enumeration_Delete'.
        /// </summary>
        /// <param name='enumeration'>The 'Enumeration' to delete.</param>
        /// <returns>True if the delete is successful or false if not.</returns>
        public bool Delete(Enumeration tempEnumeration)
        {
            // locals
            bool deleted = false;

            // Get information for calling 'DataBridgeManager.PerformDataOperation' method.
            string methodName = "DeleteEnumeration";
            string objectName = "ApplicationLogicComponent.Controllers";

            try
            {
                // verify tempenumeration exists before attemptintg to delete
                if (tempEnumeration != null)
                {
                    // Create Delegate For DataOperation
                    ApplicationController.DataOperationMethod deleteEnumerationMethod = this.AppController.DataBridge.DataOperations.EnumerationMethods.DeleteEnumeration;

                    // Create parameters for this method
                    List <PolymorphicObject> parameters = CreateEnumerationParameter(tempEnumeration);

                    // Perform DataOperation
                    PolymorphicObject returnObject = this.AppController.DataBridge.PerformDataOperation(methodName, objectName, deleteEnumerationMethod, parameters);

                    // If return object exists
                    if (returnObject != null)
                    {
                        // Test For True
                        if (returnObject.Boolean.Value == NullableBooleanEnum.True)
                        {
                            // Set Deleted To True
                            deleted = true;
                        }
                    }
                }
            }
            catch (Exception error)
            {
                // If ErrorProcessor exists
                if (this.ErrorProcessor != null)
                {
                    // Log the current error
                    this.ErrorProcessor.LogError(methodName, objectName, error);
                }
            }

            // return value
            return(deleted);
        }
        /// <summary>
        /// Finds a 'Enumeration' object by the primary key.
        /// This method used the DataBridgeManager to execute the 'Find' using the
        /// procedure 'Enumeration_Find'</param>
        /// </summary>
        /// <param name='tempEnumeration'>A temporary Enumeration for passing values.</param>
        /// <returns>A 'Enumeration' object if found else a null 'Enumeration'.</returns>
        public Enumeration Find(Enumeration tempEnumeration)
        {
            // Initial values
            Enumeration enumeration = null;

            // Get information for calling 'DataBridgeManager.PerformDataOperation' method.
            string methodName = "Find";
            string objectName = "ApplicationLogicComponent.Controllers";

            try
            {
                // If object exists
                if (tempEnumeration != null)
                {
                    // Create DataOperation
                    ApplicationController.DataOperationMethod findMethod = this.AppController.DataBridge.DataOperations.EnumerationMethods.FindEnumeration;

                    // Create parameters for this method
                    List <PolymorphicObject> parameters = CreateEnumerationParameter(tempEnumeration);

                    // Perform DataOperation
                    PolymorphicObject returnObject = this.AppController.DataBridge.PerformDataOperation(methodName, objectName, findMethod, parameters);

                    // If return object exists
                    if ((returnObject != null) && (returnObject.ObjectValue as Enumeration != null))
                    {
                        // Get ReturnObject
                        enumeration = (Enumeration)returnObject.ObjectValue;
                    }
                }
            }
            catch (Exception error)
            {
                // If ErrorProcessor exists
                if (this.ErrorProcessor != null)
                {
                    // Log the current error
                    this.ErrorProcessor.LogError(methodName, objectName, error);
                }
            }

            // return value
            return(enumeration);
        }
        /// <summary>
        /// Insert a 'Enumeration' object into the database.
        /// This method uses the DataBridgeManager to execute the 'Insert' using the
        /// procedure 'Enumeration_Insert'.</param>
        /// </summary>
        /// <param name='enumeration'>The 'Enumeration' object to insert.</param>
        /// <returns>The id (int) of the new  'Enumeration' object that was inserted.</returns>
        public int Insert(Enumeration enumeration)
        {
            // Initial values
            int newIdentity = -1;

            // Get information for calling 'DataBridgeManager.PerformDataOperation' method.
            string methodName = "Insert";
            string objectName = "ApplicationLogicComponent.Controllers";

            try
            {
                // If Enumerationexists
                if (enumeration != null)
                {
                    ApplicationController.DataOperationMethod insertMethod = this.AppController.DataBridge.DataOperations.EnumerationMethods.InsertEnumeration;

                    // Create parameters for this method
                    List <PolymorphicObject> parameters = CreateEnumerationParameter(enumeration);

                    // Perform DataOperation
                    PolymorphicObject returnObject = this.AppController.DataBridge.PerformDataOperation(methodName, objectName, insertMethod, parameters);

                    // If return object exists
                    if (returnObject != null)
                    {
                        // Set return value
                        newIdentity = returnObject.IntegerValue;
                    }
                }
            }
            catch (Exception error)
            {
                // If ErrorProcessor exists
                if (this.ErrorProcessor != null)
                {
                    // Log the current error
                    this.ErrorProcessor.LogError(methodName, objectName, error);
                }
            }

            // return value
            return(newIdentity);
        }
        /// <summary>
        /// Tests the connection to the database
        /// </summary>
        internal bool TestDatabaseConnection()
        {
            // initial value
            bool connected = false;

            // locals
            string methodName = "TestDatabaseConnection";
            string objectName = "$safeprojectname$.Controller.System.SystemController";

            try
            {
                // Create Delegate For DataOperation
                ApplicationController.DataOperationMethod testDataConnection = this.DataBridge.DataOperations.SystemMethods.TestDataConnection;

                // Create null parameters object (not needed for this, but you have to have it to call the method).
                List <PolymorphicObject> parameters = null;

                // Perform DataOperation
                PolymorphicObject connectedObject = this.DataBridge.PerformDataOperation(methodName, objectName, testDataConnection, parameters);

                // If method returned "true" value.
                if (connectedObject.Boolean.Value == NullableBooleanEnum.True)
                {
                    // set connected to true.
                    connected = true;
                }
            }
            catch (Exception error)
            {
                // If ErrorProcessor exists
                if (this.ErrorProcessor != null)
                {
                    // Create Error
                    DataConnectionFailedException dataConnectionError = new DataConnectionFailedException(methodName, objectName, error);

                    // Log the current error
                    this.ErrorProcessor.LogError(methodName, objectName, dataConnectionError);
                }
            }

            // return value
            return(connected);
        }
        /// <summary>
        /// This method Updates a 'Enumeration' object in the database.
        /// This method used the DataBridgeManager to execute the 'Update' using the
        /// procedure 'Enumeration_Update'.</param>
        /// </summary>
        /// <param name='enumeration'>The 'Enumeration' object to update.</param>
        /// <returns>True if successful else false if not.</returns>
        public bool Update(Enumeration enumeration)
        {
            // Initial value
            bool saved = false;

            // Get information for calling 'DataBridgeManager.PerformDataOperation' method.
            string methodName = "Update";
            string objectName = "ApplicationLogicComponent.Controllers";

            try
            {
                if (enumeration != null)
                {
                    // Create Delegate
                    ApplicationController.DataOperationMethod updateMethod = this.AppController.DataBridge.DataOperations.EnumerationMethods.UpdateEnumeration;

                    // Create parameters for this method
                    List <PolymorphicObject> parameters = CreateEnumerationParameter(enumeration);
                    // Perform DataOperation
                    PolymorphicObject returnObject = this.AppController.DataBridge.PerformDataOperation(methodName, objectName, updateMethod, parameters);

                    // If return object exists
                    if ((returnObject != null) && (returnObject.Boolean != null) && (returnObject.Boolean.Value == NullableBooleanEnum.True))
                    {
                        // Set saved to true
                        saved = true;
                    }
                }
            }
            catch (Exception error)
            {
                // If ErrorProcessor exists
                if (this.ErrorProcessor != null)
                {
                    // Log the current error
                    this.ErrorProcessor.LogError(methodName, objectName, error);
                }
            }

            // return value
            return(saved);
        }
示例#6
0
        /// <summary>
        /// Insert a 'NotificationHistory' object into the database.
        /// This method uses the DataBridgeManager to execute the 'Insert' using the
        /// procedure 'NotificationHistory_Insert'.</param>
        /// </summary>
        /// <param name='notificationHistory'>The 'NotificationHistory' object to insert.</param>
        /// <returns>True if successful or false if not.</returns>
        public bool Insert(NotificationHistory notificationHistory)
        {
            // Initial values
            bool inserted = false;

            // Get information for calling 'DataBridgeManager.PerformDataOperation' method.
            string methodName = "Insert";
            string objectName = "ApplicationLogicComponent.Controllers";

            try
            {
                // If NotificationHistoryexists
                if (notificationHistory != null)
                {
                    ApplicationController.DataOperationMethod insertMethod = this.AppController.DataBridge.DataOperations.NotificationHistoryMethods.InsertNotificationHistory;

                    // Create parameters for this method
                    List <PolymorphicObject> parameters = CreateNotificationHistoryParameter(notificationHistory);

                    // Perform DataOperation
                    PolymorphicObject returnObject = this.AppController.DataBridge.PerformDataOperation(methodName, objectName, insertMethod, parameters);

                    // Set the return value to true
                    inserted = true;
                }
            }
            catch (Exception error)
            {
                // If ErrorProcessor exists
                if (this.ErrorProcessor != null)
                {
                    // Set inserted to false
                    inserted = false;
                    // Log the current error
                    this.ErrorProcessor.LogError(methodName, objectName, error);
                }
            }

            // return value
            return(inserted);
        }
        /// <summary>
        /// This method fetches a collection of 'Adjective' objects.
        /// This method used the DataBridgeManager to execute the fetch all using the
        /// procedure 'Adjective_FetchAll'.</summary>
        /// <param name='tempAdjective'>A temporary Adjective for passing values.</param>
        /// <returns>A collection of 'Adjective' objects.</returns>
        public List <Adjective> FetchAll(Adjective tempAdjective)
        {
            // Initial value
            List <Adjective> adjectiveList = null;

            // Get information for calling 'DataBridgeManager.PerformDataOperation' method.
            string methodName = "FetchAll";
            string objectName = "ApplicationLogicComponent.Controllers";

            try
            {
                // Create DataOperation Method
                ApplicationController.DataOperationMethod fetchAllMethod = this.AppController.DataBridge.DataOperations.AdjectiveMethods.FetchAll;

                // Create parameters for this method
                List <PolymorphicObject> parameters = CreateAdjectiveParameter(tempAdjective);

                // Perform DataOperation
                PolymorphicObject returnObject = this.AppController.DataBridge.PerformDataOperation(methodName, objectName, fetchAllMethod, parameters);

                // If return object exists
                if ((returnObject != null) && (returnObject.ObjectValue as List <Adjective> != null))
                {
                    // Create Collection From ReturnObject.ObjectValue
                    adjectiveList = (List <Adjective>)returnObject.ObjectValue;
                }
            }
            catch (Exception error)
            {
                // If ErrorProcessor exists
                if (this.ErrorProcessor != null)
                {
                    // Log the current error
                    this.ErrorProcessor.LogError(methodName, objectName, error);
                }
            }

            // return value
            return(adjectiveList);
        }
示例#8
0
        /// <summary>
        /// Performs an operation that required a connection to the database.
        /// This method uses a delegate to execute the method so that this is the
        /// only place in the application a connection to the database is opened.
        /// </summary>
        internal PolymorphicObject PerformDataOperation(string methodName, string objectName, ApplicationController.DataOperationMethod dataMethod, List <PolymorphicObject> parameters)
        {
            // Initial Value
            PolymorphicObject returnObject = null;

            // local
            bool dataConnectionNotAvailable = false;

            try
            {
                // set the last exception to null
                this.Exception = null;

                // Connect To Database
                this.LoginManager.ConnectToDatabase(this.DataManager);

                // Testing only
                string connectionString = this.DataManager.DataConnector.ConnectionString;

                // if connected
                if (this.DataManager.DataConnector.Connected)
                {
                    // verify dataMethod exists
                    if (dataMethod != null)
                    {
                        // Invoke Method
                        returnObject = dataMethod(parameters, this.DataManager.DataConnector);
                    }
                }
                else
                {
                    // set dataConnectionNotAvailable to true
                    dataConnectionNotAvailable = true;

                    // Raise Error Data Connection Not Available
                    throw new Exception("The database connection is not available.");
                }
            }
            catch (Exception error)
            {
                // Set exception
                this.Exception = error;

                // If ErrorProcessor exists
                if (this.ErrorProcessor != null)
                {
                    // If this is a dataConnection not available error.
                    if (dataConnectionNotAvailable)
                    {
                        // Create Error for data connection failed
                        DataConnectionFailedException dataConnectionError = new DataConnectionFailedException(methodName, objectName, error);

                        // Log the current dataConnectionError
                        this.ErrorProcessor.LogError(methodName, objectName, dataConnectionError);
                    }
                    else
                    {
                        // Log the exception
                        this.ErrorProcessor.LogError(methodName, objectName, error);
                    }
                }
            }
            finally
            {
                // Close Connection To Database
                this.DataManager.DataConnector.Close();
            }

            // return value
            return(returnObject);
        }