Example #1
0
        public DtoPolicyExport Export(DtoPolicyExportGeneral exportInfo)
        {
            _policy = _policyService.GetPolicy(exportInfo.PolicyId);
            if (_policy == null)
            {
                return(null);
            }

            var validationResult = new ValidatePolicy().Validate(exportInfo.PolicyId);

            if (!validationResult.Success)
            {
                return(null);
            }

            CopyPolicy(exportInfo);

            var policyModules = _policyService.SearchAssignedPolicyModules(exportInfo.PolicyId, _filter);

            foreach (var policyModule in policyModules.OrderBy(x => x.Name))
            {
                if (policyModule.ModuleType == EnumModule.ModuleType.Command)
                {
                    CopyCommandModule(policyModule);
                }
                else if (policyModule.ModuleType == EnumModule.ModuleType.FileCopy)
                {
                    CopyFileCopyModule(policyModule);
                }
                else if (policyModule.ModuleType == EnumModule.ModuleType.Script)
                {
                    CopyScriptModule(policyModule);
                }
                else if (policyModule.ModuleType == EnumModule.ModuleType.Printer)
                {
                    CopyPrinterModule(policyModule);
                }
                else if (policyModule.ModuleType == EnumModule.ModuleType.Software)
                {
                    CopySoftwareModule(policyModule);
                }
                else if (policyModule.ModuleType == EnumModule.ModuleType.Wupdate)
                {
                    CopyWuModule(policyModule);
                }
                else if (policyModule.ModuleType == EnumModule.ModuleType.Message)
                {
                    CopyMessageModule(policyModule);
                }
            }

            return(_policyExport);
        }
Example #2
0
        public DtoClientPolicy Create(int policyId)
        {
            _policy = _policyService.GetPolicy(policyId);
            Policy();
            DtoModuleSearchFilter filter = new DtoModuleSearchFilter();

            filter.IncludeCommand  = true;
            filter.IncludeFileCopy = true;
            filter.IncludePrinter  = true;
            filter.IncludeScript   = true;
            filter.IncludeSoftware = true;
            filter.IncludeWu       = true;
            filter.IncludeMessage  = true;
            filter.Limit           = Int32.MaxValue;
            var policyModules = _policyService.SearchAssignedPolicyModules(policyId, filter);

            foreach (var policyModule in policyModules.OrderBy(x => x.Name))
            {
                if (policyModule.ModuleType == EnumModule.ModuleType.Command)
                {
                    CommandModule(policyModule);
                }
                else if (policyModule.ModuleType == EnumModule.ModuleType.FileCopy)
                {
                    FileCopyModule(policyModule);
                }
                else if (policyModule.ModuleType == EnumModule.ModuleType.Script)
                {
                    ScriptModule(policyModule);
                }
                else if (policyModule.ModuleType == EnumModule.ModuleType.Printer)
                {
                    PrinterModule(policyModule);
                }
                else if (policyModule.ModuleType == EnumModule.ModuleType.Software)
                {
                    SoftwareModule(policyModule);
                }
                else if (policyModule.ModuleType == EnumModule.ModuleType.Wupdate)
                {
                    WuModule(policyModule);
                }
                else if (policyModule.ModuleType == EnumModule.ModuleType.Message)
                {
                    MessageModule(policyModule);
                }
            }

            return(_clientPolicy);
        }
Example #3
0
        public DtoActionResult Validate(int policyId)
        {
            _policy = _policyService.GetPolicy(policyId);
            if (_policy == null)
            {
                _result.Success      = false;
                _result.ErrorMessage = "Could Not Find A Policy With Id: " + policyId;
                return(_result);
            }

            string verifyResult;

            verifyResult = VerifyPolicy();
            if (verifyResult != null)
            {
                _result.Success      = false;
                _result.ErrorMessage = verifyResult;
                return(_result);
            }

            var policyModules = _policyService.SearchAssignedPolicyModules(policyId, _filter);

            foreach (var policyModule in policyModules.OrderBy(x => x.Name))
            {
                verifyResult = VerifyConditions(policyModule, policyModules);
                if (verifyResult != null)
                {
                    _result.Success      = false;
                    _result.ErrorMessage = verifyResult;
                    return(_result);
                }

                if (policyModule.ModuleType == EnumModule.ModuleType.Command)
                {
                    verifyResult = VerifyCommand(policyModule);
                    if (verifyResult != null)
                    {
                        _result.Success      = false;
                        _result.ErrorMessage = verifyResult;
                        return(_result);
                    }
                }
                else if (policyModule.ModuleType == EnumModule.ModuleType.FileCopy)
                {
                    verifyResult = VerifyFileCopy(policyModule);
                    if (verifyResult != null)
                    {
                        _result.Success      = false;
                        _result.ErrorMessage = verifyResult;
                        return(_result);
                    }
                }
                else if (policyModule.ModuleType == EnumModule.ModuleType.Message)
                {
                    verifyResult = VerifyMessage(policyModule);
                    if (verifyResult != null)
                    {
                        _result.Success      = false;
                        _result.ErrorMessage = verifyResult;
                        return(_result);
                    }
                }
                else if (policyModule.ModuleType == EnumModule.ModuleType.Script)
                {
                    verifyResult = VerifyScript(policyModule);
                    if (verifyResult != null)
                    {
                        _result.Success      = false;
                        _result.ErrorMessage = verifyResult;
                        return(_result);
                    }
                }
                else if (policyModule.ModuleType == EnumModule.ModuleType.Printer)
                {
                    verifyResult = VerifyPrinter(policyModule);
                    if (verifyResult != null)
                    {
                        _result.Success      = false;
                        _result.ErrorMessage = verifyResult;
                        return(_result);
                    }
                }
                else if (policyModule.ModuleType == EnumModule.ModuleType.Software)
                {
                    verifyResult = VerifySoftware(policyModule);
                    if (verifyResult != null)
                    {
                        _result.Success      = false;
                        _result.ErrorMessage = verifyResult;
                        return(_result);
                    }
                }
                else if (policyModule.ModuleType == EnumModule.ModuleType.Wupdate)
                {
                    verifyResult = VerifyWindowsUpdate(policyModule);
                    if (verifyResult != null)
                    {
                        _result.Success      = false;
                        _result.ErrorMessage = verifyResult;
                        return(_result);
                    }
                }
            }

            _result.Success = true;
            return(_result);
        }
Example #4
0
 public IEnumerable <EntityPolicyModules> GetAssignedModules(int id, DtoModuleSearchFilter filter)
 {
     return(_policyServices.SearchAssignedPolicyModules(id, filter));
 }