Example #1
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}");
                }
            }
        }
Example #2
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();
                    }
                }
            }
        }