示例#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);
            }
        }
示例#2
0
        /// <summary>
        /// This takes care of executing any operation received by the server.
        /// </summary>
        /// <param name="operation"></param>
        public void RunOperation(ISofOperation operation)
        {
            var rvOperation = new RvSofOperation(operation.RawOperation);

            switch (rvOperation.Type)
            {
            case OperationValue.InstallWindowsUpdate:
                rvOperation.Api  = ApiCalls.RvInstallWinUpdateResults();
                rvOperation.Type = OperationValue.InstallWindowsUpdate;
                InstallWindowsUpdate(rvOperation);
                break;

            case OperationValue.InstallSupportedApp:
                rvOperation.Api  = ApiCalls.RvInstallSupportedAppsResults();
                rvOperation.Type = OperationValue.InstallSupportedApp;
                InstallSupportedApplication(rvOperation);
                break;

            case OperationValue.InstallCustomApp:
                rvOperation.Api  = ApiCalls.RvInstallCustomAppsResults();
                rvOperation.Type = OperationValue.InstallCustomApp;
                InstallCustomApplication(rvOperation);
                break;

            case OperationValue.InstallAgentUpdate:
                rvOperation.Api  = ApiCalls.RvInstallAgentUpdateResults();
                rvOperation.Type = OperationValue.InstallAgentUpdate;
                InstallAgentUpdate(rvOperation);
                break;

            case OperationValue.Uninstall:
                rvOperation.Api  = ApiCalls.RvUninstallOperation();
                rvOperation.Type = OperationValue.Uninstall;
                UninstallOperation(rvOperation);
                break;

            case OperationValue.AgentUninstall:
                rvOperation.Type = OperationValue.AgentUninstall;
                UninstallRvAgentOperation();
                break;

            case RvOperationValue.UpdatesAndApplications:
                rvOperation.Type      = RvOperationValue.UpdatesAndApplications;
                rvOperation           = UpdatesApplicationsOperation(rvOperation);
                rvOperation.RawResult = RvFormatter.Applications(rvOperation);
                rvOperation.Api       = ApiCalls.RvUpdatesApplications();
                SendResults(rvOperation);
                break;

            case OperationValue.ResumeOp:
                ResumeOperations();
                break;

            default:
                Logger.Log("Received unrecognized operation. Ignoring.");
                break;
            }
        }
示例#3
0
        /// <summary>
        /// On every agent startup, this method runs to send the first data collection to the server.
        /// </summary>
        /// <returns></returns>
        public ISofOperation InitialData()
        {
            var operation = new RvSofOperation();

            //If some operations are left over, do not send UpdatesApplications.
            if (Operations.OperationsRemaining())
            {
                return(null);
            }

            Logger.Log("Preparing initial data.", LogLevel.Debug);

            operation.Type         = RvOperationValue.UpdatesAndApplications;
            operation.Applications = NewUpdatesAndApplications();
            operation.RawResult    = RvFormatter.Applications(operation);
            Logger.Log("Done.", LogLevel.Debug);
            return(operation);
        }