/// <summary> /// 第4步:过滤出要更新的所有文件 /// </summary> private void CheckFilesToUpdate() { if (curWaiting >= _waitingList.Count)//完成 { _isAllFileListReady = true; if (_isSureToUpdateVersion) { DownloadVersion(); } return; } string sVersion = _waitingList[curWaiting]._strVersion; string xmlUrl = _strDownloadUrl + sVersion + "/filespath.xml"; WWWLoadTask task = new WWWLoadTask("", xmlUrl);//下载该版本的文件列表xml task.EventFinished += new task.TaskBase.FinishedHandler(delegate(bool manual, TaskBase currentTask) { if (manual) { return; } WWW _download = currentTask.GetWWW(); if (_download == null || _download.text.Length == 0) { _versionType = VersionType.Error; _errorCode = ErrorCode.DownLoadFileListXMLFailed; return;//下载版本信息文件失败 } RecordFilesNeedToDownload(_download.text, sVersion); curWaiting++; CheckFilesToUpdate();//继续下个版本 }); }
public LoadFileList(List <FileMD5Node> fileList, string sVersion, string downloadUrl) { _sVersion = sVersion; for (int i = 0; i < fileList.Count; i++) { _waittingFilesList.Add(fileList[i]); //下载资源 string _strFileUrl = downloadUrl + sVersion + "/" + fileList[i]._path; WWWLoadTask task = new WWWLoadTask(fileList[i]._path, _strFileUrl, fileList[i]._md5); _tasks.Add(task); task.EventFinished += new task.TaskBase.FinishedHandler(delegate(bool manual, TaskBase currentTask) { if (manual) { return; } WWW _download = currentTask.GetWWW(); if (_download == null || _download.bytes.Length == 0) { LoadError(VersionData.ErrorCode.DownLoadFileFailed); return; } WWWLoadTask wwwTask = currentTask as WWWLoadTask; LoadFileCallback(_download, wwwTask._strTaskName, wwwTask._strMD5); }); } }
/// <summary> /// 第1步:下载版本列表xml /// </summary> private void DownloadVersionsXML() { WWWLoadTask task = new WWWLoadTask("", _strVersionXMLUrl); task.EventFinished += new task.TaskBase.FinishedHandler(delegate(bool manual, TaskBase currentTask) { if (manual) { return; } WWW _download = currentTask.GetWWW(); if (_download == null || _download.text.Length == 0) { _versionType = VersionType.Error; _errorCode = ErrorCode.DownLoadVersionXMLFailed; return;//下载版本信息文件失败 } //解释版本列表xml。 ParseVersionsXML(_download.text); CheckVersionsToUpdate(); }); }