Ejemplo n.º 1
0
 public ModuleFileCopy(DtoClientFileCopyModule module)
 {
     _fileSystemService    = new ServiceFileSystem();
     _moduleResult         = new DtoModuleResult();
     _moduleResult.Name    = module.DisplayName;
     _moduleResult.Guid    = module.Guid;
     _moduleResult.Success = true;
     _module = module;
 }
Ejemplo n.º 2
0
        private void FileCopyModule(EntityPolicyModules policyModule)
        {
            var clientFileCopyModule = new DtoClientFileCopyModule();
            var fileCopyModule       = new ServiceFileCopyModule().GetModule(policyModule.ModuleId);

            clientFileCopyModule.Guid        = fileCopyModule.Guid;
            clientFileCopyModule.DisplayName = fileCopyModule.Name;
            clientFileCopyModule.Destination = fileCopyModule.Destination;
            clientFileCopyModule.Order       = policyModule.Order;
            clientFileCopyModule.Unzip       = fileCopyModule.DecompressAfterCopy;
            var moduleFiles = new ServiceModule().GetModuleFiles(fileCopyModule.Guid);

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

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