コード例 #1
0
ファイル: AppletCmdlet.cs プロジェクト: chochohtunn/santedb
        public static void ListApplets()
        {
            var applets = m_client.GetApplets();

            DisplayUtil.TablePrint(applets.CollectionItem.OfType <AppletManifestInfo>(),
                                   new String[] { "ID", "Name", "Version", "Publisher", "S" },
                                   new int[] { 25, 25, 10, 58, 2 },
                                   o => o.AppletInfo.Id,
                                   o => o.AppletInfo.Names.FirstOrDefault().Value,
                                   o => o.AppletInfo.Version,
                                   o => o.AppletInfo.Author,
                                   o => o.PublisherData != null ? "*" : null
                                   );
        }
コード例 #2
0
ファイル: AmiUpdateManager.cs プロジェクト: santedb/openizdc
        /// <summary>
        /// Check for updates
        /// </summary>
        public void AutoUpdate()
        {
            // Check for updates
            if (ApplicationContext.Current.GetService <INetworkInformationService>().IsNetworkAvailable)
            {
                try
                {
                    ApplicationContext.Current.SetProgress(Strings.locale_updateCheck, 0.5f);

                    // Check for new applications
                    var amiClient = new AmiServiceClient(ApplicationContext.Current.GetRestClient("ami"));
                    amiClient.Client.Credentials = this.GetCredentials(amiClient.Client);
                    amiClient.Client.Description.Endpoint[0].Timeout = 10000;
                    if (amiClient.Ping())
                    {
                        amiClient.Client.Description.Endpoint[0].Timeout = 30000;
                        foreach (var i in amiClient.GetApplets().CollectionItem)
                        {
                            var installed = ApplicationContext.Current.GetService <IAppletManagerService>().GetApplet(i.AppletInfo.Id);
                            if (installed == null ||
                                new Version(installed.Info.Version) < new Version(i.AppletInfo.Version) &&
                                ApplicationContext.Current.Configuration.GetSection <AppletConfigurationSection>().AutoUpdateApplets&&
                                ApplicationContext.Current.Confirm(String.Format(Strings.locale_upgradeConfirm, i.AppletInfo.Names[0].Value, i.AppletInfo.Version, installed.Info.Version)))
                            {
                                this.Install(i.AppletInfo.Id);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    this.m_tracer.TraceError("Error checking for updates: {0}", ex.Message);
                }
            }
            ;
            this.m_checkedForUpdates = true;
        }
コード例 #3
0
        /// <summary>
        /// Update all apps
        /// </summary>
        public void UpdateAll()
        {
            try
            {
                ApplicationContext.Current.SetProgress(Strings.locale_updateCheck, 0.5f);

                // Check for new applications
                var amiClient = new AmiServiceClient(ApplicationContext.Current.GetRestClient("ami"));
                using (this.Authenticate(amiClient.Client, out Credentials credentials))
                {
                    amiClient.Client.Credentials = credentials;
                    amiClient.Client.Description.Endpoint[0].Timeout = 30000;
                    if (amiClient.Ping())
                    {
                        var solution = this.m_configuration.AppletSolution;
                        IEnumerable <AppletManifestInfo> infos = null;
                        if (!string.IsNullOrEmpty(solution))
                        {
                            infos = amiClient.Client.Get <AmiCollection>($"AppletSolution/{solution}/applet").CollectionItem.OfType <AppletManifestInfo>();
                        }
                        else
                        {
                            infos = amiClient.GetApplets().CollectionItem.OfType <AppletManifestInfo>();
                        }

                        amiClient.Client.Description.Endpoint[0].Timeout = 30000;
                        List <AppletManifestInfo> toInstall = new List <AppletManifestInfo>();
                        foreach (var i in infos)
                        {
                            var installed = ApplicationContext.Current.GetService <IAppletManagerService>().GetApplet(i.AppletInfo.Id);
                            if ((installed == null ||
                                 new Version(installed.Info.Version) < new Version(i.AppletInfo.Version) &&
                                 this.m_configuration.AutoUpdateApplets))
                            {
                                toInstall.Add(i);
                            }
                        }

                        if (toInstall.Count > 0 && ApplicationContext.Current.Confirm(string.Format(Strings.locale_upgradeConfirm, String.Join(",", toInstall.Select(o => o.AppletInfo.GetName("en", true))))))
                        {
                            foreach (var i in toInstall)
                            {
                                this.Install(i.AppletInfo.Id);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                if (!this.m_errorTickle)
                {
                    ApplicationServiceContext.Current.GetService <ITickleService>().SendTickle(new Tickle(Guid.Empty, TickleType.Danger, string.Format(Strings.locale_updateCheckFailed, ex.GetType().Name)));
                    this.m_errorTickle = true;
                }
                this.m_tracer.TraceError("Error checking for updates: {0}", ex.Message);
            }
            finally
            {
                ApplicationContext.Current.SetProgress(Strings.locale_idle, 1.0f);
            }
        }