예제 #1
0
 private void Timer_Elapsed(object sender, ElapsedEventArgs e)
 {
     if (VZDownloadManager.getSingleton().getCallback() != null)
     {
         request4VersionInfo();
     }
 }
예제 #2
0
 public static VZDownloadManager getSingleton()
 {
     if (singleton == null)
     {
         singleton = new VZDownloadManager();
     }
     return(singleton);
 }
예제 #3
0
        void checkVersion()
        {
            if (versionInfo == null || versionInfo.version == null)
            {
                return;
            }
            long currentBuild = VZ_AppHelper.GetInstance().systemInfo.build;            //当前版本
            long onlineBuild  = versionInfo.build;                                      //线上最新版本
            long updateBuild  = VZ_AppHelper.GetInstance().systemInfo.updateBuild;      //正在更新的版本

            //if(onlineBuild == currentBuild || onlineBuild != updateBuild)
            //{
            //    Properties.Settings.Default.isUpdateReady = false;
            //    Properties.Settings.Default.Save();
            //}
            //MessageBox.Show(currentBuild + " " + onlineBuild + " " + updateBuild + " ready?" + Properties.Settings.Default.isUpdateReady);

            if (onlineBuild > currentBuild)
            {
                if (onlineBuild == updateBuild)
                {
                    updateVRZone();
                }
                else if (currentBuild != updateBuild)
                {
                    if (VZDownloadManager.getSingleton().isUpdating())
                    {
                        VZDownloadManager.getSingleton().pause();
                    }
                    try
                    {
                        if (Directory.Exists(VZDownloadManager.getSingleton().updatePath))
                        {
                            Directory.Delete(VZDownloadManager.getSingleton().updatePath, true);
                        }
                    }
                    catch (Exception ex)
                    {
                        Scratch.Log.LogConfig.Logger.Error("出错:", ex);
                    }
                    VZ_AppHelper.GetInstance().systemInfo.updateBuild = VZ_AppHelper.GetInstance().systemInfo.build;
                    updateList = "";
                    updateVRZone();
                }
                else
                {
                    updateVRZone();
                }
            }
        }
예제 #4
0
        void updateVRZone()
        {
            if (updateList == null || updateList.Equals("") || updateList.Equals("\"\""))
            {
                getUpdateList();
            }
            if (VZDownloadManager.getSingleton().isUpdating())
            {
                return;
            }

            String currentJsonPath = AppDomain.CurrentDomain.BaseDirectory + @"Update\current.json";

            VZ_AppHelper.GetInstance().systemInfo.updateBuild = versionInfo.build;
            saveBuildInfo();
            VZDownloadManager.getSingleton().setUpdateList(updateList, versionInfo.build, VZMethods.readFileToString(currentJsonPath));
            VZDownloadManager.getSingleton().start(null);
        }
예제 #5
0
 public void runUpdateApp()
 {
     if (!Directory.Exists(VZDownloadManager.getSingleton().updatePath))
     {
         checkVersion();
     }
     else
     {
         //启动更新程序,0 关闭主程序 1 覆盖项目,2 生成新的md5,3 删除更新文件
         try
         {
             Process proc = new Process();
             proc.StartInfo.FileName = AppDomain.CurrentDomain.BaseDirectory + "VRZoneUpdater.exe";
             proc.Start();
             Application.Current.Shutdown(-1);
         }
         catch (Exception ex)
         {
             Scratch.Log.LogConfig.Logger.Error("出错:", ex);
         }
     }
 }