protected void LoadFromTable(DataTable applicationsTable) { // Iterate through the returned data creating the InstalledApplication instances for each row foreach (DataRow row in applicationsTable.Rows) { try { // Create the installed application object InstalledApplication theApplication = new InstalledApplication(row); // Ensure that we add the application to it's Publishers internal list ApplicationPublisher thePublisher = FindPublisher(theApplication.Publisher); if (thePublisher == null) { thePublisher = new ApplicationPublisher(theApplication.Publisher, 0); this.Add(thePublisher); } thePublisher.Add(theApplication); // Read instances of this application theApplication.LoadData(); } catch (Exception) { // Just skip the application as this points to an internal database consistency error } } }
private void AliasApplications(int aApplicationId, InstalledApplication _targetApplication) { if (aApplicationId != _targetApplication.ApplicationID) { lApplicationsDAO.ApplicationSetAlias(aApplicationId, _targetApplication.ApplicationID); } }
public FormSelectComputers(InstalledApplication installedApplication) { InitializeComponent(); // Load the data into the form - note that we are loading the computers on which the application // has been installed and not the entire list of computers foreach (ApplicationInstance instance in installedApplication.Instances) { clbComputers.Items.Add(instance.InstalledOnComputer); } }
private void bnOK_Click(object sender, EventArgs e) { // If not all selection then ensure that the user has selected a single application if (_selectionType != SelectApplicationsControl.eSelectionType.all) { InstalledApplication selectedApplication = selectApplicationsControl.GetSelectedApplication(); if (selectedApplication == null) { MessageBox.Show("You must select an application", "Validation Error"); this.DialogResult = DialogResult.None; return; } } }
protected void PopulateApplications(UltraTreeNode publisherNode) { publisherNode.Nodes.Clear(); string publisher = publisherNode.FullPath.Substring(20); string key; UltraTreeNode applicationNode; InstalledApplication theApplication; DataTable dt = new ApplicationsDAO().GetApplicationsByPublisher(publisher, _showIncluded, _showIgnored); UltraTreeNode[] applicationNodes = new UltraTreeNode[dt.Rows.Count]; for (int j = 0; j < dt.Rows.Count; j++) { theApplication = new InstalledApplication(dt.Rows[j]); if (theApplication.Version != String.Empty) { key = publisherNode.Key + @"|" + theApplication.Name + " (v" + theApplication.Version + ")" + "|" + theApplication.ApplicationID; applicationNode = new UltraTreeNode(key, theApplication.Name + " (v" + theApplication.Version + ")"); } else { key = publisherNode.Key + @"|" + theApplication.Name + "|" + theApplication.ApplicationID; applicationNode = new UltraTreeNode(key, theApplication.Name); } applicationNode.Tag = theApplication; if (_selectionType == eSelectionType.singleapplication) { applicationNode.Override.NodeStyle = NodeStyle.Standard; } else { applicationNode.Override.NodeStyle = NodeStyle.CheckBox; } applicationNodes[j] = applicationNode; } publisherNode.Nodes.AddRange(applicationNodes); }
private void bnAlias_Click(object sender, EventArgs e) { InstalledApplication _targetApplication = selectTarget.GetSelectedApplication(); foreach (int lApplicationId in _selectedApplicationIds) { if (_targetApplication == null) { MessageBox.Show("Please select the target application to which these applications should be aliased", "Select Target Application"); DialogResult = DialogResult.None; return; } // One last check to make sure that we don't have a single application selected in both lists and it is // the same as someone is bound to try it to catch us out if (_targetApplication.ApplicationID == lApplicationId) { MessageBox.Show("You cannot alias an application to itself, please choose different applications", "Circular Alias"); DialogResult = DialogResult.None; return; } // ...and we cannot alias an application which is itself already aliased by other applications if (lApplicationsDAO.GetAliasCount(lApplicationId) != 0) { MessageBox.Show( String.Format("You cannot alias an application which is itself already the target of an alias, please choose different applications"), "Circular Alias"); DialogResult = DialogResult.None; return; } } foreach (int lApplicationId in _selectedApplicationIds) { AliasApplications(lApplicationId, _targetApplication); } }
public NotesControl(InstalledApplication application) { _application = application; InitializeComponent(); }
private void AliasApplications() { ApplicationsDAO lwDataAccess = new ApplicationsDAO(); ApplicationPublisherList listSelectedPublishers; InstalledApplicationList listSelectedApplications; selectToAlias.GetSelectedItems(out listSelectedPublishers, out listSelectedApplications); // Anything selected? // Note that the Publisher list will always be empty as we have requested multiple applications only if (listSelectedApplications.Count == 0) { MessageBox.Show("Please select one or more applications which are to be aliased", "Select Alias Application"); DialogResult = DialogResult.None; return; } // OK - we must also have the 'target' application selected InstalledApplication targetApplication = selectTarget.GetSelectedApplication(); if (targetApplication == null) { MessageBox.Show("Please select the target application to which these applications should be aliased", "Select Target Application"); DialogResult = DialogResult.None; return; } // One last check to make sure that we don't have a single application selected in both lists and it is // the same as someone is bound to try it to catch us out if ((listSelectedApplications.Count == 1) && (targetApplication.ApplicationID == listSelectedApplications[0].ApplicationID)) { MessageBox.Show("You cannot alias an application to itself, please choose different applications", "Circular Alias"); DialogResult = DialogResult.None; return; } // ...and we cannot alias an application which is itself already aliased by other applications if ((listSelectedApplications.Count == 1) && (lwDataAccess.GetAliasCount(listSelectedApplications[0].ApplicationID) != 0)) { MessageBox.Show("You cannot alias an application which is itself already the target of an alias, please choose different applications", "Circular Alias"); DialogResult = DialogResult.None; return; } List <string> lAliasedApplications = new List <string>(); // OK All validation complete - now we have to actually act on the selected applications foreach (InstalledApplication application in listSelectedApplications) { if (application.Version == "" || application.Name.EndsWith(application.Version)) { lAliasedApplications.Add(application.Name); } else { lAliasedApplications.Add(application.Name + " (" + application.Version + ")"); } if (application.ApplicationID != targetApplication.ApplicationID) { lwDataAccess.ApplicationSetAlias(application.ApplicationID, targetApplication.ApplicationID); } } string targetApplicationDisplay = ""; if (targetApplication.Version == "" || targetApplication.Name.EndsWith(targetApplication.Version)) { targetApplicationDisplay = targetApplication.Name; } else { targetApplicationDisplay = targetApplication.Name + " (" + targetApplication.Version + ")"; } MessageBox.Show( String.Format("The following application(s) have been successfully aliased to '{0}' " + Environment.NewLine + Environment.NewLine + string.Join("\n", lAliasedApplications.ToArray()), targetApplicationDisplay), "Alias Applications", MessageBoxButtons.OK, MessageBoxIcon.Information); PopulatePublisherLists(); RefreshGrid(); tabControl1.SelectedTab = tabPage2; }
/// <summary> /// This function is called to add an application to the DataSet noting that the /// DataSet actually has 3 separate (but linked) tables for Applications, Instances and Licenses /// </summary> protected void AddApplication(InstalledApplication thisApplication, bool includeOnlyCdKeys) { // First add the Application itself to the applications table // // Ensure that fields which may not have a value have something to display string publisher = (thisApplication.Publisher == "") ? "-" : thisApplication.Publisher; string isCompliant = (thisApplication.IsCompliant()) ? "Compliant" : "Not Compliant"; // Licenses count string licenses; string variance; int installs; thisApplication.GetLicenseStatistics(out installs, out licenses, out variance); // Get the Applications Table from the DataSet DataTable applicationTable = _reportDataSet.Tables["Applications"]; // Add the row to the data set try { applicationTable.Rows.Add(new object[] { thisApplication , thisApplication.ApplicationID , publisher , thisApplication.Name //, thisApplication.InstallCount() , thisApplication.InstallCountFiltered(_selectedAssets) , licenses , variance , isCompliant }); } catch (Exception ex) { //MessageBox.Show(e.Message); logger.Error(ex.Message); } // Now add any instances to the Instances table foreach (ApplicationInstance thisInstance in thisApplication.Instances) { //if (!_selectedAssets.Contains(thisInstance.InstalledOnComputer)) // continue; bool found = false; //foreach (int assetId in selectedAssetList) //{ // if (assetId == thisInstance.InstalledOnComputerID) // { // found = true; // break; // } //} if (!selectedAssetList.Contains(thisInstance.InstalledOnComputerID)) { continue; } if ((_showWithKeysOnly) && ((thisInstance.Serial.ProductId == "") && (thisInstance.Serial.CdKey == ""))) { continue; } AddInstance(thisInstance, thisApplication.ApplicationID); } // Now add any Licenses to the Licenses table foreach (ApplicationLicense thisLicense in thisApplication.Licenses) { AddLicense(thisLicense); } }
/// <summary> /// This function is responsible for generating the actual data which will be displayed by the report /// </summary> protected void GenerateReportData() { // Create a string representation of the publisher filter list passed to us // We need to get the entire licensing information at this point ApplicationsDAO lwDataAccess = new ApplicationsDAO(); //AssetGroup.GROUPTYPE displayType = AssetGroup.GROUPTYPE.userlocation; //DataTable table = new LocationsDAO().GetGroups(new AssetGroup(displayType)); //AssetGroup _cachedAssetGroups = new AssetGroup(table.Rows[0], displayType); //_cachedAssetGroups.Populate(true, _ignoreChildAssets, true); //// Now apply the filter to these groups //_cachedAssetGroups.ApplyFilters(_selectedGroups, _selectedAssets, _ignoreChildAssets); _selectedAssets = new AssetDAO().GetSelectedAssets(); selectedAssetList = new List <int>(); foreach (string id in _selectedAssets.Split(',')) { selectedAssetList.Add(Convert.ToInt32(id)); } // If we have selected all publishers and all applications then apply the publisher filter //if (_selectedPublishers == "" && _selectedApplications == "") _selectedPublishers = _publisherFilter; DataTable applicationsTable = lwDataAccess.GetApplications(_selectedPublishers, true, false); // ...then create InstalledApplication objects for each returned and add to the view for (int rowIndex = 0; rowIndex < applicationsTable.Rows.Count;) { // Get the data row DataRow row = applicationsTable.Rows[rowIndex]; // Create the object from the data row InstalledApplication thisApplication = new InstalledApplication(row); // ...and if we are only displaying the report for a specific application and this is not it then // delete this row from the table and skip it if ((_selectedApplications != "") && (!_selectedApplications.Contains(thisApplication.Name))) { applicationsTable.Rows.Remove(row); continue; } // Read instances and licenses of this application thisApplication.LoadData(); // If we are only displaying applications that have Serial numbers or CD Keys then apply that filter here if ((_showWithKeysOnly) && (!thisApplication.HaveSerialNumbers())) { applicationsTable.Rows.Remove(row); continue; } // Ensure that we look at the next row in the next loop rowIndex++; ResetSelectedAssets(); bool addApplication = false; foreach (ApplicationInstance app in thisApplication.Instances) { //if (FilterRecord(app.ComputerLocation, app.InstalledOnComputer)) // addApplication = true; if (selectedAssetList.Contains(app.InstalledOnComputerID)) { addApplication = true; } //foreach (int assetID in selectedAssetList) //{ // if (app.InstalledOnComputerID == assetID) // { // addApplication = true; // break; // } //} } if (addApplication) { AddApplication(thisApplication, _showWithKeysOnly); } } }