/// <summary> /// Install the specified package /// </summary> public void Install(string packageId) { try { if (ApplicationContext.Current.GetService <INetworkInformationService>().IsNetworkAvailable) { var amiClient = new AmiServiceClient(ApplicationContext.Current.GetRestClient("ami")); amiClient.Client.Credentials = this.GetCredentials(amiClient.Client); amiClient.Client.ProgressChanged += (o, e) => ApplicationContext.Current.SetProgress(String.Format(Strings.locale_downloading, packageId), e.Progress); amiClient.Client.Description.Endpoint[0].Timeout = 30000; // Fetch the applet package using (var ms = amiClient.DownloadApplet(packageId)) { var package = AppletPackage.Load(ms); this.m_tracer.TraceInfo("Upgrading {0}...", package.Meta.ToString()); ApplicationContext.Current.GetService <IAppletManagerService>().Install(package, true); // ApplicationContext.Current.Exit(); // restart } } else { return; } } catch (Exception ex) { this.m_tracer.TraceError("Error contacting AMI: {0}", ex.Message); throw new InvalidOperationException(Strings.err_updateFailed); } }
public static void GetApplet(AppletParameter parms) { foreach (var itm in parms.AppletId) { Console.Write("( ) Downloading {0} > {0}.pak", itm); using (var rmtstream = m_client.DownloadApplet(itm)) using (var stream = File.Create(itm + ".pak")) rmtstream.CopyTo(stream); Console.CursorLeft = 1; Console.Write("100%"); Console.WriteLine(); } }
/// <summary> /// Install the specified package /// </summary> public void Install(string packageId) { try { if (ApplicationContext.Current.GetService <INetworkInformationService>().IsNetworkAvailable) { var amiClient = new AmiServiceClient(ApplicationContext.Current.GetRestClient("ami")); using (this.Authenticate(amiClient.Client, out Credentials credentials)) { amiClient.Client.Credentials = credentials; amiClient.Client.ProgressChanged += (o, e) => ApplicationContext.Current.SetProgress(string.Format(Strings.locale_downloading, packageId), e.Progress); amiClient.Client.Description.Endpoint[0].Timeout = 30000; // Fetch the applet package if (string.IsNullOrEmpty(this.m_configuration.AppletSolution)) { using (var ms = amiClient.DownloadApplet(packageId)) { var package = AppletPackage.Load(ms); this.m_tracer.TraceInfo("Upgrading {0}...", package.Meta.ToString()); ApplicationContext.Current.GetService <IAppletManagerService>().Install(package, true); ApplicationServiceContext.Current.GetService <ITickleService>().SendTickle(new Tickle(Guid.Empty, TickleType.Information, string.Format(Strings.locale_updateInstalled, package.Meta.Id, package.Meta.Version))); // ApplicationContext.Current.Exit(); // restart } } else { using (var ms = new MemoryStream(amiClient.Client.Get($"AppletSolution/{this.m_configuration.AppletSolution}/applet/{packageId}"))) { var package = AppletPackage.Load(ms); this.m_tracer.TraceInfo("Upgrading {0}...", package.Meta.ToString()); ApplicationContext.Current.GetService <IAppletManagerService>().Install(package, true); ApplicationServiceContext.Current.GetService <ITickleService>().SendTickle(new Tickle(Guid.Empty, TickleType.Information, string.Format(Strings.locale_updateInstalled, package.Meta.Id, package.Meta.Version))); // ApplicationContext.Current.Exit(); // restart } } } } } catch (Exception ex) { this.m_tracer.TraceError("Error contacting AMI: {0}", ex.Message); throw new InvalidOperationException(Strings.err_updateFailed); } }