示例#1
0
        private void CopySoftwareModule(EntityPolicyModules policyModule)
        {
            var softwareModuleExport = new DtoSoftwareModuleExport();
            var softwareModule       = new ServiceSoftwareModule().GetModule(policyModule.ModuleId);

            softwareModuleExport.DisplayName         = softwareModule.Name;
            softwareModuleExport.Command             = softwareModule.Command;
            softwareModuleExport.Description         = softwareModule.Description;
            softwareModuleExport.Arguments           = softwareModule.Arguments;
            softwareModuleExport.AdditionalArguments = softwareModule.AdditionalArguments;
            softwareModuleExport.Order                 = policyModule.Order;
            softwareModuleExport.Timeout               = softwareModule.Timeout;
            softwareModuleExport.InstallType           = softwareModule.InstallType;
            softwareModuleExport.RedirectOutput        = softwareModule.RedirectStdOut;
            softwareModuleExport.RedirectError         = softwareModule.RedirectStdError;
            softwareModuleExport.SuccessCodes          = softwareModule.SuccessCodes;
            softwareModuleExport.Guid                  = softwareModule.Guid;
            softwareModuleExport.ConditionFailedAction = policyModule.ConditionFailedAction;
            softwareModuleExport.ConditionNextOrder    = policyModule.ConditionNextModule;


            var uploadedFiles = new ServiceUploadedFile().GetFilesForModule(softwareModule.Guid);

            foreach (var file in uploadedFiles.OrderBy(x => x.Name))
            {
                var uploadedFile = new DtoUploadedFileExport();
                uploadedFile.FileName   = file.Name;
                uploadedFile.Md5Hash    = file.Hash;
                uploadedFile.ModuleGuid = file.Guid;
                softwareModuleExport.UploadedFiles.Add(uploadedFile);
            }

            var externalFiles = new ServiceExternalDownload().GetForModule(softwareModule.Guid);

            foreach (var file in externalFiles.OrderBy(x => x.FileName))
            {
                var externalFile = new DtoExternalFileExport();
                externalFile.FileName   = file.FileName;
                externalFile.Sha256Hash = file.Sha256Hash;
                externalFile.Url        = file.Url;
                externalFile.ModuleGuid = file.ModuleGuid;
                softwareModuleExport.ExternalFiles.Add(externalFile);
            }

            if (policyModule.ConditionId != -1)
            {
                softwareModuleExport.Condition = GetCondition(policyModule.ConditionId);
            }

            _policyExport.SoftwareModules.Add(softwareModuleExport);
        }
示例#2
0
        private void CopyCommandModule(EntityPolicyModules policyModule)
        {
            var commandModuleExport = new DtoCommandModuleExport();
            var commandModule       = new ServiceCommandModule().GetModule(policyModule.ModuleId);

            commandModuleExport.Description           = commandModule.Description;
            commandModuleExport.Order                 = policyModule.Order;
            commandModuleExport.Command               = commandModule.Command;
            commandModuleExport.Arguments             = commandModule.Arguments;
            commandModuleExport.DisplayName           = commandModule.Name;
            commandModuleExport.Timeout               = commandModule.Timeout;
            commandModuleExport.RedirectOutput        = commandModule.RedirectStdOut;
            commandModuleExport.RedirectError         = commandModule.RedirectStdError;
            commandModuleExport.WorkingDirectory      = commandModule.WorkingDirectory;
            commandModuleExport.SuccessCodes          = commandModule.SuccessCodes;
            commandModuleExport.Guid                  = commandModule.Guid;
            commandModuleExport.ConditionFailedAction = policyModule.ConditionFailedAction;
            commandModuleExport.ConditionNextOrder    = policyModule.ConditionNextModule;

            var uploadedFiles = new ServiceUploadedFile().GetFilesForModule(commandModule.Guid);

            foreach (var file in uploadedFiles.OrderBy(x => x.Name))
            {
                var uploadedFile = new DtoUploadedFileExport();
                uploadedFile.FileName   = file.Name;
                uploadedFile.Md5Hash    = file.Hash;
                uploadedFile.ModuleGuid = file.Guid;
                commandModuleExport.UploadedFiles.Add(uploadedFile);
            }

            var externalFiles = new ServiceExternalDownload().GetForModule(commandModule.Guid);

            foreach (var file in externalFiles.OrderBy(x => x.FileName))
            {
                var externalFile = new DtoExternalFileExport();
                externalFile.FileName   = file.FileName;
                externalFile.Sha256Hash = file.Sha256Hash;
                externalFile.Url        = file.Url;
                externalFile.ModuleGuid = file.ModuleGuid;
                commandModuleExport.ExternalFiles.Add(externalFile);
            }

            if (policyModule.ConditionId != -1)
            {
                commandModuleExport.Condition = GetCondition(policyModule.ConditionId);
            }


            _policyExport.CommandModules.Add(commandModuleExport);
        }
示例#3
0
        private void CopyFileCopyModule(EntityPolicyModules policyModule)
        {
            var fileCopyModuleExport = new DtoFileCopyModuleExport();
            var fileCopyModule       = new ServiceFileCopyModule().GetModule(policyModule.ModuleId);

            fileCopyModuleExport.DisplayName           = fileCopyModule.Name;
            fileCopyModuleExport.Description           = fileCopyModule.Description;
            fileCopyModuleExport.Destination           = fileCopyModule.Destination;
            fileCopyModuleExport.Order                 = policyModule.Order;
            fileCopyModuleExport.Unzip                 = fileCopyModule.DecompressAfterCopy;
            fileCopyModuleExport.Guid                  = fileCopyModule.Guid;
            fileCopyModuleExport.ConditionFailedAction = policyModule.ConditionFailedAction;
            fileCopyModuleExport.ConditionNextOrder    = policyModule.ConditionNextModule;

            var uploadedFiles = new ServiceUploadedFile().GetFilesForModule(fileCopyModule.Guid);

            foreach (var file in uploadedFiles.OrderBy(x => x.Name))
            {
                var uploadedFile = new DtoUploadedFileExport();
                uploadedFile.FileName   = file.Name;
                uploadedFile.Md5Hash    = file.Hash;
                uploadedFile.ModuleGuid = file.Guid;
                fileCopyModuleExport.UploadedFiles.Add(uploadedFile);
            }

            var externalFiles = new ServiceExternalDownload().GetForModule(fileCopyModule.Guid);

            foreach (var file in externalFiles.OrderBy(x => x.FileName))
            {
                var externalFile = new DtoExternalFileExport();
                externalFile.FileName   = file.FileName;
                externalFile.Sha256Hash = file.Sha256Hash;
                externalFile.Url        = file.Url;
                externalFile.ModuleGuid = file.ModuleGuid;
                fileCopyModuleExport.ExternalFiles.Add(externalFile);
            }

            if (policyModule.ConditionId != -1)
            {
                fileCopyModuleExport.Condition = GetCondition(policyModule.ConditionId);
            }

            _policyExport.FileCopyModules.Add(fileCopyModuleExport);
        }