private void startResumingUpdate(List <string> needDownloadFiles)
    {
        bar.UpdateProgress(0);

        string dataPath = Util.DataPath;  //数据目录
        string url      = Config.User_Config.web_url + "/";
        string random   = DateTime.Now.ToString("yyyymmddhhmmss");

        resumingUpdates = new List <IThreadWorkerObject>();
        for (int i = 0; i < needDownloadFiles.Count; i++)
        {
            var      file     = needDownloadFiles[i].TrimEnd('\r');
            string[] keyValue = file.Split('|');

            string f         = keyValue[0];
            string localfile = (dataPath + f).Trim();

            string fileUrl = string.Concat(url, keyValue[0], "?v=", random);
            string md5     = keyValue[1].Trim();

            string localMd5 = PlayerPrefs.GetString(f + "_md5", "");
            if (!localMd5.Equals(md5) || !File.Exists(localfile))
            {
                //更新:
                //1.本地文件与资源服不一致
                //2.本地文件丢失
                ResumingUpdateExecutor updateExe = new ResumingUpdateExecutor();

                updateExe.DownloadUrl = fileUrl;
                updateExe.LocalPath   = localfile;
                updateExe.FileName    = f;
                updateExe.SrcMD5      = md5;
                updateExe.FileSize    = Convert.ToInt64(keyValue[2]);
                updateExe.OnComplete  = OnUpdateChangeStatus;
                updateExe.OnWorkDone  = StartResumingDownload;
                resumingUpdates.Add(updateExe);
            }
            else
            {
                downloadedSize += Convert.ToInt64(keyValue[2]);
            }
        }

        if (resumingUpdates.Count <= 0)
        {
            //异常情况: 如果不存在更新文件时
            this.onThreadWorkComplete(null);
        }
        else
        {
            //更新当前的进度
            float percent = (float)downloadedSize / (float)totalSize;
            bar.SetMessage(string.Format("{0}({1}/{2})", LanguageTips.DOWNLOAD_FILE_ING,
                                         GameManager.GetSizeString(downloadedSize),
                                         GameManager.GetSizeString(totalSize)));
            bar.UpdateProgress(percent);
            resumingUpdates[0].ExecuteThreadedWork();
        }
    }
 public void UpdateResumingDownloadProgress()
 {
     if (resumingUpdates != null && resumingUpdates.Count > 0)
     {
         ResumingUpdateExecutor executor = resumingUpdates[0] as ResumingUpdateExecutor;
         if (executor != null)
         {
             long  curSize = downloadedSize + executor.GetCurrentDownloadSize();
             float percent = (float)curSize / (float)totalSize;
             bar.SetMessage(string.Format("{0}({1}/{2})", LanguageTips.DOWNLOAD_FILE_ING,
                                          GameManager.GetSizeString(curSize),
                                          GameManager.GetSizeString(totalSize)));
             bar.UpdateProgress(percent);
         }
     }
 }
    /// <summary>
    /// 单个下载完成
    /// </summary>
    /// <param name="finishedObject"></param>
    private void onWorkObjectDone(IThreadWorkerObject finishedObject)
    {
        ResumingUpdateExecutor updateExe = finishedObject as ResumingUpdateExecutor;

        Debugger.Log(string.Format("Download file>>{0}", updateExe.DownloadUrl));


        downloadedSize += updateExe.FileSize;
        float percent = (float)downloadedSize / (float)totalSize;

        bar.SetMessage(string.Format("{0}({1}/{2})", LanguageTips.DOWNLOAD_FILE_ING,
                                     GameManager.GetSizeString(downloadedSize),
                                     GameManager.GetSizeString(totalSize)));
        bar.UpdateProgress(percent);

        downloadFiles.Add(updateExe.FileName);

        //检查下载文件的合法性,是否更新一致
        if (!updateExe.SrcMD5.Equals(updateExe.DownloadFileMD5))
        {
            if (!downloadErrorFiles.Contains(updateExe.FileName))
            {
                downloadErrorFiles.Add(updateExe.FileName);
            }
        }
        else
        {
            if (downloadErrorFiles.Contains(updateExe.FileName))
            {
                downloadErrorFiles.Remove(updateExe.FileName);
            }

            if (beginPackDownload)
            {
                Util.CallMethod("Game", "OnOnePackFileDownload", updateExe.LocalPath);
            }
            LuaHelper.GetGameManager().SetMd5(updateExe.FileName, updateExe.DownloadFileMD5, downloadFiles.Count % 3 == 0);
        }
    }