コード例 #1
0
ファイル: PolicyController.cs プロジェクト: theopenem/Toems
        public DtoActionResult Delete(int id)
        {
            var policy = _policyServices.GetPolicy(id);
            var result = _policyServices.DeletePolicy(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.Delete;
                _auditLogService.AddAuditLog(auditLog);
            }
            return(result);
        }
コード例 #2
0
ファイル: ImportPolicy.cs プロジェクト: theopenem/Toems
        public DtoImportResult Import()
        {
            if (_export == null)
            {
                return(new DtoImportResult()
                {
                    ErrorMessage = "Policy Was Null"
                });
            }

            var result = CreatePolicy();

            if (!result.Success)
            {
                return new DtoImportResult()
                       {
                           ErrorMessage = result.ErrorMessage
                       }
            }
            ;

            result = CreateScripts();
            if (!result.Success)
            {
                _policyService.DeletePolicy(_policy.Id);

                return(new DtoImportResult()
                {
                    ErrorMessage = result.ErrorMessage
                });
            }

            result = CreatePrinters();
            if (!result.Success)
            {
                _policyService.DeletePolicy(_policy.Id);
                return(new DtoImportResult()
                {
                    ErrorMessage = result.ErrorMessage
                });
            }

            result = CreateCommands();
            if (!result.Success)
            {
                _policyService.DeletePolicy(_policy.Id);
                return(new DtoImportResult()
                {
                    ErrorMessage = result.ErrorMessage
                });
            }

            result = CreateFileCopy();
            if (!result.Success)
            {
                _policyService.DeletePolicy(_policy.Id);
                return(new DtoImportResult()
                {
                    ErrorMessage = result.ErrorMessage
                });
            }

            result = CreateSoftware();
            if (!result.Success)
            {
                _policyService.DeletePolicy(_policy.Id);
                return(new DtoImportResult()
                {
                    ErrorMessage = result.ErrorMessage
                });
            }

            result = CreateWindowsUpdate();
            if (!result.Success)
            {
                _policyService.DeletePolicy(_policy.Id);
                return(new DtoImportResult()
                {
                    ErrorMessage = result.ErrorMessage
                });
            }

            result = CreateMessages();
            if (!result.Success)
            {
                _policyService.DeletePolicy(_policy.Id);
                return(new DtoImportResult()
                {
                    ErrorMessage = result.ErrorMessage
                });
            }

            _uow.Save();

            if (_export.Instructions.Contains("[skip-policy-create]"))
            {
                _policyService.DeletePolicy(_policy.Id);
                _uow.Save();
            }


            QueueExternalDownloads();

            var importResult = new DtoImportResult();

            importResult.Success          = true;
            importResult.HasExternalFiles = _policyHasExternalFiles;
            importResult.HasInternalFiles = _policyHasInternalFiles;
            return(importResult);
        }