Пример #1
0
        private static bool FetchUpdatePackage(VersionUpdateInfo updateInfo)
        {
            string updatePackageLocalFile = Path.Combine(UPDATE_PACKAGE_PATH, string.Format("{0}.zip", updateInfo.MD5));
            bool downloadResult = false;
            bool resolveResult = false;
            int downloadTimes = 0;
            do
            {
                downloadResult = DownloadUpdatePackage(updateInfo.Url, updatePackageLocalFile);
                if (downloadResult)
                {
                    resolveResult = ResolveUpdatePackage(updateInfo, updatePackageLocalFile);
                    if (resolveResult)
                    {
                        break;
                    }
                }
                downloadTimes++;
            } while (downloadTimes < RETRY_TIMES);

            if (downloadResult && resolveResult)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
Пример #2
0
        private static bool ResolveUpdatePackage(VersionUpdateInfo updateInfo, string updatePackageLocalFile)
        {
            bool isMatch;
            MD5Helper.FileMD5ErrorMode errCode;
            isMatch = CheckUpdatePackageMD5(updatePackageLocalFile, updateInfo.MD5, out errCode);
            if (errCode != MD5Helper.FileMD5ErrorMode.OK || !isMatch)
            {
                return false;
            }
            string upzipUpdatePackagePath = Path.Combine(UNZIP_UPDATE_PACKAGE_PATH, updateInfo.MD5);
            if (!UnZipUpdatePackage(updatePackageLocalFile, upzipUpdatePackagePath))
            {
                return false;
            }

            if (GetUpdateDetailsList(Path.Combine(upzipUpdatePackagePath, UPATE_DETAILS_FILE_NAME)))
                return true;
            else
                return false;
        }
Пример #3
0
 private static bool ApplyUpdatePackage(VersionUpdateInfo updateInfo)
 {
     try
     {
         foreach (var item in _updateDetailsList)
         {
             if (item.Type == TargetType.File)
             {
                 IOHelper.CopyFile(Path.Combine(Path.Combine(UNZIP_UPDATE_PACKAGE_PATH, updateInfo.MD5), item.UpdateSource), Path.Combine(CURRENT_PATH, item.UpdateTarget));
             }
             else if (item.Type == TargetType.Folder)
             {
                 IOHelper.CopyFolder(Path.Combine(Path.Combine(UNZIP_UPDATE_PACKAGE_PATH, updateInfo.MD5), item.UpdateSource), Path.Combine(CURRENT_PATH, item.UpdateTarget));
             }
         }
     }
     catch (Exception ex)
     {
         System.Console.WriteLine("StartOldSoftWare:Move directory error," + ex.ToString());
         return false;
     }
     return true;
 }