Example #1
0
        /// <summary>
        /// Update the definition stored for the specified LicenseType
        /// </summary>
        /// <param name="theAsset"></param>
        /// <returns></returns>
        public int LicenseTypeUpdate(LicenseType aLicenseType)
        {
            if (isDebugEnabled)
            {
                logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " in with license type id : " + aLicenseType.LicenseTypeID);
            }

            if (compactDatabaseType)
            {
                try
                {
                    using (SqlCeConnection conn = DatabaseConnection.CreateOpenCEConnection())
                    {
                        string commandText =
                            "UPDATE LICENSE_TYPES SET _COUNTED = @bPerPC " +
                            "WHERE _LICENSETYPEID = @nLicenseTypeID";

                        using (SqlCeCommand command = new SqlCeCommand(commandText, conn))
                        {
                            command.Parameters.AddWithValue("@bPerPC", aLicenseType.PerComputer);
                            command.Parameters.AddWithValue("@nLicenseTypeID", aLicenseType.LicenseTypeID);

                            command.ExecuteNonQuery();
                        }
                    }
                }
                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();
                lAuditWizardDataAccess.LicenseTypeUpdate(aLicenseType);
            }

            if (isDebugEnabled)
            {
                logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " out");
            }
            return(0);
        }
Example #2
0
        /// <summary>
        /// Return a table containing all of the license types that have been declared
        /// </summary>
        /// <returns></returns>
        public DataTable EnumerateLicenses(LicenseType aLicenseType)
        {
            if (isDebugEnabled)
            {
                logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " in");
            }

            DataTable licensesTable = new DataTable(TableNames.LICENSES);

            if (compactDatabaseType)
            {
                try
                {
                    using (SqlCeConnection conn = DatabaseConnection.CreateOpenCEConnection())
                    {
                        string commandText =
                            "SELECT _LICENSEID ,_LICENSETYPEID ,_APPLICATIONID ,_COUNT " +
                            "FROM LICENSES";

                        if (aLicenseType != null)
                        {
                            commandText += " WHERE _LICENSETYPEID = @nLicenseTypeID";
                        }

                        using (SqlCeCommand command = new SqlCeCommand(commandText, conn))
                        {
                            if (aLicenseType != null)
                            {
                                command.Parameters.AddWithValue("@nLicenseTypeID", aLicenseType.LicenseTypeID);
                            }

                            new SqlCeDataAdapter(command).Fill(licensesTable);
                        }
                    }
                }
                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();
                licensesTable = lAuditWizardDataAccess.EnumerateLicenses(aLicenseType);
            }

            if (isDebugEnabled)
            {
                logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " out");
            }
            return(licensesTable);
        }
Example #3
0
        /// <summary>
        /// Add a new License Type to the database
        /// </summary>
        /// <param name="theLicenseType"></param>
        /// <returns></returns>
        public int LicenseTypeAdd(LicenseType theLicenseType)
        {
            if (isDebugEnabled)
            {
                logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " in");
            }
            int lItemID = 0;

            if (compactDatabaseType)
            {
                try
                {
                    string commandText =
                        "INSERT INTO LICENSE_TYPES (_NAME, _COUNTED) " +
                        "VALUES (@cName, @bPerPC)";

                    using (SqlCeConnection conn = DatabaseConnection.CreateOpenCEConnection())
                    {
                        SqlCeParameter[] spParams = new SqlCeParameter[2];
                        spParams[0] = new SqlCeParameter("@cName", theLicenseType.Name);
                        spParams[1] = new SqlCeParameter("@bPerPC", theLicenseType.PerComputer);

                        using (SqlCeCommand command = new SqlCeCommand(commandText, conn))
                        {
                            command.Parameters.AddRange(spParams);
                            command.ExecuteNonQuery();
                        }

                        // then get id of newly inserted record
                        using (SqlCeCommand command = new SqlCeCommand("SELECT @@IDENTITY", conn))
                        {
                            lItemID = Convert.ToInt32(command.ExecuteScalar());
                        }
                    }
                }
                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();
                lItemID = lAuditWizardDataAccess.LicenseTypeAdd(theLicenseType);
            }

            if (isDebugEnabled)
            {
                logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " out");
            }
            return(lItemID);
        }
Example #4
0
        /// <summary>
        /// Delete the specified License TYPE from the database
        /// </summary>
        /// <param name="licenseTypeID"></param>
        /// <returns></returns>
        public int LicenseTypeDelete(LicenseType aLicenseType)
        {
            if (isDebugEnabled)
            {
                logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " in");
            }

            if (compactDatabaseType)
            {
                if (aLicenseType.LicenseTypeID != 0)
                {
                    SqlCeTransaction transaction = null;

                    using (SqlCeConnection conn = DatabaseConnection.CreateOpenCEConnection())
                    {
                        try
                        {
                            transaction = conn.BeginTransaction();

                            string commandText =
                                "DELETE FROM LICENSES WHERE _LICENSETYPEID = @nLicenseTypeID";

                            using (SqlCeCommand command = new SqlCeCommand(commandText, conn))
                            {
                                command.Parameters.AddWithValue("@nLicenseTypeID", aLicenseType.LicenseTypeID);
                                command.ExecuteNonQuery();
                            }

                            commandText =
                                "DELETE FROM LICENSE_TYPES WHERE _LICENSETYPEID = @nLicenseTypeID";

                            using (SqlCeCommand command = new SqlCeCommand(commandText, conn))
                            {
                                command.Parameters.AddWithValue("@nLicenseTypeID", aLicenseType.LicenseTypeID);
                                command.ExecuteNonQuery();
                            }

                            transaction.Commit();
                        }
                        catch (SqlCeException ex)
                        {
                            transaction.Rollback();

                            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)
                        {
                            transaction.Rollback();

                            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();
                lAuditWizardDataAccess.LicenseTypeDelete(aLicenseType);
            }

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