Changeset 3006 for trunk/sources/HeuristicLab.PluginInfrastructure/Advanced
- Timestamp:
- 03/11/10 18:23:52 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.PluginInfrastructure/Advanced
- Files:
-
- 17 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.PluginInfrastructure/Advanced/DeploymentService/RegenerateServiceClasses.cmd
r2812 r3006 1 1 # 2 svcutil http:// localhost:8731/Design_Time_Addresses/HeuristicLab.Services.Deployment/Update/mex http://localhost:8731/Design_Time_Addresses/HeuristicLab.Services.Deployment/Admin/mex /language:C# /targetClientVersion:Version35 /out:DeploymentService /namespace:*,HeuristicLab.PluginInfrastructure.Advanced.DeploymentService /mergeConfig /config:../../app.config2 svcutil http://servdev.heuristiclab.com/Deployment/Update.svc/mex http://servdev.heuristiclab.com/Deployment/Admin.svc/mex /language:C# /targetClientVersion:Version35 /out:DeploymentService /namespace:*,HeuristicLab.PluginInfrastructure.Advanced.DeploymentService /mergeConfig /config:../../app.config -
trunk/sources/HeuristicLab.PluginInfrastructure/Advanced/InstallationManager.cs
r2922 r3006 29 29 using System.Reflection; 30 30 using ICSharpCode.SharpZipLib.Zip; 31 using System.ServiceModel; 31 32 32 33 namespace HeuristicLab.PluginInfrastructure.Advanced { … … 129 130 /// <param name="connectionString"></param> 130 131 /// <returns></returns> 131 public IEnumerable<IPluginDescription> GetRemotePluginList(string connectionString) { 132 using (var client = new DeploymentService.UpdateClient()) { 133 return client.GetPlugins(); 132 public IEnumerable<IPluginDescription> GetRemotePluginList() { 133 var client = DeploymentService.UpdateClientFactory.CreateClient(); 134 try { 135 List<IPluginDescription> plugins = new List<IPluginDescription>(client.GetPlugins()); 136 client.Close(); 137 return plugins; 138 } 139 catch (FaultException) { 140 client.Abort(); 141 return new IPluginDescription[] { }; 134 142 } 135 143 } … … 140 148 /// <param name="connectionString"></param> 141 149 /// <returns></returns> 142 public IEnumerable<DeploymentService.ProductDescription> GetRemoteProductList(string connectionString) { 143 using (var client = new DeploymentService.UpdateClient()) { 144 return client.GetProducts(); 150 public IEnumerable<DeploymentService.ProductDescription> GetRemoteProductList() { 151 var client = DeploymentService.UpdateClientFactory.CreateClient(); 152 try { 153 List<DeploymentService.ProductDescription> products = new List<DeploymentService.ProductDescription>(client.GetProducts()); 154 client.Close(); 155 return products; 156 } 157 catch (FaultException) { 158 client.Abort(); 159 return new DeploymentService.ProductDescription[] { }; 145 160 } 146 161 } … … 151 166 /// <param name="connectionString"></param> 152 167 /// <param name="pluginNames"></param> 153 public void Install(string connectionString, IEnumerable<IPluginDescription> plugins) { 154 using (var client = new DeploymentService.UpdateClient()) { 155 var args = new PluginInfrastructureCancelEventArgs(plugins.Select(x => x.Name + " " + x.Version)); 156 OnPreInstall(args); 157 foreach (DeploymentService.PluginDescription plugin in plugins) { 158 byte[] zippedPackage = client.GetPlugin(plugin); 159 Unpack(zippedPackage); 160 OnInstalled(new PluginInfrastructureEventArgs(plugin)); 168 public void Install(IEnumerable<IPluginDescription> plugins) { 169 var args = new PluginInfrastructureCancelEventArgs(plugins); 170 OnPreInstall(args); 171 if (!args.Cancel) { 172 var client = DeploymentService.UpdateClientFactory.CreateClient(); 173 try { 174 foreach (DeploymentService.PluginDescription plugin in plugins) { 175 byte[] zippedPackage = client.GetPlugin(plugin); 176 Unpack(zippedPackage); 177 OnInstalled(new PluginInfrastructureEventArgs(plugin)); 178 } 179 client.Close(); 180 } 181 catch (FaultException) { 182 client.Abort(); 161 183 } 162 184 } … … 167 189 /// </summary> 168 190 /// <param name="pluginNames"></param> 169 public void Update( string connectionString,IEnumerable<IPluginDescription> plugins) {170 PluginInfrastructureCancelEventArgs args = new PluginInfrastructureCancelEventArgs(plugins .Select(x => x.Name + " " + x.Version));191 public void Update(IEnumerable<IPluginDescription> plugins) { 192 PluginInfrastructureCancelEventArgs args = new PluginInfrastructureCancelEventArgs(plugins); 171 193 OnPreUpdate(args); 172 194 if (!args.Cancel) { 173 using (var client = new DeploymentService.UpdateClient()) { 195 var client = DeploymentService.UpdateClientFactory.CreateClient(); 196 try { 174 197 foreach (DeploymentService.PluginDescription plugin in plugins) { 175 198 byte[] zippedPackage = client.GetPlugin(plugin); … … 177 200 OnUpdated(new PluginInfrastructureEventArgs(plugin)); 178 201 } 202 client.Close(); 203 } 204 catch (FaultException) { 205 client.Abort(); 179 206 } 180 207 } … … 189 216 from file in pluginToDelete.Files 190 217 select Path.Combine(pluginDir, file.Name); 191 var args = new PluginInfrastructureCancelEventArgs( fileNames);218 var args = new PluginInfrastructureCancelEventArgs(plugins); 192 219 OnPreDelete(args); 193 220 if (!args.Cancel) { -
trunk/sources/HeuristicLab.PluginInfrastructure/Advanced/InstallationManagerConsole.cs
r2922 r3006 52 52 void installManager_PreUpdatePlugin(object sender, PluginInfrastructureCancelEventArgs e) { 53 53 Console.WriteLine("Following plugins are updated:"); 54 foreach (var info in e. Entities) {54 foreach (var info in e.Plugins) { 55 55 Console.WriteLine(e); 56 56 } … … 67 67 void installManager_PreRemovePlugin(object sender, PluginInfrastructureCancelEventArgs e) { 68 68 Console.WriteLine("Following files are deleted:"); 69 foreach (string fileName in e.Entities) { 70 Console.WriteLine(fileName); 69 foreach (var plugin in e.Plugins) { 70 foreach (var file in plugin.Files) 71 Console.WriteLine(file); 71 72 } 72 73 if (GetUserConfirmation()) e.Cancel = false; -
trunk/sources/HeuristicLab.PluginInfrastructure/Advanced/InstallationManagerForm.Designer.cs
r2922 r3006 28 28 this.toolStripStatusLabel = new System.Windows.Forms.ToolStripStatusLabel(); 29 29 this.removeButton = new System.Windows.Forms.Button(); 30 this.serverUrlLabel = new System.Windows.Forms.Label();31 this.serverUrlTextBox = new System.Windows.Forms.TextBox();32 this.refreshButton = new System.Windows.Forms.Button();33 30 this.installButton = new System.Windows.Forms.Button(); 34 31 this.tabControl = new System.Windows.Forms.TabControl(); … … 39 36 this.logTabPage = new System.Windows.Forms.TabPage(); 40 37 this.logTextBox = new System.Windows.Forms.TextBox(); 38 this.refreshButton = new System.Windows.Forms.Button(); 39 this.editConnectionButton = new System.Windows.Forms.Button(); 41 40 this.statusStrip.SuspendLayout(); 42 41 this.tabControl.SuspendLayout(); … … 81 80 this.removeButton.Click += new System.EventHandler(this.removeButton_Click); 82 81 // 83 // serverUrlLabel84 //85 this.serverUrlLabel.AutoSize = true;86 this.serverUrlLabel.Location = new System.Drawing.Point(9, 11);87 this.serverUrlLabel.Name = "serverUrlLabel";88 this.serverUrlLabel.Size = new System.Drawing.Size(73, 13);89 this.serverUrlLabel.TabIndex = 13;90 this.serverUrlLabel.Text = "Plugin Server:";91 //92 // serverUrlTextBox93 //94 this.serverUrlTextBox.Location = new System.Drawing.Point(88, 8);95 this.serverUrlTextBox.Name = "serverUrlTextBox";96 this.serverUrlTextBox.Size = new System.Drawing.Size(264, 20);97 this.serverUrlTextBox.TabIndex = 12;98 //99 // refreshButton100 //101 this.refreshButton.Location = new System.Drawing.Point(358, 6);102 this.refreshButton.Name = "refreshButton";103 this.refreshButton.Size = new System.Drawing.Size(75, 23);104 this.refreshButton.TabIndex = 11;105 this.refreshButton.Text = "Refresh";106 this.refreshButton.UseVisualStyleBackColor = true;107 this.refreshButton.Click += new System.EventHandler(this.refreshButton_Click);108 //109 82 // installButton 110 83 // … … 157 130 // remotePluginsTabPage 158 131 // 159 this.remotePluginsTabPage.Controls.Add(this. serverUrlLabel);132 this.remotePluginsTabPage.Controls.Add(this.editConnectionButton); 160 133 this.remotePluginsTabPage.Controls.Add(this.remotePluginInstaller); 161 this.remotePluginsTabPage.Controls.Add(this.serverUrlTextBox);162 134 this.remotePluginsTabPage.Controls.Add(this.refreshButton); 163 135 this.remotePluginsTabPage.Controls.Add(this.installButton); … … 204 176 this.logTextBox.Size = new System.Drawing.Size(598, 586); 205 177 this.logTextBox.TabIndex = 0; 178 // 179 // refreshButton 180 // 181 this.refreshButton.Location = new System.Drawing.Point(8, 6); 182 this.refreshButton.Name = "refreshButton"; 183 this.refreshButton.Size = new System.Drawing.Size(75, 23); 184 this.refreshButton.TabIndex = 11; 185 this.refreshButton.Text = "Refresh"; 186 this.refreshButton.UseVisualStyleBackColor = true; 187 this.refreshButton.Click += new System.EventHandler(this.refreshButton_Click); 188 // 189 // editConnectionButton 190 // 191 this.editConnectionButton.Location = new System.Drawing.Point(89, 6); 192 this.editConnectionButton.Name = "editConnectionButton"; 193 this.editConnectionButton.Size = new System.Drawing.Size(108, 23); 194 this.editConnectionButton.TabIndex = 16; 195 this.editConnectionButton.Text = "Edit Connection..."; 196 this.editConnectionButton.UseVisualStyleBackColor = true; 197 this.editConnectionButton.Click += new System.EventHandler(this.editConnectionButton_Click); 206 198 // 207 199 // InstallationManagerForm … … 219 211 this.localPluginsTabPage.ResumeLayout(false); 220 212 this.remotePluginsTabPage.ResumeLayout(false); 221 this.remotePluginsTabPage.PerformLayout();222 213 this.logTabPage.ResumeLayout(false); 223 214 this.logTabPage.PerformLayout(); … … 232 223 private System.Windows.Forms.ToolStripProgressBar toolStripProgressBar; 233 224 private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel; 234 private System.Windows.Forms.Label serverUrlLabel;235 private System.Windows.Forms.TextBox serverUrlTextBox;236 private System.Windows.Forms.Button refreshButton;237 225 private LocalPluginManager localPluginManager; 238 226 private RemotePluginInstaller remotePluginInstaller; … … 244 232 private System.Windows.Forms.TabPage logTabPage; 245 233 private System.Windows.Forms.TextBox logTextBox; 234 private System.Windows.Forms.Button editConnectionButton; 235 private System.Windows.Forms.Button refreshButton; 246 236 } 247 237 } -
trunk/sources/HeuristicLab.PluginInfrastructure/Advanced/InstallationManagerForm.cs
r2922 r3006 13 13 public partial class InstallationManagerForm : Form { 14 14 private class UpdateOrInstallPluginsBackgroundWorkerArgument { 15 public string ConnectionString { get; set; }16 15 public IEnumerable<IPluginDescription> PluginsToUpdate { get; set; } 17 16 public IEnumerable<IPluginDescription> PluginsToInstall { get; set; } … … 56 55 refreshLocalPluginsBackgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(refreshLocalPluginsBackgroundWorker_RunWorkerCompleted); 57 56 #endregion 58 59 // get default connection string60 using (var client = new DeploymentService.UpdateClient()) {61 serverUrlTextBox.Text = client.Endpoint.Address.ToString();62 }63 57 64 58 installationManager = new InstallationManager(pluginDir); … … 130 124 void updateOrInstallPluginsBackgroundWorker_DoWork(object sender, DoWorkEventArgs e) { 131 125 UpdateOrInstallPluginsBackgroundWorkerArgument info = (UpdateOrInstallPluginsBackgroundWorkerArgument)e.Argument; 132 installationManager.Install(info. ConnectionString, info.PluginsToInstall);133 installationManager.Update(info. ConnectionString, info.PluginsToUpdate);126 installationManager.Install(info.PluginsToInstall); 127 installationManager.Update(info.PluginsToUpdate); 134 128 } 135 129 #endregion … … 147 141 148 142 void refreshServerPluginsBackgroundWorker_DoWork(object sender, DoWorkEventArgs e) { 149 string connectionString = (string)e.Argument;150 151 143 RefreshBackgroundWorkerResult result = new RefreshBackgroundWorkerResult(); 152 result.RemotePlugins = installationManager.GetRemotePluginList( connectionString);153 result.RemoteProducts = installationManager.GetRemoteProductList( connectionString);144 result.RemotePlugins = installationManager.GetRemotePluginList(); 145 result.RemoteProducts = installationManager.GetRemoteProductList(); 154 146 e.Cancel = false; 155 147 e.Result = result; … … 180 172 #region installation manager event handlers 181 173 void installationManager_PreUpdatePlugin(object sender, PluginInfrastructureCancelEventArgs e) { 182 if (ConfirmUpdateAction(e.Entities) == true) e.Cancel = false; 183 else e.Cancel = true; 174 if (e.Plugins.Count() > 0) { 175 e.Cancel = ConfirmUpdateAction(e.Plugins) == false; 176 } 184 177 } 185 178 186 179 void installationManager_PreRemovePlugin(object sender, PluginInfrastructureCancelEventArgs e) { 187 if (ConfirmRemoveAction(e.Entities) == true) e.Cancel = false; 188 else e.Cancel = true; 180 if (e.Plugins.Count() > 0) { 181 e.Cancel = ConfirmRemoveAction(e.Plugins) == false; 182 } 189 183 } 190 184 191 185 void installationManager_PreInstallPlugin(object sender, PluginInfrastructureCancelEventArgs e) { 192 if (e.Entities.Count() > 0) 193 SetStatusStrip("Installing " + e.Entities.Aggregate((a, b) => a + Environment.NewLine + b)); 186 if (e.Plugins.Count() > 0) 187 if (ConfirmInstallAction(e.Plugins) == true) { 188 SetStatusStrip("Installing " + e.Plugins.Aggregate("", (a, b) => a.ToString() + "; " + b.ToString())); 189 e.Cancel = false; 190 } else { 191 e.Cancel = true; 192 SetStatusStrip("Install canceled"); 193 } 194 194 } 195 195 … … 239 239 var pluginsToInstall = remotePluginInstaller.CheckedPlugins.Except(pluginsToUpdate); 240 240 241 updateOrInstallInfo.ConnectionString = serverUrlTextBox.Text;242 241 updateOrInstallInfo.PluginsToInstall = pluginsToInstall; 243 242 updateOrInstallInfo.PluginsToUpdate = pluginsToUpdate; … … 255 254 256 255 #region confirmation dialogs 257 private bool ConfirmRemoveAction(IEnumerable< string> fileNames) {256 private bool ConfirmRemoveAction(IEnumerable<IPluginDescription> plugins) { 258 257 StringBuilder strBuilder = new StringBuilder(); 259 258 strBuilder.AppendLine("Delete files:"); 260 foreach (var fileName in fileNames) { 261 strBuilder.AppendLine(fileName); 259 foreach (var plugin in plugins) { 260 foreach (var file in plugin.Files) { 261 strBuilder.AppendLine(file.ToString()); 262 } 262 263 } 263 264 return MessageBox.Show(strBuilder.ToString(), "Confirm Delete", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK; 264 265 } 265 266 266 private bool ConfirmUpdateAction(IEnumerable< string> plugins) {267 private bool ConfirmUpdateAction(IEnumerable<IPluginDescription> plugins) { 267 268 StringBuilder strBuilder = new StringBuilder(); 268 269 strBuilder.AppendLine("Update plugins:"); 269 270 foreach (var plugin in plugins) { 270 strBuilder.AppendLine(plugin );271 strBuilder.AppendLine(plugin.ToString()); 271 272 } 272 273 return MessageBox.Show(strBuilder.ToString(), "Confirm Update", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK; 273 274 } 275 276 private bool ConfirmInstallAction(IEnumerable<IPluginDescription> plugins) { 277 foreach (var plugin in plugins) { 278 if (!string.IsNullOrEmpty(plugin.LicenseText)) { 279 var licenseConfirmationBox = new LicenseConfirmationBox(plugin); 280 if (licenseConfirmationBox.ShowDialog() != DialogResult.OK) 281 return false; 282 } 283 } 284 return true; 285 } 286 274 287 275 288 #endregion … … 306 319 toolStripProgressBar.Visible = true; 307 320 DisableControls(); 308 refreshServerPluginsBackgroundWorker.RunWorkerAsync( serverUrlTextBox.Text);321 refreshServerPluginsBackgroundWorker.RunWorkerAsync(); 309 322 } 310 323 … … 320 333 //ClearPluginsList(remotePluginsListView); 321 334 refreshButton.Enabled = true; 322 serverUrlTextBox.Enabled = true;323 335 toolStripProgressBar.Visible = false; 324 336 Cursor = Cursors.Default; … … 327 339 private void UpdateControlsConnected() { 328 340 refreshButton.Enabled = true; 329 serverUrlTextBox.Enabled = true;330 341 toolStripProgressBar.Visible = false; 331 342 Cursor = Cursors.Default; … … 345 356 installButton.Enabled = remotePluginInstaller.CheckedPlugins.Count() > 0; 346 357 } 358 359 private void editConnectionButton_Click(object sender, EventArgs e) { 360 (new ConnectionSetupView()).ShowInForm(); 361 } 347 362 } 348 363 } -
trunk/sources/HeuristicLab.PluginInfrastructure/Advanced/LocalPluginManager.Designer.cs
r2922 r3006 57 57 this.localPluginsListView.UseCompatibleStateImageBehavior = false; 58 58 this.localPluginsListView.View = System.Windows.Forms.View.Details; 59 this.localPluginsListView.ItemActivate += new System.EventHandler(this.localPluginsListView_ItemActivate); 59 60 this.localPluginsListView.ItemChecked += new System.Windows.Forms.ItemCheckedEventHandler(this.pluginsListView_ItemChecked); 60 61 // -
trunk/sources/HeuristicLab.PluginInfrastructure/Advanced/LocalPluginManager.cs
r2922 r3006 92 92 if (ItemChecked != null) ItemChecked(this, e); 93 93 } 94 95 private void localPluginsListView_ItemActivate(object sender, EventArgs e) { 96 if (localPluginsListView.SelectedItems.Count > 0) { 97 var plugin = (PluginDescription)localPluginsListView.SelectedItems[0].Tag; 98 PluginView pluginView = new PluginView(plugin); 99 pluginView.ShowInForm(); 100 } 101 } 94 102 } 95 103 }
Note: See TracChangeset
for help on using the changeset viewer.