Exemple #1
0
		private void TestGenerateProject()
		{
			// Check whether the debug project exists.
			if (Controller.Instance.CheckDebugOptions(true) == false)
				return;

			Cursor = Cursors.WaitCursor;
			try
			{
				using (var worker = new BackgroundWorker())
				{
					worker.DoWork += delegate
					{
						var project = new WorkbenchProject();
						SharedData.CurrentProject = project;

						Utility.DisplayMessagePanel(this, "Generating Files", MessagePanel.ImageType.Hourglass);
						Utility.UpdateMessagePanelStatus(this, "Compiling Project");

						// Compile the template to the new temporary location.
						bool compileResult = FunctionRunner.CreateTemplateFile(false, false);

						if (compileResult == false)
						{
							//ErrorReportingService.ReportError(ErrorLevel.Error, "Could not compile project");
							throw new Exception("Could not compile project");
							//return;
						}

						Utility.UpdateMessagePanelStatus(this, "Loading Project File");

						// Load the project
						bool loadResult = project.Load(Project.Instance.DebugProjectFile, this, false, CompileHelper.CompiledAssemblyFileName);

						if (loadResult == false)
						{
							//ErrorReportingService.ReportError(ErrorLevel.Error, "Could not load project file. Open in ArchAngel Workbench for more information.");
							throw new Exception("Could not load project file. Open in ArchAngel Workbench for more information.");
							//return;
						}

						var helper = new GenerationHelper(new NullTaskProgressHelper<GenerateFilesProgress>(),
										 project.TemplateLoader, project,
										 new FileController());
						Utility.UpdateMessagePanelStatus(this, "Writing Files");
						project.PerformPreAnalysisActions();
						helper.GenerateAllFiles("", project.CombinedOutput.RootFolder, null, null,
							Project.Instance.TestGenerateDirectory);
					};

					worker.RunWorkerCompleted += (sndr, evnt) => Utility.HideMessagePanel(this);

					worker.RunWorkerAsync();
				}
			}
			finally
			{
				Cursor = Cursors.Default;
			}
		}