Example #1
0
        /// <summary>
        /// Loads the files
        /// </summary>
        public void LoadFilesExcel()
        {
            DataTable dtResult = new DataTable();

            dtResult = GetDataTable(_fileName, FILE_SHEET, "Name <> '' AND AttributesList <> ''");

            UMLPackage pack = new UMLPackage();

            pack.Name  = "FileImport";
            pack.Owner = _designModel;
            Packages.Add(pack);

            foreach (DataRow dr in dtResult.Rows)
            {
                UMLFile file = new UMLFile();
                file.Name = dr["Name"].ToString().Trim();
                string test = file.Name.GetType().Name;
                file.Dets  = Convert.ToInt32(dr["Dets"].ToString());
                file.Rets  = Convert.ToInt32(dr["Rets"].ToString());
                file.Type  = dr["Type"].ToString();
                file.Owner = pack;

                string[] attributes = dr["AttributesList"].ToString().Split(',');
                foreach (string a in attributes)
                {
                    UMLAttribute attri = new UMLAttribute();
                    attri.Name  = a.Trim();
                    attri.Owner = file;
                    file.Attributes.Add(attri);
                }
                AddFile(file);
            }
        }
Example #2
0
        /// <summary>
        /// Loads the use cases and collaborations
        /// </summary>
        public void LoadUseCasesCollaborationsExcel()
        {
            DataTable dtResult = new DataTable();

            dtResult = GetDataTable(_fileName, COLLABORATION_SHEET, "Name <> ''");

            UMLPackage pack = new UMLPackage();

            pack.Name  = "UseCaseImport";
            pack.Owner = _scenariosModel;
            Packages.Add(pack);

            foreach (DataRow dr in dtResult.Rows)
            {
                UMLUseCase useCase = new UMLUseCase();
                useCase.Name  = dr["UseCase"].ToString().Trim();
                useCase.Owner = pack;
                useCase       = AddUseCase(useCase);

                UMLCollaboration collaboration = new UMLCollaboration();
                collaboration.Name = dr["Name"].ToString().Trim();
                collaboration.Type = dr["Type"].ToString();

                if (dr["SendMessage"].ToString() == "X")
                {
                    collaboration.SendMessage = true;
                }

                if (dr["GenerateAction"].ToString() == "X")
                {
                    collaboration.GenerateAction = true;
                }

                string[] filesName = dr["FilesList"].ToString().Split(',');
                foreach (string fName in filesName)
                {
                    UMLFile file = new UMLFile();
                    file.Name = fName.Trim();
                    file      = AddFile(file);
                    collaboration.Files.Add(file);
                }

                collaboration.Owner = useCase;
                collaboration       = AddCollaboration(collaboration);
                useCase.Collaborations.Add(collaboration);
            }
        }
Example #3
0
        /// <summary>
        /// Loads the iterations and phases
        /// </summary>
        public void LoadPhasesIterationsExcel()
        {
            DataTable dtResult = new DataTable();

            dtResult = GetDataTable(_fileName, PHASE_SHEET, "Phase <> ''");
            UMLPackage pack = new UMLPackage();

            pack.Name  = "IterationsFaseImport";
            pack.Owner = _iterationModel;

            Packages.Add(pack);
            foreach (DataRow dr in dtResult.Rows)
            {
                UMLPhase phase = new UMLPhase();
                phase.Name  = dr["Phase"].ToString().Trim();
                phase.Owner = pack;
                phase       = AddPhase(phase);

                UMLIteration iteration = new UMLIteration();
                iteration.Name = dr["Name"].ToString().Trim();
                string[] usecasesName = dr["UseCaseList"].ToString().Split(',');
                foreach (string useCaseName in usecasesName)
                {
                    UMLUseCase useCase = new UMLUseCase();
                    useCase.Name = useCaseName.Trim();
                    useCase      = AddUseCase(useCase);
                    iteration.UseCases.Add(useCase);
                }

                //iteration.Owner = _logical;
                iteration.Owner = phase;
                iteration       = AddIteration(iteration);
                iteration.Prev  = getIterationByName(dr["Prev"].ToString());
                phase.Iterations.Add(iteration);
            }
        }
Example #4
0
        public static void OpenSolution(object sender, DoWorkEventArgs e)
        {
            bwAsync = sender as BackgroundWorker;
            EnvDTE80.DTE2 dte = null;
            Dictionary <string, IUMLElement> listElements = new Dictionary <string, IUMLElement>();

            try
            {
                dte = (EnvDTE80.DTE2)Microsoft.VisualBasic.Interaction.CreateObject("VisualStudio.DTE.8.0", "");


                Solution2 soln = (Solution2)dte.Solution;

                soln.Open(File);


                SolutionBuild2 build = (SolutionBuild2)soln.SolutionBuild;

                addMessageBackgroundWorker(0, "Building Solution...");

                build.SolutionConfigurations.Item("Debug").Activate();

                build.Clean(true);

                build.Build(true);


                UMLModel model = Helper.GetCurrentElement <UMLModel>();
                if (build.LastBuildInfo == 0 && model != null)
                {
                    IUMLElement solutionUML = new UMLPackage();
                    solutionUML.Name  = Path.GetFileName(soln.FileName);
                    solutionUML.Owner = model;
                    listElements.Add(solutionUML.Name, solutionUML);


                    for (int i = 1; i <= soln.Projects.Count; i++)
                    {
                        Project project = soln.Projects.Item(i);

                        if (project.Properties != null)
                        {
                            string   fullPath       = (string)project.Properties.Item("FullPath").Value;
                            string   outputfileName = (string)project.Properties.Item("OutputFileName").Value;
                            Assembly assembly       = Assembly.LoadFile(fullPath + @"Bin\Debug\" + outputfileName);


                            IUMLElement projectUML = new UMLPackage();
                            projectUML.Name = project.Name;
                            listElements.Add(project.Name, projectUML);
                            projectUML.Owner = solutionUML;

                            addMessageBackgroundWorker(0, "Processing Types: \n" + project.Name);

                            foreach (Type type in assembly.GetTypes())
                            {
                                if (type.MemberType == MemberTypes.TypeInfo)
                                {
                                    IUMLElement element = null;

                                    if (type.IsEnum && IncludeEnumeration)
                                    {
                                        element      = new UMLEnumeration();
                                        element.Name = type.Name;
                                        ((UMLEnumeration)element).Literals = GetLiterals(type);
                                    }
                                    else
                                    {
                                        if (type.IsClass && IncludeClass)
                                        {
                                            element      = new UMLClass();
                                            element.Name = type.Name;
                                            ((UMLClass)element).Attributes = GetProperties(type);
                                            ((UMLClass)element).Attributes.AddRange(GetStaticAndConstants(type));
                                            ((UMLClass)element).Methods = GetMethods(type);
                                            if (type.IsGenericType)
                                            {
                                                element.Name = element.Name.Substring(0, element.Name.IndexOf("`"));

                                                element.Name += "<";
                                                foreach (Type t in type.GetGenericArguments())
                                                {
                                                    element.Name += t.Name + ",";
                                                }

                                                element.Name  = element.Name.TrimEnd(',');
                                                element.Name += ">";
                                            }
                                        }
                                        else if (type.IsInterface && IncludeInterface)
                                        {
                                            element      = new UMLInterface();
                                            element.Name = type.Name;
                                            ((UMLInterface)element).Attributes = GetProperties(type);
                                        }
                                    }

                                    if (element != null)
                                    {
                                        IUMLElement owner = null;

                                        if (type.Namespace == null)
                                        {
                                            owner = projectUML;
                                        }
                                        else if (listElements.ContainsKey(type.Namespace))
                                        {
                                            owner = listElements[type.Namespace];
                                        }
                                        else
                                        {
                                            owner = new UMLPackage();
                                            //if(type.Namespace.Contains(projectUML.Name))
                                            //{
                                            //    owner.Name = type.Namespace.Replace(projectUML.Name, "");
                                            //}
                                            owner.Stereotype = "ClassPackage";
                                            owner.Name       = type.Namespace;
                                            owner.Owner      = projectUML;
                                            listElements.Add(type.Namespace, owner);
                                        }

                                        element.Owner = owner;
                                        if ((type.Attributes & TypeAttributes.Public) == TypeAttributes.Public)
                                        {
                                            element.Visibility = Visibility.Public;
                                        }
                                        else
                                        {
                                            element.Visibility = Visibility.Private;
                                        }

                                        XmlNode node = DocsByReflection.XMLFromType(type);
                                        if (node != null)
                                        {
                                            element.Documentation = node.InnerXml.Trim();
                                        }

                                        if (!listElements.ContainsKey(type.Namespace + "." + type.Name))
                                        {
                                            listElements.Add(type.Namespace + "." + type.Name, element);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                else
                {
                    // Error Build
                }
                soln.Close(true);
            }
            catch (SystemException ex)
            {
                //MessageBox.Show("ERROR: " + ex);
            }
            finally
            {
                if (dte != null)
                {
                    dte.Quit();
                }
            }

            Helper.BeginUpdate();
            addMessageBackgroundWorker(0, "Init import...");
            int pos = 0;

            foreach (IUMLElement element in listElements.Values)
            {
                pos++;
                addMessageBackgroundWorker((pos * 100) / listElements.Count, "Creating: \n" + element.Name);
                element.GetType().InvokeMember("Save", BindingFlags.Default | BindingFlags.InvokeMethod, null, element, new object[] { });
            }
            addMessageBackgroundWorker(100, "End import");
            Helper.EndUpdate();
        }