Example #1
0
        private void InstallSendResults(Operations.SavedOpData updateData, RvSofOperation operation, List <RVsofResult.AppsToAdd2> appsToAdd = null, List <RVsofResult.AppsToDelete2> appsToDelete = null)
        {
            try
            {
                var results = new RVsofResult();

                results.AppsToAdd    = results.AppsToAdd != null ? appsToAdd : new List <RVsofResult.AppsToAdd2>();
                results.AppsToDelete = results.AppsToDelete != null ? appsToDelete : new List <RVsofResult.AppsToDelete2>();

                results.AppId          = updateData.filedata_app_id;
                results.Operation      = updateData.operation;
                results.OperationId    = updateData.operation_id;
                results.Error          = updateData.error;
                results.RebootRequired = updateData.reboot_required;
                results.Success        = updateData.success;

                switch (updateData.operation)
                {
                case OperationValue.InstallWindowsUpdate:
                    results             = WindowsUpdates.AddAppDetailsToResults(results);
                    operation.RawResult = RvFormatter.Install(results);
                    break;

                case OperationValue.InstallCustomApp:
                    results             = CustomAppsManager.AddAppDetailsToResults(results);
                    operation.RawResult = RvFormatter.Install(results);
                    break;

                case OperationValue.InstallSupportedApp:
                    results             = SupportedAppsManager.AddAppDetailsToResults(results);
                    operation.RawResult = RvFormatter.Install(results);
                    break;

                case OperationValue.InstallAgentUpdate:
                    results             = AgentUpdateManager.AddAppDetailsToResults(results);
                    operation.RawResult = RvFormatter.AgentUpdate(results);
                    break;

                case OperationValue.Uninstall:
                    operation.RawResult = RvFormatter.Install(results);
                    break;
                }

                operation.Id     = updateData.operation_id;
                operation.Plugin = "rv";

                Operations.UpdateStatus(updateData, Operations.OperationStatus.ResultsPending);

                Logger.Log("Sending back results for {0}.", LogLevel.Info, updateData.filedata_app_name);
                if (SendResults(operation))
                {
                    Operations.CleanAllOperationData(updateData);
                }
            }
            catch (Exception e)
            {
                Logger.Log("Failed when attempting to send back results, Exception inside InstallSendResults().");
                Logger.LogException(e);
            }
        }
Example #2
0
        private static List <Application> NewUpdatesAndApplications()
        {
            var applications = new List <Application>();

            applications.AddRange(WindowsUpdates.GetAvailableUpdates());
            applications.AddRange(WindowsUpdates.GetInstalledUpdates());
            applications.AddRange(SupportedAppsManager.GetInstalledApplications());

            return(applications);
        }
Example #3
0
        private void InstallSupportedApplication(RvSofOperation operation)
        {
            var registry         = new RegistryReader();
            var tempAppsToAdd    = new List <RVsofResult.AppsToAdd2>();
            var tempAppsToDelete = new List <RVsofResult.AppsToDelete2>();

            var savedOperations = Operations.LoadOpDirectory().Where(p => p.operation == OperationValue.InstallSupportedApp).ToList();

            if (!savedOperations.Any())
            {
                Logger.Log("There are no operations remaining, Unable to install supported app: {0}", LogLevel.Warning, operation.Type);
                return;
            }

            foreach (var update in savedOperations)
            {
                if (operation.ListOfInstalledApps.Count > 0)
                {
                    operation.ListOfInstalledApps.Clear();
                }
                if (operation.ListOfAppsAfterInstall.Count > 0)
                {
                    operation.ListOfAppsAfterInstall.Clear();
                }

                operation.ListOfInstalledApps = registry.GetRegistryInstalledApplicationNames();

                Logger.Log("Preparing to Install {0}", LogLevel.Info, update.filedata_app_name);

                Operations.SavedOpData updateDownloadResults = Downloader.DownloadFile(update, Downloader.UpdateDirectories.SupportedAppDir);
                Operations.UpdateStatus(updateDownloadResults, Operations.OperationStatus.Processing);

                //If download fails, send back results to server and move to next package (if any)
                if (!String.IsNullOrEmpty(updateDownloadResults.error))
                {
                    InstallSendResults(updateDownloadResults, operation);
                    continue;
                }
                Logger.Log("Download completed for {0}", LogLevel.Info, update.filedata_app_name);

                Operations.SavedOpData updateInstallResults = SupportedAppsManager.InstallSupportedAppsOperation(updateDownloadResults);

                //Get all installed application after installing..
                operation.ListOfAppsAfterInstall = registry.GetRegistryInstalledApplicationNames();

                //GET DATA FOR APPSTOADD/APPSTODELETE
                var appListToDelete = RegistryReader.GetAppsToDelete(operation.ListOfInstalledApps, operation.ListOfAppsAfterInstall);
                var appListToAdd    = RegistryReader.GetAppsToAdd(operation.ListOfInstalledApps, operation.ListOfAppsAfterInstall);

                //APPS TO DELETE
                #region Apps to Delete
                if (appListToDelete != null)
                {
                    var temp = registry.GetAllInstalledApplicationDetails();
                    foreach (var app in appListToDelete)
                    {
                        var appsToDelete = new RVsofResult.AppsToDelete2();
                        var version      = (from d in temp where d.Name == updateInstallResults.filedata_app_name select d.Version).FirstOrDefault();

                        appsToDelete.Name    = (String.IsNullOrEmpty(app)) ? String.Empty : app;
                        appsToDelete.Version = (String.IsNullOrEmpty(version)) ? String.Empty : version;

                        tempAppsToDelete.Add(appsToDelete);
                    }
                }
                #endregion

                //APPS TO ADD
                #region Apps to Add
                if (appListToAdd != null)
                {
                    var installedAppsDetails = registry.GetAllInstalledApplicationDetails();

                    foreach (var app in appListToAdd)
                    {
                        var temp        = new RVsofResult.AppsToAdd2();
                        var localApp    = app;
                        var version     = (from d in installedAppsDetails where d.Name == updateInstallResults.filedata_app_name select d.Version).FirstOrDefault(); //Default NULL
                        var vendor      = (from d in installedAppsDetails where d.Name == localApp select d.VendorName).FirstOrDefault();                            //Default NULL
                        var installDate = Tools.ConvertDateToEpoch((from d in installedAppsDetails where d.Name == localApp select d.Date).FirstOrDefault());        //Default 0.0D

                        temp.AppsToAdd.Name           = (String.IsNullOrEmpty(localApp)) ? String.Empty : localApp;
                        temp.AppsToAdd.Version        = (String.IsNullOrEmpty(version)) ? String.Empty : version;
                        temp.AppsToAdd.InstallDate    = (installDate.Equals(0.0D)) ? 0.0D : installDate;
                        temp.AppsToAdd.VendorName     = (String.IsNullOrEmpty(vendor)) ? String.Empty : vendor;
                        temp.AppsToAdd.RebootRequired = "no";
                        temp.AppsToAdd.ReleaseDate    = 0.0;
                        temp.AppsToAdd.Status         = "installed";
                        temp.AppsToAdd.Description    = String.Empty;
                        temp.AppsToAdd.SupportUrl     = String.Empty;
                        temp.AppsToAdd.VendorId       = String.Empty;
                        temp.AppsToAdd.VendorSeverity = String.Empty;
                        temp.AppsToAdd.KB             = String.Empty;

                        tempAppsToAdd.Add(temp);
                    }
                }
                #endregion

                InstallSendResults(updateInstallResults, operation, tempAppsToAdd, tempAppsToDelete);
            }
        }