/// <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);
        }
Esempio n. 2
0
        /// <summary>
        /// This method creates the parameter for a 'DTNProcedure' data operation.
        /// </summary>
        /// <param name='dtnprocedure'>The 'DTNProcedure' to use as the first
        /// parameter (parameters[0]).</param>
        /// <returns>A List<PolymorphicObject> collection.</returns>
        private List <PolymorphicObject> CreateDTNProcedureParameter(DTNProcedure dTNProcedure)
        {
            // Initial Value
            List <PolymorphicObject> parameters = new List <PolymorphicObject>();

            // Create PolymorphicObject to hold the parameter
            PolymorphicObject parameter = new PolymorphicObject();

            // Set parameter.ObjectValue
            parameter.ObjectValue = dTNProcedure;

            // Add userParameter to parameters
            parameters.Add(parameter);

            // return value
            return(parameters);
        }
        /// <summary>
        /// This method creates the parameter for a 'RawImport' data operation.
        /// </summary>
        /// <param name='rawimport'>The 'RawImport' to use as the first
        /// parameter (parameters[0]).</param>
        /// <returns>A List<PolymorphicObject> collection.</returns>
        private List <PolymorphicObject> CreateRawImportParameter(RawImport rawImport)
        {
            // Initial Value
            List <PolymorphicObject> parameters = new List <PolymorphicObject>();

            // Create PolymorphicObject to hold the parameter
            PolymorphicObject parameter = new PolymorphicObject();

            // Set parameter.ObjectValue
            parameter.ObjectValue = rawImport;

            // Add userParameter to parameters
            parameters.Add(parameter);

            // return value
            return(parameters);
        }
        /// <summary>
        /// This method creates the parameter for a 'ProjectReference' data operation.
        /// </summary>
        /// <param name='projectreference'>The 'ProjectReference' to use as the first
        /// parameter (parameters[0]).</param>
        /// <returns>A List<PolymorphicObject> collection.</returns>
        private List <PolymorphicObject> CreateProjectReferenceParameter(ProjectReference projectReference)
        {
            // Initial Value
            List <PolymorphicObject> parameters = new List <PolymorphicObject>();

            // Create PolymorphicObject to hold the parameter
            PolymorphicObject parameter = new PolymorphicObject();

            // Set parameter.ObjectValue
            parameter.ObjectValue = projectReference;

            // Add userParameter to parameters
            parameters.Add(parameter);

            // return value
            return(parameters);
        }
        /// <summary>
        /// This method creates the parameter for a 'Adjective' data operation.
        /// </summary>
        /// <param name='adjective'>The 'Adjective' to use as the first
        /// parameter (parameters[0]).</param>
        /// <returns>A List<PolymorphicObject> collection.</returns>
        private List <PolymorphicObject> CreateAdjectiveParameter(Adjective adjective)
        {
            // Initial Value
            List <PolymorphicObject> parameters = new List <PolymorphicObject>();

            // Create PolymorphicObject to hold the parameter
            PolymorphicObject parameter = new PolymorphicObject();

            // Set parameter.ObjectValue
            parameter.ObjectValue = adjective;

            // Add userParameter to parameters
            parameters.Add(parameter);

            // return value
            return(parameters);
        }
        /// <summary>
        /// This method creates the parameter for a 'Enumeration' data operation.
        /// </summary>
        /// <param name='enumeration'>The 'Enumeration' to use as the first
        /// parameter (parameters[0]).</param>
        /// <returns>A List<PolymorphicObject> collection.</returns>
        private List <PolymorphicObject> CreateEnumerationParameter(Enumeration enumeration)
        {
            // Initial Value
            List <PolymorphicObject> parameters = new List <PolymorphicObject>();

            // Create PolymorphicObject to hold the parameter
            PolymorphicObject parameter = new PolymorphicObject();

            // Set parameter.ObjectValue
            parameter.ObjectValue = enumeration;

            // Add userParameter to parameters
            parameters.Add(parameter);

            // return value
            return(parameters);
        }
        /// <summary>
        /// This method creates the parameter for a 'FieldSetFieldView' data operation.
        /// </summary>
        /// <param name='fieldsetfieldview'>The 'FieldSetFieldView' to use as the first
        /// parameter (parameters[0]).</param>
        /// <returns>A List<PolymorphicObject> collection.</returns>
        private List <PolymorphicObject> CreateFieldSetFieldViewParameter(FieldSetFieldView fieldSetFieldView)
        {
            // Initial Value
            List <PolymorphicObject> parameters = new List <PolymorphicObject>();

            // Create PolymorphicObject to hold the parameter
            PolymorphicObject parameter = new PolymorphicObject();

            // Set parameter.ObjectValue
            parameter.ObjectValue = fieldSetFieldView;

            // Add userParameter to parameters
            parameters.Add(parameter);

            // return value
            return(parameters);
        }
Esempio n. 8
0
        /// <summary>
        /// This method creates the parameter for a 'GitHubFollower' data operation.
        /// </summary>
        /// <param name='githubfollower'>The 'GitHubFollower' to use as the first
        /// parameter (parameters[0]).</param>
        /// <returns>A List<PolymorphicObject> collection.</returns>
        private List <PolymorphicObject> CreateGitHubFollowerParameter(GitHubFollower gitHubFollower)
        {
            // Initial Value
            List <PolymorphicObject> parameters = new List <PolymorphicObject>();

            // Create PolymorphicObject to hold the parameter
            PolymorphicObject parameter = new PolymorphicObject();

            // Set parameter.ObjectValue
            parameter.ObjectValue = gitHubFollower;

            // Add userParameter to parameters
            parameters.Add(parameter);

            // return value
            return(parameters);
        }
        /// <summary>
        /// This method creates the parameter for a 'CustomReader' data operation.
        /// </summary>
        /// <param name='customreader'>The 'CustomReader' to use as the first
        /// parameter (parameters[0]).</param>
        /// <returns>A List<PolymorphicObject> collection.</returns>
        private List <PolymorphicObject> CreateCustomReaderParameter(CustomReader customReader)
        {
            // Initial Value
            List <PolymorphicObject> parameters = new List <PolymorphicObject>();

            // Create PolymorphicObject to hold the parameter
            PolymorphicObject parameter = new PolymorphicObject();

            // Set parameter.ObjectValue
            parameter.ObjectValue = customReader;

            // Add userParameter to parameters
            parameters.Add(parameter);

            // return value
            return(parameters);
        }
Esempio n. 10
0
        /// <summary>
        /// This method creates the parameter for a 'Method' data operation.
        /// </summary>
        /// <param name='method'>The 'Method' to use as the first
        /// parameter (parameters[0]).</param>
        /// <returns>A List<PolymorphicObject> collection.</returns>
        private List <PolymorphicObject> CreateMethodParameter(Method method)
        {
            // Initial Value
            List <PolymorphicObject> parameters = new List <PolymorphicObject>();

            // Create PolymorphicObject to hold the parameter
            PolymorphicObject parameter = new PolymorphicObject();

            // Set parameter.ObjectValue
            parameter.ObjectValue = method;

            // Add userParameter to parameters
            parameters.Add(parameter);

            // return value
            return(parameters);
        }
Esempio n. 11
0
        /// <summary>
        /// This method creates the parameter for a 'NotificationHistory' data operation.
        /// </summary>
        /// <param name='notificationhistory'>The 'NotificationHistory' to use as the first
        /// parameter (parameters[0]).</param>
        /// <returns>A List<PolymorphicObject> collection.</returns>
        private List <PolymorphicObject> CreateNotificationHistoryParameter(NotificationHistory notificationHistory)
        {
            // Initial Value
            List <PolymorphicObject> parameters = new List <PolymorphicObject>();

            // Create PolymorphicObject to hold the parameter
            PolymorphicObject parameter = new PolymorphicObject();

            // Set parameter.ObjectValue
            parameter.ObjectValue = notificationHistory;

            // Add userParameter to parameters
            parameters.Add(parameter);

            // return value
            return(parameters);
        }
        /// <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);
        }
Esempio n. 14
0
        /// <summary>
        /// Tests the connection to the database
        /// </summary>
        internal bool TestDatabaseConnection()
        {
            // initial value
            bool connected = false;

            // locals
            string methodName = "TestDatabaseConnection";
            string objectName = "ApplicationLogicComponent.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);
        }
Esempio n. 16
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 Executes a Non Query StoredProcedure
        /// </summary>
        public PolymorphicObject ExecuteNonQuery(string procedureName, SqlParameter[] sqlParameters)
        {
            // initial value
            PolymorphicObject returnValue = new PolymorphicObject();

            // locals
            List <PolymorphicObject> parameters = new List <PolymorphicObject>();

            // create the parameters
            PolymorphicObject procedureNameParameter = new PolymorphicObject();
            PolymorphicObject sqlParametersParameter = new PolymorphicObject();

            // if the procedureName exists
            if (!String.IsNullOrEmpty(procedureName))
            {
                // Create an instance of the SystemMethods object
                SystemMethods systemMethods = new SystemMethods();

                // setup procedureNameParameter
                procedureNameParameter.Name = "ProcedureName";
                procedureNameParameter.Text = procedureName;

                // setup sqlParametersParameter
                sqlParametersParameter.Name        = "SqlParameters";
                sqlParametersParameter.ObjectValue = sqlParameters;

                // Add these parameters to the parameters
                parameters.Add(procedureNameParameter);
                parameters.Add(sqlParametersParameter);

                // get the dataConnector
                DataAccessComponent.DataManager.DataConnector dataConnector = GetDataConnector();

                // Execute the query
                returnValue = systemMethods.ExecuteNonQuery(parameters, dataConnector);
            }

            // return value
            return(returnValue);
        }
        /// <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);
        }
Esempio n. 19
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);
        }