public void LoadAutosave(string InFilename) { try { FileStream File = new FileStream(InFilename, FileMode.Open); CurData = DiffData.Load(File); File.Close(); } catch (System.Exception e) { Debug.Log("Load autosave exception: " + e.Message); } }
public void ReceiveDiffData(string JudgeGuid, string InData) { DiffData NewDiffData = DiffData.Load(Global.GenerateStreamFromString(InData)); if (NewDiffData != null) { TeamData TData = Global.GetTeamData(NewDiffData.Division, NewDiffData.Round, NewDiffData.Pool, NewDiffData.Team); if (TData != null) { bool bNewScore = TData.RoutineScores.SetDiffResults(NewDiffData); OnRecievedResultsData(bNewScore); } } }
public override void RecoverAutosave() { base.RecoverAutosave(); BackupList.Clear(); string BackupPath = Application.persistentDataPath + "/Backup"; string[] Files = Directory.GetFiles(BackupPath); foreach (string filename in Files) { if (filename.Contains("DiffBackup")) { BackupDiffData backup = new BackupDiffData(); try { FileStream BackupFile = new FileStream(filename, FileMode.Open); backup.Data = DiffData.Load(BackupFile); backup.Filename = filename; BackupFile.Close(); } catch (System.Exception e) { Debug.Log("Load autosave exception: " + e.Message); } backup.WrittenTime = File.GetLastWriteTime(filename); BackupList.Add(backup); } } BackupList.Sort( delegate(BackupDiffData b1, BackupDiffData b2) { if (b1 == b2) { return(0); } else if (b1.WrittenTime < b2.WrittenTime) { return(1); } else { return(-1); } }); // Delete old backup files if (BackupList.Count > Global.MaxBackupFileCount) { for (int FileIndex = Global.MaxBackupFileCount; FileIndex < BackupList.Count; ++FileIndex) { try { File.Delete(BackupList[FileIndex].Filename); } catch (System.Exception e) { Debug.Log("Delete old backup files exception: " + e.Message); } } while (BackupList.Count > Global.MaxBackupFileCount) { BackupList.RemoveAt(Global.MaxBackupFileCount); } } }