Exemplo n.º 1
0
        public bool Save(string dataSourceName)
        {
            string dynamicXamlBody = string.Empty;
            bool   allGood         = true;

            List <Control> mappers = new List <Control>(pnlMain.Controls.Cast <Control>());

            mappers.Reverse();

            foreach (Control ctl in mappers)
            {
                if (ctl is AttributeMapper)
                {
                    AttributeMapper attributeMapper = (AttributeMapper)ctl;
                    if (attributeMapper.ValidateData() == false)
                    {
                        attributeMapper.Focus();
                        allGood = false;
                    }
                    else
                    {
                        dynamicXamlBody += attributeMapper.XamlString + Environment.NewLine;
                    }
                }
            }

            if (allGood)
            {
                InputBox inputBox = new InputBox(dataSourceName + " - Map", "Enter Rule Name", "Save Rule", this.ParentForm.Icon);
                if (inputBox.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    IdpeRule rule = new IdpeRule();
                    rule.Name        = inputBox.TheInput;
                    rule.Description = inputBox.TheInput + " was created by wizard";
                    rule.Xaml        = string.Format(XamlBody, rule.Name, dynamicXamlBody);
                    new Manager().Save(rule);
                }
            }
            return(allGood);
        }