Ejemplo n.º 1
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);
        }
        public PolicyConfigurationModel GetAll()
        {
            var model          = new PolicyConfigurationModel();
            var allConfigs     = _configurationService.GetAll().ToModelList <Configuration, ConfigurationModel>();
            var policyDocument = allConfigs.FirstOrDefault(x => x.Name.Equals(PolicyDocumentKey, StringComparison.OrdinalIgnoreCase));

            if (policyDocument != null)
            {
                allConfigs.Remove(policyDocument);
                model.PolicyDocument = policyDocument;
            }
            model.AllConfigurations = allConfigs;
            return(model);
        }
Ejemplo n.º 3
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;
                }
            }
        }
Ejemplo n.º 4
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;
                }
            }
        }
Ejemplo n.º 5
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;
                }
            }
        }
Ejemplo n.º 6
0
        /// <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;
                }
            }
        }
Ejemplo n.º 7
0
        /// <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
                }
            }
        }
Ejemplo n.º 8
0
        /// <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;
                }
            }
        }
Ejemplo n.º 9
0
        /// <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;
                }
            }
        }
Ejemplo n.º 10
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;
                }
            }
        }
Ejemplo n.º 11
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;
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        /// An instance of a dialog in which the policies to check can be defined
        /// </summary>
        public PolicyConfigurationDialog()
        {
            InitializeComponent();

            postInitialize();

            FormBorderStyle = FormBorderStyle.FixedDialog;
            PolicyConfigurationModel settings = DataModel.Instance.CurrentWorkbook.PolicySettings;

            SetNoConstants(settings);
            SetReadingDir(settings);
            SetFormuCompl(settings);
            SetMultSamRef(settings);
            SetNonConCon(settings);
            SetRefToNull(settings);
            SetOneAmongOth(settings);
            SetStringDist(settings);
            SetErrorinCell(settings);

            cb_Ask_Thousands.Checked = !Settings.Default.SifUseThousandsSeparator;


            ShowDialog();
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Create the sprudel xml document
        /// </summary>
        /// <param name="n">WorkbookModel</param>
        /// <returns>complete sprudel xml as XElement</returns>
        public object Visit(WorkbookModel n)
        {
            PolicyConfigurationModel settings = n.PolicySettings;
            var root          = new XElement("policyList");
            var dynamicPolicy = new XElement("dynamicPolicy");

            //attributes
            dynamicPolicy.Add(new XAttribute("name", NullCheck(n.Title) + " Inspection"));
            dynamicPolicy.Add(new XAttribute("description", GetDocumentProperty(n, "Comments")));
            dynamicPolicy.Add(new XAttribute("author", GetDocumentProperty(n, "Author")));

            //rules
            var rules = new XElement("rules");

            foreach (var scenario in n.Scenarios)
            {
                rules.Add(scenario.Accept(this) as XElement);
            }
            dynamicPolicy.Add(rules);

            //spreadsheet file path
            dynamicPolicy.Add(new XElement("spreadsheetFilePath", NullCheck(n.Spreadsheet)));

            //input cells
            dynamicPolicy.Add(CreateInputCells(n));

            //output cells
            dynamicPolicy.Add(CreateOutputCells(n));
            // TODO: don't add when no scenario is present
            root.Add(dynamicPolicy);
            XElement sanityRules = CreateSanityRules(n);

            if (sanityRules != null)
            {
                root.Add(sanityRules);
            }
            if ((settings.ReadingDirection && type == InspectionType.MANUAL) ||
                (settings.ReadingDirection && settings.ReadingDirectionAutomatic))
            {
                XElement readingDirection = createReadingDirection();
                root.Add(readingDirection);
            }
            if ((settings.NoConstantsInFormulas && type == InspectionType.MANUAL) ||
                (settings.NoConstantsInFormulas && settings.NoConstantsInFormulasAutomatic))
            {
                XElement constants = createNoConstants();
                root.Add(constants);
            }
            if ((settings.FormulaComplexity && type == InspectionType.MANUAL) ||
                (settings.FormulaComplexity && settings.FormulaComplexityAutomatic))
            {
                XElement formulaComplexity = createFormulaComplexity();
                root.Add(formulaComplexity);
            }

            if ((settings.NonConsideredConstants && type == InspectionType.MANUAL) ||
                (settings.NonConsideredConstants && settings.NonConsideredConstantsAutomatic))
            {
                XElement nonConsidered = createNonConsideredValues();
                root.Add(nonConsidered);
            }
            if ((settings.OneAmongOthers && type == InspectionType.MANUAL) ||
                (settings.OneAmongOthers && settings.OneAmongOthersAutomatic))
            {
                XElement oneAmongOthers = createOneAmongOthers();
                root.Add(oneAmongOthers);
            }
            if ((settings.RefToNull && type == InspectionType.MANUAL) ||
                (settings.RefToNull && settings.RefToNullAutomatic))
            {
                XElement refToNull = createRefToNull();
                root.Add(refToNull);
            }
            if ((settings.StringDistance && type == InspectionType.MANUAL) ||
                (settings.StringDistance && settings.StringDistanceAutomatic))
            {
                XElement stringDistance = createStringDistance(settings);
                root.Add(stringDistance);
            }
            if ((settings.MultipleSameRef && type == InspectionType.MANUAL) ||
                (settings.MultipleSameRef && settings.MultipleSameRefAutomatic))
            {
                XElement msr = createMultipleSameRef();
                root.Add(msr);
            }
            if ((settings.ErrorInCells && type == InspectionType.MANUAL) ||
                (settings.ErrorInCells && settings.ErrorInCellsAutomatic))
            {
                XElement eic = createErrorInCells();
                root.Add(eic);
            }

            return(root);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Eventhandler for when the ok Button is clicked
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Button_OK_Click(object sender, EventArgs e)
        {
            bool error = false;
            PolicyConfigurationModel settings = DataModel.Instance.CurrentWorkbook.PolicySettings;

            #region Parsing w/ possible errors
            if (SD_Amount.Enabled)
            {
                int stringDstMax = 0;
                try
                {
                    stringDstMax = Convert.ToInt32(SD_Amount.Text);
                    if (stringDstMax < 1)
                    {
                        error = true;
                    }
                }
                catch (FormatException)
                {
                    error = true;
                }
                if (error)
                {
                    SD_Amount.BackColor = Color.LightPink;
                }
                else
                {
                    settings.StringDistanceMaxDist = stringDstMax;
                }
            }

            #endregion

            if (error) // abort the closing and further parsing of members
            {
                return;
            }

            settings.NoConstantsInFormulas          = CB_NoConstantsInFormulas.Checked;
            settings.NoConstantsInFormulasAutomatic = NCIF_A.Checked;

            settings.ReadingDirection          = CB_ReadingDirection.Checked;
            settings.ReadingDirectionAutomatic = RD_A.Checked;

            settings.FormulaComplexity          = CB_FormulaComplexity.Checked;
            settings.FormulaComplexityAutomatic = FC_A.Checked;

            settings.MultipleSameRef          = CB_MultipleSameRef.Checked;
            settings.MultipleSameRefAutomatic = MSR_A.Checked;

            settings.NonConsideredConstants          = CB_NonConsideredConstants.Checked;
            settings.NonConsideredConstantsAutomatic = NCC_A.Checked;

            settings.RefToNull          = CB_RefToNull.Checked;
            settings.RefToNullAutomatic = RTN_A.Checked;

            settings.OneAmongOthers          = CB_OneAmongOthers.Checked;
            settings.OneAmongOthersAutomatic = OAO_A.Checked;

            settings.StringDistance          = CB_StringDistance.Checked;
            settings.StringDistanceAutomatic = SD_A.Checked;

            settings.ErrorInCells          = CB_ErrorInCells.Checked;
            settings.ErrorInCellsAutomatic = EIC_A.Checked;

            Settings.Default.SifUseThousandsSeparator = !cb_Ask_Thousands.Checked;

            DataModel.Instance.CurrentWorkbook.PolicySettings = settings;
            DataModel.Instance.CurrentWorkbook.Workbook.Saved = false;

            Close();
        }
Ejemplo n.º 15
0
        public PolicyConfigurationDialog()
        {
            InitializeComponent();

            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
            PolicyConfigurationModel settings = DataModel.Instance.CurrentWorkbook.PolicySettings;

            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
                }
            }

            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;
                }
            }

            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;
                }
            }

            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;
                }
            }

            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;
                }
            }

            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;
                }
            }

            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;
                }
            }

            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;
            }

            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;
                }
            }

            if (File.Exists(debugFile))
            {
                CB_SifDebugMode.Checked = true;
            }

            cb_Ask_Thousands.Checked = !Settings.Default.SifUseThousandsSeparator;


            this.ShowDialog();
        }