/// <summary>
        /// This function is called when we have selected a specific 'Operating System Family' node below 'All Assets'
        /// In this case we need to display a list of assets for which this Operating System has been installed
        /// </summary>
        /// <param name="displayedNode"></param>
        protected void DisplayAllAssets_OS(UltraTreeNode displayedNode)
        {
            // Ensure that the tree view is already populated for this branch
            NetworkExplorerView explorerView = workItem.ExplorerView as NetworkExplorerView;

            explorerView.ExpandNode(displayedNode);

            // We are displaying ALL publishers - add in columns for
            // Application Object and Publisher
            DataColumn column1 = new DataColumn("ApplicationObject", typeof(object));
            DataColumn column2 = new DataColumn("Asset", typeof(string));
            DataColumn column3 = new DataColumn("Version", typeof(string));
            DataColumn column4 = new DataColumn("Serial Number", typeof(string));
            DataColumn column5 = new DataColumn("CD Key", typeof(string));

            // Add these columns to the DataSet
            applicationsDataSet.Tables[0].Columns.AddRange(new System.Data.DataColumn[] { column1, column2, column3, column4, column5 });

            // Get a list of assets for which this application has
            AllAssets   allAssets = displayedNode.Tag as AllAssets;
            InstalledOS thisOS    = allAssets.Tag as InstalledOS;

            // This will give us (any) instances
            foreach (OSInstance instance in thisOS.Instances)
            {
                // Note we save the UltraTreeNode tag with this row as this should relate to the application
                Asset asset = new Asset();
                asset.Name    = instance.InstalledOnComputer;
                asset.AssetID = instance.InstalledOnComputerID;
                asset.Icon    = instance.InstalledOnComputerIcon;
                applicationsDataSet.Tables[0].Rows.Add(new object[] { asset, asset.Name, instance.Version, instance.Serial.ProductId, instance.Serial.CdKey });
            }
        }
    static void Main(string[] args)
    {
        Database.SetInitializer(new DropCreateDatabaseAlways <Context>());
        Context     context = new Context();
        InstalledOS os1     = new InstalledOS();

        context.InstalledOSs.Add(os1);
        LicenceType l1 = new LicenceType();

        context.LicenceTypes.Add(l1);
        Machine m1 = new Machine
        {
            InstalledOS = os1,
            LicenceType = l1
        };

        context.Machines.Add(m1);
        context.SaveChanges();
        Repository <Machine> repo = new Repository <Machine>(context.Machines);
        var     query             = repo.AllIncluding(m => m.InstalledOS, m => m.LicenceType);
        Machine m2 = query.First();

        Console.WriteLine(m2.InstalledOS.InstalledOSId);
        Console.ReadLine();
    }
Ejemplo n.º 3
0
        /// <summary>
        /// Initialize the 'All Operating Systems' node of the applications tree
        /// </summary>
        private void InitializeAllOperatingSystems()
        {
            // Add the entries to the tree
            try
            {
                DataTable       dt = new ApplicationsDAO().GetOperatingSystems();
                UltraTreeNode   osNode;
                UltraTreeNode[] nodes = new UltraTreeNode[dt.Rows.Count];
                InstalledOS     theOS;

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    theOS = new InstalledOS(dt.Rows[i]);

                    osNode     = new UltraTreeNode(theOS.Name + "|" + theOS.Version, theOS.Name);
                    osNode.Tag = theOS;
                    osNode.Override.ShowExpansionIndicator = ShowExpansionIndicator.CheckOnExpand;
                    nodes[i] = osNode;
                }

                // Add the OS node (and it's sub-nodes to the tree
                explorerView.AllOperatingSystemsNode.Nodes.AddRange(nodes);
            }

            catch (Exception ex)
            {
                //MessageBox.Show("An exception occurred while populating the list of Operating Systems [InitializeAllOperatingSystems], the exception text was " + ex.Message);
                logger.Error(ex.Message);
            }
        }
Ejemplo n.º 4
0
        private void newLicenseToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // We can only create a license for a single specified item
            UltraGridRow selectedRow = this.OSGridView.Selected.Rows[0];

            InstalledOS thisOS = selectedRow.Cells[0].Value as InstalledOS;

            ((ApplicationsWorkItemController)WorkItem.Controller).NewLicense(thisOS);
        }
Ejemplo n.º 5
0
        private void applicationsTree_BeforeExpand(object sender, CancelableNodeEventArgs e)
        {
            UltraTreeNode node = e.TreeNode;

            if (node.Parent == null)
            {
                return;
            }

            node.Nodes.Clear();

            InstalledApplication theApplication;
            string key;

            if (node.Parent == AllPublishersNode)
            {
                _presenter.ExpandApplications(node);
            }
            else if (node.Parent.Parent == AllPublishersNode)
            {
                // here after clicking the application node - show licenses and installations

                string publisher = node.FullPath.Substring(20);
                theApplication = node.Tag as InstalledApplication;
                key            = publisher + "|" + theApplication.Name + "|" + theApplication.ApplicationID;

                UltraTreeNode licensesNode = new UltraTreeNode(key + "|" + MiscStrings.ApplicationLicenseNode, "Licenses");
                licensesNode.Tag = theApplication;
                node.Nodes.Add(licensesNode);

                UltraTreeNode instancesNode = new UltraTreeNode(key + "|" + MiscStrings.ApplicationInstanceNode, "Installations");
                instancesNode.Tag = theApplication;
                node.Nodes.Add(instancesNode);

                theApplication.LoadData();
            }
            else if (node.Parent == AllOperatingSystemsNode)
            {
                // Beneath each Operating System we have placeholders for licenses and instances which
                // we can add now as two sub-nodes
                key = node.Key;

                InstalledOS theOS = node.Tag as InstalledOS;

                UltraTreeNode licensesNode = new UltraTreeNode(key + "|" + MiscStrings.ApplicationLicenseNode, "Licenses");
                licensesNode.LeftImages.Add(Properties.Resources.application_license_16);
                licensesNode.Tag = theOS;
                node.Nodes.Add(licensesNode);
                //
                UltraTreeNode instancesNode = new UltraTreeNode(key + "|" + MiscStrings.ApplicationInstanceNode, "Installations");
                instancesNode.LeftImages.Add(Properties.Resources.computer16);
                instancesNode.Tag = theOS;
                node.Nodes.Add(instancesNode);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Called to show the list of Operating Systems (or details of a specific one)
        /// </summary>
        /// <param name="forPublisher"></param>
        public void ShowOS(InstalledOS forOS)
        {
            // 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 showHidden = wiController.ShowIgnoredApplications;

            // Are we displaying all OS's or a specific one as we need to save this state
            _isAllOSDisplayed = (forOS == null);

            // clear the existing view
            _tabView.Clear();

            // 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  = (forOS == null) ? MiscStrings.OperatingSystems : forOS.Name;
            _tabView.HeaderImage = Properties.Resources.os_96;

            // If we have not been supplied a specific OS to display then flag that we are not displaying
            // an OS at this time but save the supplied OS regardless
            if (_isAllOSDisplayed)
            {
                // Displaying all Operating Systems

                // Call database function to return list of Operating Systems
                ApplicationsDAO lwDataAccess = new ApplicationsDAO();
                DataTable       OSTable      = lwDataAccess.GetOperatingSystems();

                // ...and add these to the tab view
                foreach (DataRow row in OSTable.Rows)
                {
                    InstalledOS thisOS = new InstalledOS(row);

                    // Read instances/licenses of this OS
                    thisOS.LoadData();

                    if (thisOS.Instances.Count == 0)
                    {
                        continue;
                    }

                    // ...and add to the tab view
                    _tabView.AddOS(thisOS);
                }
            }

            else
            {
                // Displaying a specific OS
                _currentOS = forOS;
                _tabView.AddOS(_currentOS);
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Add a new application to the data set to be displayed
        /// </summary>
        /// <param name="thisComputer"></param>
        public void AddOS(InstalledOS theOS)
        {
            // Licenses count
            String licenses = "";
            String variance = "";

            // Is the OS compliant?
            //bool isCompliant = theOS.IsCompliant();

            string isCompliant = (theOS.IsCompliant()) ? "Compliant" : "Non-Compliant";

            // What is the license count for this application?
            int licenseCount = GetLicenseCount(theOS.Licenses);

            // OK format the license count and variance for display
            if (licenseCount == -1)
            {
                licenses = "Unlimited";
                variance = "None";
            }

            else if (licenseCount == 0)
            {
                licenses    = "None Specified";
                isCompliant = licenses;
                variance    = "Shortfall : " + theOS.InstallCount.ToString();
            }

            else
            {
                licenses = "Licenses for " + licenseCount.ToString() + " Asset(s)";
                if (licenseCount == theOS.InstallCount)
                {
                    variance = "None : All Instances Licensed";
                }
                else if (licenseCount < theOS.InstallCount)
                {
                    variance = "Shortfall : " + (theOS.InstallCount - licenseCount).ToString();
                }
                else
                {
                    variance = "Surplus : " + (licenseCount - theOS.InstallCount).ToString();
                }
            }

            // Add the row to the data set
            OSDataSet.Tables[0].Rows.Add(new object[]
                                         { theOS
                                           , theOS.Name
                                           , licenses
                                           , theOS.InstallCount.ToString()
                                           , variance
                                           , isCompliant });
        }
Ejemplo n.º 8
0
        public List <InstalledOS> GetSelectedOS()
        {
            List <InstalledOS> listOS = new List <InstalledOS>();
            int selectedRowCount      = OSGridView.Selected.Rows.Count;

            for (int isub = 0; isub < selectedRowCount; isub++)
            {
                UltraGridRow selectedRow = this.OSGridView.Selected.Rows[isub];
                InstalledOS  thisOS      = selectedRow.Cells[0].Value as InstalledOS;
                listOS.Add(thisOS);
            }
            return(listOS);
        }
Ejemplo n.º 9
0
        private List <InstalledOS> GetSelectedOSs()
        {
            List <InstalledOS> listOSs = new List <InstalledOS>();
            int selectedRowCount       = applicationsGridView.Selected.Rows.Count;

            for (int isub = 0; isub < selectedRowCount; isub++)
            {
                UltraGridRow selectedRow = this.applicationsGridView.Selected.Rows[isub];
                InstalledOS  thisOS      = selectedRow.Cells["ApplicationObject"].Value as InstalledOS;
                listOSs.Add(thisOS);
            }
            return(listOSs);
        }
        private void EditApplicationLicense(ApplicationLicense theLicense, InstalledOS aSelectedOS)
        {
            FormLicenseProperties form = new FormLicenseProperties(aSelectedOS.Name, theLicense);

            if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                aSelectedOS.LoadData();

                // The license will have been added to the application already so we simply refresh the active tab view
                workItem.ExplorerView.RefreshView();
                workItem.GetActiveTabView().RefreshView();
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Called to show the list of LICENSES for a specific APPLICATION
        /// </summary>
        public void ShowApplicationLicenses(Object licenseObject)
        {
            // Initialize the tab view
            InitializeTabView();

            // Reject NULL passed in values
            if (licenseObject == null)
            {
                return;
            }

            // Save the license object passed in to us
            _licenseObject = licenseObject;

            // Set the header and image for the tab view
            if (licenseObject is InstalledApplication)
            {
                // Update the internal data for this InstalledApplication as we are refreshing it
                InstalledApplication theApplication = (InstalledApplication)licenseObject;
                theApplication.LoadData();

                // ...then display it's attributes in the view
                tabView.HeaderText  = theApplication.Name;
                tabView.HeaderImage = Properties.Resources.application_license_72;

                // Add the licenses to our tab view
                foreach (ApplicationLicense thisLicense in theApplication.Licenses)
                {
                    tabView.AddApplicationLicense(thisLicense);
                }
            }

            else
            {
                // Update the internal data for this InstalledOS as we are refreshing it
                InstalledOS theOS = (InstalledOS)licenseObject;
                theOS.LoadData();

                // ...then display it's attributes in the view
                tabView.HeaderText  = theOS.Name;
                tabView.HeaderImage = Properties.Resources.application_license_72;

                // Add the licenses to our tab view
                foreach (ApplicationLicense thisLicense in theOS.Licenses)
                {
                    tabView.AddApplicationLicense(thisLicense);
                }
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Called to show the list of installed instances of the specified application / OS
        /// </summary>
        /// <param name="publisherName"></param>
        public void ShowApplicationInstances(Object instanceObject)
        {
            // First initialize the tab view
            InitializeTabView();

            // Reject NULL passed in values
            if (instanceObject == null)
            {
                return;
            }

            // Set the header and image for the tab view
            if (instanceObject is InstalledApplication)
            {
                InstalledApplication theApplication = (InstalledApplication)instanceObject;
                theApplication.LoadData();

                tabView.HeaderText  = theApplication.Name + " - Instances";
                tabView.HeaderImage = Properties.Resources.application_instance_72;

                // Add the instances to our dataset
                foreach (ApplicationInstance thisInstance in theApplication.Instances)
                {
                    tabView.AddInstance(thisInstance);
                }
            }
            else
            {
                InstalledOS theOS = (InstalledOS)instanceObject;
                theOS.LoadData();

                tabView.HeaderText  = theOS.Name;
                tabView.HeaderImage = Properties.Resources.application_license_72;

                // Add the licenses to our tab view
                foreach (ApplicationInstance thisInstance in theOS.Instances)
                {
                    tabView.AddInstance(thisInstance);
                }
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Called as each row in the grid is initialized - we use this to set the appearance of the row
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OSGridView_InitializeRow(object sender, InitializeRowEventArgs e)
        {
            // Get the application object being displayed
            UltraGridRow  thisRow    = e.Row;
            UltraGridCell objectCell = thisRow.Cells[0];
            InstalledOS   thisOS     = objectCell.Value as InstalledOS;

            // Set the appearance and icon based on the compliancy status
            if (thisOS.LicenseCount == 0)
            {
                thisRow.Appearance = _notSpecifiedAppearance;
            }
            else if (thisOS.IsCompliant())
            {
                thisRow.Appearance = _compliantAppearance;
            }
            else
            {
                thisRow.Appearance = _noncompliantAppearance;
            }
        }
        /// <summary>
        /// Called to allow a new application license to be defined
        /// Note that this is only applicable if we are displaying the LicenseTabView or have selected an
        /// application in the explorer view
        /// </summary>
        /// <param name="theApplication"></param>
        public void NewLicense(InstalledOS aOS)
        {
            // Create a new license and then call the license form to define it
            ApplicationLicense newLicense = new ApplicationLicense();

            newLicense.ApplicationID   = aOS.OSid;
            newLicense.ApplicationName = aOS.Name;
            //
            FormLicenseProperties form = new FormLicenseProperties(aOS.Name, newLicense);

            if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                // Update this installed application with the new license
                aOS.LoadData();

                // The license will have been added to the application already so we simply refresh the views
                //workItem.ExplorerView.RefreshView();
                workItem.GetActiveTabView().RefreshView();

                //ILaytonView applicationsTabView = WorkItem.Items[Layton.Cab.Interface.ViewNames.MainTabView] as ILaytonView;
                //((ApplicationsTabView)applicationsTabView).Presenter.DisplayPublishers();
            }
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Called after we select a different node in the Explorer Tree
        /// This function deals with the firing of the appropriate event to inform interested parties
        /// of the change in selection so that they may update themselves accordingly.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void applicationTree_AfterSelect(object sender, SelectEventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            if (e.NewSelections.Count > 0)
            {
                UltraTreeNode node = e.NewSelections[0];

                // check if the 'All Publishers' node is selected and fire the PublisherSelectedChanged event
                // to inform other interested parties
                if (node.Key == MiscStrings.AllPublishers)
                {
                    List <ApplicationPublisher> allPublishers = new List <ApplicationPublisher>();
                    //allPublishers.Add(_presenter.FindPublisher(node.Key));

                    ApplicationPublisher thePublisher = new ApplicationPublisher(node.Key, 0);
                    //thePublisher.Populate(true, false);
                    allPublishers.Add(thePublisher);

                    if (PublisherSelectionChanged != null)
                    {
                        PublisherSelectionChanged(this, new PublishersEventArgs(allPublishers));
                    }
                }

                // If we have clicked on the Operating systems node and fire the OperatingSystemSelecyionChanged
                // event to inform other interested parties
                else if (node.Key == MiscStrings.OperatingSystems)
                {
                    List <InstalledOS> allPublishers = new List <InstalledOS>();
                    allPublishers.Add(null);

                    if (OperatingSystemSelectionChanged != null)
                    {
                        OperatingSystemSelectionChanged(this, new OperatingSystemEventArgs(allPublishers));
                    }
                }

                // If we have clicked on the Actions node and fire the ActionsSelectionChanged
                // event to inform other interestted parties
                else if (node.Key == MiscStrings.Actions)
                {
                    if (ActionsSelectionChanged != null)
                    {
                        ActionsSelectionChanged(this, new ActionsEventArgs());
                    }
                }

                // If the parent is the 'All Publishers' node, then we have selected a publisher in the tree
                // - populate the list of publishers in the tree and fire the PublisherSelectionChanged
                // event.
                else if (node.Parent == AllPublishersNode)
                {
                    // fire PublisherSelectionChanged event
                    List <ApplicationPublisher> allPublishers = new List <ApplicationPublisher>();
                    foreach (UltraTreeNode publisherNode in e.NewSelections)
                    {
                        ApplicationPublisher thePublisher = new ApplicationPublisher(publisherNode.Key, 0);
                        //thePublisher.Populate(true, false);
                        allPublishers.Add(thePublisher);
                    }

                    if (PublisherSelectionChanged != null)
                    {
                        PublisherSelectionChanged(this, new PublishersEventArgs(allPublishers));
                    }
                }

                // If the parent is the 'All Operating Systems' node, then we have selected an OS in the tree
                // Fire the OperatingSystemSelectionChanged event passing the selected OS.
                else if (node.Parent == AllOperatingSystemsNode)
                {
                    List <InstalledOS> listOSs = new List <InstalledOS>();
                    foreach (UltraTreeNode osNode in e.NewSelections)
                    {
                        InstalledOS thisOS = osNode.Tag as InstalledOS;
                        thisOS.LoadData();
                        listOSs.Add(thisOS);
                    }

                    if (OperatingSystemSelectionChanged != null)
                    {
                        OperatingSystemSelectionChanged(this, new OperatingSystemEventArgs(listOSs));
                    }

                    //UltraTreeNode OSNode = e.NewSelections[0] as UltraTreeNode;
                    //InstalledOS thisOS = OSNode.Tag as InstalledOS;
                    //if (OperatingSystemSelectionChanged != null)
                    //    OperatingSystemSelectionChanged(this, new OperatingSystemEventArgs(thisOS));
                }


                // Applications have a parent of publisher and grand-parent of the root node
                // So if our grand parent is the root node we know that we are an application
                else if (node.Parent.Parent == AllPublishersNode)
                {
                    List <InstalledApplication> listApplications = new List <InstalledApplication>();
                    foreach (UltraTreeNode applicationNode in e.NewSelections)
                    {
                        InstalledApplication thisApplication = applicationNode.Tag as InstalledApplication;
                        thisApplication.LoadData();
                        listApplications.Add(thisApplication);
                    }

                    // fire ApplicationSelectionChanged event
                    if (ApplicationSelectionChanged != null)
                    {
                        ApplicationSelectionChanged(this, new ApplicationsEventArgs(listApplications));
                    }
                }

                // OK we must be right at the bottom of the heirarchy displaying application/OS instances
                // and licenses nodes - determine which by checking the last entry in the key
                // If we have selected the 'licenses' node beneath an application/OS then we fire the
                // 'ApplicationLicenseSelectionChanged' event
                else if (node.Key.EndsWith(MiscStrings.ApplicationLicenseNode))
                {
                    Object nodeTag = node.Tag;

                    // fire ApplicationLicenseSelectionChanged event
                    if (ApplicationLicenseSelectionChanged != null)
                    {
                        ApplicationLicenseSelectionChanged(this, new ApplicationLicenseEventArgs(nodeTag));
                    }
                }

                else if (node.Key.EndsWith(MiscStrings.ApplicationInstanceNode))
                {
                    Object nodeTag = node.Tag;

                    // fire ApplicationLicenseSelectionChanged event
                    if (ApplicationInstallsSelectionChanged != null)
                    {
                        ApplicationInstallsSelectionChanged(this, new ApplicationInstallsEventArgs(nodeTag));
                    }
                }
            }

            Cursor.Current = Cursors.Default;
        }