示例#1
0
        private string HandleAssetDetailsData(string assetFilter)
        {
            string        assetValue;
            string        assetCriteria;
            DataTable     resultsDataTable   = new DataTable();
            AssetDAO      lAssetDAO          = new AssetDAO();
            AssetTypesDAO lAssetTypesDAO     = new AssetTypesDAO();
            LocationsDAO  lLocationsDAO      = new LocationsDAO();
            string        newIds             = String.Empty;
            string        complianceCriteria = String.Empty;

            //foreach (string assetFilter in applicationFilters)
            //{
            assetCriteria = assetFilter.Substring(41, assetFilter.IndexOf("and _value") - 43);

            switch (assetCriteria)
            {
            case "Asset Name":
                complianceCriteria = "_name";
                break;

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

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

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

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

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

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

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

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

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

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

            if (complianceCriteria == "_category")
            {
                assetValue       = assetFilter.Substring(assetFilter.LastIndexOf("=") + 2);
                resultsDataTable = lAssetTypesDAO.GetCompliantAssetCategoriesValue(assetValue);
            }
            else if (complianceCriteria == "_type")
            {
                assetValue       = assetFilter.Substring(assetFilter.LastIndexOf("=") + 2);
                resultsDataTable = lAssetTypesDAO.GetCompliantAssetTypesValue(assetValue);
            }
            else if (complianceCriteria == "_locationid")
            {
                assetValue       = assetFilter.Substring(assetFilter.LastIndexOf("=") + 2);
                resultsDataTable = lLocationsDAO.GetCompliantLocationValues(assetValue);
            }
            else if (complianceCriteria == "_lastaudit")
            {
                if (assetFilter.IndexOf("and _value") != -1)
                {
                    resultsDataTable =
                        lAssetDAO.GetCompliantAssetValueForLastAudit(assetFilter.Substring(assetFilter.IndexOf("and _value") + 11));
                }
            }
            else
            {
                assetValue = assetFilter.Substring(assetFilter.LastIndexOf("=") + 2);
                //resultsDataTable = lAssetDAO.GetCompliantAssetValue(complianceCriteria, assetValue, compliantIds);
                resultsDataTable = lAssetDAO.GetCompliantAssetValue(complianceCriteria, assetValue);
            }

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

            newIds = newIds.TrimEnd(',');
            return(newIds);
        }