Пример #1
0
        /// <summary>
        /// Equality test - check to see if this instance matches another
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public override bool Equals(object obj)
        {
            if (obj != null && obj.GetType().Equals(this.GetType()))
            {
                ApplicationLicense other = obj as ApplicationLicense;

                if ((object)other != null)
                {
                    bool equality;
                    equality = other.LicenseID == LicenseID &&
                               other.ApplicationID == ApplicationID &&
                               other.ApplicationName == ApplicationName &&
                               other.LicenseTypeID == LicenseTypeID &&
                               other.LicenseTypeName == LicenseTypeName &&
                               other.UsageCounted == UsageCounted &&
                               other.Supported == Supported &&
                               other.SupplierID == SupplierID &&
                               other.SupplierName == SupplierName;

                    // If still equal and we are supported then check the support fields also
                    if (equality && Supported)
                    {
                        equality = other.SupportExpiryDate == SupportExpiryDate &&
                                   other.SupportAlertDays == other.SupportAlertDays &&
                                   other.SupportAlertEmail == other.SupportAlertEmail &&
                                   other.SupportAlertRecipients == other.SupportAlertRecipients;
                    }

                    return(equality);
                }
            }
            return(base.Equals(obj));
        }
Пример #2
0
        /// <summary>
        /// Delete the specified License from the database
        /// </summary>
        /// <param name="licenseID"></param>
        /// <returns></returns>
        public int LicenseDelete(ApplicationLicense aLicense)
        {
            if (isDebugEnabled)
            {
                logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " in with id : " + aLicense.LicenseID);
            }

            if (compactDatabaseType)
            {
                if (aLicense.LicenseID != 0)
                {
                    using (SqlCeConnection conn = DatabaseConnection.CreateOpenCEConnection())
                    {
                        try
                        {
                            string commandText =
                                "DELETE FROM LICENSES WHERE _LICENSEID = @nLicenseID";

                            using (SqlCeCommand command = new SqlCeCommand(commandText, conn))
                            {
                                command.Parameters.AddWithValue("@nLicenseID", aLicense.LicenseID);
                                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.LicenseDelete(aLicense);
            }

            if (isDebugEnabled)
            {
                logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " out");
            }
            return(0);
        }
Пример #3
0
        /// <summary>
        /// Update this defininition in the database
        /// </summary>
        /// <returns></returns>
        public int Update(ApplicationLicense oldLicense)
        {
            LicensesDAO lwDataAccess = new LicensesDAO();

            if (_licenseID == 0)
            {
                Add();
            }
            else if (oldLicense != this)
            {
                lwDataAccess.LicenseUpdate(this);
                AuditChanges(oldLicense);
            }

            return(0);
        }
Пример #4
0
 /// <summary>
 /// Load licenses for this application from the supplied DataTable
 /// </summary>
 /// <param name="licensesTable"></param>
 protected void LoadLicenses(DataTable licensesTable)
 {
     _listLicenses.Clear();
     foreach (DataRow row in licensesTable.Rows)
     {
         try
         {
             ApplicationLicense newLicense = new ApplicationLicense(row);
             _listLicenses.Add(newLicense);
         }
         catch (Exception)
         {
             // Just skip the license as this points to an internal database consistency error
         }
     }
 }
Пример #5
0
 /// <summary>
 /// Load licenses for this application from the supplied DataTable
 /// </summary>
 public void LoadLicenses1(DataRow[] licensesTableRows)
 {
     //_listLicenses.Clear();
     foreach (DataRow row in licensesTableRows)
     {
         try
         {
             ApplicationLicense newLicense = new ApplicationLicense(row);
             _listLicenses.Add(newLicense);
         }
         catch (Exception)
         {
             // Just skip the license as this points to an internal database consistency error
         }
     }
     _licensesLoaded = true;
 }
Пример #6
0
 // Copy Constructor
 public ApplicationLicense(ApplicationLicense theLicense)
 {
     this.LicenseID       = theLicense.LicenseID;
     this.ApplicationID   = theLicense.ApplicationID;
     this.ApplicationName = theLicense.ApplicationName;
     this.LicenseTypeID   = theLicense.LicenseTypeID;
     this.LicenseTypeName = theLicense.LicenseTypeName;
     this.UsageCounted    = theLicense.UsageCounted;
     this.Count           = theLicense.Count;
     //
     this.Supported              = theLicense.Supported;
     this.SupportExpiryDate      = theLicense.SupportExpiryDate;
     this.SupportAlertDays       = theLicense.SupportAlertDays;
     this.SupportAlertEmail      = theLicense.SupportAlertEmail;
     this.SupportAlertRecipients = theLicense.SupportAlertRecipients;
     //
     this.SupplierID   = theLicense.SupplierID;
     this.SupplierName = theLicense.SupplierName;
 }
Пример #7
0
        /// <summary>
        /// Update the definition stored for the specified Application License
        /// </summary>
        /// <returns></returns>
        public int LicenseUpdate(ApplicationLicense aLicense)
        {
            if (isDebugEnabled)
            {
                logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " in");
            }

            if (compactDatabaseType)
            {
                try
                {
                    using (SqlCeConnection conn = DatabaseConnection.CreateOpenCEConnection())
                    {
                        string commandText =
                            "UPDATE LICENSES SET _LICENSETYPEID = @nLicenseTypeID " +
                            ",_APPLICATIONID = @nApplicationID " +
                            ",_COUNT = @nCount " +
                            ",_SUPPORTED = @bSupported " +
                            ",_SUPPORT_EXPIRES = @dtSupportExpiry " +
                            ",_SUPPORT_ALERTDAYS = @nSupportAlertDays " +
                            ",_SUPPORT_ALERTBYEMAIL = @bSupportAlertEmail " +
                            ",_SUPPORT_ALERTRECIPIENTS = @cSupportAlertRecipients " +
                            ",_SUPPLIERID = @nSupplierID " +
                            "WHERE _LICENSEID = @nLicenseID";

                        SqlCeParameter[] spParams = new SqlCeParameter[10];
                        spParams[0] = new SqlCeParameter("@nLicenseID", aLicense.LicenseID);
                        spParams[1] = new SqlCeParameter("@nLicenseTypeID", aLicense.LicenseTypeID);
                        spParams[2] = new SqlCeParameter("@nApplicationID", aLicense.ApplicationID);
                        spParams[3] = new SqlCeParameter("@nCount", aLicense.Count);
                        spParams[3] = new SqlCeParameter("@nCount", aLicense.Count);
                        spParams[4] = new SqlCeParameter("@bSupported", Convert.ToInt32(aLicense.Supported));
                        spParams[5] = new SqlCeParameter("@dtSupportExpiry", aLicense.SupportExpiryDate);
                        spParams[6] = new SqlCeParameter("@nSupportAlertDays", aLicense.SupportAlertDays);
                        spParams[7] = new SqlCeParameter("@bSupportAlertEmail", Convert.ToInt32(aLicense.SupportAlertEmail));
                        spParams[8] = new SqlCeParameter("@cSupportAlertRecipients", aLicense.SupportAlertRecipients);
                        spParams[9] = new SqlCeParameter("@nSupplierID", aLicense.SupplierID);

                        using (SqlCeCommand command = new SqlCeCommand(commandText, conn))
                        {
                            command.Parameters.AddRange(spParams);
                            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.LicenseUpdate(aLicense);
            }

            if (isDebugEnabled)
            {
                logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " out");
            }
            return(0);
        }
Пример #8
0
        /// <summary>
        /// Add a new Application License to the database
        /// </summary>
        /// <returns></returns>
        public int LicenseAdd(ApplicationLicense aLicense)
        {
            if (isDebugEnabled)
            {
                logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " in");
            }

            int lItemID = 0;

            if (compactDatabaseType)
            {
                try
                {
                    using (SqlCeConnection conn = DatabaseConnection.CreateOpenCEConnection())
                    {
                        string commandText =
                            "INSERT INTO LICENSES " +
                            "(_LICENSETYPEID ,_APPLICATIONID ,_COUNT ,_SUPPORTED ,_SUPPORT_EXPIRES " +
                            ",_SUPPORT_ALERTDAYS ,_SUPPORT_ALERTBYEMAIL ,_SUPPORT_ALERTRECIPIENTS ,_SUPPLIERID) " +
                            "VALUES " +
                            "(@nLicenseTypeID, @nForApplicationID, @nCount, @bSupported " +
                            ",@dtSupportExpiry, @nSupportAlertDays, @bSupportAlertEmail, @cSupportAlertRecipients " +
                            ",@nSupplierID)";

                        SqlCeParameter[] spParams = new SqlCeParameter[9];
                        spParams[0] = new SqlCeParameter("@nLicenseTypeID", aLicense.LicenseTypeID);
                        spParams[1] = new SqlCeParameter("@nForApplicationID", aLicense.ApplicationID);
                        spParams[2] = new SqlCeParameter("@nCount", aLicense.Count);
                        spParams[3] = new SqlCeParameter("@bSupported", Convert.ToInt32(aLicense.Supported));
                        spParams[4] = new SqlCeParameter("@dtSupportExpiry", aLicense.SupportExpiryDate);
                        spParams[5] = new SqlCeParameter("@nSupportAlertDays", aLicense.SupportAlertDays);
                        spParams[6] = new SqlCeParameter("@bSupportAlertEmail", Convert.ToInt32(aLicense.SupportAlertEmail));
                        spParams[7] = new SqlCeParameter("@cSupportAlertRecipients", aLicense.SupportAlertRecipients);
                        spParams[8] = new SqlCeParameter("@nSupplierID", aLicense.SupplierID);

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

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

            if (isDebugEnabled)
            {
                logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " out with id : " + lItemID);
            }
            return(lItemID);
        }
Пример #9
0
        /// <summary>
        /// Return a list of changes between this object and an old version
        /// </summary>
        /// <param name="oldObject"></param>
        /// <returns></returns>
        public List <AuditTrailEntry> AuditChanges(ApplicationLicense oldObject)
        {
            AuditTrailDAO lwDataAccess = new AuditTrailDAO();

            // Construct the return list
            List <AuditTrailEntry> listChanges = new List <AuditTrailEntry>();

            // License ID and ApplicationID must not change as these are basic properties of
            // the application license - Build a blank AuditTrailEntry
            AuditTrailEntry ate = BuildATE();

            // Is this a new license rather than one we are modifying?
            if (LicenseID == 0)
            {
                ate.Type = AuditTrailEntry.TYPE.added;
                AddChange(listChanges, ate, "", "", "");
            }

            else if (oldObject != null)
            {
                // License Type ID - note that if we change this we ignore related changes such as to the
                // usage counted or count fields as these will change if the type is changed
                if (this.LicenseTypeID != oldObject.LicenseTypeID)
                {
                    ate = AddChange(listChanges, ate, "License Type", oldObject.LicenseTypeName, LicenseTypeName);
                }
                else
                {
                    // Usage Counted
                    if (this.UsageCounted != oldObject.UsageCounted)
                    {
                        ate = AddChange(listChanges
                                        , ate
                                        , "Usage Counted"
                                        , (oldObject.UsageCounted) ? "Yes" : "No"
                                        , (UsageCounted) ? "Yes" : "No");
                    }

                    // Usage Count
                    if (this.Count != oldObject.Count)
                    {
                        ate = AddChange(listChanges
                                        , ate
                                        , "Usage Count"
                                        , oldObject.Count.ToString()
                                        , Count.ToString());
                    }
                }

                // Supported Status
                if (Supported != oldObject.Supported)
                {
                    ate = AddChange(listChanges
                                    , ate
                                    , "Support Status"
                                    , (oldObject.Supported) ? "Yes" : "No"
                                    , (Supported) ? "Yes" : "No");
                }

                // If we are supported then we need to log other support fields also
                if (Supported)
                {
                    // Support Expiry Date
                    if (SupportExpiryDate != oldObject.SupportExpiryDate)
                    {
                        ate = AddChange(listChanges, ate, "Support Expiry Date", oldObject.SupportExpiryDate.ToString(), SupportExpiryDate.ToString());
                    }

                    // Support Alert Days
                    if (SupportAlertDays != oldObject.SupportAlertDays)
                    {
                        ate = AddChange(listChanges, ate, "Support Expiry Alert Days", oldObject.SupportAlertDays.ToString(), SupportAlertDays.ToString());
                    }

                    // Support Alert by Email Status
                    if (SupportAlertEmail != oldObject.SupportAlertEmail)
                    {
                        ate = AddChange(listChanges
                                        , ate
                                        , "Support Alert by Email"
                                        , (oldObject.SupportAlertEmail) ? "Yes" : "No"
                                        , (SupportAlertEmail) ? "Yes" : "No");
                    }

                    // Support Alert Email Recipients
                    if (this.SupportAlertRecipients != oldObject.SupportAlertRecipients)
                    {
                        ate = AddChange(listChanges, ate, "Support Alert Email Recipients", oldObject.SupportAlertRecipients.ToString(), SupportAlertRecipients);
                    }
                }

                // Supplier
                if (SupplierID != oldObject.SupplierID)
                {
                    ate = AddChange(listChanges
                                    , ate
                                    , "Supplier"
                                    , oldObject.SupplierName
                                    , SupplierName);
                }
            }

            // Add all of these changes to the Audit Trail
            foreach (AuditTrailEntry entry in listChanges)
            {
                lwDataAccess.AuditTrailAdd(entry);
            }

            // Return the constructed list
            return(listChanges);
        }
Пример #10
0
 /// <summary>
 /// Return a table containing all of the Documents defined for an application license
 /// </summary>
 /// <returns></returns>
 public DataTable EnumerateDocuments(ApplicationLicense aLicense)
 {
     return(EnumerateDocuments(SCOPE.License, aLicense.LicenseID));
 }