public override bool ValidateElement(IEAElement element)
        {
            IEARepository repository = EAMain.Repository;

            return(!(from IEAElement e in repository.GetAllElements()
                     where EAConstants.States.Contains(e.Stereotype)
                     where (!e.GUID.Equals(element.GUID))
                     where element.Name.Equals(e.Name)
                     select e).Any());
        }
示例#2
0
        /// <summary>
        /// Populates the listbox with the concerns from the repository
        /// </summary>
        private void PopulateConcerns()
        {
            IEARepository repository = EAFacade.EA.Repository;

            var concerns =
                repository.GetAllElements()
                .Where(element => element != null && element.IsConcern())
                .ToDictionary(element => element.GUID, element => element.Name + " (" + element.ParentPackage.Name + ")");

            if (concerns.Count <= 0) //No concerns found
            {
                _btnAddForce.Enabled = false;
                return;
            }
            _lbConcern.DataSource    = new BindingSource(concerns, null);
            _lbConcern.DisplayMember = "Value";
            _lbConcern.ValueMember   = "Key";
        }
示例#3
0
        public static void GenerateReport(IEAPackage decisionViewPackage, string filename, ReportType reportType)
        {
            IEARepository    repository = EAMain.Repository;
            List <IDecision> decisions  =
                decisionViewPackage.GetAllDecisions().Select(element => Decision.Load(element)).ToList();
            List <IEADiagram> diagrams = decisionViewPackage.GetAllDiagrams().ToList();

            IReportDocument report = null;

            try
            {
                string filenameExtension = filename.Substring(filename.IndexOf('.'));
                var    saveFileDialog1   = new SaveFileDialog();
                saveFileDialog1.Title  = Messages.SaveReportAs;
                saveFileDialog1.Filter = "Microsoft " + reportType.ToString() + " (*" + filenameExtension + ")|*" +
                                         filenameExtension;
                saveFileDialog1.FilterIndex = 0;

                if (saveFileDialog1.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                saveFileDialog1.CheckFileExists = true;
                saveFileDialog1.CheckPathExists = true;
                string reportFilename = saveFileDialog1.FileName;
                report = ReportFactory.Create(reportType, reportFilename);
                //if the report cannot be created because is already used by another program a message will appear
                if (report == null)
                {
                    MessageBox.Show("Check if another program is using this file.",
                                    "Fail to create report",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                    return;
                }
                report.Open();


                //Insert Decision Relationship Viewpoint
                foreach (IEADiagram diagram in diagrams.Where(diagram => diagram.IsRelationshipView()))
                {
                    report.InsertDiagramImage(diagram);
                }

                //Retrieve Topics
                List <ITopic> topics = (from IEAElement element in repository.GetAllElements()
                                        where EAMain.IsTopic(element)
                                        select Topic.Load(element)).ToList();

                report.InsertDecisionDetailViewMessage();

                // Insert Decisions that have a Topic
                foreach (ITopic topic in topics)
                {
                    report.InsertTopicTable(topic);
                    //Insert Decisions with parent element the current Topic
                    foreach (IDecision decision in decisions)
                    {
                        IEAElement parent = EAMain.Repository.GetElementByGUID(decision.Topic.GUID);
                        if (parent != null && EAMain.IsTopic(parent))
                        {
                            if (parent.GUID.Equals(topic.GUID))
                            {
                                report.InsertDecisionTable(decision);
                            }
                        }
                    }
                }

                // Insert an appropriate message before the decisions that are not included in a topic
                report.InsertDecisionWithoutTopicMessage();

                // Insert decisions without a Topic
                foreach (IDecision decision in decisions)
                {
                    IEAElement parent = EAMain.Repository.GetElementByID(decision.ID).ParentElement;
                    if (parent == null || !EAMain.IsTopic(parent))
                    {
                        report.InsertDecisionTable(decision);
                    }
                }

                foreach (
                    IEADiagram diagram in
                    diagrams.Where(diagram => !diagram.IsForcesView() && !diagram.IsRelationshipView()))
                {
                    report.InsertDiagramImage(diagram);
                }
                foreach (IEADiagram diagram in diagrams.Where(diagram => diagram.IsForcesView()))
                {
                    report.InsertForcesTable(new ForcesModel(diagram));
                }
                var customMessage = new ExportReportsCustomMessageBox(reportType.ToString(), reportFilename);
                customMessage.Show();
            }
            finally
            {
                if (report != null)
                {
                    report.Close();
                }
            }
        }