Пример #1
0
        private void FormSelectApplication_Load(object sender, EventArgs e)
        {
            ApplicationsDAO lwDataAccess      = new ApplicationsDAO();
            DataTable       applicationsTable = lwDataAccess.GetApplications("", true, false);

            //
            foreach (DataRow row in applicationsTable.Rows)
            {
                cbApplications.Items.Add(row["_NAME"]);
            }
        }
Пример #2
0
        /// <summary>
        /// Constructor = this takes a publisher filter and will populate the ApplicationPublisherList
        /// </summary>
        /// <param name="forPublisherFilter"></param>
        public ApplicationPublisherList(string forPublisherFilter, bool includeNotIgnore, bool includeIgnore)
        {
            _forPublisherFilter = forPublisherFilter;

            // Now build the list of applications (for the specified publisher)
            // First get a list of the applications which match the publisher filter
            // We will build the list of Publishers as we go along
            ApplicationsDAO lwDataAccess      = new ApplicationsDAO();
            DataTable       applicationsTable = lwDataAccess.GetApplications(_forPublisherFilter, includeNotIgnore, includeIgnore);

            LoadFromTable(applicationsTable);
        }
Пример #3
0
        /// <summary>
        /// Called to rebuild the application list for this publisher
        /// </summary>
        public void Populate(bool includeIncluded, bool includeIgnore)
        {
            ApplicationsDAO lwDataAccess = new ApplicationsDAO();

            // First clear any existing entries
            this.Clear();

            // ...then get all applications for this publisher
            DataTable applicationsTable = lwDataAccess.GetApplications(this.Name, includeIncluded, includeIgnore);

            foreach (DataRow row in applicationsTable.Rows)
            {
                InstalledApplication application = new InstalledApplication(row);

                // Load child data for this application
                application.LoadData();

                // ...add to our list
                this.Add(application);
            }
        }
        /// <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);
            }
        }
Пример #6
0
        /// <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);
                }
            }
        }