Exemple #1
0
        /// <summary>
        /// 检测版本
        /// </summary>
        public void Check()
        {
            try
            {
                latestVersion = ProjectVersion.GetLatestVersion();
                localVersion = ProjectVersion.GetLocalVersion();

                if (localVersion.BuildNumber < latestVersion.BuildNumber)
                {
                    mainWindow.Dispatcher.Invoke(new AskForUpdateEventHandler(AskForUpdate));
                }
                else
                {
                    if (!autoCheck)
                    {
                        mainWindow.Dispatcher.Invoke(ShowMessageBox, MessageBoxType.Infomation, "已经是最新版啦!");
                    }
                }
            }
            catch (WebException we)
            {
                if (!autoCheck)
                {
                    mainWindow.Dispatcher.Invoke(ShowMessageBox, MessageBoxType.Error, "检测新版本出现错误,请检查网络或稍后再试!");
                }
                App.writeLog.Error("检查版本失败", we);
            }
            catch (Exception ex)
            {
                App.writeLog.Error("检查版本失败", ex);
            }
        }
Exemple #2
0
        /// <summary>
        /// 生成本地版本XML
        /// </summary>
        private void GenerateLocalXml()
        {
            try
            {
                ProjectVersion localProjectVersion = new ProjectVersion
                    {
                        AssemblyVersion = Info.AssemblyVersion,
                        BuildNumber = Info.BuildNumber
                    };
                FilesPackage filesPackage = new FilesPackage
                    {
                        FileName = "ListManagerUpdate_" + Info.BuildNumber + ".zip",
                        FileUrl = ""
                    };
                localProjectVersion.NewFilesPackage = filesPackage;

                FileStream fileStream = new FileStream("LocalVersion.xml", FileMode.Create);
                XmlSerializer xmlSerializer = new XmlSerializer(typeof(ProjectVersion));
                xmlSerializer.Serialize(fileStream, localProjectVersion);
            }
            catch (Exception ex)
            {
                App.writeLog.Error("生成本地版本XML失败!", ex);
            }
        }
Exemple #3
0
 public static ProjectVersion GetLocalVersion()
 {
     try
     {
         ProjectVersion localVersion = new ProjectVersion();
         localVersion.BuildNumber = Info.GetBuildNumber(Info.GetDirectory() + "\\ListManager.exe");
         localVersion.AssemblyVersion = Info.GetAssemblyVersion(Info.GetDirectory() + "\\ListManager.exe");
         return localVersion;
     }
     catch
     {
         throw;
     }
 }