Exemple #1
0
        /// <summary>
        /// Return a list of changes between this object and an old version
        /// We really aren't that interested in changes to these details just adding and deletion
        /// </summary>
        /// <param name="oldObject"></param>
        /// <returns></returns>
        public List <AuditTrailEntry> AuditChanges(AssetGroup oldObject)
        {
            AuditTrailDAO lwDataAccess = new AuditTrailDAO();

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

            // Is this a new item or an update to an existing one
            if (GroupID == 0)
            {
                AuditTrailEntry ate = new AuditTrailEntry();
                ate.Date      = DateTime.Now;
                ate.Class     = AuditTrailEntry.CLASS.location;
                ate.Type      = AuditTrailEntry.TYPE.added;
                ate.Key       = _name;
                ate.AssetID   = 0;
                ate.AssetName = "";
                ate.Username  = System.Environment.UserName;
                listChanges.Add(ate);
            }

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

            // Return the constructed list
            return(listChanges);
        }
Exemple #2
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(User oldObject)
        {
            AuditTrailDAO lwDataAccess = new AuditTrailDAO();

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

            // The following fields may change for an Action
            //
            //	Associated Computers
            //	Notes
            //  Status
            //
            // Build a blank AuditTrailEntry
            AuditTrailEntry ate = BuildATE();

            // If the ld of the old object was 0 then this is a NEW item and not a change to an existing item
            if (UserID == 0)
            {
                ate.Type = AuditTrailEntry.TYPE.added;
                AddChange(listChanges, ate, "", "", "");
            }

            else if (oldObject != null)
            {
                // First / Last Name
                if (this._firstName != oldObject._firstName)
                {
                    ate = AddChange(listChanges, ate, "First Name", oldObject._firstName, _firstName);
                }

                if (this._lastName != oldObject._lastName)
                {
                    ate = AddChange(listChanges, ate, "Last Name", oldObject._lastName, _lastName);
                }

                // Access Level
                if (_accessLevel != oldObject._accessLevel)
                {
                    ate = AddChange(listChanges, ate, "Access Level", oldObject.AccessLevelAsString, AccessLevelAsString);
                }
            }

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


            // Return the constructed list
            return(listChanges);
        }
Exemple #3
0
        /// <summary>
        /// Delete the current license from the database
        /// </summary>
        public void Delete()
        {
            // Delete from the database
            ActionsDAO lwDataAccess = new ActionsDAO();

            lwDataAccess.ActionDelete(this);

            // ...and audit the deletion
            AuditTrailEntry ate = BuildATE();

            ate.Type = AuditTrailEntry.TYPE.deleted;

            AuditTrailDAO lAuditTrailDAO = new AuditTrailDAO();

            lAuditTrailDAO.AuditTrailAdd(ate);
        }
Exemple #4
0
        /// <summary>
        /// Delete this asset from the database
        /// </summary>
        /// <returns></returns>
        public int Delete()
        {
            AuditTrailDAO lwDataAccess = new AuditTrailDAO();

            // ...and audit the deletion
            AuditTrailEntry ate = new AuditTrailEntry();

            ate.Date      = DateTime.Now;
            ate.Class     = AuditTrailEntry.CLASS.asset;
            ate.Type      = AuditTrailEntry.TYPE.deleted;
            ate.Key       = _name;
            ate.AssetID   = 0;
            ate.AssetName = "";
            ate.Username  = System.Environment.UserName;
            lwDataAccess.AuditTrailAdd(ate);

            // Delete the asset
            AssetDAO lAssetDAO = new AssetDAO();

            lAssetDAO.AssetDelete(this);
            return(0);
        }
Exemple #5
0
        /// <summary>
        /// Return a list of changes between this object and an old version
        /// </summary>
        /// <param name="oldObject"></param>
        /// <returns></returns>
        public void AuditChanges(Asset oldObject)
        {
            AuditTrailDAO lwDataAccess = new AuditTrailDAO();

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

            // The following fields are auditable for an Asset
            //
            //	Stock Status
            //	Category
            //  Type
            //	Make
            //	Model
            //	Serial
            //	Supplier
            //
            // Build a blank AuditTrailEntry
            AuditTrailEntry ate = BuildATE();

            // We only audit changes made for existing assets so ignore if we weren't passed an original
            if (oldObject != null)
            {
                // Stock Status
                if (_stockStatus != oldObject._stockStatus)
                {
                    AddChange(listChanges, ate, "Stock Status", Asset.GetStockStatusText(oldObject._stockStatus), Asset.GetStockStatusText(_stockStatus));
                }

                // Asset Category / Tuype is the same thing
                if (_assetTypeID != oldObject._assetTypeID)
                {
                    AddChange(listChanges, ate, "Asset Type", oldObject.TypeAsString, this.TypeAsString);
                }

                // Make
                if (_make != oldObject._make)
                {
                    AddChange(listChanges, ate, "Make", oldObject._make, this._make);
                }

                // Model
                if (_model != oldObject._model)
                {
                    AddChange(listChanges, ate, "Model", oldObject._model, this._model);
                }

                // Serial
                if (_serial != oldObject._serial)
                {
                    AddChange(listChanges, ate, "Serial Number", oldObject._serial, this._serial);
                }


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

            // Return the constructed list
            return;
        }
Exemple #6
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(Action oldObject)
        {
            AuditTrailDAO lwDataAccess = new AuditTrailDAO();

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

            // The following fields may change for an Action
            //
            //	Associated Computers
            //	Notes
            //  Status
            //
            // Build a blank AuditTrailEntry
            AuditTrailEntry ate = BuildATE();

            // Is this a new item or a change to an existing item
            if (ActionID == 0)
            {
                ate.Type = AuditTrailEntry.TYPE.added;
                AddChange(listChanges, ate, "", ActionTypeText, "");
            }

            else if (oldObject != null)
            {
                // Associated Computers
                if (this._associatedAssets != oldObject.AssociatedAssets)
                {
                    ate = AddChange(listChanges, ate, "Associated Computers", oldObject.AssociatedAssets, AssociatedAssets);
                }

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

                // Status
                if (Status != oldObject.Status)
                {
                    ate = AddChange(listChanges
                                    , ate
                                    , "Status"
                                    , oldObject.StatusText
                                    , StatusText);
                }
            }

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


            // Return the constructed list
            return(listChanges);
        }
        /// <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);
        }