Esempio n. 1
0
        public int Populate(Operation.OPERATION operationType, Operation.STATUS status)
        {
            // Ensure that the list is empty initially
            this.Clear();

            AuditWizardDataAccess lwDataAccess = new AuditWizardDataAccess();
            DataTable             table        = lwDataAccess.EnumerateOperations(operationType, status);

            // Iterate through the returned rows in the table and create AssetType objects for each
            foreach (DataRow row in table.Rows)
            {
                AddOperation(row);
            }
            return(this.Count);
        }
Esempio n. 2
0
        /// <summary>
        /// Return a table containing all of the Operations defined
        /// </summary>
        /// <returns></returns>
        public DataTable EnumerateOperations(Operation.OPERATION aOperationType, Operation.STATUS aStatus)
        {
            if (isDebugEnabled)
            {
                logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " in");
            }

            DataTable table = new DataTable(TableNames.OPERATIONS);

            if (compactDatabaseType)
            {
                try
                {
                    using (SqlCeConnection conn = DatabaseConnection.CreateOpenCEConnection())
                    {
                        string commandText =
                            "SELECT OPERATIONS.* " +
                            ",ASSETS._NAME AS ASSETNAME " +
                            "FROM OPERATIONS " +
                            "LEFT JOIN ASSETS ON (ASSETS._ASSETID = OPERATIONS._ASSETID) ";

                        if ((int)aOperationType != -1)
                        {
                            commandText += "WHERE OPERATIONS._OPERATION = @nOperation ";
                        }

                        if ((int)aStatus != -1)
                        {
                            if ((int)aOperationType == -1)
                            {
                                commandText += "WHERE OPERATIONS._STATUS = @nStatus ";
                            }
                            else
                            {
                                commandText += "AND OPERATIONS._STATUS = @nStatus ";
                            }
                        }

                        commandText += "ORDER BY _OPERATIONID";

                        using (SqlCeCommand command = new SqlCeCommand(commandText, conn))
                        {
                            if ((int)aOperationType != -1)
                            {
                                command.Parameters.AddWithValue("@nOperation", (int)aOperationType);
                            }

                            if ((int)aStatus != -1)
                            {
                                command.Parameters.AddWithValue("@nStatus", (int)aStatus);
                            }

                            new SqlCeDataAdapter(command).Fill(table);
                        }
                    }
                }
                catch (SqlCeException ex)
                {
                    Utility.DisplayErrorMessage("A database error has occurred in AuditWizard." + Environment.NewLine + Environment.NewLine +
                                                "Please see the log file for further details.");
                    logger.Error("Exception in " + System.Reflection.MethodBase.GetCurrentMethod().Name, ex);
                }
                catch (Exception ex)
                {
                    Utility.DisplayErrorMessage("A database error has occurred in AuditWizard." + Environment.NewLine + Environment.NewLine +
                                                "Please see the log file for further details.");

                    logger.Error("Exception in " + System.Reflection.MethodBase.GetCurrentMethod().Name, ex);
                }
            }
            else
            {
                AuditWizardDataAccess lAuditWizardDataAccess = new AuditWizardDataAccess();
                table = lAuditWizardDataAccess.EnumerateOperations(aOperationType, aStatus);
            }

            if (isDebugEnabled)
            {
                logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " out");
            }
            return(table);
        }