/// <summary>
 /// This is called when we have selected a single application and we simply want to display its
 /// attributes in the explorer view
 /// </summary>
 /// <param name="selectedApplication">The application to display</param>
 public void ShowApplication(InstalledApplication selectedApplication)
 {
     InitializeTabView();
     _tabView.AddApplication(selectedApplication);
     _tabView.HeaderText  = selectedApplication.Name;
     _tabView.HeaderImage = Properties.Resources.application_72;
 }
Ejemplo n.º 2
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 applicationsGridView_InitializeRow(object sender, InitializeRowEventArgs e)
        {
            // Get the application object being displayed
            UltraGridRow         thisRow         = e.Row;
            UltraGridCell        objectCell      = thisRow.Cells[0];
            InstalledApplication thisApplication = objectCell.Value as InstalledApplication;

            // Set the appearance and icon based on the compliancy status
            if (thisApplication.IsIgnored)
            {
                thisRow.Appearance = _ignoredAppearance;
            }
            else if (thisApplication.Licenses.Count == 0)
            {
                thisRow.Appearance = _notSpecifiedAppearance;
            }
            else if (thisApplication.IsCompliant())
            {
                thisRow.Appearance = _compliantAppearance;
            }
            else
            {
                thisRow.Appearance = _noncompliantAppearance;
            }

            // Set the 'application' image to either be a NotIgnore or non-NotIgnore application
            //UltraGridCell applicationCell = thisRow.Cells["Application Name"];
            //if (thisApplication.IsIgnored)
            //    applicationCell.Appearance.Image = Properties.Resources.application_hidden_16;
            //else
            //    applicationCell.Appearance.Image = Properties.Resources.application_16;
        }
Ejemplo n.º 3
0
        public Deployment DeploySingleAppFromInstalledApplication(InstalledApplication installedApplication, bool force = false, string buildId = null, bool sync = false)
        {
            var deployer   = this.GetDeployer(installedApplication);
            var deployment = deployer.DeployApp(this, force, buildId, sync);

            return(deployment);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Deploy a single app from it's YAML settings. For testing purposes only.
        /// </summary>
        /// <param name="settings"></param>
        public Deployment DeploySingleAppFromTextSettings(string settings, bool force = false, string buildId = null)
        {
            InstalledApplication installedApplication = new InstalledApplication();

            installedApplication.ParseFromString(settings);
            return(this.DeploySingleAppFromInstalledApplication(installedApplication, force, buildId, true));
        }
        private Dictionary <string, InstalledApplication> GetApplications(string registryKey)
        {
            var applications = new Dictionary <string, InstalledApplication>();

            using (var key = Registry.LocalMachine.OpenSubKey(registryKey))
            {
                foreach (var subkeyName in key.GetSubKeyNames())
                {
                    using (var subkey = key.OpenSubKey(subkeyName))
                    {
                        var name = (subkey.GetValue("DisplayName") ?? "").ToString();
                        if (string.IsNullOrWhiteSpace(name) || applications.ContainsKey(name))
                        {
                            continue;
                        }

                        var application = new InstalledApplication
                        {
                            Name = name.ToString()
                        };
                        applications.Add(name, application);
                    }
                }
            }

            return(applications);
        }
Ejemplo n.º 6
0
        private List <int> GetSelectedApplications()
        {
            List <int> appIdsToDelete = new List <int>();

            if (applicationsTree.SelectedNodes[0].Tag.ToString() == "PUBLISHER")
            {
                ApplicationsDAO lApplicationsDAO = new ApplicationsDAO();
                foreach (UltraTreeNode node in applicationsTree.SelectedNodes)
                {
                    DataTable dt = lApplicationsDAO.GetApplicationIdsByPublisherName(node.Text);

                    foreach (DataRow row in dt.Rows)
                    {
                        appIdsToDelete.Add((int)row[0]);
                    }
                }
            }
            else
            {
                foreach (UltraTreeNode node in applicationsTree.SelectedNodes)
                {
                    InstalledApplication installedApplication = node.Tag as InstalledApplication;
                    if (installedApplication != null)
                    {
                        appIdsToDelete.Add(installedApplication.ApplicationID);
                    }
                }
            }
            return(appIdsToDelete);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Gets all available data values for the specifed APPLICATION field.  In this case we need to know
        /// for each asset whether or not the application is installed.
        /// </summary>
        /// <param name="reportColumn"></param>
        protected void GetApplicationFieldValues(AssetList cachedAssetList, AuditDataReportColumn reportColumn)
        {
            try
            {
                List <string> fieldParts      = Utility.ListFromString(reportColumn.FieldName, '|', true);
                string        publisherName   = fieldParts[1];
                string        applicationName = fieldParts[2];

                // The application name is formatted as Applications | Publisher | Application - we need to find this specific
                // application in our internal cached list
                ApplicationPublisher publisher   = _cachedApplicationsList.FindPublisher(publisherName);
                InstalledApplication application = publisher.FindApplication(applicationName);

                // Now loop through the Assets and determine which does have the application and which does not
                // We store the value 'Installed' or 'Not Installed' for the value for each asset
                foreach (Asset asset in cachedAssetList)
                {
                    string value = (application.FindInstance(asset.AssetID) == null) ? AuditDataReportColumn.ApplicationNotInstalled : AuditDataReportColumn.ApplicationInstalled;
                    reportColumn.Values.Add(new AuditDataReportColumnValue(value, asset.Name, asset.AssetID, asset.Location));
                }
            }
            catch (Exception)
            {
            }
        }
Ejemplo n.º 8
0
        public Deployment(
            ApplicationSettings appSettings,
            EnvironmentSettings globalSettings,
            Artifact source,
            InstalledApplication installedApplicationSettings,
            InstalledApplication parentInstalledApplicationSettings)
        {
            this.artifact       = source;
            this.id             = (Guid.NewGuid()).ToString();
            this.appSettings    = appSettings;
            this.globalSettings = globalSettings;
            this.installedApplicationSettings = installedApplicationSettings;

            // We have a prefix to allow services to easily identify
            // chef bound resources.
            this.shortid = this.GetShortIdPrefix() + this.ShortHash(this.id, 4).ToLower();
            if (!this.IsShortId(this.shortid))
            {
                throw new Exception("Invalid shortId generated ????");
            }

            this.runtimeSettings = new Dictionary <string, string>();
            this.parentInstalledApplicationSettings = parentInstalledApplicationSettings;
            this.DeploymentUnixTime = (long)DateTime.UtcNow.ToUnixTimestamp();
            this.DeployRuntimeSettings();
        }
        /// <summary>
        /// Get a deployer for the installed application.
        /// </summary>
        /// <param name="globalSettings">The global settings.</param>
        /// <param name="installedApplicationSettings">The installed application settings.</param>
        /// <param name="logger">The logger.</param>
        public ApplicationDeployer(
            EnvironmentSettings globalSettings,
            InstalledApplication installedApplicationSettings,
            ILoggerInterface logger)
        {
            this.GlobalSettings       = globalSettings;
            this.installedAppSettings = installedApplicationSettings;
            this.Logger = logger;

            if (this.GlobalSettings == null)
            {
                throw new InvalidDataException("settings argument cannot be null.");
            }

            if (this.installedAppSettings == null)
            {
                throw new Exception("installedApplicationSettings argument cannot be null.");
            }

            // Try to grab previous deployment...
            this.activeDeploymentPathStorage = UtilsSystem.CombinePaths(globalSettings.activeDeploymentDir, "active." + this.installedAppSettings.GetId() + ".json");

            if (File.Exists(this.activeDeploymentPathStorage))
            {
                this.DeploymentActive = Deployment.InstanceFromPath(this.activeDeploymentPathStorage, globalSettings);
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Get list of installed application templates.
        /// </summary>
        /// <returns></returns>
        public List <InstalledApplication> GetInstalledApplicationTemplates(string identifiers = null)
        {
            List <InstalledApplication> apps = new List <InstalledApplication>();

            var installedAppsFolder = this.GlobalSettings.applicationTemplateDir;
            var difo = new DirectoryInfo(installedAppsFolder);

            if (!difo.Exists)
            {
                throw new Exception($"Non existent installed applications folder: {installedAppsFolder}");
            }

            foreach (var file in difo.EnumerateFiles())
            {
                var installedApp = new InstalledApplication();
                installedApp.ParseFromString(File.ReadAllText(file.FullName));

                if (string.IsNullOrWhiteSpace(identifiers) ||
                    this.ExplodeAndCleanList(identifiers, ",").Contains(installedApp.GetId()))
                {
                    apps.Add(installedApp);
                }
            }

            return(apps);
        }
Ejemplo n.º 11
0
        private static void ReadScenarioSetttings(string scenario, ref InstalledApplication installedApp, ref AvailableApplication availableApp, ref AppSecurityModel security)
        {
            Guid appId = Guid.NewGuid( );

            string [] parts = scenario.Split(',');
            foreach (string part in parts)
            {
                string [] pair  = part.Trim( ).Split('=');
                string    key   = pair [0];
                string    value = pair [1];

                switch (key)
                {
                case "AppLib":
                    // Pass a version string, or 'none' to indicate that no version is available.
                    if (value != "none")
                    {
                        availableApp = new AvailableApplication
                        {
                            ApplicationId  = appId,
                            Name           = "TestApp",
                            PackageVersion = value
                        };
                    }
                    break;

                case "Tenant":
                    // Pass a version string, or 'none' to indicate that no version is available.
                    if (value != "none")
                    {
                        installedApp = new InstalledApplication
                        {
                            ApplicationId   = appId,
                            Name            = "TestApp",
                            PackageVersion  = value,
                            SolutionVersion = value,
                        };
                    }
                    break;

                case "Security":
                    security = ( AppSecurityModel )Enum.Parse(typeof(AppSecurityModel), value);
                    break;

                case "InstallPerm":
                    if (availableApp != null)
                    {
                        availableApp.HasInstallPermission = value == "True";
                    }
                    break;

                case "PublishPerm":
                    if (availableApp != null)
                    {
                        availableApp.HasPublishPermission = value == "True";
                    }
                    break;
                }
            }
        }
Ejemplo n.º 12
0
        public Deployment SyncSingleAppFromInstalledApplication(InstalledApplication installedApplication)
        {
            var deployer   = this.GetDeployer(installedApplication);
            var deployment = deployer.SyncApp();

            return(deployment);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// View the properties of the currently selected application
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void propertiesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // We can only get the properties of a single item
            UltraGridRow         selectedRow     = this.applicationsGridView.Selected.Rows[0];
            InstalledApplication thisApplication = selectedRow.Cells[0].Value as InstalledApplication;

            ((ApplicationsWorkItemController)WorkItem.Controller).ApplicationProperties(thisApplication);
        }
Ejemplo n.º 14
0
 private ApplicationInstanceDescription CreateBrowserInstance(InstalledApplication app)
 {
     return(new ApplicationInstanceDescription
     {
         ApplicationName = app.Name,
         Executable = app.Files.First(x => x.Filename.EndsWith("SampleBrowser.exe")),
         Name = "Sample Browser autostart",
     });
 }
Ejemplo n.º 15
0
 public override void initialize(
     EnvironmentSettings globalSettings,
     JObject deployerSettings,
     Deployment deployment,
     ILoggerInterface logger,
     InstalledApplication inhertApp)
 {
     base.initialize(globalSettings, deployerSettings, deployment, logger, inhertApp);
     this.PhpSettings = deployerSettings.castTo <PhpEnvironment>();
 }
Ejemplo n.º 16
0
        /// <summary>
        /// Undeploy a single app from it's YAML settings. For testing purposes only.
        /// </summary>
        /// <param name="settings"></param>
        public void UndeploySingleApp(string settings)
        {
            InstalledApplication app = new InstalledApplication();

            app.ParseFromString(settings);

            ApplicationDeployer deployer = new ApplicationDeployer(this.GlobalSettings, app, this.Logger);

            deployer.UninstallApp();
        }
Ejemplo n.º 17
0
        private void bnOK_Click(object sender, EventArgs e)
        {
            // Create an installed application object
            InstalledApplication newApplication = new InstalledApplication();

            newApplication.Publisher   = tbPublisher.Text;
            newApplication.Name        = tbName.Text;
            newApplication.UserDefined = true;
            newApplication.Add();
        }
        /// <summary>
        /// Show the Application Properties window for the specified application
        /// </summary>
        /// <param name="theApplication"></param>
        public void ApplicationProperties(InstalledApplication theApplication)
        {
            FormApplicationProperties form = new FormApplicationProperties(theApplication);

            if (form.ShowDialog() == DialogResult.OK)
            {
                workItem.GetActiveTabView().RefreshView();
                WorkItem.ExplorerView.RefreshView();
            }
        }
 /// <summary>
 /// Get an instance of DeployerCollection
 /// </summary>
 public DeployerCollection(
     EnvironmentSettings globalSettings,
     Deployment deployment,
     ILoggerInterface logger,
     InstalledApplication inhertApp)
 {
     this.GlobalSettings = globalSettings;
     this.Deployment     = deployment;
     this.Logger         = logger;
     this.InhertApp      = inhertApp;
 }
Ejemplo n.º 20
0
        /// <summary>
        /// Assign the file given the details specified
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void bnAssignFile_Click(object sender, EventArgs e)
        {
            // OK we are going to assign this file - first we need to create the application itself
            InstalledApplication application = new InstalledApplication();

            application.Name      = tbProductName.Text;
            application.Publisher = tbPublisher.Text;
            application.Version   = tbVersion.Text;
            application.Add();
            _file.Assign(application.ApplicationID);
        }
Ejemplo n.º 21
0
        private List <InstalledApplication> GetSelectedApplications()
        {
            List <InstalledApplication> listApplications = new List <InstalledApplication>();
            int selectedRowCount = applicationsGridView.Selected.Rows.Count;

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

            if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                aSelectedApplication.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.º 23
0
        /// <summary>
        /// Remove an installed application from the specified app-bank.
        /// </summary>
        /// <param name="app">The application.</param>
        /// <returns>
        /// An async task to wait
        /// </returns>
        public async Task <bool> RemoveAppAsync(InstalledApplication app)
        {
            ServiceLocator.Logger.WriteLine("RemoveAppAsync");
            var result = await this.SendMessageAndAwaitResponseAsync <AppManagerMessage>(new AppManagerMessage(AppManagerAction.RemoveApp, app.Id, app.Index));

            if (result != null)
            {
                return(result.Result == AppManagerResult.AppRemoved);
            }
            else
            {
                throw new TimeoutException();
            }
        }
Ejemplo n.º 24
0
        private void VerifyPostSharpDeployment(InstalledApplication app)
        {
            string sourceFolder =
                Path.GetDirectoryName(Uri.UnescapeDataString(new UriBuilder(typeof(InternalWatchdog).Assembly.CodeBase).Path));

            foreach (string file in SharpRemoteFiles)
            {
                string sourceFileName = Path.Combine(sourceFolder, file);
                string destFileName   = InternalWatchdog.Resolve(app, Environment.SpecialFolder.LocalApplicationData, file);

                ApplicationInstallerTest.FilesAreEqual(sourceFileName, destFileName)
                .Should().BeTrue();
            }
        }
Ejemplo n.º 25
0
        private bool CheckIfPossible(string scenario, Func <InstalledApplication, AvailableApplication, AppSecurityModel, bool> validationFunction)
        {
            InstalledApplication installedApp = null;
            AvailableApplication availableApp = null;
            AppSecurityModel     security     = AppSecurityModel.Full;

            // Process scenario settings
            ReadScenarioSetttings(scenario, ref installedApp, ref availableApp, ref security);

            // Run test
            bool res = validationFunction(installedApp, availableApp, security);

            return(res);
        }
Ejemplo n.º 26
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.º 27
0
        public FormApplicationProperties(InstalledApplication application)
        {
            notesControl     = new NotesControl(application);
            documentsControl = new DocumentsControl(application);
            InitializeComponent();
            _installedApplication = application;

            // Populate the tabs
            InitializeGeneralTab();
            InitializeNotesTab();
            InitializeDocumentsTab();

            // Initialize User Defined Data Tabe for this application
            InitializeUserDefinedData();
        }
Ejemplo n.º 28
0
        public void ExpandApplications(UltraTreeNode node)
        {
            Infragistics.Win.Appearance ignoredAppearance = new Infragistics.Win.Appearance();
            ignoredAppearance.ForeColor = System.Drawing.Color.Gray;

            ApplicationsWorkItemController wiController = explorerView.WorkItem.Controller as ApplicationsWorkItemController;
            bool showIncluded = wiController.ShowIncludedApplications;
            bool showIgnored  = wiController.ShowIgnoredApplications;

            InstalledApplication theApplication;
            string publisher;
            string key;


            publisher = node.FullPath.Substring(20);
            UltraTreeNode applicationNode;
            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]);
                key            = publisher + "|" + theApplication.Name + "|" + theApplication.ApplicationID;

                if (theApplication.Version == String.Empty || theApplication.Name.EndsWith(theApplication.Version))
                {
                    applicationNode = new UltraTreeNode(key, theApplication.Name);
                }
                else
                {
                    applicationNode = new UltraTreeNode(key, theApplication.Name + " (" + theApplication.Version + ")");
                }

                applicationNode.Tag = theApplication;
                applicationNode.Override.ShowExpansionIndicator = ShowExpansionIndicator.CheckOnExpand;

                if (theApplication.IsIgnored)
                {
                    applicationNode.Override.NodeAppearance = ignoredAppearance;
                }

                applicationNodes[j] = applicationNode;
            }

            node.Nodes.AddRange(applicationNodes);
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Add a new application to the data set to be displayed
        /// </summary>
        /// <param name="thisComputer"></param>
        public void AddApplication(InstalledApplication thisApplication)
        {
            // Ensure that fields which may noit have a value have something to display
            string publisher   = (thisApplication.Publisher == "") ? "-" : thisApplication.Publisher;
            string isCompliant = (thisApplication.IsCompliant()) ? "Compliant" : "Non-Compliant";

            // Licenses count
            string licenses;
            string variance;
            int    installs;

            thisApplication.GetLicenseStatistics(out installs, out licenses, out variance);

            if (licenses == "None Specified")
            {
                isCompliant = licenses;
            }

            if (thisApplication.IsIgnored)
            {
                isCompliant = "Ignored";
            }

            // Add the row to the data set
            applicationsDataSet.Tables[0].Rows.Add(new object[]
                                                   { thisApplication,
                                                     publisher,
                                                     thisApplication.Name,
                                                     licenses,
                                                     installs,
                                                     variance,
                                                     isCompliant,
                                                     thisApplication.Version });

            //applicationsDataSet.Tables[0].Rows.Add(new object[]
            //    { thisApplication.ApplicationID
            //    , publisher
            //    , thisApplication.Name
            //    , licenses
            //    , installs
            //    , variance
            //    , isCompliant
            //    , thisApplication.Version});
        }
        private bool CheckApplicationState(int aCompliantType, InstalledApplication thisApplication)
        {
            switch (aCompliantType)
            {
            case 0:
                return(true);

            case 1:
                return(thisApplication.IsCompliant() && !thisApplication.IsIgnored);

            default:
                if (!thisApplication.IsCompliant())
                {
                    return(!thisApplication.IsIgnored && thisApplication.Licenses.Count > 0);
                }
                break;
            }

            return(false);
        }