Exemple #1
0
 public static void ParseVersionFile(string txt, ref VersionFileModel versionFile)
 {
     string[] content = txt.Split('\n');
     if (content != null)
     {
         if (versionFile == null)
         {
             versionFile = new VersionFileModel();
         }
         for (int i = 0; i < content.Length - 1; i++)
         {
             if (!string.IsNullOrEmpty(content[i]))
             {
                 string [] kvp = content[i].Split(',');
                 if (kvp == null || kvp.Length < 3)
                 {
                     Debug.LogError("Can not parse last update file with content " + content[i]);
                     return;
                 }
                 versionFile.files[kvp[0]] = new VersionFileInfo(kvp[1], kvp[2]);
             }
         }
         versionFile.resVersion = content[content.Length - 1];
     }
 }
Exemple #2
0
        public static string ConvertVersionFileToString(VersionFileModel versionFile)
        {
            StringBuilder sb = new StringBuilder();

            foreach (KeyValuePair <string, VersionFileInfo> kvp in versionFile.files)
            {
                string content = string.Format("{0},{1},{2}\n", kvp.Key, kvp.Value.md5, kvp.Value.version);
                sb.Append(content);
            }
            sb.Append(versionFile.resVersion);
            return(sb.ToString());
        }
        void DownloadUpdateFiles(int index, float delay = -1)
        {
            if (index >= _needUpdateFileList.Count)
            {
                //下载完所有更新文件之后,写入新的updateFile
                _lastVersionFile = _versionFileOnServer;
                WriteVersionFileToDisk();
                return;
            }
            Debug.Log("Begin download update files " + _needUpdateFileList[index]);
            string version     = _versionFileOnServer.files[_needUpdateFileList[index]].version;
            string downloadUrl = string.Format("{0}/{1}/{2}", _serverResult.downloadBaseUrl, version, _needUpdateFileList[index]);

            DownloadMgr.instance.Download(downloadUrl, OnUpdateFileDownloadFinised);
        }
Exemple #4
0
 static VersionFileModel LoadVersionFileOnDisk()
 {
     _versionFile = new VersionFileModel();
     if (File.Exists(_verionFileName))
     {
         try
         {
             string content = File.ReadAllText(_verionFileName);
             VersionHelper.ParseVersionFile(content, ref _versionFile);
         }
         catch (Exception ex)
         {
             throw new Exception("Load UpdateFile Error:" + ex.Message);
             return(null);
         }
     }
     return(_versionFile);
 }