diff --git a/Xrm.Sdk.PluginRegistration/Forms/PluginRegistrationForm.cs b/Xrm.Sdk.PluginRegistration/Forms/PluginRegistrationForm.cs index 6294685..eccb714 100644 --- a/Xrm.Sdk.PluginRegistration/Forms/PluginRegistrationForm.cs +++ b/Xrm.Sdk.PluginRegistration/Forms/PluginRegistrationForm.cs @@ -42,6 +42,10 @@ public partial class PluginRegistrationForm : Form private List m_registeredPluginList; #endregion Private Fields + + #region Public Properties + public string AssemblyFileName { get; set; } + #endregion Public Properties #region Public Constructors @@ -161,13 +165,30 @@ private void AssemblyPathControl_PathChanged(object sender, EventArgs e) } } + public void RepeatRegistration(string assemblyFileName) + { + CheckAndLoadAssembly(assemblyFileName); + RegisterPlugin(); + } + private void btnCancel_Click(object sender, EventArgs e) { Close(); } + private void btnLoadAssembly_Click(object sender, EventArgs e) { + CheckAndLoadAssembly(); + } + + private void CheckAndLoadAssembly(string assemblyFileName = null) + { + if (!string.IsNullOrEmpty(assemblyFileName)) + { + AssemblyPathControl.FileName = assemblyFileName; + } + if (!AssemblyPathControl.FileExists) { MessageBox.Show("Error: Unable to locate the specified file. Please ensure that it exists", @@ -179,6 +200,7 @@ private void btnLoadAssembly_Click(object sender, EventArgs e) CrmPluginAssembly assembly; try { + AssemblyFileName = AssemblyPathControl.FileName; assembly = RegistrationHelper.RetrievePluginsFromAssembly(AssemblyPathControl.FileName); } catch (Exception ex) @@ -202,6 +224,11 @@ private void btnLoadAssembly_Click(object sender, EventArgs e) } private void btnRegister_Click(object sender, EventArgs e) + { + RegisterPlugin(); + } + + private void RegisterPlugin() { const string ERROR_CAPTION = "Registration Error"; string ERROR_MESSAGE; diff --git a/Xrm.Sdk.PluginRegistration/MainControl.Designer.cs b/Xrm.Sdk.PluginRegistration/MainControl.Designer.cs index 9857a6d..fac8f42 100644 --- a/Xrm.Sdk.PluginRegistration/MainControl.Designer.cs +++ b/Xrm.Sdk.PluginRegistration/MainControl.Designer.cs @@ -62,6 +62,7 @@ private void InitializeComponent() this.toolProfilerSep = new System.Windows.Forms.ToolStripSeparator(); this.toolUpdate = new System.Windows.Forms.ToolStripButton(); this.toolEnable = new System.Windows.Forms.ToolStripButton(); + this.toolRepeat = new System.Windows.Forms.ToolStripButton(); this.toolUnregister = new System.Windows.Forms.ToolStripButton(); this.toolCommonSep2 = new System.Windows.Forms.ToolStripSeparator(); this.toolRefresh = new System.Windows.Forms.ToolStripButton(); @@ -270,6 +271,7 @@ private void InitializeComponent() this.toolProfilerSep, this.toolUpdate, this.toolEnable, + this.toolRepeat, this.toolUnregister, this.toolCommonSep2, this.toolRefresh, @@ -388,6 +390,15 @@ private void InitializeComponent() this.toolEnable.Visible = false; this.toolEnable.Click += new System.EventHandler(this.toolEnable_Click); // + // toolRepeat + // + this.toolRepeat.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolRepeat.Name = "toolRepeat"; + this.toolRepeat.Size = new System.Drawing.Size(47, 22); + this.toolRepeat.Text = "Re&peat"; + this.toolRepeat.Visible = false; + this.toolRepeat.Click += new System.EventHandler(this.toolRepeat_Click); + // // toolUnregister // this.toolUnregister.ImageTransparentColor = System.Drawing.Color.Magenta; @@ -601,5 +612,6 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripButton toolClose; private System.Windows.Forms.ToolStripButton toolExport; private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; + private System.Windows.Forms.ToolStripButton toolRepeat; } } diff --git a/Xrm.Sdk.PluginRegistration/MainControl.cs b/Xrm.Sdk.PluginRegistration/MainControl.cs index d3cb4b8..41d4499 100644 --- a/Xrm.Sdk.PluginRegistration/MainControl.cs +++ b/Xrm.Sdk.PluginRegistration/MainControl.cs @@ -56,6 +56,9 @@ public partial class MainControl : PluginControlBase, IStatusBarMessenger, IGitH private Dictionary m_stepEntityMap = new Dictionary(); private Dictionary m_stepParentList = null; private Dictionary m_viewNodeList = null; + private string m_lastAssemblyFileName = null; + private string m_lastRepeatedAssemblyName = null; + #endregion Private Fields @@ -138,7 +141,8 @@ public MainControl() "UninstallProfiler", "Debug", "Close", - "Save"); + "Save", + "Repeat"); toolRegister.Image = imageList["Register"]; toolView.Image = imageList["View"]; @@ -149,6 +153,8 @@ public MainControl() toolUnregister.Image = imageList["Delete"]; mnuContextNodeUnregister.Image = toolUnregister.Image; + toolRepeat.Image = imageList["Repeat"]; + toolSearch.Image = imageList["Search"]; mnuContextNodeSearch.Image = toolSearch.Image; mnuContextGeneralSearch.Image = toolSearch.Image; @@ -607,7 +613,7 @@ public void ShowAboutDialog() } } - public void ShowSystemItemError(string text) + public void ShowSystemItemError(string text, bool showSystemMessage = true) { if (text == null) { @@ -615,8 +621,15 @@ public void ShowSystemItemError(string text) } else { - MessageBox.Show(string.Format("{0}\n{1}", SYSTEM_ERROR_MESSAGE, text), - SYSTEM_ERROR_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error); + if (showSystemMessage) + { + MessageBox.Show(string.Format("{0}\n{1}", SYSTEM_ERROR_MESSAGE, text), + SYSTEM_ERROR_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error); + } + else + { + MessageBox.Show( text, SYSTEM_ERROR_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error); + } } } @@ -1282,6 +1295,7 @@ private void SelectItem(ICrmTreeNode node) { //Reset the visibility and enabled properties because we don't what is enabled toolUpdate.Visible = false; + toolRepeat.Visible = false; mnuContextNodeUpdate.Visible = false; toolEnable.Visible = false; @@ -1327,6 +1341,9 @@ private void SelectItem(ICrmTreeNode node) btnSave.Enabled = true; //Load the data table and display information gridTable = OrganizationHelper.CreateDataTable(CrmPlugin.Columns, assembly.Plugins); + + toolRepeat.Visible = true; + } break; @@ -1697,6 +1714,55 @@ private void toolUnregister_Click(object sender, EventArgs e) } } + + private void toolRepeat_Click(object sender, EventArgs e) + { + if (IsNodeSystemItem(trvPlugins.SelectedNode)) + { + ShowSystemItemError("The assembly cannot be updated."); + return; + } + + if (String.IsNullOrEmpty(m_lastAssemblyFileName)) + { + ShowSystemItemError("Please register the assembly manually first", false); + return; + } + + switch (trvPlugins.SelectedNode.NodeType) + { + case CrmTreeNodeType.Assembly: + { + + if (m_lastRepeatedAssemblyName != ((CrmPluginAssembly)trvPlugins.SelectedNode).Name) + { + ShowSystemItemError("Repeat can only be used on the last registered assembly", false); + return; + } + + var regForm = new PluginRegistrationForm(Organization, this, (CrmPluginAssembly)trvPlugins.SelectedNode); + m_lastRepeatedAssemblyName = ((CrmPluginAssembly)trvPlugins.SelectedNode).Name; + + + regForm.RepeatRegistration(m_lastAssemblyFileName); + } + break; + + + default: + ShowSystemItemError("Repeat can only be used on assemblies", false); + break; + } + + ICrmTreeNode node = trvPlugins.SelectedNode; + if (node != null) + { + trvPlugins_SelectionChanged(sender, new CrmTreeNodeTreeEventArgs(node, TreeViewAction.Unknown)); + } + + } + + private void toolUpdate_Click(object sender, EventArgs e) { if (IsNodeSystemItem(trvPlugins.SelectedNode)) @@ -1711,6 +1777,8 @@ private void toolUpdate_Click(object sender, EventArgs e) { var regForm = new PluginRegistrationForm(Organization, this, (CrmPluginAssembly)trvPlugins.SelectedNode); regForm.ShowDialog(ParentForm); + m_lastAssemblyFileName = regForm.AssemblyFileName; + m_lastRepeatedAssemblyName = ((CrmPluginAssembly)trvPlugins.SelectedNode).Name; } break; @@ -2350,5 +2418,7 @@ private void UpdateNodeText() } #endregion Private Classes + + } } \ No newline at end of file diff --git a/Xrm.Sdk.PluginRegistration/MainControl.resx b/Xrm.Sdk.PluginRegistration/MainControl.resx index fcf2f98..360d89a 100644 --- a/Xrm.Sdk.PluginRegistration/MainControl.resx +++ b/Xrm.Sdk.PluginRegistration/MainControl.resx @@ -117,21 +117,16 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - + 153, 17 - - + + 291, 17 - - + + 441, 17 - - + + 17, 17 - - - - Resources\dynamics365_icon_32.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - + \ No newline at end of file diff --git a/Xrm.Sdk.PluginRegistration/Resources.Designer.cs b/Xrm.Sdk.PluginRegistration/Resources.Designer.cs index a2f69e6..6f29bd7 100644 --- a/Xrm.Sdk.PluginRegistration/Resources.Designer.cs +++ b/Xrm.Sdk.PluginRegistration/Resources.Designer.cs @@ -239,6 +239,16 @@ internal static System.Drawing.Bitmap Register { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap Repeat { + get { + object obj = ResourceManager.GetObject("Repeat", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// diff --git a/Xrm.Sdk.PluginRegistration/Resources.resx b/Xrm.Sdk.PluginRegistration/Resources.resx index 8512827..5414c07 100644 --- a/Xrm.Sdk.PluginRegistration/Resources.resx +++ b/Xrm.Sdk.PluginRegistration/Resources.resx @@ -204,4 +204,7 @@ Resources\dynamics365-icon-16.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + Resources\Repeat-All-24.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/Xrm.Sdk.PluginRegistration/Resources/Repeat-All-24.png b/Xrm.Sdk.PluginRegistration/Resources/Repeat-All-24.png new file mode 100644 index 0000000..4c5e4bc Binary files /dev/null and b/Xrm.Sdk.PluginRegistration/Resources/Repeat-All-24.png differ diff --git a/Xrm.Sdk.PluginRegistration/Resources/Repeat.png b/Xrm.Sdk.PluginRegistration/Resources/Repeat.png new file mode 100644 index 0000000..3e9d6ed Binary files /dev/null and b/Xrm.Sdk.PluginRegistration/Resources/Repeat.png differ diff --git a/Xrm.Sdk.PluginRegistration/Xrm.Sdk.PluginRegistration.csproj b/Xrm.Sdk.PluginRegistration/Xrm.Sdk.PluginRegistration.csproj index 4d4f5e5..7729ac6 100644 --- a/Xrm.Sdk.PluginRegistration/Xrm.Sdk.PluginRegistration.csproj +++ b/Xrm.Sdk.PluginRegistration/Xrm.Sdk.PluginRegistration.csproj @@ -302,6 +302,8 @@ + +