コード例 #1
0
        void OnReadEvent(HttpClientResponse response, long totalReadBytes)
        {
            if (totalReadBytes >= response.MaxReadBytes)
            {
                HttpClientStrResponse r = response as HttpClientStrResponse;
                string fileList         = r.Txt;
                if (string.IsNullOrEmpty(fileList))
                {
                    AutoUpdateMgr.Instance.EndAutoUpdate();
                    return;
                }

                string writePath   = AutoUpdateMgr.Instance.WritePath;
                string srcFileName = string.Format("{0}/{1}", writePath, AutoUpdateMgr._cFileListTxt);
                if (!File.Exists(srcFileName))
                {
                    // 直接生成写到update.txt里
                    ResListFile resListFile = AutoUpdateMgr.Instance.ServerResListFile;
                    resListFile.Load(fileList);
                    ResListFile.ResDiffInfo[] infos = resListFile.AllToDiffInfos();

                    AutoUpdateMgr.Instance.UpdateToUpdateTxt(infos);
                    AutoUpdateMgr.Instance.UpdateTotalDownloadBytes(infos);

                    ToNextState();
                    return;
                }

                ResListFile srcListFile = AutoUpdateMgr.Instance.LocalResListFile;
                ResListFile dstListFile = AutoUpdateMgr.Instance.ServerResListFile;

                dstListFile.Load(fileList);

                ResListFile.ResDiffInfo[] diffInfos = srcListFile.GetDiffInfos(dstListFile);

                AutoUpdateMgr.Instance.UpdateToUpdateTxt(diffInfos);
                AutoUpdateMgr.Instance.UpdateTotalDownloadBytes(diffInfos);
                ToNextState();
            }
        }
コード例 #2
0
        void OnReadEvent(HttpClientResponse response, long totalReadBytes)
        {
            if (totalReadBytes >= response.MaxReadBytes)
            {
                HttpClientStrResponse r = response as HttpClientStrResponse;
                string zipVerList       = r.Txt;
                if (string.IsNullOrEmpty(zipVerList))
                {
                    AutoUpdateMgr.Instance.CurrUpdateZipFileMd5 = string.Empty;
                    ToNextStatus();
                    return;
                }

                string oldVer      = AutoUpdateMgr.Instance.LocalResVersion;
                string newVer      = AutoUpdateMgr.Instance.CurrServeResrVersion;
                string zipFileName = ZipTools.GetZipFileName(oldVer, newVer);

                ResListFile zipFiles = new ResListFile();
                zipFiles.Load(zipVerList);

                ResListFile.ResDiffInfo[] diff;
                if (!zipFiles.FileToDiffInfo(zipFileName, out diff) || diff == null ||
                    string.IsNullOrEmpty(diff[0].fileContentMd5) ||
                    diff[0].fileSize <= 0)
                {
                    AutoUpdateMgr.Instance.CurrUpdateZipFileMd5 = string.Empty;
                    ToNextStatus();
                    return;
                }

                AutoUpdateMgr.Instance.UpdateToUpdateTxt(diff);
                AutoUpdateMgr.Instance.UpdateTotalDownloadBytes(diff);
                AutoUpdateMgr.Instance.CurrUpdateZipFileMd5 = diff[0].fileContentMd5;
                ToNextStatus();
            }
        }
コード例 #3
0
        void DoFileListTxt(string fileList)
        {
            if (string.IsNullOrEmpty(fileList))
            {
                AutoUpdateMgr.Instance.EndAutoUpdate();
                return;
            }

            string writePath   = AutoUpdateMgr.Instance.WritePath;
            string srcFileName = StringHelper.Format("{0}/{1}", writePath, AutoUpdateMgr._cFileListTxt);

            if (!File.Exists(srcFileName))
            {
                // 直接生成写到update.txt里
                ResListFile resListFile = AutoUpdateMgr.Instance.ServerResListFile;
                resListFile.Load(fileList);
                ResListFile.ResDiffInfo[] infos = resListFile.AllToDiffInfos();

                AutoUpdateMgr.Instance.UpdateToUpdateTxt(infos);
                AutoUpdateMgr.Instance.UpdateTotalDownloadBytes(infos);

                ToNextState();
                return;
            }

            ResListFile srcListFile = AutoUpdateMgr.Instance.LocalResListFile;
            ResListFile dstListFile = AutoUpdateMgr.Instance.ServerResListFile;

            dstListFile.Load(fileList);

            ResListFile.ResDiffInfo[] diffInfos = srcListFile.GetDiffInfos(dstListFile);

            AutoUpdateMgr.Instance.UpdateToUpdateTxt(diffInfos);
            AutoUpdateMgr.Instance.UpdateTotalDownloadBytes(diffInfos);
            ToNextState();
        }