Exemple #1
0
 public ModuleSoftwareManager(DtoClientSoftwareModule module)
 {
     _moduleResult         = new DtoModuleResult();
     _moduleResult.Name    = module.DisplayName;
     _moduleResult.Guid    = module.Guid;
     _moduleResult.Success = true;
     _module = module;
 }
Exemple #2
0
        private void SoftwareModule(EntityPolicyModules policyModule)
        {
            var clientSoftwareModule = new DtoClientSoftwareModule();
            var softwareModule       = new ServiceSoftwareModule().GetModule(policyModule.ModuleId);

            clientSoftwareModule.Guid           = softwareModule.Guid;
            clientSoftwareModule.DisplayName    = softwareModule.Name;
            clientSoftwareModule.Command        = softwareModule.Command;
            clientSoftwareModule.Arguments      = softwareModule.Arguments + " " + softwareModule.AdditionalArguments;
            clientSoftwareModule.Order          = policyModule.Order;
            clientSoftwareModule.Timeout        = softwareModule.Timeout;
            clientSoftwareModule.InstallType    = softwareModule.InstallType;
            clientSoftwareModule.RedirectOutput = softwareModule.RedirectStdOut;
            clientSoftwareModule.RedirectError  = softwareModule.RedirectStdError;
            foreach (var successCode in softwareModule.SuccessCodes.Split(','))
            {
                clientSoftwareModule.SuccessCodes.Add(successCode);
            }

            var moduleFiles = new ServiceModule().GetModuleFiles(softwareModule.Guid);

            foreach (var file in moduleFiles.OrderBy(x => x.FileName))
            {
                var clientFile = new DtoClientFileHash();
                clientFile.FileName = file.FileName;
                clientFile.FileHash = file.Md5Hash;
                clientSoftwareModule.Files.Add(clientFile);
            }

            if (softwareModule.ImpersonationId != -1)
            {
                var impersonationGuid = new ServiceImpersonationAccount().GetGuid(softwareModule.ImpersonationId);
                if (!string.IsNullOrEmpty(impersonationGuid))
                {
                    clientSoftwareModule.RunAs = impersonationGuid;
                }
            }

            if (policyModule.ConditionId != -1)
            {
                var conditionScript = new ServiceScriptModule().GetModule(policyModule.ConditionId);
                if (conditionScript != null)
                {
                    clientSoftwareModule.ConditionFailedAction    = policyModule.ConditionFailedAction;
                    clientSoftwareModule.ConditionNextOrder       = policyModule.ConditionNextModule;
                    clientSoftwareModule.Condition                = new DtoClientModuleCondition();
                    clientSoftwareModule.Condition.Arguments      = conditionScript.Arguments;
                    clientSoftwareModule.Condition.DisplayName    = conditionScript.Name;
                    clientSoftwareModule.Condition.Guid           = conditionScript.Guid;
                    clientSoftwareModule.Condition.RedirectError  = conditionScript.RedirectStdError;
                    clientSoftwareModule.Condition.RedirectOutput = conditionScript.RedirectStdOut;
                    if (conditionScript.ImpersonationId != -1)
                    {
                        var scriptImpersonationGuid = new ServiceImpersonationAccount().GetGuid(conditionScript.ImpersonationId);
                        if (!string.IsNullOrEmpty(scriptImpersonationGuid))
                        {
                            clientSoftwareModule.Condition.RunAs = scriptImpersonationGuid;
                        }
                    }
                    clientSoftwareModule.Condition.ScriptType = conditionScript.ScriptType;
                    foreach (var successCode in conditionScript.SuccessCodes.Split(','))
                    {
                        clientSoftwareModule.Condition.SuccessCodes.Add(successCode);
                    }
                    clientSoftwareModule.Condition.Timeout          = conditionScript.Timeout;
                    clientSoftwareModule.Condition.WorkingDirectory = conditionScript.WorkingDirectory;
                }
            }

            _clientPolicy.SoftwareModules.Add(clientSoftwareModule);
        }