// 새로운 버전의 패치 정보를 추가 bool AddNewVersionPatchInfo(int NextVersion, List <PatchFileInfo> PatchFileInfoList) { // 다음 버전이 현재 패치정보파일의 마지막 버전보다 작으면 에러 // 다음 버전이 현재 패치정보파일의 마지막 버전보다 같으면 마지막 정보를 제거한다. int LastVersion = GetLastVersion(); if (LastVersion > NextVersion) { MessageBox.Show(string.Format("Invalid NextVersion {0}", NextVersion)); return(false); } else if (LastVersion == NextVersion) { PatchVersionInfoList.RemoveAt(PatchVersionInfoList.Count - 1); } PatchVersionInfo NewPatchInfo = new PatchVersionInfo(); NewPatchInfo.VersionNumber = NextVersion; foreach (PatchFileInfo fileinfo in PatchFileInfoList) { NewPatchInfo.Add(fileinfo.FileName, fileinfo.FileSize, fileinfo.FileCRC); } PatchVersionInfoList.Add(NewPatchInfo); return(true); }
// 패치정보 파일을 읽는다. bool ReadPatchInfoFile(string FullPathFileName) { bool bResult = false; PatchVersionInfoList.Clear(); if (false == File.Exists(FullPathFileName)) { //MessageBox.Show("have not file"); return(bResult); } try { StreamReader sr = File.OpenText(FullPathFileName); string JsonText = sr.ReadToEnd(); // http://james.newtonking.com/pages/json-net.aspx // http://james.newtonking.com/projects/json/help/LINQtoJSON.html JObject root = JObject.Parse(JsonText); JArray VersionList = (JArray)root["VERSION_LIST"]; foreach (JObject VersionInfo in VersionList) { PatchVersionInfo patchinfo = new PatchVersionInfo(); patchinfo.VersionNumber = (int)VersionInfo["Version"]; JArray FileInfos = (JArray)VersionInfo["Files"]; foreach (JObject fileInfo in FileInfos) { patchinfo.Add((string)fileInfo["filename"], (Int64)fileInfo["size"], (Int64)fileInfo["CRC"]); } PatchVersionInfoList.Add(patchinfo); } bResult = true; sr.Close(); } catch (Exception ex) { MessageBox.Show(string.Format("Failed Read PatchInfofile. file:{0}, Error:{1}", FullPathFileName, ex.ToString())); } return(bResult); }