Beispiel #1
0
        void downloadInfo()
        {
            try
            {
                IsBusy = true;

                string rssXml = tryDownloadRss();
                rssXml = cacheManager(rssXml);

                if (string.IsNullOrWhiteSpace(rssXml))
                {
                    IsBusy = false;
                    return;
                }

                VersionsInfoData.Clear();
                VersionsInfoData = DownloadHistory.ParseInfo(rssXml);
            }
            catch (Exception ex)
            {
                ExceptionLogger.LogExceptionToFile(ex);
                LogWindow.AddMessage(LogType.Error, ex.Message);
            }
            finally
            {
                IsBusy = false;
            }
        }
        // Public Methods (1)

        public static VersionsInfo ParseInfo(string rssXml)
        {
            var result = new VersionsInfo();
            var rss    = Deserializer.MapToRss(rssXml);

            var channels = rss.channel;

            foreach (var channel in channels)
            {
                var items = channel.item;
                foreach (var item in items)
                {
                    var author = item.author.StripHtmlTags().UnescapeXml();
                    if (string.IsNullOrWhiteSpace(author))
                    {
                        continue;
                    }

                    var desc = fixDescription(item);
                    result.Add(
                        new VersionInfo
                    {
                        Author      = author,
                        Description = desc.UnescapeXml(),
                        Link        = item.link.StripHtmlTags(),
                        PubDate     = DateTime.Parse(item.pubDate, CultureInfo.InvariantCulture),
                        Title       = item.title.StripHtmlTags().UnescapeXml()
                    });
                }
            }

            return(result);
        }
Beispiel #3
0
        /// <summary>
        /// 检查程序版本
        /// </summary>
        /// <param name="type"></param>
        /// <returns>
        /// true 表示版本一致不需要更新
        /// false 表示有异常,需要更新
        /// </returns>
        public static bool Update(SoftwareType type)
        {
            //if (SysConfig.IsTest)
            //    return true;
            VersionsInfo vi = LocalDataService.GetVersionsInfo((int)type);

            if (vi == null)
            {
                MessageBox.Show("检查软件版本时异常,软件即将关闭,请检查网络连接是否正常,再重启软件",
                                "提示", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return(false);
            }

            string currentVersion = Application.ProductVersion;

            if (vi.Version != currentVersion)
            {
                //需要更新版本
                MessageBox.Show(
                    string.Format("当前程序有更新版本,点击确定开始更新,请耐心等待...\r\n(升级完成后程序将自动重启)"),
                    "提示", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                string path = Application.StartupPath + @"\" + "HLAUpdate.exe";
                if (File.Exists(path))
                {
                    StringBuilder sb = new StringBuilder();
                    sb.Append(vi.DownloadUrl);
                    sb.Append(" ");
                    sb.Append(currentVersion);
                    sb.Append(" ");
                    sb.Append(vi.Version);
                    sb.Append(" ");
                    string log = vi.UpdateLog.Replace(' ', '_');
                    if ("" == log)
                    {
                        log = "log";
                    }
                    sb.Append(log);
                    sb.Append(" ");
                    sb.Append(Application.ProductName);
                    var process = Process.Start(path, sb.ToString());
                    Application.Exit();
                }
                else
                {
                    MessageBox.Show("自动升级模块损坏,或已不存在,请联系开发商解决!",
                                    "提示", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                }
                return(false);
            }
            else
            {
                return(true);
            }
        }
        void UpdateLatestCompatibleDCCPlugin(VersionsInfo versionsInfo)
        {
            PackageVersion pluginVer = MeshSyncEditorConstants.GetPluginVersion();

            foreach (string dccPluginVerStr in versionsInfo.all)
            {
                //Skip incompatible versions
                if (!IsPackageVersionCompatible(dccPluginVerStr, pluginVer, out PackageVersion dccPluginVer))
                {
                    continue;
                }

                if (null == m_latestCompatibleDCCPluginVersion ||
                    dccPluginVer.GetPatch() > m_latestCompatibleDCCPluginVersion.GetPatch())
                {
                    m_latestCompatibleDCCPluginVersion = dccPluginVer;
                }
            }
        }
Beispiel #5
0
        void UpdateLatestCompatibleDCCPlugin(VersionsInfo versionsInfo)
        {
            foreach (string dccPluginVer in versionsInfo.all)
            {
                bool parsed = PackageVersion.TryParse(dccPluginVer, out PackageVersion dccPluginPackageVersion);
                Assert.IsTrue(parsed);

                //Skip incompatible versions
                if (dccPluginPackageVersion.Major != MeshSyncEditorConstants.PACKAGE_VERSION.Major ||
                    dccPluginPackageVersion.Minor != MeshSyncEditorConstants.PACKAGE_VERSION.Minor)
                {
                    continue;
                }

                if (null == m_latestCompatibleDCCPluginVersion ||
                    dccPluginPackageVersion.Patch > m_latestCompatibleDCCPluginVersion.Patch)
                {
                    m_latestCompatibleDCCPluginVersion = dccPluginPackageVersion;
                }
            }
        }
        void UpdateLatestCompatibleDCCPlugin(VersionsInfo versionsInfo)
        {
            PackageVersion pluginVer = MeshSyncEditorConstants.GetPluginVersion();

            foreach (string dccPluginVer in versionsInfo.all)
            {
                bool parsed = PackageVersion.TryParse(dccPluginVer, out PackageVersion dccPluginPackageVersion);
                Assert.IsTrue(parsed);

                //Skip incompatible versions
                if (dccPluginPackageVersion.GetMajor() != pluginVer.GetMajor() ||
                    dccPluginPackageVersion.GetMinor() != pluginVer.GetMinor())
                {
                    continue;
                }

                if (null == m_latestCompatibleDCCPluginVersion ||
                    dccPluginPackageVersion.GetPatch() > m_latestCompatibleDCCPluginVersion.GetPatch())
                {
                    m_latestCompatibleDCCPluginVersion = dccPluginPackageVersion;
                }
            }
        }
Beispiel #7
0
 public AboutViewModel()
 {
     VersionsInfoData = new VersionsInfo();
     new Thread(downloadInfo).Start();
 }