Exemplo n.º 1
0
        private void CreateProject_Worker(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;

            MOG_Project project = new MOG_Project();

            try
            {
                MOG_System sys = MOG_ControllerSystem.GetSystem();
                if (sys != null)
                {
                    project = sys.ProjectCreate(this.projectInfoControl.ProjectName);
                    if (project != null)
                    {
                        worker.ReportProgress(0, "Setting project info...");

                        // project info
                        project.SetProjectPath(this.projectInfoControl.ProjectPath);
                        project.SetProjectToolsPath(this.projectInfoControl.ProjectPath + "\\Tools");
                        project.SetProjectUsersPath(this.projectInfoControl.ProjectPath + "\\Users");

                        worker.ReportProgress(0, "Copying tools...");

                        worker.ReportProgress(0, "Saving and logging in...");

                        // create project and login
                        project.Save();

                        MOG_ControllerProject.LoginProject(this.projectInfoControl.ProjectName, "");

                        worker.ReportProgress(0, "Creating current branch...");

                        // create default branch
                        MOG_ControllerProject.BranchCreate("", "Current");

                        worker.ReportProgress(0, "Creating classification tree...");

                        // platforms
                        MOG_Platform pcPlatform = new MOG_Platform();
                        pcPlatform.mPlatformName = "PC";
                        project.PlatformAdd(pcPlatform);

                        // create classifications
                        MogUtil_ClassificationLoader classLoader = new MogUtil_ClassificationLoader();
                        classLoader.ProjectName = this.projectInfoControl.ProjectName;
                        foreach (MOG_Properties props in classLoader.GetClassPropertiesListFromFiles())
                        {
                            if (props.Classification.ToLower() == project.GetProjectName().ToLower())
                            {
                                // create only project name root class node
                                project.ClassificationAdd(props.Classification);
                                MOG_Properties properties = project.GetClassificationProperties(props.Classification);
                                properties.SetImmeadiateMode(true);
                                properties.SetProperties(props.GetPropertyList());
                                break;
                            }
                        }

                        project.Save();
                    }
                    else
                    {
                        throw new Exception("Failed to create the project.");
                    }
                }
                else
                {
                    throw new Exception("System not initialized.");
                }
            }
            catch (Exception ex)
            {
                MOG_Report.ReportMessage("Project Creation Failed", ex.Message, ex.StackTrace, MOG_ALERT_LEVEL.CRITICAL);
            }

            e.Result = project;
        }