From 62df37f5a51650f21f46580ffe260d19652c2973 Mon Sep 17 00:00:00 2001 From: kenjiuno Date: Tue, 22 Dec 2015 22:47:12 +0900 Subject: [PATCH] Refine. - checker. - Open also https://github.com/kenjiuno/Npgsql/releases - grant prompt message. --- .../CheckNpgsqlForm.Designer.cs | 84 +++++++++------- src/NpgsqlDdexProvider/CheckNpgsqlForm.cs | 96 +++++++++++++++---- .../NpgsqlDdexProviderPackage.cs | 4 +- 3 files changed, 131 insertions(+), 53 deletions(-) diff --git a/src/NpgsqlDdexProvider/CheckNpgsqlForm.Designer.cs b/src/NpgsqlDdexProvider/CheckNpgsqlForm.Designer.cs index 84dab5638d..2b0e48bd9f 100644 --- a/src/NpgsqlDdexProvider/CheckNpgsqlForm.Designer.cs +++ b/src/NpgsqlDdexProvider/CheckNpgsqlForm.Designer.cs @@ -43,13 +43,14 @@ private void InitializeComponent() { this.tabPage2 = new System.Windows.Forms.TabPage(); this.rtb = new System.Windows.Forms.RichTextBox(); this.tabPage3 = new System.Windows.Forms.TabPage(); + this.llBuild = new System.Windows.Forms.LinkLabel(); this.llRestart = new System.Windows.Forms.LinkLabel(); this.llEFv5 = new System.Windows.Forms.LinkLabel(); this.llEFv6 = new System.Windows.Forms.LinkLabel(); this.llProvider = new System.Windows.Forms.LinkLabel(); this.llADONet = new System.Windows.Forms.LinkLabel(); this.llGrab = new System.Windows.Forms.LinkLabel(); - this.llBuild = new System.Windows.Forms.LinkLabel(); + this.llConfigSections = new System.Windows.Forms.LinkLabel(); bEFv5 = new System.Windows.Forms.ToolStripButton(); bEFv6 = new System.Windows.Forms.ToolStripButton(); toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); @@ -163,10 +164,10 @@ private void InitializeComponent() { this.tabControl1.Controls.Add(this.tabPage3); this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill; this.tabControl1.Location = new System.Drawing.Point(0, 0); - this.tabControl1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.tabControl1.Margin = new System.Windows.Forms.Padding(4); this.tabControl1.Name = "tabControl1"; this.tabControl1.SelectedIndex = 0; - this.tabControl1.Size = new System.Drawing.Size(777, 563); + this.tabControl1.Size = new System.Drawing.Size(900, 563); this.tabControl1.TabIndex = 4; // // tabPage1 @@ -175,10 +176,10 @@ private void InitializeComponent() { this.tabPage1.Controls.Add(this.b6); this.tabPage1.Controls.Add(this.b5); this.tabPage1.Location = new System.Drawing.Point(4, 28); - this.tabPage1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.tabPage1.Margin = new System.Windows.Forms.Padding(4); this.tabPage1.Name = "tabPage1"; - this.tabPage1.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4); - this.tabPage1.Size = new System.Drawing.Size(742, 520); + this.tabPage1.Padding = new System.Windows.Forms.Padding(4); + this.tabPage1.Size = new System.Drawing.Size(892, 531); this.tabPage1.TabIndex = 0; this.tabPage1.Text = "Welcome!"; this.tabPage1.UseVisualStyleBackColor = true; @@ -196,7 +197,7 @@ private void InitializeComponent() { // b6 // this.b6.Location = new System.Drawing.Point(10, 197); - this.b6.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.b6.Margin = new System.Windows.Forms.Padding(4); this.b6.Name = "b6"; this.b6.Size = new System.Drawing.Size(375, 55); this.b6.TabIndex = 2; @@ -207,7 +208,7 @@ private void InitializeComponent() { // b5 // this.b5.Location = new System.Drawing.Point(10, 101); - this.b5.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.b5.Margin = new System.Windows.Forms.Padding(4); this.b5.Name = "b5"; this.b5.Size = new System.Drawing.Size(375, 55); this.b5.TabIndex = 1; @@ -219,10 +220,10 @@ private void InitializeComponent() { // this.tabPage2.Controls.Add(this.rtb); this.tabPage2.Location = new System.Drawing.Point(4, 28); - this.tabPage2.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.tabPage2.Margin = new System.Windows.Forms.Padding(4); this.tabPage2.Name = "tabPage2"; - this.tabPage2.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4); - this.tabPage2.Size = new System.Drawing.Size(742, 520); + this.tabPage2.Padding = new System.Windows.Forms.Padding(4); + this.tabPage2.Size = new System.Drawing.Size(892, 531); this.tabPage2.TabIndex = 1; this.tabPage2.Text = "Test and result"; this.tabPage2.UseVisualStyleBackColor = true; @@ -233,15 +234,16 @@ private void InitializeComponent() { this.rtb.Dock = System.Windows.Forms.DockStyle.Fill; this.rtb.Font = new System.Drawing.Font("Arial", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(128))); this.rtb.Location = new System.Drawing.Point(4, 4); - this.rtb.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.rtb.Margin = new System.Windows.Forms.Padding(4); this.rtb.Name = "rtb"; - this.rtb.Size = new System.Drawing.Size(734, 512); + this.rtb.Size = new System.Drawing.Size(884, 523); this.rtb.TabIndex = 3; this.rtb.Text = ""; this.rtb.WordWrap = false; // // tabPage3 // + this.tabPage3.Controls.Add(this.llConfigSections); this.tabPage3.Controls.Add(this.llBuild); this.tabPage3.Controls.Add(this.llRestart); this.tabPage3.Controls.Add(this.llEFv5); @@ -250,18 +252,29 @@ private void InitializeComponent() { this.tabPage3.Controls.Add(this.llADONet); this.tabPage3.Controls.Add(this.llGrab); this.tabPage3.Location = new System.Drawing.Point(4, 28); - this.tabPage3.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.tabPage3.Margin = new System.Windows.Forms.Padding(4); this.tabPage3.Name = "tabPage3"; - this.tabPage3.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4); - this.tabPage3.Size = new System.Drawing.Size(769, 531); + this.tabPage3.Padding = new System.Windows.Forms.Padding(4); + this.tabPage3.Size = new System.Drawing.Size(892, 531); this.tabPage3.TabIndex = 2; this.tabPage3.Text = "Suggestions"; this.tabPage3.UseVisualStyleBackColor = true; // + // llBuild + // + this.llBuild.AutoSize = true; + this.llBuild.Location = new System.Drawing.Point(10, 379); + this.llBuild.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.llBuild.Name = "llBuild"; + this.llBuild.Size = new System.Drawing.Size(487, 18); + this.llBuild.TabIndex = 6; + this.llBuild.TabStop = true; + this.llBuild.Text = " Build your project once, in order to update Npgsql.dll in bin\\xxx"; + // // llRestart // this.llRestart.AutoSize = true; - this.llRestart.Location = new System.Drawing.Point(10, 332); + this.llRestart.Location = new System.Drawing.Point(10, 322); this.llRestart.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.llRestart.Name = "llRestart"; this.llRestart.Size = new System.Drawing.Size(383, 18); @@ -272,7 +285,7 @@ private void InitializeComponent() { // llEFv5 // this.llEFv5.AutoSize = true; - this.llEFv5.Location = new System.Drawing.Point(10, 214); + this.llEFv5.Location = new System.Drawing.Point(10, 208); this.llEFv5.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.llEFv5.Name = "llEFv5"; this.llEFv5.Size = new System.Drawing.Size(288, 18); @@ -284,7 +297,7 @@ private void InitializeComponent() { // llEFv6 // this.llEFv6.AutoSize = true; - this.llEFv6.Location = new System.Drawing.Point(10, 273); + this.llEFv6.Location = new System.Drawing.Point(10, 265); this.llEFv6.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.llEFv6.Name = "llEFv6"; this.llEFv6.Size = new System.Drawing.Size(288, 18); @@ -296,7 +309,7 @@ private void InitializeComponent() { // llProvider // this.llProvider.AutoSize = true; - this.llProvider.Location = new System.Drawing.Point(10, 155); + this.llProvider.Location = new System.Drawing.Point(10, 151); this.llProvider.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.llProvider.Name = "llProvider"; this.llProvider.Size = new System.Drawing.Size(417, 18); @@ -308,7 +321,7 @@ private void InitializeComponent() { // llADONet // this.llADONet.AutoSize = true; - this.llADONet.Location = new System.Drawing.Point(10, 96); + this.llADONet.Location = new System.Drawing.Point(10, 94); this.llADONet.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.llADONet.Name = "llADONet"; this.llADONet.Size = new System.Drawing.Size(443, 18); @@ -323,30 +336,32 @@ private void InitializeComponent() { this.llGrab.Location = new System.Drawing.Point(10, 37); this.llGrab.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.llGrab.Name = "llGrab"; - this.llGrab.Size = new System.Drawing.Size(361, 18); + this.llGrab.Size = new System.Drawing.Size(803, 18); this.llGrab.TabIndex = 0; this.llGrab.TabStop = true; - this.llGrab.Text = " Grab NpgsqlDdexProvider %ver%, and install it."; + this.llGrab.Text = " Grab NpgsqlDdexProvider %ver%, and install it. And then [Tool] -> [Setup Npgs" + + "ql DbProviderFactories...]"; this.llGrab.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.llGrab_LinkClicked); // - // llBuild + // llConfigSections // - this.llBuild.AutoSize = true; - this.llBuild.Location = new System.Drawing.Point(10, 391); - this.llBuild.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - this.llBuild.Name = "llBuild"; - this.llBuild.Size = new System.Drawing.Size(487, 18); - this.llBuild.TabIndex = 6; - this.llBuild.TabStop = true; - this.llBuild.Text = " Build your project once, in order to update Npgsql.dll in bin\\xxx"; + this.llConfigSections.AutoSize = true; + this.llConfigSections.Location = new System.Drawing.Point(10, 436); + this.llConfigSections.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.llConfigSections.Name = "llConfigSections"; + this.llConfigSections.Size = new System.Drawing.Size(509, 18); + this.llConfigSections.TabIndex = 7; + this.llConfigSections.TabStop = true; + this.llConfigSections.Text = " in App.config/Web.config has to be first element!"; + this.llConfigSections.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.llConfigSections_LinkClicked); // // CheckNpgsqlForm // this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 18F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(777, 563); + this.ClientSize = new System.Drawing.Size(900, 563); this.Controls.Add(this.tabControl1); - this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.Margin = new System.Windows.Forms.Padding(4); this.Name = "CheckNpgsqlForm"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Check NpgsqlDdexProvider"; @@ -386,5 +401,6 @@ private void InitializeComponent() { private System.Windows.Forms.LinkLabel llEFv6; private System.Windows.Forms.LinkLabel llRestart; private System.Windows.Forms.LinkLabel llBuild; + private System.Windows.Forms.LinkLabel llConfigSections; } } \ No newline at end of file diff --git a/src/NpgsqlDdexProvider/CheckNpgsqlForm.cs b/src/NpgsqlDdexProvider/CheckNpgsqlForm.cs index e5e454e563..c2c11107ca 100644 --- a/src/NpgsqlDdexProvider/CheckNpgsqlForm.cs +++ b/src/NpgsqlDdexProvider/CheckNpgsqlForm.cs @@ -73,13 +73,9 @@ private void bEFv5_Click(object sender, EventArgs e) { } private void UnsuggestAll() { - UnsuggestIt(llGrab); - UnsuggestIt(llADONet); - UnsuggestIt(llProvider); - UnsuggestIt(llEFv5); - UnsuggestIt(llEFv6); - UnsuggestIt(llRestart); - UnsuggestIt(llBuild); + foreach (var ll in tabPage3.Controls.OfType()) { + UnsuggestIt(ll); + } } private void SuggestIt(LinkLabel ll) { @@ -163,7 +159,7 @@ void CheckEF(bool v6) { Log(loc2, Color.Blue); Newl(); - Log("Check if 2 Npgsql assemblies are equivalent... "); + Log("Check if 2 Npgsql assemblies have equivalent file path... "); if (loc1.Equals(loc2)) { Log("Yes", Color.Blue); Newl(); @@ -430,16 +426,33 @@ void CheckEF(bool v6) { Log("Yes", Color.Blue); Newl(); - Log("Check
... "); - var el3 = el2.SelectSingleNode("section[@name='entityFramework']") as XmlElement; - if (el3 != null) { - Log("Yes", Color.Blue); - Newl(); + { + Log("Check
... "); + var el3 = el2.SelectSingleNode("section[@name='entityFramework']") as XmlElement; + if (el3 != null) { + Log("Yes", Color.Blue); + Newl(); + } + else { + Log("No", Color.Red); + Newl(); + } } - else { - Log("No", Color.Red); - Newl(); + + { + Log("Check is located at first element... "); + var el3 = el2.PreviousSibling as XmlElement; + if (el3 == null) { + Log("Yes", Color.Blue); + Newl(); + } + else { + Log("No", Color.Red); + Newl(); + + SuggestIt(llConfigSections); + } } } else { @@ -558,8 +571,17 @@ private bool TryOpen(String url) { return false; } + private bool TryOpen2(params String[] urls) { + if (MessageBox.Show(this, "Open them?\n\n" + String.Join("\n", urls), null, MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.OK) { + foreach (var url in urls) + System.Diagnostics.Process.Start(url); + return true; + } + return false; + } + private void llGrab_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { - if (TryOpen("https://github.com/npgsql/npgsql/releases")) { + if (TryOpen2("https://github.com/npgsql/npgsql/releases", "https://github.com/kenjiuno/Npgsql/releases")) { //UnsuggestIt((LinkLabel)sender); } } @@ -717,6 +739,7 @@ private void llEFv5_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) IVsPackageInstaller installer = componentModel.GetService(); installer.InstallPackage(null, proj, "EntityFramework5.Npgsql", typeof(NpgsqlConnection).Assembly.GetName().Version, false); + UnsuggestIt(llEFv5); MessageBox.Show(this, "Done.", null, MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception err) { @@ -735,11 +758,50 @@ private void llEFv6_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) IVsPackageInstaller installer = componentModel.GetService(); installer.InstallPackage(null, proj, "EntityFramework6.Npgsql", typeof(NpgsqlConnection).Assembly.GetName().Version, false); + UnsuggestIt(llEFv6); MessageBox.Show(this, "Done.", null, MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception err) { MessageBox.Show(this, "InstallPackage failed.\n\n" + err, null, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } + + private void llConfigSections_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { + if (MessageBox.Show(this, "Are you really?", null, MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.OK) { + var proj = GetActiveProject(); + if (proj != null) { + String fpXml = null; + foreach (EnvDTE.ProjectItem pi in proj.ProjectItems) { + if (false + || "App.config".Equals(pi.Name, StringComparison.InvariantCultureIgnoreCase) + || "Web.config".Equals(pi.Name, StringComparison.InvariantCultureIgnoreCase) + ) { + fpXml = pi.FileNames[1]; + break; + } + } + if (fpXml != null) { + XmlDocument xd = new XmlDocument(); + xd.Load(fpXml); + + var el2 = xd.SelectSingleNode("/configuration/configSections") as XmlElement; + if (el2 != null) { + if (el2.PreviousSibling as XmlElement != null) { + var el1 = el2.ParentNode as XmlElement; + el1.PrependChild(el2); + + xd.Save(fpXml); + MessageBox.Show(this, "Done.", null, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + UnsuggestIt((LinkLabel)sender); + return; + } + } + } + } + } + + MessageBox.Show(this, "Not changed.", null, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; + } } } \ No newline at end of file diff --git a/src/NpgsqlDdexProvider/NpgsqlDdexProviderPackage.cs b/src/NpgsqlDdexProvider/NpgsqlDdexProviderPackage.cs index 3b7ab11297..649dc462a9 100644 --- a/src/NpgsqlDdexProvider/NpgsqlDdexProviderPackage.cs +++ b/src/NpgsqlDdexProvider/NpgsqlDdexProviderPackage.cs @@ -134,7 +134,7 @@ private void MenuItemSetupNpgsqlDdexProvider(object sender, EventArgs e) { CheckNpgsqlStatus.DoInst(); } catch (UnauthorizedAccessException err) { - UIUt.Alert(this, "Grant write access to: \n" + CheckNpgsqlStatus.Ut.HostConfig + "\n\n---\n" + err, "NpgsqlDdexProvider"); + UIUt.Alert(this, "Grant write access to: \n" + CheckNpgsqlStatus.Ut.HostConfig + "\n\nException message:\n---\n" + err + "\n---", "NpgsqlDdexProvider"); if (PEUt.GrantEditAccess(CheckNpgsqlStatus.Ut.HostConfig)) { CheckNpgsqlStatus.DoInst(); } @@ -178,7 +178,7 @@ private void MenuItemUninstNpgsqlDdexProvider(object sender, EventArgs e) { CheckNpgsqlStatus.DoUninst(); } catch (UnauthorizedAccessException err) { - UIUt.Alert(this, "Grant write access to: \n" + CheckNpgsqlStatus.Ut.HostConfig + "\n\n---\n" + err, "NpgsqlDdexProvider"); + UIUt.Alert(this, "Grant write access to: \n" + CheckNpgsqlStatus.Ut.HostConfig + "\n\nException message:\n---\n" + err + "\n---", "NpgsqlDdexProvider"); if (PEUt.GrantEditAccess(CheckNpgsqlStatus.Ut.HostConfig)) { CheckNpgsqlStatus.DoUninst(); }