private string HandleUserData(string applicationFilter)
        {
            string    parentDefinition;
            string    userDataName;
            string    userDataValue;
            string    newIds           = String.Empty;
            DataTable resultsDataTable = new DataTable();
            UserDataDefinitionsDAO lUserDataDefinitionsDAO = new UserDataDefinitionsDAO();

            string uf = applicationFilter;

            userDataName     = uf.Substring(uf.IndexOf("and _name = '") + 13, uf.IndexOf("and _value") - (uf.IndexOf("and _name = '") + 15));
            userDataValue    = uf.Substring(uf.LastIndexOf("=") + 2);
            parentDefinition = uf.Substring(22, uf.IndexOf("and _name =") - 24);

            resultsDataTable = lUserDataDefinitionsDAO.GetCompliantUserData(userDataName, parentDefinition, userDataValue);

            foreach (DataRow compliantRow in resultsDataTable.Rows)
            {
                if (!newIds.Contains(compliantRow.ItemArray[0].ToString()))
                {
                    newIds += compliantRow.ItemArray[0].ToString() + ",";
                }
            }

            return(newIds.TrimEnd(','));
        }
Exemple #2
0
        /// <summary>
        /// Recover the values for the fields within this category for the specified asset
        /// </summary>
        /// <param name="asset"></param>
        public void GetValuesFor(int itemID)
        {
            UserDataDefinitionsDAO lwDataAccess = new UserDataDefinitionsDAO();
            DataTable table = lwDataAccess.EnumerateUserDataValues(_scope, itemID, _categoryID);

            foreach (DataRow row in table.Rows)
            {
                // Get the value and ID of the field
                string value     = (string)row["_VALUE"];
                int    userDefID = (int)row["_USERDEFID"];
                SetValueFor(itemID, userDefID, value, false);
            }
        }
        private void UpdateCategoriesTabOrder()
        {
            UserDataDefinitionsDAO lUserDataDefinitionsDao = new UserDataDefinitionsDAO();

            for (int i = 0; i < userDataExplorerBar.Groups[0].Items.Count; i++)
            {
                UserDataCategory userDataCategory = userDataExplorerBar.Groups[0].Items[i].Tag as UserDataCategory;
                if (userDataCategory != null)
                {
                    userDataCategory.TabOrder = i;
                    lUserDataDefinitionsDao.UserDataCategoryUpdate(userDataCategory);
                }
            }
        }
        private void UpdateFieldsTabOrder()
        {
            UserDataDefinitionsDAO lUserDataDefinitionsDao = new UserDataDefinitionsDAO();

            for (int i = 0; i < ulvUserData.Items.Count; i++)
            {
                UserDataField udf = ulvUserData.Items[i].Tag as UserDataField;
                if (udf != null)
                {
                    udf.TabOrder = i;
                    lUserDataDefinitionsDao.UserDataFieldUpdate(udf);
                }
            }
        }
Exemple #5
0
        public bool Delete()
        {
            UserDataDefinitionsDAO lwDataAccess = new UserDataDefinitionsDAO();

            foreach (UserDataField dataField in this)
            {
                if (!lwDataAccess.UserDataDefinitionFieldDelete(dataField.FieldID))
                {
                    return(false);
                }
            }

            return(lwDataAccess.UserDataDefinitionCategoryDelete(CategoryID));
        }
Exemple #6
0
        /// <summary>
        /// Add this User Data Category to the database (or possibly update an existing item)
        /// </summary>
        /// <returns></returns>
        public int Add()
        {
            UserDataDefinitionsDAO lwDataAccess = new UserDataDefinitionsDAO();

            if (CategoryID == 0)
            {
                _categoryID = lwDataAccess.UserDataCategoryAdd(this);
            }
            else
            {
                lwDataAccess.UserDataCategoryUpdate(this);
            }
            return(0);
        }
Exemple #7
0
        /// <summary>
        /// Recover ALL stored values for this field
        /// </summary>
        public void PopulateValues()
        {
            UserDataDefinitionsDAO lwDataAccess = new UserDataDefinitionsDAO();
            DataTable table = lwDataAccess.EnumerateUserDataFieldValues(_fieldID);

            foreach (DataRow row in table.Rows)
            {
                // Get the value and ID of the field
                int    assetID = (int)row["_PARENTID"];
                string value   = (string)row["_VALUE"];
                SetValueFor(assetID, value, false);
            }

            _populated = true;
        }
Exemple #8
0
        /// <summary>
        /// Add this User Data Field to the database (or possibly update an existing item)
        /// </summary>
        /// <returns></returns>
        public int Add()
        {
            UserDataDefinitionsDAO lUserDataDefinitionsDAO = new UserDataDefinitionsDAO();

            if (FieldID == 0)
            {
                _fieldID = lUserDataDefinitionsDAO.UserDataFieldAdd(this);
            }
            else
            {
                // editing a user data field
                lUserDataDefinitionsDAO.UserDataFieldUpdate(this);
                lUserDataDefinitionsDAO.UpdateUserDataValueParentType(FieldID, (int)ParentScope);
            }
            return(0);
        }
Exemple #9
0
        /// <summary>
        /// Add a value for this data field for the specified asset
        /// </summary>
        /// <param name="itemID"></param>
        /// <param name="value"></param>
        /// <param name="updateDatabase"></param>
        public void SetValueFor(int itemID, string value, bool updateDatabase)
        {
            if (_listCurrentValues.ContainsKey(itemID))
            {
                _listCurrentValues[itemID] = value;
            }
            else
            {
                _listCurrentValues.Add(itemID, value);
            }

            // Update the database also if requested
            if (updateDatabase)
            {
                UserDataDefinitionsDAO lwDataAccess = new UserDataDefinitionsDAO();
                lwDataAccess.UserDataUpdateValue(_parentScope, itemID, _fieldID, value);
            }
        }
Exemple #10
0
        /// <summary>
        /// Populate the list with all currently defined user defined data categories and associated fields
        /// </summary>
        /// <returns></returns>
        public int Populate()
        {
            // Ensure that the list is empty initially
            Clear();

            UserDataDefinitionsDAO lwDataAccess = new UserDataDefinitionsDAO();
            DataTable table = lwDataAccess.EnumerateUserDataDefinitions(_scope);

            // Iterate through the returned table and add to our internal list
            Clear();
            foreach (DataRow thisRow in table.Rows)
            {
                AddItem(thisRow);
            }

            // Flag as having populated the list
            _populated = true;

            return(Count);
        }
Exemple #11
0
        private void PopulatePickerList(List <string> itemParts)
        {
            string category;
            string name;
            string value;

            if (itemParts.Count == 3)
            {
                category = itemParts[0] + "|" + itemParts[1];
                name     = itemParts[2];
            }
            else if (itemParts.Count == 4)
            {
                category = itemParts[0] + "|" + itemParts[1] + "|" + itemParts[2];
                name     = itemParts[3];
            }
            else if (itemParts.Count == 5)
            {
                category = itemParts[0] + "|" + itemParts[1] + "|" + itemParts[2] + "|" + itemParts[3];
                name     = itemParts[4];
            }
            else
            {
                category = itemParts[0];
                name     = itemParts[1];
            }

            cbValuePicker.Items.Clear();
            cbValuePicker.Text = String.Empty;
            cbValuePicker.Refresh();

            DataTable pickerValuesDataTable = new DataTable();

            if (category.StartsWith("UserData|"))
            {
                pickerValuesDataTable = new UserDataDefinitionsDAO().GetUserDataPickerValues(name, category.Split('|')[1]);
            }
            else if (category.StartsWith("Asset Details"))
            {
                string columnName = String.Empty;

                switch (name)
                {
                case "Asset Name":
                    columnName = "_name";
                    break;

                case "Location":
                    columnName = "_locationid";
                    break;

                case "Date of last Audit":
                    columnName = "_lastaudit";
                    break;

                case "IP Address":
                    columnName = "_ipaddress";
                    break;

                case "MAC Address":
                    columnName = "_macaddress";
                    break;

                case "Make":
                    columnName = "_make";
                    break;

                case "Model":
                    columnName = "_model";
                    break;

                case "Serial Number":
                    columnName = "_serial_number";
                    break;

                case "Category":
                    columnName = "_category";
                    break;

                case "Type":
                    columnName = "_type";
                    break;

                case "Asset Tag":
                    columnName = "_assettag";
                    break;
                }

                if (columnName == "_category")
                {
                    pickerValuesDataTable = new AssetTypesDAO().GetAssetCategoriesPickerValues();
                }
                else if (columnName == "_lastaudit")
                {
                    pickerValuesDataTable = new AssetDAO().GetAssetPickerValuesForLastAudit();
                }
                else if (columnName == "_locationid")
                {
                    pickerValuesDataTable = new LocationsDAO().GetLocationPickerValues();
                }
                else if (columnName == "_type")
                {
                    pickerValuesDataTable = new AssetTypesDAO().GetAssetTypesPickerValues();
                }
                else
                {
                    pickerValuesDataTable = new AssetDAO().GetAssetPickerValues(columnName);
                }
            }
            else if (category.StartsWith("Operating Systems"))
            {
                switch (name)
                {
                case "Family":
                    pickerValuesDataTable = new ApplicationsDAO().GetOSPickerValues("_name");
                    break;

                case "Version":
                    pickerValuesDataTable = new ApplicationsDAO().GetOSPickerValues("_version");
                    break;

                case "CD Key":
                    pickerValuesDataTable = new ApplicationInstanceDAO().GetOSPickerValues("_cdkey");
                    break;

                case "Serial Number":
                    pickerValuesDataTable = new ApplicationInstanceDAO().GetOSPickerValues("_productid");
                    break;
                }
            }
            else
            {
                pickerValuesDataTable = lAuditedItemsDAO.GetPickerValue(category, name);
                lblUnits.Text         = lAuditedItemsDAO.GetDisplayUnitValue(category, name);
            }

            foreach (DataRow pickerValueRow in pickerValuesDataTable.Rows)
            {
                value = pickerValueRow.ItemArray[0].ToString();

                if (value != String.Empty)
                {
                    cbValuePicker.Items.Add(value);
                }
            }

            if (cbValuePicker.Items.Count > 0)
            {
                cbValuePicker.SelectedIndex = 0;
            }
        }