示例#1
0
        private XElement createStringDistance(PolicyConfigurationModel settings)
        {
            var stringDst = new XElement("stringDistancePolicy");
            var dist      = new XElement("minDistance");

            dist.Value = settings.StringDistanceMinDist.ToString();
            stringDst.Add(dist);

            return(stringDst);
        }
示例#2
0
        private XElement createReadingDirection(PolicyConfigurationModel settings)
        {
            var reading = new XElement("readingDirectionPolicy");
            var left    = new XElement("leftToRight");

            left.Value = settings.ReadingDirectionLeftRight.ToString().ToLower();
            var top = new XElement("topToBottom");

            top.Value = settings.ReadingDirectionTopBottom.ToString().ToLower();
            reading.Add(left);
            reading.Add(top);
            return(reading);
        }
示例#3
0
        private XElement createOneAmongOthers(PolicyConfigurationModel settings)
        {
            var oneAmong = new XElement("oneAmongOthersPolicy");
            var style    = new XElement("environmentStyle");

            style.Value = settings.OneAmongOthersStyle;
            var length = new XElement("environmentLength");

            length.Value = settings.OneAmongOthersLength.ToString();
            oneAmong.Add(style);
            oneAmong.Add(length);

            return(oneAmong);
        }
示例#4
0
        private XElement createFormulaComplexity(PolicyConfigurationModel settings)
        {
            var formulaRule = new XElement("formulaComplexityPolicy");
            var maxNesting  = new XElement("maxNesting");

            maxNesting.Value = settings.FormulaComplexityMaxDepth.ToString();
            var maxOperations = new XElement("maxOperations");

            maxOperations.Value = settings.FormulaComplexityMaxOperations.ToString();
            formulaRule.Add(maxNesting);
            formulaRule.Add(maxOperations);

            return(formulaRule);
        }
        /// <summary>
        /// Sets Settings for non consider constants
        /// </summary>
        /// <param name="settings"></param>
        private void SetNonConCon(PolicyConfigurationModel settings)
        {
            if (settings.NonConsideredConstants)
            {
                CB_NonConsideredConstants.Checked = true;
                NCC_A.Enabled = true;
                NCC_M.Enabled = true;

                if (!settings.NonConsideredConstantsAutomatic)
                {
                    NCC_M.Checked = true;
                }
                else
                {
                    NCC_A.Checked = true;
                }
            }
        }
        /// <summary>
        /// Sets the settings for No Constants in Formulas
        /// </summary>
        /// <param name="settings"></param>
        private void SetNoConstants(PolicyConfigurationModel settings)
        {
            if (settings.NoConstantsInFormulas)                                   // if the Constraints box was previously selected and is stored in the settings
            {
                CB_NoConstantsInFormulas.Checked = true;                                  // display the Constraints box as checked
                NCIF_A.Enabled = true;                                   // and enable the Always and Manual radio buttons
                NCIF_M.Enabled = true;

                if (settings.NoConstantsInFormulasAutomatic)                     // The frequency is set to Always by default. If it is changed to false (aka Manual)
                {
                    NCIF_A.Checked = true;                               // display the frequency as Manual
                }
                else
                {
                    NCIF_M.Checked = true;                               // otherwise, keep the defaul setting of Always
                }
            }
        }
        /// <summary>
        /// Sets the Settings for Multiple same References in a formula
        /// </summary>
        /// <param name="settings"></param>
        private void SetMultSamRef(PolicyConfigurationModel settings)
        {
            if (settings.MultipleSameRef)
            {
                CB_MultipleSameRef.Checked = true;
                MSR_A.Enabled = true;
                MSR_M.Enabled = true;

                if (!settings.MultipleSameRefAutomatic)
                {
                    MSR_M.Checked = true;
                }
                else
                {
                    MSR_A.Checked = true;
                }
            }
        }
        /// <summary>
        /// Sets the Settings for Formula Complexity 
        /// </summary>
        /// <param name="settings"></param>
        private void SetFormuCompl(PolicyConfigurationModel settings)
        {
            if (settings.FormulaComplexity)
            {
                CB_FormulaComplexity.Checked = true;
                FC_A.Enabled = true;
                FC_M.Enabled = true;

                if (!settings.FormulaComplexityAutomatic)
                {
                    FC_M.Checked = true;
                }
                else
                {
                    FC_A.Checked = true;
                }
            }
        }
示例#9
0
        public void LoadExtraInformation()
        {
            String error = "";

            try
            {
                // Load cell definitions
                this.Accept(new XMLToCellDefinitionVisitor(XMLPartManager.Instance.LoadXMLPart(this, "CellDefinitions")));
            }
            catch (Exception)
            {
                error += "Loading the cell definitions failed.\n";
            }
            try
            {
                // Load the scenarios
                this.Accept(new XMLToScenarioVisitor(XMLPartManager.Instance.LoadXMLPart(this, "Scenario")));
            }
            catch (Exception)
            {
                error += "Loading the scenarios failed.\n";
            }

            try
            {
                // Load the violations
                var violationsXml = XMLPartManager.Instance.LoadXMLPart(this, "Violations");
                if (violationsXml != null)
                {
                    // Add them to the violations collection
                    (from p in violationsXml.Elements(XName.Get("violation"))
                     select new Violation(p, workbook)).ToList().ForEach(p => this.Violations.Add(p));
                }
            }
            catch (Exception)
            {
                error += "Loading the displayed violations failed.\n";
            }

            try
            {
                // Load the ignored
                var ignoredXml = XMLPartManager.Instance.LoadXMLPart(this, "IgnoredViolations");
                if (ignoredXml != null)
                {
                    // Add them to the ignored violations collection
                    (from p in ignoredXml.Elements(XName.Get("ignoredviolations"))
                     select new Violation(p, workbook)).ToList().ForEach(p => this.IgnoredViolations.Add(p));
                }
            }
            catch (Exception)
            {
                error += "Loading the ignored violations failed.\n";
            }

            try
            {
                // Load the later violations
                var laterXml = XMLPartManager.Instance.LoadXMLPart(this, "LaterViolations");
                if (laterXml != null)
                {
                    // Add them to the later violations collection
                    (from p in laterXml.Elements(XName.Get("laterviolation"))
                     select new Violation(p, workbook)).ToList().ForEach(p => this.LaterViolations.Add(p));
                }
            }
            catch (Exception)
            {
                error += "Loading the 'later' violations failed.\n";
            }

            try
            {
                // Load the archived violations
                var archivedXml = XMLPartManager.Instance.LoadXMLPart(this, "ArchivedViolations");
                if (archivedXml != null)
                {
                    // Add them to the archived violations collection
                    (from p in archivedXml.Elements(XName.Get("archivedviolation"))
                     select new Violation(p, workbook)).ToList().ForEach(p => this.SolvedViolations.Add(p));
                }
            }
            catch (Exception)
            {
                error += "Loading the archived violations failed.\n";
            }

            XElement polSettings = XMLPartManager.Instance.LoadXMLPart(this, "policySettings");
            PolicyConfigurationModel polModel = new PolicyConfigurationModel();

            try
            {
                polModel.loadXML(polSettings);
            }
            catch (Exception e)
            {
                // no settings existed, use the default config
                polModel = new PolicyConfigurationModel();
            }
            this.policySettings = polModel;

            if (!String.IsNullOrWhiteSpace(error))
            {
                MessageBox.Show("The following parts were unable to load:\n" + error,
                                "Loading from workbook failed");
            }
        }
示例#10
0
        /// <summary>
        ///     Loads all the data related to violations and scenarios
        /// </summary>
        public void LoadExtraInformation()
        {
            disableScreenUpdating();
            var error = string.Empty;

            try
            {
                var violationsElement = XMLPartManager.Instance.LoadXMLPart(this, "ArrayOfViolation");
                if (violationsElement != null)
                {
                    _violations =
                        XMLPartManager.Instance.Deserialize <ObservableCollection <Violation> >(
                            violationsElement.ToString());
                    NotifyPropertyChanged("Violations");
                }
            }
            catch (Exception)
            {
                error += "Loading the violations failed.\n";
            }

            try
            {
                var rulesElement = XMLPartManager.Instance.LoadXMLPart(this, "ArrayOfRule");
                if (rulesElement != null)
                {
                    _rules = XMLPartManager.Instance.Deserialize <ObservableCollection <Rule> >(rulesElement.ToString());
                    NotifyPropertyChanged("Rules");
                }
            }
            catch (Exception)
            {
                error += "Loading the Rules failed.\n";
            }

            try
            {
                var scenariosElement = XMLPartManager.Instance.LoadXMLPart(this, "ArrayOfScenario");
                if (scenariosElement != null)
                {
                    _scenarios =
                        XMLPartManager.Instance
                        .Deserialize <ObservableCollection <Scenario> >(scenariosElement.ToString());
                    NotifyPropertyChanged("Scenarios");
                }
            }
            catch (Exception)
            {
                error += "Loading the scenarios failed.\n";
            }


            try
            {
                var policyElement = XMLPartManager.Instance.LoadXMLPart(this, "PolicyConfigurationModel");
                if (policyElement != null)
                {
                    _policySettings =
                        XMLPartManager.Instance.Deserialize <PolicyConfigurationModel>(policyElement.ToString());
                }
            }
            catch (Exception)
            {
                error += "Loading the policy settings failed.\n";
            }
            enableScreenUpdating();

            if (!string.IsNullOrWhiteSpace(error))
            {
                MessageBox.Show(Resources.tl_Load_Failed + error, Resources.tl_Load_Failed_Title);
            }
            else
            {
                // iterate over all violations and update cells
                UpdateCellViolations();
                // recalulate visibility for violations
                RecalculateViewModel();
            }
        }
示例#11
0
        /// <summary>
        /// Sets the Settings for the reference to null in a cell
        /// </summary>
        /// <param name="settings"></param>
        private void SetRefToNull(PolicyConfigurationModel settings)
        {
            if (settings.RefToNull)
            {
                CB_RefToNull.Checked = true;
                RTN_A.Enabled = true;
                RTN_M.Enabled = true;

                if (!settings.RefToNullAutomatic)
                {
                    RTN_M.Checked = true;
                }
                else
                {
                    RTN_A.Checked = true;
                }
            }
        }
示例#12
0
        private XElement createNonConsideredValues(PolicyConfigurationModel settings)
        {
            var nonConsidered = new XElement("nonConsideredValuesPolicy");

            return(nonConsidered);
        }
示例#13
0
        private XElement createRefToNull(PolicyConfigurationModel settings)
        {
            var refToNull = new XElement("refToNullPolicy");

            return(refToNull);
        }
示例#14
0
        private XElement createMultipleSameRef(PolicyConfigurationModel settings)
        {
            var msr = new XElement("multipleSameRefPolicy");

            return(msr);
        }
示例#15
0
        private XElement createErrorInCells(PolicyConfigurationModel settings)
        {
            var eic = new XElement("errorContainingCellPolicy");

            return(eic);
        }
示例#16
0
        /// <summary>
        /// Sets settings for the one among others rule 
        /// </summary>
        /// <param name="settings"></param>
        private void SetOneAmongOth(PolicyConfigurationModel settings)
        {
            if (settings.OneAmongOthers)
            {
                CB_OneAmongOthers.Checked = true;
                OAO_A.Enabled = true;
                OAO_M.Enabled = true;

                if (!settings.OneAmongOthersAutomatic)
                {
                    OAO_M.Checked = true;
                }
                else
                {
                    OAO_A.Checked = true;
                }
            }
        }
示例#17
0
        /// <summary>
        /// Sets the settings for the Reading Direction
        /// </summary>
        /// <param name="settings"></param>
        private void SetReadingDir(PolicyConfigurationModel settings)
        {
            if (settings.ReadingDirection)
            {
                CB_ReadingDirection.Checked = true;
                RD_A.Enabled = true;
                RD_M.Enabled = true;

                if (!settings.ReadingDirectionAutomatic)
                {
                    RD_M.Checked = true;
                }
                else
                {
                    RD_A.Checked = true;
                }
            }
        }
示例#18
0
        private XElement createNoConstants(PolicyConfigurationModel settings)
        {
            var noConstant = new XElement("noConstantsInFormulasPolicy");

            return(noConstant);
        }
示例#19
0
        /// <summary>
        /// Sets the Setting for the string distance
        /// </summary>
        /// <param name="settings"></param>
        private void SetStringDist(PolicyConfigurationModel settings)
        {
            if (settings.StringDistance)
            {
                CB_StringDistance.Checked = true;
                SD_A.Enabled = true;
                SD_M.Enabled = true;

                if (!settings.StringDistanceAutomatic)
                {
                    SD_M.Checked = true;
                }
                else
                {
                    SD_A.Checked = true;
                }
                SD_Amount.Text = settings.StringDistanceMaxDist.ToString();
            }
            else
            {
                SD_Amount.Enabled = false;
            }
        }
示例#20
0
        /// <summary>
        /// Sets the setting for Error in Cells
        /// </summary>
        /// <param name="settings"></param>
        private void SetErrorinCell(PolicyConfigurationModel settings)
        {
            if (settings.ErrorInCells)
            {
                CB_ErrorInCells.Checked = true;
                EIC_A.Enabled = true;
                EIC_M.Enabled = true;

                if (!settings.OneAmongOthersAutomatic)
                {
                    EIC_M.Checked = true;
                }
                else
                {
                    EIC_A.Checked = true;
                }
            }
        }
示例#21
0
        private XElement createStringDistance(PolicyConfigurationModel settings)
        {
            XElement stringDst = new XElement("stringDistancePolicyRule");
            XElement dist = new XElement("stringDistanceDifference");
            dist.Value = settings.StringDistanceMaxDist.ToString();
            stringDst.Add(dist);

            return stringDst;
        }
示例#22
0
        public void LoadExtraInformation()
        {
            String error = "";
            try
            {
                // Load cell definitions
                this.Accept(new XMLToCellDefinitionVisitor(XMLPartManager.Instance.LoadXMLPart(this, "CellDefinitions")));
            }
            catch (Exception)
            {
                error += "Loading the cell definitions failed.\n";
            }
            try
            {
                // Load the scenarios
                this.Accept(new XMLToScenarioVisitor(XMLPartManager.Instance.LoadXMLPart(this, "Scenario")));
            }
            catch (Exception)
            {
                error += "Loading the scenarios failed.\n";
            }

            try
            {
                // Load the violations
                var violationsXml = XMLPartManager.Instance.LoadXMLPart(this, "Violations");
                if (violationsXml != null)
                {
                    // Add them to the violations collection
                    (from p in violationsXml.Elements(XName.Get("violation"))
                     select new Violation(p, workbook)).ToList().ForEach(p => this.Violations.Add(p));
                }
            }
            catch (Exception)
            {
                error += "Loading the displayed violations failed.\n";
            }

            try
            {
                // Load the ignored
                var ignoredXml = XMLPartManager.Instance.LoadXMLPart(this, "IgnoredViolations");
                if (ignoredXml != null)
                {
                    // Add them to the ignored violations collection
                    (from p in ignoredXml.Elements(XName.Get("ignoredviolations"))
                     select new Violation(p, workbook)).ToList().ForEach(p => this.IgnoredViolations.Add(p));
                }
            }
            catch (Exception)
            {
                error += "Loading the ignored violations failed.\n";
            }

            try
            {
                // Load the later violations
                var laterXml = XMLPartManager.Instance.LoadXMLPart(this, "LaterViolations");
                if (laterXml != null)
                {
                    // Add them to the later violations collection
                    (from p in laterXml.Elements(XName.Get("laterviolation"))
                     select new Violation(p, workbook)).ToList().ForEach(p => this.LaterViolations.Add(p));
                }
            }
            catch (Exception)
            {
                error += "Loading the 'later' violations failed.\n";
            }

            try
            {
                // Load the archived violations
                var archivedXml = XMLPartManager.Instance.LoadXMLPart(this, "ArchivedViolations");
                if (archivedXml != null)
                {
                    // Add them to the archived violations collection
                    (from p in archivedXml.Elements(XName.Get("archivedviolation"))
                     select new Violation(p, workbook)).ToList().ForEach(p => this.SolvedViolations.Add(p));
                }
            }
            catch (Exception)
            {
                error += "Loading the archived violations failed.\n";
            }

            XElement polSettings = XMLPartManager.Instance.LoadXMLPart(this, "policySettings");
            PolicyConfigurationModel polModel = new PolicyConfigurationModel();
            try
            {
                polModel.loadXML(polSettings);
            }
            catch (Exception e)
            {
                // no settings existed, use the default config
                polModel = new PolicyConfigurationModel();
            }
            this.policySettings = polModel;

            if (!String.IsNullOrWhiteSpace(error))
            {
                MessageBox.Show("The following parts were unable to load:\n" + error,
                    "Loading from workbook failed");
            }
        }