Ejemplo n.º 1
0
 public DtoActionResult ValidatePolicyExport(DtoPolicyExportGeneral exportInfo)
 {
     Request.Method = Method.POST;
     Request.AddJsonBody(exportInfo);
     Request.Resource = string.Format("{0}/ValidatePolicyExport/", Resource);
     return(new ApiRequest().Execute <DtoActionResult>(Request));
 }
Ejemplo n.º 2
0
        protected void buttonExport_OnClick(object sender, EventArgs e)
        {
            var exportInfo = new DtoPolicyExportGeneral();

            exportInfo.PolicyId     = Policy.Id;
            exportInfo.Description  = txtDescription.Text;
            exportInfo.Instructions = txtInstructions.Text;
            exportInfo.Requirements = txtRequirements.Text;
            exportInfo.Name         = txtName.Text;

            var validationResult = Call.PolicyApi.ValidatePolicyExport(exportInfo);

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

                var policyExport = Call.PolicyApi.ExportPolicy(exportInfo);
                Response.ContentType = "text/plain";
                Response.AppendHeader("Content-Disposition", "attachment; filename=policy.json");
                Response.Write(JsonConvert.SerializeObject(policyExport));
                Response.End();
            }
        }
Ejemplo n.º 3
0
 public DtoPolicyExport ExportPolicy(DtoPolicyExportGeneral exportInfo)
 {
     Request.Method = Method.POST;
     Request.AddJsonBody(exportInfo);
     Request.Resource = string.Format("{0}/ExportPolicy/", Resource);
     return(new ApiRequest().Execute <DtoPolicyExport>(Request));
 }
Ejemplo n.º 4
0
 private void CopyPolicy(DtoPolicyExportGeneral exportInfo)
 {
     _policyExport.Name                  = exportInfo.Name;
     _policyExport.Description           = exportInfo.Description;
     _policyExport.Instructions          = exportInfo.Instructions;
     _policyExport.Requirements          = exportInfo.Requirements;
     _policyExport.Guid                  = _policy.Guid;
     _policyExport.Frequency             = _policy.Frequency;
     _policyExport.Trigger               = _policy.Trigger;
     _policyExport.SubFrequency          = _policy.SubFrequency;
     _policyExport.CompletedAction       = _policy.CompletedAction;
     _policyExport.RemoveInstallCache    = _policy.RemoveInstallCache;
     _policyExport.ExecutionType         = _policy.ExecutionType;
     _policyExport.ErrorAction           = _policy.ErrorAction;
     _policyExport.IsInventory           = _policy.RunInventory;
     _policyExport.IsLoginTracker        = _policy.RunLoginTracker;
     _policyExport.FrequencyMissedAction = _policy.MissedAction;
     _policyExport.LogLevel              = _policy.LogLevel;
     _policyExport.SkipServerResult      = _policy.SkipServerResult;
     _policyExport.IsApplicationMonitor  = _policy.RunApplicationMonitor;
     _policyExport.WuType                = _policy.WuType;
     _policyExport.ConditionFailedAction = _policy.ConditionFailedAction;
     if (_policy.ConditionId != -1)
     {
         _policyExport.Condition = GetCondition(_policy.ConditionId);
     }
 }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
        public DtoActionResult ValidatePolicyExport(DtoPolicyExportGeneral info)
        {
            var result = new DtoActionResult();

            if (string.IsNullOrEmpty(info.Name))
            {
                result.ErrorMessage = "Policy Export Must Have A Name.";
                return(result);
            }

            if (string.IsNullOrEmpty(info.Description))
            {
                result.ErrorMessage = "Policy Export Must Have A Description";
                return(result);
            }

            return(new Workflows.ValidatePolicy().Validate(info.PolicyId));
        }
Ejemplo n.º 7
0
 public DtoPolicyExport ExportPolicy(DtoPolicyExportGeneral exportInfo)
 {
     return(new ExportPolicy().Export(exportInfo));
 }
Ejemplo n.º 8
0
 public DtoActionResult ValidatePolicyExport(DtoPolicyExportGeneral exportInfo)
 {
     return(_policyServices.ValidatePolicyExport(exportInfo));
 }