Inheritance: System.Windows.Forms.Form
Ejemplo n.º 1
0
        // private IVsOutputWindowPane outputWindow = null;
        private void GenerateAll()
        {
            var processKey = string.Empty;

            try
            {
                var startTime = DateTime.Now;
                //object outputWindow = this.CreatePane(new Guid("{2C997982-CA6C-4640-8073-DB1B9BD8D93B}"), "Generation", true, true);

                processKey = UIHelper.ProgressingStarted();

                this.FilesSkipped = 0;
                this.FilesSuccess = 0;
                this.FilesFailed  = 0;
                this.GeneratedFileList.Clear();

                this.tvwModel.Enabled = false;
                this.ClearContentPane();

                try
                {
                    //If error then do not gen
                    var messageCollection = ((INHydrateGenerator)this.Generator).RootController.Verify();
                    UIHelper.ProgressingComplete(processKey);

                    if (messageCollection.Count > 0)
                    {
                        var errorCount = messageCollection.Count(x => x.MessageType == MessageTypeConstants.Error);
                        this.lvwError.ClearMessages();
                        this.lvwError.AddMessages(messageCollection);
                        if (errorCount > 0)
                        {
                            MessageBox.Show("The model cannot be generated until all errors are corrected.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                    }

                    tabControl1.SelectedTab = tabControl1.TabPages[1];                     //Show the output window
                    lvwOutput.Items.Clear();
                    var g = new GeneratorHelper();

                    var excludeList       = new List <Type>();
                    var generatorTypeList = g.GetProjectGenerators(this.Generator);
                    if (generatorTypeList.Count == 0)
                    {
                        return;
                    }

                    //Show wizard first
                    var F1 = new GenerateSettingsWizard(this.Generator, generatorTypeList);
                    List <System.Type> selectedTypes = null;
                    if (F1.IsValid)
                    {
                        if (F1.ShowDialog() == DialogResult.OK)
                        {
                            selectedTypes = F1.SelectGenerators;
                        }
                    }

                    //Show generator list
                    using (var F = new GenerateSettings(this.Generator, generatorTypeList, selectedTypes))
                    {
                        if (F.ShowDialog() != DialogResult.OK)
                        {
                            return;
                        }
                        excludeList = F.ExcludeList;
                    }

                    g.ProjectItemGenerated      += new ProjectItemGeneratedEventHandler(ProjectItemGeneratedHandler);
                    g.GenerationComplete        += new ProjectItemGenerationCompleteEventHandler(GenerationCompleteHandler);
                    g.ProjectItemGeneratedError += new ProjectItemGeneratedEventHandler(ProjectItemGeneratedError);
                    g.GenerateAll(this.Generator, excludeList);
                }
                catch (Exception ex)
                {
                    throw;
                }
                finally
                {
                    this.ResetContentPane();
                }

                var endTime  = DateTime.Now;
                var duration = endTime.Subtract(startTime);
                using (var F = new StatisticsForm())
                {
                    var text = "The generation was successful.\r\n\r\n";
                    text += "Files generated: " + this.FilesSuccess + "\r\n";
                    text += "Files skipped: " + this.FilesSkipped + "\r\n";
                    text += "Files failed: " + this.FilesFailed + "\r\n";
                    text += "\r\n\r\n";
                    text += "Generation time: " + duration.Hours.ToString("00") + ":" +
                            duration.Minutes.ToString("00") + ":" +
                            duration.Seconds.ToString("00");
                    F.DisplayText       = text;
                    F.GeneratedFileList = this.GeneratedFileList;
                    F.ShowDialog();
                }
            }
            catch (Exception ex)
            {
                GlobalHelper.ShowError(ex);
            }
            finally
            {
                UIHelper.ProgressingComplete(processKey);
                this.tvwModel.Enabled = true;
            }
        }
Ejemplo n.º 2
0
		// private IVsOutputWindowPane outputWindow = null;
		private void GenerateAll()
		{
			var processKey = string.Empty;
			try
			{
				var startTime = DateTime.Now;
				//object outputWindow = this.CreatePane(new Guid("{2C997982-CA6C-4640-8073-DB1B9BD8D93B}"), "Generation", true, true);

				processKey = UIHelper.ProgressingStarted();

				this.FilesSkipped = 0;
				this.FilesSuccess = 0;
				this.FilesFailed = 0;
				this.GeneratedFileList.Clear();

				this.tvwModel.Enabled = false;
				this.ClearContentPane();

				try
				{
					//If error then do not gen
					var messageCollection = ((INHydrateGenerator)this.Generator).RootController.Verify();
					UIHelper.ProgressingComplete(processKey);

					if (messageCollection.Count > 0)
					{
						var errorCount = messageCollection.Count(x => x.MessageType == MessageTypeConstants.Error);
						this.lvwError.ClearMessages();
						this.lvwError.AddMessages(messageCollection);
						if (errorCount > 0)
						{
							MessageBox.Show("The model cannot be generated until all errors are corrected.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
							return;
						}
					}

					tabControl1.SelectedTab = tabControl1.TabPages[1]; //Show the output window
					lvwOutput.Items.Clear();
					var g = new GeneratorHelper();

					var excludeList = new List<Type>();
					var generatorTypeList = g.GetProjectGenerators(this.Generator);
					if (generatorTypeList.Count == 0)
						return;

					//Show wizard first
					var F1 = new GenerateSettingsWizard(this.Generator, generatorTypeList);
					List<System.Type> selectedTypes = null;
					if (F1.IsValid)
					{
						if (F1.ShowDialog() == DialogResult.OK)
						{
							selectedTypes = F1.SelectGenerators;
						}
					}

					//Show generator list
					using (var F = new GenerateSettings(this.Generator, generatorTypeList, selectedTypes))
					{
						if (F.ShowDialog() != DialogResult.OK) return;
						excludeList = F.ExcludeList;
					}

					g.ProjectItemGenerated += new ProjectItemGeneratedEventHandler(ProjectItemGeneratedHandler);
					g.GenerationComplete += new ProjectItemGenerationCompleteEventHandler(GenerationCompleteHandler);
					g.ProjectItemGeneratedError += new ProjectItemGeneratedEventHandler(ProjectItemGeneratedError);
					g.GenerateAll(this.Generator, excludeList);
				}
				catch (Exception ex)
				{
					throw;
				}
				finally
				{
					this.ResetContentPane();
				}

				var endTime = DateTime.Now;
				var duration = endTime.Subtract(startTime);
				using (var F = new StatisticsForm())
				{
					var text = "The generation was successful.\r\n\r\n";
					text += "Files generated: " + this.FilesSuccess + "\r\n";
					text += "Files skipped: " + this.FilesSkipped + "\r\n";
					text += "Files failed: " + this.FilesFailed + "\r\n";
					text += "\r\n\r\n";
					text += "Generation time: " + duration.Hours.ToString("00") + ":" +
							duration.Minutes.ToString("00") + ":" +
							duration.Seconds.ToString("00");
					F.DisplayText = text;
					F.GeneratedFileList = this.GeneratedFileList;
					F.ShowDialog();
				}

			}
			catch (Exception ex)
			{
				GlobalHelper.ShowError(ex);
			}
			finally
			{
				UIHelper.ProgressingComplete(processKey);
				this.tvwModel.Enabled = true;
			}

		}