/// <summary> /// Called to show the list of applications for a specific publisher /// </summary> /// <param name="forPublisher"></param> public void ShowPublisher(string forPublisher) { // JML_LINDE if (forPublisher == null) { return; } try { _tabView.SuspendLayout(); DataRow[] dataRows; // Get the work item controller ApplicationsWorkItemController wiController = _tabView.WorkItem.Controller as ApplicationsWorkItemController; // ...and from there settings which alter what we display in this view bool showIncluded = wiController.ShowIncludedApplications; bool showIgnored = wiController.ShowIgnoredApplications; string publisherFilter = wiController.PublisherFilter; // If we have not been supplied a publisher to display then flag that we are not displaying // a publisher at this time, regardless save the supplied publisher if (forPublisher == null) { _isPublisherDisplayed = false; // OK there is no explicit publisher but is there a general publisher filter that we // will need to supply to reduce the number of Publishers reported? if (wiController.PublisherFilter != "") { publisherFilter = wiController.PublisherFilter; } } else { _isPublisherDisplayed = true; _currentPublisher = forPublisher; publisherFilter = forPublisher; } // Initialize the tab view now that we know what we are displaying InitializeTabView(); // Call database function to return list of applications (for the specified publisher) ApplicationsDAO lwDataAccess = new ApplicationsDAO(); DataTable applicationsTable = lwDataAccess.GetApplications(forPublisher, showIncluded, showIgnored); // Set the header text and image for the tab view based on whether we are displaying // all (possibly filtered) publishers or a sepcific publisher _tabView.HeaderText = (forPublisher == null) ? MiscStrings.AllPublishers : forPublisher; _tabView.HeaderImage = Properties.Resources.application_publisher_72; DataTable applicationInstancesTable = new ApplicationInstanceDAO().GetApplicationInstances(forPublisher); DataTable applicationLicensesTable = new LicensesDAO().GetApplicationLicenses(); // get a list of aliased applications - will save processing time later List <int> aliasedToApplicationsList = new List <int>(); foreach (DataRow dataRow in lwDataAccess.GetAliasedToApplications().Rows) { aliasedToApplicationsList.Add(Convert.ToInt32(dataRow[0])); } // ...the create InstalledApplication objects for each returned and add to the view foreach (DataRow row in applicationsTable.Rows) { InstalledApplication thisApplication = new InstalledApplication(row); // Read instances/licenses of this application dataRows = applicationInstancesTable.Select("_APPLICATIONID = " + thisApplication.ApplicationID); thisApplication.LoadInstances1(dataRows); dataRows = applicationLicensesTable.Select("_APPLICATIONID = " + thisApplication.ApplicationID); thisApplication.LoadLicenses1(dataRows); // find any applications which are aliased to this application as we also need their licenses if (aliasedToApplicationsList.Contains(thisApplication.ApplicationID)) { foreach (DataRow dataRow in lwDataAccess.GetAliasedApplicationsByApplicationId(thisApplication.ApplicationID).Rows) { dataRows = applicationLicensesTable.Select("_APPLICATIONID = " + dataRow[0]); thisApplication.LoadLicenses1(dataRows); } } // ...and add to the tab view _tabView.AddApplication(thisApplication); } } catch (Exception ex) { logger.Error("Error in ShowPublisher()", ex); } finally { _tabView.ResumeLayout(); } }
public void ShowPublisher(int aCompliantType) { try { // Get the work item controller ApplicationsWorkItemController wiController = _tabView.WorkItem.Controller as ApplicationsWorkItemController; // ...and from there settings which alter what we display in this view bool showIncluded = wiController.ShowIncludedApplications; bool showIgnored = wiController.ShowIgnoredApplications; string publisherFilter = wiController.PublisherFilter; _isPublisherDisplayed = false; _currentPublisher = null; // Initialize the tab view now that we know what we are displaying InitializeTabView(); // Call database function to return list of applications (for the specified publisher) ApplicationsDAO lwDataAccess = new ApplicationsDAO(); DataTable applicationsTable = lwDataAccess.GetApplications(publisherFilter, showIncluded, showIgnored); // Set the header text and image for the tab view based on whether we are displaying // all (possibly filtered) publishers or a sepcific publisher _tabView.HeaderText = "Generating report data, please wait..."; _tabView.HeaderImage = Properties.Resources.application_publisher_72; _tabView.Refresh(); DataTable applicationInstancesTable = new ApplicationInstanceDAO().GetApplicationInstances(); DataTable applicationLicensesTable = new LicensesDAO().GetApplicationLicenses(); // get a list of aliased applications - will save processing time later List <int> aliasedToApplicationsList = new List <int>(); foreach (DataRow dataRow in lwDataAccess.GetAliasedToApplications().Rows) { aliasedToApplicationsList.Add(Convert.ToInt32(dataRow[0])); } // ...the create InstalledApplication objects for each returned and add to the view foreach (DataRow row in applicationsTable.Rows) { InstalledApplication thisApplication = new InstalledApplication(row); // Read instances/licenses of this application DataRow[] dataRows = applicationInstancesTable.Select("_APPLICATIONID = " + thisApplication.ApplicationID); thisApplication.LoadInstances1(dataRows); dataRows = applicationLicensesTable.Select("_APPLICATIONID = " + thisApplication.ApplicationID); thisApplication.LoadLicenses1(dataRows); // find any applications which are aliased to this application as we also need their licenses if (aliasedToApplicationsList.Contains(thisApplication.ApplicationID)) { foreach (DataRow dataRow in lwDataAccess.GetAliasedApplicationsByApplicationId(thisApplication.ApplicationID).Rows) { dataRows = applicationLicensesTable.Select("_APPLICATIONID = " + dataRow[0]); thisApplication.LoadLicenses1(dataRows); } } //thisApplication.LoadData(); if (CheckApplicationState(aCompliantType, thisApplication)) { // ...and add to the tab view _tabView.AddApplication(thisApplication); } } switch (aCompliantType) { case 1: _tabView.HeaderText = "Compliant Applications"; break; case 2: _tabView.HeaderText = "Non-compliant Applications"; break; default: _tabView.HeaderText = "All Applications"; break; } } catch (Exception ex) { logger.Error("Error in ShowPublisher()", ex); } }