Esempio n. 1
0
        /// <summary>
        /// Edit an existing registry key mapping
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void bnEditKey_Click(object sender, EventArgs e)
        {
            // Get the mapping that is to be edited
            UltraListViewItem editItem = lvRegistryKeys.SelectedItems[0];
            string            key      = editItem.Text;
            string            value    = editItem.SubItems[0].Text;

            // ...and invoke a form to edit it
            FormShadedAskInput2 form = new FormShadedAskInput2("Please enter the registry key name and value name to be audited.  You should include the registry hive (e.g. HKEY_LOCAL_MACHINE)"
                                                               , "Enter Registry Key"
                                                               , "Registry Key Name:"
                                                               , "Value Name"
                                                               , key
                                                               , value
                                                               , Properties.Resources.application_serial_number_corner,
                                                               false);

            if (form.ShowDialog() == DialogResult.OK)
            {
                // Remove the existing item from the list
                int index = editItem.Index;
                lvRegistryKeys.Items.Remove(editItem);

                // ...and add in the new item
                UltraListViewSubItem[] subItemArray = new UltraListViewSubItem[1];
                subItemArray[0]       = new UltraListViewSubItem();
                subItemArray[0].Value = form.Value2Entered();
                UltraListViewItem item = new UltraListViewItem(form.Value1Entered(), subItemArray);
                lvRegistryKeys.Items.Add(item);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Load the records from the input file into the list view
        ///
        /// When importing user defined data fields and their values the file should be in the following format
        ///
        /// Picklist Name		PickItem
        ///
        /// We assume that the first row will be labels but the user may elect to include it if not
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FormImportPicklists_Load(object sender, EventArgs e)
        {
            // try and read the CSV file into the list view
            try
            {
                using (CSVReader csv = new CSVReader(_fromFile))
                {
                    // Read each line from the file noting that we MUST have 2 columns and 2 only
                    string[] fields;
                    while ((fields = csv.GetCSVLine()) != null)
                    {
                        if (fields.Length != 2)
                        {
                            continue;
                        }

                        // Add the 2 fields to the ListView
                        UltraListViewSubItem[] subItemArray = new UltraListViewSubItem[1];
                        subItemArray[0]       = new UltraListViewSubItem();
                        subItemArray[0].Value = fields[1];
                        //
                        UltraListViewItem item = new UltraListViewItem(fields[0], subItemArray);
                        item.CheckState = (lvRecords.Items.Count == 0) ? CheckState.Unchecked : CheckState.Checked;
                        lvRecords.Items.Add(item);
                    }
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show("Failed to import the file " + _fromFile + ".  Reason: " + ex.Message, "Import Failed");
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Load data into the controls
        /// </summary>
        private void InitializeRegistryMappings()
        {
            foreach (string registryKey in _scannerConfiguration.ListRegistryKeys)
            {
                string key       = "";
                string value     = "";
                int    delimiter = registryKey.IndexOf(';');
                if (delimiter == -1)
                {
                    key = registryKey;
                }
                else
                {
                    key   = registryKey.Substring(0, delimiter);
                    value = registryKey.Substring(delimiter + 1);
                }

                // Add to the list
                UltraListViewSubItem[] subItemArray = new UltraListViewSubItem[1];
                subItemArray[0]       = new UltraListViewSubItem();
                subItemArray[0].Value = value;
                UltraListViewItem item = new UltraListViewItem(key, subItemArray);
                lvRegistryKeys.Items.Add(item);
            }
        }
        /// <summary>
        /// Refresh the list of Asset Types for the currently selected asset type category
        /// </summary>
        /// <param name="category"></param>
        private void RefreshList(UserDataCategory category)
        {
            ulvUserData.BeginUpdate();
            ulvUserData.Items.Clear();

            // Get the small icon which we will display
            Bitmap image = IconMapping.LoadIcon(category.Icon, IconMapping.Iconsize.Small);

            // Add the items to the list
            foreach (UserDataField field in category)
            {
                // Subitems are type and description
                UltraListViewSubItem[] subItemArray = new UltraListViewSubItem[2];
                subItemArray[0] = new UltraListViewSubItem {
                    Value = field.TypeAsString
                };
                subItemArray[1] = new UltraListViewSubItem {
                    Value = field.Description()
                };
                //
                UltraListViewItem lvi = new UltraListViewItem(field.Name, subItemArray);
                lvi.Tag = field;
                lvi.Appearance.Image = image;
                ulvUserData.Items.Add(lvi);
            }
            ulvUserData.EndUpdate();
        }
Esempio n. 5
0
        /// <summary>
        /// Called when we want to add a new registry mapping
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void bnAddKey_Click(object sender, EventArgs e)
        {
            FormShadedAskInput2 form = new FormShadedAskInput2("Please enter the registry key name and value name to map to the application.  Do not specify the registry hive as HKEY_LOCAL_MACHINE is assumed."
                                                               , "Enter Registry Key (beneath HKEY_LOCAL_MACHINE)"
                                                               , "Registry Key Name:", "Value Name", "", "", Properties.Resources.application_serial_number_corner
                                                               , true);

            if (form.ShowDialog() == DialogResult.OK)
            {
                // OK add the new mapping to our list
                RegistryMapping        mapping      = new RegistryMapping(form.Value1Entered(), form.Value2Entered());
                UltraListViewSubItem[] subItemArray = new UltraListViewSubItem[1];
                subItemArray[0]       = new UltraListViewSubItem();
                subItemArray[0].Value = mapping.ValueName;
                UltraListViewItem item = new UltraListViewItem(mapping.RegistryKey, subItemArray);
                item.Tag = mapping;
                lvRegistryKeys.Items.Add(item);

                // Build the mappings string
                String mappingString = BuildMappingString();

                // ..and update the configuration file
                _applicationsFile.SetString(cbApplications.SelectedItem.ToString(), mappingString, true);
            }
        }
Esempio n. 6
0
        public FormUserLocation(AssetGroup parentLocation, AssetGroup theLocation)
        {
            InitializeComponent();

            _parentLocation = parentLocation;
            _location       = theLocation;

            // If this entry is null or the InstanceID is 0 then we are creating a new Location type
            if (_location == null)
            {
                _location           = new AssetGroup();
                _location.GroupType = AssetGroup.GROUPTYPE.userlocation;
            }

            this.Text     = (_location.GroupID == 0) ? "New Location" : "Edit Location";
            tbParent.Text = (_parentLocation == null) ? "" : _parentLocation.FullName;
            tbChild.Text  = (_location.GroupID == 0) ? "New Location" : _location.Name;

            // Add (any) IP address ranges to the list
            string[] startIpAddresses = _location.StartIP.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
            string[] endIpAddresses   = _location.EndIP.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);

            ulvTcpRanges.BeginUpdate();
            for (int isub = 0; isub < startIpAddresses.Length; isub++)
            {
                UltraListViewSubItem[] subItemArray = new UltraListViewSubItem[1];
                subItemArray[0]       = new UltraListViewSubItem();
                subItemArray[0].Value = endIpAddresses[isub];
                UltraListViewItem item = new UltraListViewItem(startIpAddresses[isub], subItemArray);
                ulvTcpRanges.Items.Add(item);
            }
            ulvTcpRanges.EndUpdate();
        }
Esempio n. 7
0
        private void PopulateResultsListView(DataTable aDataTable, string aSearchType)
        {
            UltraListViewItem[] items = new UltraListViewItem[aDataTable.Rows.Count];

            lvResults.BeginUpdate();

            for (int i = 0; i < aDataTable.Rows.Count; i++)
            {
                DataRow row = aDataTable.Rows[i];
                UltraListViewSubItem[] subItemArray = new UltraListViewSubItem[3];
                subItemArray[0]       = new UltraListViewSubItem();
                subItemArray[0].Value = row[1];

                subItemArray[1]       = new UltraListViewSubItem();
                subItemArray[1].Value = aSearchType;

                subItemArray[2]       = new UltraListViewSubItem();
                subItemArray[2].Value = row[2];

                UltraListViewItem item = new UltraListViewItem(row[0], subItemArray);
                items[i] = item;
            }

            lvResults.Items.AddRange(items);
            lvResults.EndUpdate();
        }
Esempio n. 8
0
        private void AddDocumentToListView(Document document)
        {
            UltraListViewSubItem[] subItemArray = new UltraListViewSubItem[1];
            subItemArray[0]       = new UltraListViewSubItem();
            subItemArray[0].Value = document.Path;
            UltraListViewItem item = new UltraListViewItem(document.Name, subItemArray);

            item.Tag = document;
            lvDocuments.Items.Add(item);
        }
Esempio n. 9
0
        /// <summary>
        /// Called to add a new IP address range to the list displayed
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void bnAdd_Click(object sender, EventArgs e)
        {
            FormIPAddressRange form = new FormIPAddressRange("", "");

            if (form.ShowDialog() == DialogResult.OK)
            {
                UltraListViewSubItem[] subItemArray = new UltraListViewSubItem[1];
                subItemArray[0]       = new UltraListViewSubItem();
                subItemArray[0].Value = form.Upper;
                UltraListViewItem item = new UltraListViewItem(form.Lower, subItemArray);
                ulvTcpRanges.Items.Add(item);
            }
        }
Esempio n. 10
0
        /// <summary>
        /// Adds a newly defined trigger to the list
        /// </summary>
        /// <param name="alertTrigger"></param>
        private void AddTriggerToList(AlertTrigger alertTrigger)
        {
            UltraListViewSubItem[] subItemArray = new UltraListViewSubItem[2];
            subItemArray[0]       = new UltraListViewSubItem();
            subItemArray[0].Value = alertTrigger.ConditionAsText;
            subItemArray[1]       = new UltraListViewSubItem();
            subItemArray[1].Value = alertTrigger.Value;
            //
            UltraListViewItem item = new UltraListViewItem(alertTrigger.TriggerField, subItemArray);

            item.Tag = alertTrigger;
            lvTriggers.Items.Add(item);
        }
Esempio n. 11
0
        /// <summary>
        /// Called when we want to add a new license type
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void bnAddLicenseType_Click(object sender, EventArgs e)
        {
            FormLicenseType form = new FormLicenseType(null);

            if (form.ShowDialog() == DialogResult.OK)
            {
                LicenseType            newLicenseType = form.LicenseType;
                UltraListViewSubItem[] subItemArray   = new UltraListViewSubItem[1];
                subItemArray[0]       = new UltraListViewSubItem();
                subItemArray[0].Value = (newLicenseType.PerComputer) ? "Yes" : "No";
                UltraListViewItem item = new UltraListViewItem(newLicenseType.Name, subItemArray);
                item.Tag = newLicenseType;
                lvLicenseTypes.Items.Add(item);
            }
        }
        /// <summary>
        /// Load the records from the input file into the list view
        ///
        /// When importing user defined data fields and their values the file should be in the following format
        ///
        /// Asset Name		Category     Field Name		Field Value
        ///
        /// Note that assets should have been previously created.  Any assets which do not currently exist within
        /// the database will be created as PCs
        ///
        /// We assume that the first row will be labels but the user may elect to include it if not
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FormImportUserDefinedData_Load(object sender, EventArgs e)
        {
            lvRecords.BeginUpdate();
            lvRecords.Items.Clear();

            // User data categories
            _listCategories.Populate();

            // try and read the CSV file into the list view
            try
            {
                using (CSVReader csv = new CSVReader(_fromFile))
                {
                    // Read each line from the file noting that we MUST have 4 columns and 4 only
                    string[] fields;
                    while ((fields = csv.GetCSVLine()) != null)
                    {
                        if (fields.Length != 4)
                        {
                            continue;
                        }

                        // Add the 3 fields to the ListView
                        UltraListViewSubItem[] subItemArray = new UltraListViewSubItem[3];
                        subItemArray[0]       = new UltraListViewSubItem();
                        subItemArray[0].Value = fields[2];
                        subItemArray[1]       = new UltraListViewSubItem();
                        subItemArray[1].Value = fields[3];
                        subItemArray[2]       = new UltraListViewSubItem();
                        subItemArray[2].Value = fields[1];
                        //
                        UltraListViewItem item = new UltraListViewItem(fields[0], subItemArray);
                        item.CheckState = (lvRecords.Items.Count == 0) ? CheckState.Unchecked : CheckState.Checked;
                        lvRecords.Items.Add(item);
                    }
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show("Failed to import the file " + _fromFile + ".  Reason: " + ex.Message, "Import Failed");
            }
            lvRecords.EndUpdate();
        }
Esempio n. 13
0
        /// <summary>
        /// Edit an existing registry key mapping
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void bnEditKey_Click(object sender, EventArgs e)
        {
            // Get the mapping that is to be edited
            UltraListViewItem editItem    = lvRegistryKeys.SelectedItems[0];
            RegistryMapping   editMapping = editItem.Tag as RegistryMapping;

            // ...and invoke a form to edit it
            //FormAskInput2 form = new FormAskInput2("Please enter the registry key name and value name to map to the application.  Do not specify the registry hive as HKEY_LOCAL_MACHINE is assumed"
            //                                     , "Enter Registry Key (beneath HKEY_LOCAL_MACHINE)"
            //                                     , "Registry Key Name:"
            //                                     , "Value Name"
            //                                     , editMapping.RegistryKey
            //                                     , editMapping.ValueName);
            FormShadedAskInput2 form = new FormShadedAskInput2("Please enter the registry key name and value name to map to the application.  Do not specify the registry hive as HKEY_LOCAL_MACHINE is assumed"
                                                               , "Enter Registry Key (beneath HKEY_LOCAL_MACHINE)"
                                                               , "Registry Key Name:"
                                                               , "Value Name"
                                                               , editMapping.RegistryKey
                                                               , editMapping.ValueName
                                                               , Properties.Resources.application_serial_number_corner
                                                               , true);

            if (form.ShowDialog() == DialogResult.OK)
            {
                // Remove the existing item from the list
                int index = editItem.Index;
                lvRegistryKeys.Items.Remove(editItem);

                // ...and add in the new item
                RegistryMapping        mapping      = new RegistryMapping(form.Value1Entered(), form.Value2Entered());
                UltraListViewSubItem[] subItemArray = new UltraListViewSubItem[1];
                subItemArray[0]       = new UltraListViewSubItem();
                subItemArray[0].Value = mapping.ValueName;
                UltraListViewItem item = new UltraListViewItem(mapping.RegistryKey, subItemArray);
                item.Tag = mapping;
                lvRegistryKeys.Items.Insert(index, item);

                // Build the mappings string
                String mappingString = BuildMappingString();

                // ..and update the configuration file
                _applicationsFile.SetString(cbApplications.SelectedItem.ToString(), mappingString, true);
            }
        }
Esempio n. 14
0
        /// <summary>
        /// Load the records from the input file into the list view
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FormImportLocations_Load(object sender, EventArgs e)
        {
            // recover the root group as we need its name to prefix to all created location names
            LocationsDAO lwDataAccess   = new LocationsDAO();
            DataTable    table          = lwDataAccess.GetGroups(new AssetGroup(AssetGroup.GROUPTYPE.userlocation));
            AssetGroup   rootAssetGroup = new AssetGroup(table.Rows[0], AssetGroup.GROUPTYPE.userlocation);

            _rootName = rootAssetGroup.Name;

            // try and read the CSV file into the list view
            try
            {
                using (CSVReader csv = new CSVReader(_fromFile))
                {
                    // Read each line from the file noting that we MUST have 4 columns and 4 only
                    string[] fields;
                    while ((fields = csv.GetCSVLine()) != null)
                    {
                        if (fields.Length != 4)
                        {
                            continue;
                        }

                        // Add the 4 fields to the ListView
                        UltraListViewSubItem[] subItemArray = new UltraListViewSubItem[3];
                        subItemArray[0]       = new UltraListViewSubItem();
                        subItemArray[0].Value = fields[1];
                        subItemArray[1]       = new UltraListViewSubItem();
                        subItemArray[1].Value = fields[2];
                        subItemArray[2]       = new UltraListViewSubItem();
                        subItemArray[2].Value = fields[3];
                        //
                        UltraListViewItem item = new UltraListViewItem(fields[0], subItemArray);
                        item.CheckState = (lvRecords.Items.Count == 0) ? CheckState.Unchecked : CheckState.Checked;
                        lvRecords.Items.Add(item);
                    }
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show("Failed to import the file " + _fromFile + ".  Reason: " + ex.Message, "Import Failed");
            }
        }
Esempio n. 15
0
        private void bindData(Sql8rTable t)
        {
            _view.txtDataSpaceUsage.Text  = string.Format("Data Space: {0} kb", t.DataSpaceUsed);
            _view.txtIndexSpaceUsage.Text = string.Format("Index Space: {0} kb", t.IndexSpaceUsed);

            _view.lvwIndexes.Items.Clear();
            var fragmentationBar = new UltraProgressBar();

            fragmentationBar.Appearance.BackColor = Color.GreenYellow;
            var spaceBar = new UltraProgressBar();
            int max      = getMaxIndexSpaceUsed(t);

            spaceBar.Maximum = max;
            spaceBar.Text    = "[Value]";

            _view.lvwIndexes.MainColumn.DataType             = typeof(string);
            _view.lvwIndexes.SubItemColumns[0].DataType      = typeof(double);
            _view.lvwIndexes.SubItemColumns[0].EditorControl = fragmentationBar;
            _view.lvwIndexes.SubItemColumns[1].DataType      = typeof(int);
            _view.lvwIndexes.SubItemColumns[1].EditorControl = spaceBar;
            _view.lvwIndexes.SubItemColumns[2].DataType      = typeof(string);

            var ulvis = new List <UltraListViewItem>(t.Indexes.Count);

            foreach (Sql8rIndex i in t.Indexes.Values)
            {
                var ulvsiFragmentation = new UltraListViewSubItem();
                ulvsiFragmentation.Value = i.AvgFragmentation;

                var ulvsiSpaceUsed = new UltraListViewSubItem();
                ulvsiSpaceUsed.Value = i.SpaceUsed;

                var ulvsiRecommendation = new UltraListViewSubItem();
                i.Recommendation          = recommend(i);
                ulvsiRecommendation.Value = i.Recommendation;

                var ulvi = new UltraListViewItem(i.Name, new[] { ulvsiFragmentation, ulvsiSpaceUsed, ulvsiRecommendation });
                ulvi.Tag = i;
                ulvi.Appearance.Image = MainPresenter.Instance.View.TreeImageList.Images[11];
                ulvis.Add(ulvi);
            }
            _view.lvwIndexes.Items.AddRange(ulvis.ToArray());
        }
Esempio n. 16
0
        /// <summary>
        /// Called as we change the selection in the combo box of applications
        /// we need to populate the list of registry mappings for the newly selected
        /// application
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cbApplications_SelectionChanged(object sender, EventArgs e)
        {
            // First clear the list view of any existing items
            lvRegistryKeys.Items.Clear();

            // Get the selected application object
            ApplicationRegistryMapping applicationMapping = cbApplications.SelectedItem.Tag as ApplicationRegistryMapping;

            // ...and add to the list view
            foreach (RegistryMapping mapping in applicationMapping)
            {
                UltraListViewSubItem[] subItemArray = new UltraListViewSubItem[1];
                subItemArray[0]       = new UltraListViewSubItem();
                subItemArray[0].Value = mapping.ValueName;
                UltraListViewItem item = new UltraListViewItem(mapping.RegistryKey, subItemArray);
                item.Tag = mapping;
                lvRegistryKeys.Items.Add(item);
            }
        }
Esempio n. 17
0
        /// <summary>
        /// Called when we want to add a new registry mapping
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void bnAddKey_Click(object sender, EventArgs e)
        {
            FormShadedAskInput2 form = new FormShadedAskInput2("Please enter the registry key name and value name to be audited.  You should include the registry hive (e.g. HKEY_LOCAL_MACHINE)"
                                                               , "Enter Registry Key"
                                                               , "Registry Key Name:"
                                                               , "Value Name"
                                                               , ""
                                                               , ""
                                                               , Properties.Resources.application_serial_number_corner,
                                                               false);

            if (form.ShowDialog() == DialogResult.OK)
            {
                // OK add the new mapping to our list
                UltraListViewSubItem[] subItemArray = new UltraListViewSubItem[1];
                subItemArray[0]       = new UltraListViewSubItem();
                subItemArray[0].Value = form.Value2Entered();
                UltraListViewItem item = new UltraListViewItem(form.Value1Entered(), subItemArray);
                lvRegistryKeys.Items.Add(item);
            }
        }
Esempio n. 18
0
        /// <summary>
        /// Initialize the license types form
        /// </summary>
        private void InitializeLicenseTypes()
        {
            lvLicenseTypes.BeginUpdate();
            lvLicenseTypes.Items.Clear();

            // Populate the list view with the existing license types
            LicenseTypesDAO lwDataAccess      = new LicenseTypesDAO();
            DataTable       licenseTypesTable = lwDataAccess.EnumerateLicenseTypes();

            // Iterate through the returned items
            foreach (DataRow row in licenseTypesTable.Rows)
            {
                LicenseType            licenseType  = new LicenseType(row);
                UltraListViewSubItem[] subItemArray = new UltraListViewSubItem[1];
                subItemArray[0]       = new UltraListViewSubItem();
                subItemArray[0].Value = (licenseType.PerComputer) ? "Yes" : "No";
                UltraListViewItem item = new UltraListViewItem(licenseType.Name, subItemArray);
                item.Tag = licenseType;
                lvLicenseTypes.Items.Add(item);
            }
            lvLicenseTypes.EndUpdate();
        }
Esempio n. 19
0
        /// <summary>
        /// Adds a newly defined trigger to the list
        /// </summary>
        /// <param name="complianceField"></param>
        private void AddComplianceFieldToList(ComplianceField complianceField)
        {
            UltraListViewSubItem[] subItemArray = new UltraListViewSubItem[3];
            subItemArray[0]       = new UltraListViewSubItem();
            subItemArray[0].Value = complianceField.ConditionAsText;
            subItemArray[1]       = new UltraListViewSubItem();
            subItemArray[1].Value = complianceField.Value;
            subItemArray[2]       = new UltraListViewSubItem();
            subItemArray[2].Value = (_complianceIndex == 0) ? "" : complianceField.BooleanValue;
            //
            UltraListViewItem item = new UltraListViewItem(complianceField.TriggerField, subItemArray);

            item.Tag = complianceField;

            if (_complianceIndex == -1)
            {
                lvTriggers.Items.Add(item);
            }
            else
            {
                lvTriggers.Items.Insert(_complianceIndex, item);
            }
        }
        private void RefreshAlertMonitors()
        {
            try
            {
                lvAlertDefinitions.Items.Clear();

                // Get the path to the scanner configurations
                string scannerPath = Path.Combine(Application.StartupPath, "scanners\\alertmonitors\\");

                DirectoryInfo di      = new DirectoryInfo(scannerPath);
                FileInfo[]    rgFiles = di.GetFiles("*.xml");
                foreach (FileInfo fi in rgFiles)
                {
                    string          selectedFileName = Path.Combine(Application.StartupPath, "scanners\\alertmonitors\\") + fi.Name;
                    AlertDefinition alertDefinition  = GetAlertDefinitionFromFileName(selectedFileName);

                    UltraListViewSubItem[] subItemArray = new UltraListViewSubItem[2];
                    subItemArray[0]       = new UltraListViewSubItem();
                    subItemArray[0].Value = alertDefinition.Description;
                    subItemArray[1]       = new UltraListViewSubItem();
                    subItemArray[1].Value = fi.LastWriteTime.ToShortDateString() + " " + fi.LastWriteTime.ToShortTimeString();
                    //
                    UltraListViewItem item = new UltraListViewItem(alertDefinition.Name, subItemArray);
                    item.Tag = alertDefinition;

                    if (!lvAlertDefinitions.Items.Contains(item))
                    {
                        lvAlertDefinitions.Items.Add(item);
                    }
                }
            }

            catch (Exception ex)
            {
                //MessageBox.Show(ex.Message);
            }
        }
Esempio n. 21
0
        private void LoadLicenseInformation()
        {
            m_Licenses        = m_BBSProductLicense.Licenses;
            m_CombinedLicense = m_BBSProductLicense.CombinedLicense;

            ultraListView_Licenses.Items.Clear();
            textBox_DaysToExpire.Text      = string.Empty;
            textBox_LicensedFor.Text       = string.Empty;
            textBox_LicensedServers.Text   = string.Empty;
            textBox_LicenseExpiration.Text = string.Empty;
            textBox_LicenseType.Text       = string.Empty;

            foreach (BBSProductLicense.LicenseData licDataTemp in m_Licenses)
            {
                BBSProductLicense.LicenseData licData = licDataTemp;
                if (licData.licState == BBSProductLicense.LicenseState.Valid)
                {
                    UltraListViewItem li = ultraListView_Licenses.Items.Add(null, licData.key);
                    li.Tag = licData;
                    li.SubItems["colServer"].Value = licData.numLicensedServersStr;
                    UltraListViewSubItem si = li.SubItems["colDaysToExpiration"];
                    si.Value = licData.daysToExpireStr;
                    if (licData.isAboutToExpire)
                    {
                        si.Appearance.ForeColor = warningColor;
                    }
                }
                else
                {
                    string message = null;
                    switch (licData.licState)
                    {
                    case BBSProductLicense.LicenseState.InvalidKey:
                        licData.typeStr           = "Invalid License";
                        licData.forStr            = string.Empty;
                        licData.expirationDateStr = string.Empty;
                        licData.daysToExpireStr   = string.Empty;
                        message = string.Format(Utility.ErrorMsgs.LicenseInvalid, licData.key);
                        break;

                    case BBSProductLicense.LicenseState.InvalidExpired:
                        message         = Utility.ErrorMsgs.LicenseExpired;
                        licData.typeStr = message;
                        break;

                    case BBSProductLicense.LicenseState.InvalidProductID:
                        message         = Utility.ErrorMsgs.LicenseInvalidProductID;
                        licData.typeStr = message;
                        break;

                    case BBSProductLicense.LicenseState.InvalidProductVersion:
                        message         = Utility.ErrorMsgs.LicenseInvalidProductVersion;
                        licData.typeStr = message;
                        break;

                    case BBSProductLicense.LicenseState.InvalidScope:
                        message         = string.Format(Utility.ErrorMsgs.LicenseInvalidRepository, m_BBSProductLicense.OrginalScopeString);
                        licData.typeStr = message;
                        break;

                    case BBSProductLicense.LicenseState.InvalidDuplicateLicense:
                        message         = Utility.ErrorMsgs.LicenseInvalidDuplicate;
                        licData.typeStr = message;
                        break;

                    default:
                        licData.typeStr           = "Invalid License";
                        licData.forStr            = string.Empty;
                        licData.expirationDateStr = string.Empty;
                        licData.daysToExpireStr   = string.Empty;
                        message = string.Format(Utility.ErrorMsgs.LicenseInvalid, licData.key);
                        break;
                    }
//                    Utility.MsgBox.ShowWarning(Utility.ErrorMsgs.LicenseCaption, message);
                    UltraListViewItem li = ultraListView_Licenses.Items.Add(null, licData.key);
                    li.Tag = licData;
                    li.SubItems["colServer"].Value           = licData.numLicensedServersStr;
                    li.SubItems["colDaysToExpiration"].Value = "Expired";
                    li.Appearance.ForeColor = errorColor;
                }
            }
            if (m_Licenses.Count > 1)
            {
                UltraListViewItem li = ultraListView_Licenses.Items.Add(null, m_CombinedLicense.key);
                li.Appearance.ForeColor = Color.DodgerBlue;
                li.Value = m_CombinedLicense.key;
                li.Tag   = m_CombinedLicense;
                li.SubItems["colServer"].Value           = m_CombinedLicense.numLicensedServersStr;
                li.SubItems["colDaysToExpiration"].Value = m_CombinedLicense.daysToExpireStr;
                ultraListView_Licenses.SelectedItems.Clear();
                ultraListView_Licenses.SelectedItems.Add(li);
                ultraListView_Licenses.ActiveItem = li;
                button_Delete.Enabled             = false;
            }
            else if (ultraListView_Licenses.Items.Count > 0)
            {
                ultraListView_Licenses.SelectedItems.Clear();
                ultraListView_Licenses.SelectedItems.Add(ultraListView_Licenses.Items[0]);
                ultraListView_Licenses.ActiveItem = ultraListView_Licenses.Items[0];
            }
            if (ultraListView_Licenses.Items.Count == 0)
            {
                button_Delete.Enabled = false;
            }
        }
Esempio n. 22
0
        /// <summary>
        /// Populates the UltraListView control with the child locations of the Location
        /// represented by the specified UltraTreeNode.
        /// </summary>
        private void PopulateListView(UltraTreeNode node)
        {
            AssetGroup parentGroup;

            if (node != null && node.Tag != null)
            {
                parentGroup = node.Tag as AssetGroup;
            }
            else
            {
                parentGroup = new AssetGroup(AssetGroup.GROUPTYPE.userlocation);
            }

            //	Call BeginUpdate to prevent drawing while we are populating the control
            this.locationsList.BeginUpdate();

            //	Show a wait cursor since this could take a while
            this.Cursor = Cursors.WaitCursor;

            //	Clear the Items collection to removes the directories and files
            //	of the last folder we displayed
            this.locationsList.Items.Clear();

            // So request the database for a list of locations beneath that specified
            LocationsDAO lwDataAccess = new LocationsDAO();
            DataTable    table        = lwDataAccess.GetGroups(parentGroup);

            //	Create an array of UltraListViewItems, with a size equal to the number of directories
            UltraListViewItem[] itemArrayLocations = new UltraListViewItem[table.Rows.Count];

            // ...and add these locations to the tree as children of the selected node
            int index = 0;

            foreach (DataRow row in table.Rows)
            {
                AssetGroup newLocation = new AssetGroup(row, AssetGroup.GROUPTYPE.userlocation);

                //	Create an array of UltraListViewSubItems
                UltraListViewSubItem[] subItemArray = new UltraListViewSubItem[2];

                //	Create new UltraListViewSubItem instances for this item
                subItemArray[0] = new UltraListViewSubItem();
                subItemArray[1] = new UltraListViewSubItem();

                //	Assign the values to the UltraListViewSubItem instances
                subItemArray[0].Value = newLocation.StartIP;
                subItemArray[1].Value = newLocation.EndIP;

                //	Create an UltraListViewItem instance
                UltraListViewItem item = new UltraListViewItem(newLocation.Name, subItemArray);

                //	Store a reference to the associated Location in the item's Tag property
                item.Tag = newLocation;

                //	Add the UltraListViewItem to the array
                itemArrayLocations[index++] = item;
            }

            // Add the items to the Items collection using the AddRange method, so that we only trigger two property
            // change notifications, as opposed to one for each item added to the collection.
            this.locationsList.Items.AddRange(itemArrayLocations);

            //	Assign the items to their respective groups
            //this.AssignItemsToGroups();

            // Auto-size the width of the 'Name' column; if the size of the Items collection is not too large,
            // size all items, but to avoid impacting performance, only size the ones that are currently on-screen
            // if there are a relatively large number of items.
            Infragistics.Win.UltraWinListView.ColumnAutoSizeMode autoSizeMode = Infragistics.Win.UltraWinListView.ColumnAutoSizeMode.Header;

            if (this.locationsList.Items.Count <= 100)
            {
                autoSizeMode |= Infragistics.Win.UltraWinListView.ColumnAutoSizeMode.AllItems;
            }
            else
            {
                autoSizeMode |= Infragistics.Win.UltraWinListView.ColumnAutoSizeMode.VisibleItems;
            }

            this.locationsList.MainColumn.PerformAutoResize(autoSizeMode);

            //	Activate the first item
            if (this.locationsList.ActiveItem == null && this.locationsList.Items.Count > 0)
            {
                this.locationsList.ActiveItem = this.locationsList.Items[0];
            }

            //	Restore the cursor
            this.Cursor = Cursors.Default;

            //	Call EndUpdate to resume drawing operations
            this.locationsList.EndUpdate(true);
        }
Esempio n. 23
0
        /// <summary>
        /// Refresh the list of files in the specified folder
        /// </summary>
        private void RefreshList()
        {
            // Clear the list view initially
            lvAudits.BeginUpdate();
            lvAudits.Items.Clear();

            // If we have no data folder then we may as well just exit
            _uploadFolder = tbAuditFolder.Text;
            if (_uploadFolder != "")
            {
                // build a temporary list of matching files
                List <AuditFileInfo> listAuditFiles = new List <AuditFileInfo>();
                AuditUploader        auditLoader    = new AuditUploader(_uploadFolder, _licenseCount);
                auditLoader.EnumerateFiles(listAuditFiles);

                // sort the list by audit scan date
                listAuditFiles.Sort();

                UltraListViewItem[] items = new UltraListViewItem[listAuditFiles.Count];

                for (int i = 0; i < listAuditFiles.Count; i++)
                {
                    AuditFileInfo thisAuditFile = listAuditFiles[i];

                    UltraListViewSubItem[] subItemArray = new UltraListViewSubItem[3];
                    subItemArray[0]       = new UltraListViewSubItem();
                    subItemArray[0].Value = thisAuditFile.Assetname;
                    subItemArray[1]       = new UltraListViewSubItem();
                    subItemArray[1].Value = thisAuditFile.AuditDate.ToString();
                    subItemArray[2]       = new UltraListViewSubItem();
                    subItemArray[2].Value = thisAuditFile.StatusAsText;
                    //
                    UltraListViewItem item = new UltraListViewItem(thisAuditFile.Filename, subItemArray);
                    item.Tag = thisAuditFile;
                    item.Key = thisAuditFile.AuditFile.FileName;

                    items[i] = item;
                }

                lvAudits.Items.AddRange(items);

                // Also build a list of LYNC audit files which should be uploaded
                LyncAuditFileList listLyncAudits = new LyncAuditFileList();
                listLyncAudits.Populate(_uploadFolder);

                // then add to the file list control
                foreach (LyncAuditFile lyncAuditFile in listLyncAudits.LyncAuditFiles)
                {
                    AuditDataFile thisAuditFile = lyncAuditFile.ConvertedFile();
                    if (thisAuditFile == null)
                    {
                        continue;
                    }

                    // We need an AuditFileInfo object for this file
                    AuditFileInfo auditFileInfo = new AuditFileInfo();
                    auditFileInfo.Assetname = thisAuditFile.AssetName;
                    auditFileInfo.AuditDate = thisAuditFile.AuditDate;
                    auditFileInfo.AuditFile = thisAuditFile;
                    auditFileInfo.Filename  = lyncAuditFile.FileName;

                    UltraListViewSubItem[] subItemArray = new UltraListViewSubItem[3];
                    subItemArray[0]       = new UltraListViewSubItem();
                    subItemArray[0].Value = auditFileInfo.Assetname;
                    subItemArray[1]       = new UltraListViewSubItem();
                    subItemArray[1].Value = auditFileInfo.AuditDate.ToString();
                    subItemArray[2]       = new UltraListViewSubItem();
                    subItemArray[2].Value = auditFileInfo.StatusAsText;
                    //
                    UltraListViewItem item = new UltraListViewItem(auditFileInfo.Filename, subItemArray);
                    item.Tag = auditFileInfo;
                    item.Key = auditFileInfo.Filename;
                    lvAudits.Items.Add(item);
                }
            }

            lvAudits.EndUpdate();
        }