private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e) { this.backgroundWorker = sender as BackgroundWorker; string xmlPath = String.Empty; if (this.Workflow == WorkflowType.ArbitraryEventLog) { List <string> policyPaths = ConvertDriverFilestoXml(this.DriverFiles); xmlPath = MergeAllPolicies(policyPaths); } else if (this.Workflow == WorkflowType.DeviceEventLog) { SiPolicy siPolicy = Helper.ReadMachineEventLogs(this._MainWindow.TempFolderPath, this.SelectedLevel.ToString()); xmlPath = Path.Combine(this._MainWindow.TempFolderPath, EVENT_LOG_POLICY_PATH); Helper.SerializePolicytoXML(siPolicy, xmlPath); } else { } // Set paths correctly so policy rules page can parse the policy this.EditPath = xmlPath; this._MainWindow.Policy.EditPolicyPath = this.EditPath; }
public WDAC_Policy() { this.siPolicy = null; this._PolicyTemplate = NewPolicyTemplate.None; this._PolicyType = PolicyType.None; this._Format = Format.None; this.EnableHVCI = false; this.EnableAudit = true; this.EKUs = new List <PolicyEKUs>(); this.FileRules = new Dictionary <string, PolicyFileRules>(); this.Signers = new Dictionary <string, PolicySigners>();//<PolicySigners>(); this.SigningScenarios = new List <PolicySigningScenarios>(); this.UpdateSigners = new List <PolicyUpdateSigners>(); this.SupplementalSigners = new List <PolicySupplementalSigners>(); this.CISigners = new List <PolicyCISigners>(); this.PolicySettings = new List <PolicySettings>(); this.CustomRules = new List <PolicyCustomRules>(); this.PoliciesToMerge = new List <string>(); this.VersionNumber = "10.0.0.0"; // Default policy version when calling the New-CIPolicy cmdlet this.PolicyID = formatDate(false); }
public static void SerializePolicytoXML(SiPolicy siPolicy, string xmlPath) { if (siPolicy == null || xmlPath == null) { return; } // Serialize policy to XML file XmlSerializer serializer = new XmlSerializer(typeof(SiPolicy)); StreamWriter writer = new StreamWriter(xmlPath); serializer.Serialize(writer, siPolicy); writer.Close(); }