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); }
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); }
public DtoActionResult Archive(int id) { var policy = _policyServices.GetPolicy(id); var result = _policyServices.ArchivePolicy(id); if (result == null) { throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound)); } if (result.Success) { var auditLog = new EntityAuditLog(); auditLog.ObjectType = "Policy"; auditLog.ObjectId = result.Id; auditLog.ObjectName = policy.Name; auditLog.ObjectJson = JsonConvert.SerializeObject(policy); auditLog.UserId = _userId; auditLog.AuditType = EnumAuditEntry.AuditType.Archive; _auditLogService.AddAuditLog(auditLog); } return(result); }
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); }