コード例 #1
0
 private bool ReplaceRule(GenericRule editedRule, GenericRule backupRule, RulesGroup groupToSearchInto)
 {
     Logger.EnteringMethod();
     Logger.Write("Edited Rule : " + editedRule.GetXmlFormattedRule());
     Logger.Write("Backup Rule : " + backupRule.GetXmlFormattedRule());
     if (groupToSearchInto.InnerRules.ContainsKey(editedRule.Id))
     {
         groupToSearchInto.InnerRules.Remove(editedRule.Id);
         groupToSearchInto.AddRule(backupRule);
         if (rdBtnUpdateLevel.Checked)
         {
             grpDspUpdateLevel.Initialize(_masterGroupUpdateLevel);
         }
         else
         {
             grpDspPackageLevel.Initialize(_masterGroupPackageLevel);
         }
         return(true);
     }
     else
     {
         foreach (RulesGroup group in groupToSearchInto.InnerGroups.Values)
         {
             if (ReplaceRule(editedRule, backupRule, group))
             {
                 break;
             }
         }
     }
     return(true);
 }
コード例 #2
0
 private void Rule_EditionRequested(GenericRule RequestingRule)
 {
     if (RuleEditionRequest != null)
     {
         RuleEditionRequest(RequestingRule);
     }
 }
コード例 #3
0
        private void EditRule(GenericRule editedRule)
        {
            Logger.EnteringMethod(editedRule.GetXmlFormattedRule());
            GenericRule backup = editedRule.Clone();
            Form        frm    = new Form();

            frm.KeyPreview    = true;
            frm.KeyDown      += new KeyEventHandler(frm_KeyDown);
            frm.StartPosition = FormStartPosition.CenterParent;
            frm.Size          = new Size(editedRule.Width + 20, editedRule.Height + 2 * SystemInformation.CaptionHeight);
            editedRule.Dock   = DockStyle.Fill;
            frm.Controls.Add(editedRule);
            if (frm.ShowDialog() == DialogResult.Cancel)
            {
                if (rdBtnUpdateLevel.Checked)
                {
                    ReplaceRule(editedRule, backup, _masterGroupUpdateLevel);
                }
                else
                {
                    ReplaceRule(editedRule, backup, _masterGroupPackageLevel);
                }
            }
            frm.Hide();
            frm.KeyDown -= new KeyEventHandler(frm_KeyDown);
            frm          = null;
        }
コード例 #4
0
 private bool DeleteRule(GenericRule ruleToDelete, RulesGroup groupToSearchInto)
 {
     Logger.EnteringMethod();
     if (groupToSearchInto.InnerRules.ContainsKey(ruleToDelete.Id))
     {
         Logger.Write("Deleting Rule : " + ruleToDelete.GetXmlFormattedRule());
         groupToSearchInto.InnerRules.Remove(ruleToDelete.Id);
         return(true);
     }
     else
     {
         foreach (RulesGroup group in groupToSearchInto.InnerGroups.Values)
         {
             if (DeleteRule(ruleToDelete, group))
             {
                 break;
             }
         }
     }
     return(true);
 }
コード例 #5
0
 private void grpDsp1_RuleEditionRequest(GenericRule ResquestingRule)
 {
     Logger.EnteringMethod(ResquestingRule.ToString());
     EditRule(ResquestingRule);
 }
コード例 #6
0
        private RulesGroup ParseXml(RulesGroup group, string xml, bool mergeGroup)
        {
            Logger.EnteringMethod(xml);
            bool reverseRule = false;
            bool thisGroup   = true;
            XmlNamespaceManager namespaceMng = new XmlNamespaceManager(new System.Xml.NameTable());

            namespaceMng.AddNamespace("lar", "http://schemas.microsoft.com/wsus/2005/04/CorporatePublishing/LogicalApplicabilityRules.xsd");
            namespaceMng.AddNamespace("bar", "http://schemas.microsoft.com/wsus/2005/04/CorporatePublishing/BaseApplicabilityRules.xsd");
            namespaceMng.AddNamespace("msiar", "http://schemas.microsoft.com/wsus/2005/04/CorporatePublishing/MsiApplicabilityRules.xsd");

            XmlParserContext context   = new XmlParserContext(null, namespaceMng, null, XmlSpace.Default);
            XmlTextReader    xmlReader = new XmlTextReader(xml, XmlNodeType.Element, context);

            xmlReader.WhitespaceHandling = WhitespaceHandling.None;
            xmlReader.Read();
            while (!xmlReader.EOF)
            {
                switch (xmlReader.Prefix)
                {
                case "lar":
                    switch (xmlReader.LocalName)
                    {
                    case "Not":
                        reverseRule = (xmlReader.NodeType != XmlNodeType.EndElement);
                        xmlReader.Read();
                        break;

                    case "And":
                        if (xmlReader.NodeType == XmlNodeType.Element)
                        {
                            if (thisGroup && mergeGroup)
                            {
                                group.GroupType = RulesGroup.GroupLogicalOperator.And;
                                thisGroup       = false;
                                xmlReader.Read();
                            }
                            else
                            {
                                RulesGroup tempGroup = new RulesGroup();
                                group.AddGroup(ParseXml(tempGroup, xmlReader.ReadOuterXml(), true));
                            }
                        }
                        else
                        if (xmlReader.NodeType == XmlNodeType.EndElement)
                        {
                            return(group);
                        }
                        break;

                    case "Or":
                        if (xmlReader.NodeType == XmlNodeType.Element)
                        {
                            if (thisGroup && mergeGroup)
                            {
                                group.GroupType = RulesGroup.GroupLogicalOperator.Or;
                                thisGroup       = false;
                                xmlReader.Read();
                            }
                            else
                            {
                                RulesGroup tempGroup = new RulesGroup();
                                group.AddGroup(ParseXml(tempGroup, xmlReader.ReadOuterXml(), true));
                            }
                        }
                        else
                        if (xmlReader.NodeType == XmlNodeType.EndElement)
                        {
                            return(group);
                        }
                        break;

                    default:
                        xmlReader.Read();
                        break;
                    }
                    break;

                case "bar":
                case "msiar":
                    foreach (GenericRule rule in _allSupportedRules)
                    {
                        if (xmlReader.LocalName == rule.XmlElementName)
                        {
                            GenericRule tempRule = GetSelectedForm(rule);
                            tempRule.ReverseRule = reverseRule;
                            tempRule.InitializeWithAttributes(GetAttributes(xmlReader));
                            group.AddRule(tempRule);
                            break;
                        }
                    }
                    xmlReader.Read();
                    break;

                default:
                    xmlReader.Read();
                    break;
                }
            }
            return(group);
        }
コード例 #7
0
 private void Rule_SelectedChange(GenericRule ChangedRule)
 {
     UpdateSelectedRulesAndGroupsList();
 }
コード例 #8
0
 internal void AddRule(GenericRule ruleToAdd)
 {
     _innerRules.Add(ruleToAdd.Id, ruleToAdd);
 }
コード例 #9
0
 internal RuleDisplayer(GenericRule ruleToDisplay)
 {
     InitializeComponent();
     DisplayedRule = ruleToDisplay;
 }