//--------------------------------------------------------------------- private void WriteTableRows(MP mp) { foreach (var mpClass in mp.Classes) { foreach (var workflowPair in mpClass.Value.MPWorkflows) { // this is a piece which will be used on each row pertaining to this workflow string workflowType = string.Empty; if (workflowPair.Value.Workflow is ManagementPackMonitor) { workflowType = "Monitor"; } else if (workflowPair.Value.Workflow is ManagementPackRule) { workflowType = "Rule"; } else if (workflowPair.Value.Workflow is ManagementPackDiscovery) { workflowType = "Discovery"; } else { throw new ApplicationException("Unknown element type"); } // this is a piece which will be used on each row pertaining to this workflow string workflowName = Common.GetBestElementName(workflowPair.Value.Workflow); foreach (ManagementPackOverride mpOverride in workflowPair.Value.Overrides) { string parameter; string newValue; Common.RetrieveParameterInfo(mpOverride, out parameter, out newValue); // let's start outputting the row m_contents.AppendLine("<Row>"); // CDATA added dmuscett march 8th 2012 to MPViewer because Exchange MP contains invalid characters such as "<" and ">" and that was breaking the XML file format // it is safe to leave it here too :-) m_contents.AppendFormat(@"<Cell><Data ss:Type=""String""><![CDATA[{0}]]></Data></Cell>", mp.Name); //"Management Pack" m_contents.AppendFormat(@"<Cell><Data ss:Type=""String""><![CDATA[{0}]]></Data></Cell>", mp.Name); //"Class" m_contents.AppendFormat(@"<Cell><Data ss:Type=""String""><![CDATA[{0}]]></Data></Cell>", workflowType); //"Workflow Type" m_contents.AppendFormat(@"<Cell><Data ss:Type=""String""><![CDATA[{0}]]></Data></Cell>", workflowName); //"Workflow Name" m_contents.AppendFormat(@"<Cell><Data ss:Type=""String""><![CDATA[{0}]]></Data></Cell>", parameter); //"Override Parameter" m_contents.AppendFormat(@"<Cell><Data ss:Type=""String""><![CDATA[{0}]]></Data></Cell>", newValue); //"Override Value" m_contents.AppendFormat(@"<Cell><Data ss:Type=""String""><![CDATA[{0}]]></Data></Cell>", Common.RetrieveContext(mpOverride, m_managementGroup)); //"Context" m_contents.AppendFormat(@"<Cell><Data ss:Type=""String""><![CDATA[{0}]]></Data></Cell>", mpOverride.Enforced.ToString()); //"Is Enforced" m_contents.AppendFormat(@"<Cell><Data ss:Type=""String""><![CDATA[{0}]]></Data></Cell>", Common.GetManagementPackSealedFlag(mpOverride.GetManagementPack())); //"Is Sealed" m_contents.AppendFormat(@"<Cell><Data ss:Type=""String""><![CDATA[{0}]]></Data></Cell>", mpOverride.TimeAdded.ToLocalTime().ToString()); //"Time Added" m_contents.AppendLine("</Row>"); } } } }
//--------------------------------------------------------------------- private void AddClassToXmlDocument(MP mp, XmlElement mpElement, XmlDocument document) { foreach (KeyValuePair <Guid, MPClass> classPair in mp.Classes) { XmlElement classElement = document.CreateElement("Type"); classElement.SetAttribute("Name", classPair.Value.Name); mpElement.AppendChild(classElement); AddWorkflowsToXmlDocument(classPair.Value, classElement, document); } }
//--------------------------------------------------------------------- private void AddClassToXmlDocument(MP mp, XmlElement mpElement, XmlDocument document) { foreach (KeyValuePair<Guid, MPClass> classPair in mp.Classes) { XmlElement classElement = document.CreateElement("Type"); classElement.SetAttribute("Name", classPair.Value.Name); mpElement.AppendChild(classElement); AddWorkflowsToXmlDocument(classPair.Value, classElement, document); } }
//--------------------------------------------------------------------- internal void WriteOverridesToExcel(MP mp) { WriteTableRows(mp); }