Esempio n. 1
0
        private async Task InstallOrUpdatePlugins(IList <Plugin> plugins)
        {
            if (_semaphore.Wait(100))
            {
                try
                {
                    var tasks = new List <Task>();
                    foreach (var plug in plugins)
                    {
                        var pluginDownloader = new PluginDownloader(plug, false, _api, _updateHub, _coreServer,
                                                                    _loader, false);

                        tasks.Add(pluginDownloader.Download());
                    }

                    await Task.WhenAll(tasks.ToArray());

                    _coreServer.Restart();
                }
                finally
                {
                    _semaphore.Release();
                }
            }
        }
Esempio n. 2
0
        private async void WebClient_DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
        {
            var automaticaPluginUpdateFile = Path.Combine(ServerInfo.GetTempPath(), ServerInfo.PluginUpdateDirectoryName, _plugin.AzureFileName);

            try
            {
                if (e.Error == null && !e.Cancelled)
                {
                    await _updateHub.Clients.All.SendAsync("PluginFinished", new object[] { _plugin.PluginGuid });

                    if (_install)
                    {
                        if (await _api.InstallPlugin(_plugin, automaticaPluginUpdateFile))
                        {
                            await _pluginLoader.LoadPlugin(_plugin);
                        }
                    }
                    else
                    {
                        if (_restartOnUpdate)
                        {
                            _coreServer.Restart();
                        }
                    }
                }
            }
            finally
            {
                if (_install && File.Exists(automaticaPluginUpdateFile))
                {
                    File.Delete(automaticaPluginUpdateFile);
                    SystemLogger.Instance.LogDebug($"Remove update file for {_plugin.ComponentName}: {automaticaPluginUpdateFile}");
                }
            }
        }
Esempio n. 3
0
        private async void WebClient_DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
        {
            var automaticaPluginUpdateFile = Path.Combine(Path.GetTempPath(), ServerInfo.PluginUpdateDirectoryName, _plugin.AzureFileName);

            if (e.Error == null && !e.Cancelled)
            {
                await _updateHub.Clients.All.SendAsync("PluginFinished", new object[] { _plugin.PluginGuid });

                if (_install)
                {
                    await _api.InstallPlugin(_plugin, automaticaPluginUpdateFile);

                    _coreServer.LoadPlugin(_plugin);
                }
                else
                {
                    if (_restartOnUpdate)
                    {
                        _coreServer.Restart();
                    }
                }
            }
        }
Esempio n. 4
0
 public void Restart()
 {
     _coreServer.Restart();
 }