Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.PluginInfrastructure/Advanced/InstallationManagerConsole.cs @ 3038

Last change on this file since 3038 was 3006, checked in by gkronber, 15 years ago

Implemented deployment service on servdev.heuristiclab.com and changed all service references and configurations to point to the service address. Improved GUI of installation manager. Implemented user name authentication and authorization for the deployment service. #860 (Deployment server for plugin installation from web locations)

File size: 4.5 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using System.Collections.Generic;
24using System.Linq;
25using System.Text;
26using HeuristicLab.PluginInfrastructure.Manager;
27using System.IO;
28using System.ComponentModel;
29using HeuristicLab.PluginInfrastructure.Advanced.DeploymentService;
30
31
32namespace HeuristicLab.PluginInfrastructure.Advanced {
33  public class InstallationManagerConsole {
34    private InstallationManager installManager;
35    private string connectionString;
36    public InstallationManagerConsole(string pluginDir) {
37
38      // get default connection string
39      using (var client = new UpdateClient()) {
40        connectionString = client.Endpoint.Address.ToString();
41      }
42
43      this.installManager = new InstallationManager(pluginDir);
44      installManager.PreInstallPlugin += new EventHandler<PluginInfrastructureCancelEventArgs>(installManager_PreInstallPlugin);
45      installManager.PreRemovePlugin += new EventHandler<PluginInfrastructureCancelEventArgs>(installManager_PreRemovePlugin);
46      installManager.PreUpdatePlugin += new EventHandler<PluginInfrastructureCancelEventArgs>(installManager_PreUpdatePlugin);
47      installManager.PluginInstalled += new EventHandler<PluginInfrastructureEventArgs>(installManager_PluginInstalled);
48      installManager.PluginRemoved += new EventHandler<PluginInfrastructureEventArgs>(installManager_PluginRemoved);
49      installManager.PluginUpdated += new EventHandler<PluginInfrastructureEventArgs>(installManager_PluginUpdated);
50    }
51
52    void installManager_PreUpdatePlugin(object sender, PluginInfrastructureCancelEventArgs e) {
53      Console.WriteLine("Following plugins are updated:");
54      foreach (var info in e.Plugins) {
55        Console.WriteLine(e);
56      }
57      if (GetUserConfirmation()) e.Cancel = false;
58      else e.Cancel = true;
59      return;
60    }
61
62    void installManager_PluginUpdated(object sender, PluginInfrastructureEventArgs e) {
63      foreach (var info in (IEnumerable<IPluginDescription>)e.Entity)
64        Console.WriteLine("Updated: {0}", info.Name);
65    }
66
67    void installManager_PreRemovePlugin(object sender, PluginInfrastructureCancelEventArgs e) {
68      Console.WriteLine("Following files are deleted:");
69      foreach (var plugin in e.Plugins) {
70        foreach (var file in plugin.Files)
71          Console.WriteLine(file);
72      }
73      if (GetUserConfirmation()) e.Cancel = false;
74      else e.Cancel = true;
75      return;
76    }
77
78    void installManager_PluginRemoved(object sender, PluginInfrastructureEventArgs e) {
79      foreach (string fileName in (IEnumerable<string>)e.Entity)
80        Console.WriteLine("Deleted: {0}", fileName);
81    }
82
83    void installManager_PreInstallPlugin(object sender, PluginInfrastructureCancelEventArgs e) {
84
85    }
86
87    void installManager_PluginInstalled(object sender, PluginInfrastructureEventArgs e) {
88
89    }
90
91    private static bool GetUserConfirmation() {
92      Console.Write("Are you sure? (Y/n)");
93      string input = Console.ReadLine().ToUpperInvariant();
94      if (string.IsNullOrEmpty(input) || input == "Y") return true;
95      else return false;
96    }
97
98    public void Show(IEnumerable<string> pluginNames) {
99      //foreach (string pluginName in pluginNames)
100      //  Console.WriteLine(installManager.GetInformation(pluginName));
101    }
102
103    public void Install(IEnumerable<string> pluginNames) {
104      //installManager.Install(connectionString, pluginNames);
105    }
106
107    public void Remove(IEnumerable<string> pluginNames) {
108      // installManager.Remove(pluginNames);
109    }
110
111    public void Update(IEnumerable<string> pluginNames) {
112      // installManager.Update(connectionString, pluginNames);
113    }
114  }
115}
Note: See TracBrowser for help on using the repository browser.