void OpenWith() { string check = FileTest.FileCheck(OpenWithDirectory); switch (check) { case "RS2": byte[] bytes = File.ReadAllBytes(OpenWithDirectory); string JSON = Encoding.ASCII.GetString(bytes); FilesClass Files; Files = JsonUtility.FromJson <FilesClass>(JSON); CreatedWithCache = Files.CreatedWith; ScouterCache = Files.Scouter; QuestionsCount = Files.QuestionsInt; QuestionsType = Files.QuestionsType; QuestionsData = Files.Questions; AnswersData = Files.Answers; StartCoroutine(LoadQuestions(true)); Match = MatchNumber.text; Team = TeamNumber.text; DeleteButton.SetActive(true); NewFileCheck = true; Manager.GetComponent <ErrorManager>().Log("Scouting file " + MatchNumber.text + "-" + TeamNumber.text + ".rs loaded"); break; case "RS1.5": Manager.GetComponent <ErrorManager>().Error(MatchNumber.text + "-" + TeamNumber.text + ".rs is a RS1.5 scouting file and is unsupported in RS2"); break; case "RS1": string[] ScoutFiles = RS1Files.LoadRS1Files(OpenWithDirectory); Manager.GetComponent <ErrorManager>().Log(MatchNumber.text + "-" + TeamNumber.text + ".rs has been loaded in RS1 compatibility mode"); break; case "Error": Manager.GetComponent <ErrorManager>().Error(MatchNumber.text + "-" + TeamNumber.text + ".rs is unreadable"); break; } }
public static string FileCheck(string Directory) { string Test; string CreatedWith; string Scouter; int QuestionsCount; int[] QuestionsType; string[] QuestionsData; string[] AnswersData; byte[] bytes = File.ReadAllBytes(Directory); string JSON = Encoding.ASCII.GetString(bytes); FilesClass Files; try { Files = JsonUtility.FromJson <FilesClass>(JSON); try { if (Files.SaveVersion == "v1") { CreatedWith = Files.CreatedWith; Scouter = Files.Scouter; QuestionsCount = Files.QuestionsInt; QuestionsType = Files.QuestionsType; QuestionsData = Files.Questions; AnswersData = Files.Answers; Test = "RS2"; } else { Test = "Future"; } } catch (Exception) { Test = "Error"; } } catch (ArgumentException) { try { string[] ScoutFiles = RS1Files.LoadRS1Files(Directory); if (ScoutFiles[0] != "RSFSV1") { Test = "RS1"; } else { Test = "RS1.5"; } } catch (Exception) { Test = "Error"; } } return(Test); }
IEnumerator ExportCSV(string path) { List <string> AllFiles = GetFiles(); List <string> InfoFiles = new List <string>(); List <FilesClass> CompFiles = new List <FilesClass>(); int ErrorsCount = 0; IgnoreButton.SetActive(false); OverwriteButton.SetActive(false); ConfirmButton.SetActive(false); PackageManager.SetActive(true); Title.text = "Exporting " + Path.GetFileName(path); Total.text = "Scouting files to export: " + AllFiles.Count; DateInfo.text = "Created on " + DateTime.Now.Month.ToString() + "/" + DateTime.Now.Day.ToString() + "/" + DateTime.Now.Year.ToString() + ":v1"; int Current = 1; foreach (string Directory in AllFiles) { Percent.text = (Current / AllFiles.Count) * 100 + "%"; CurrentFile.text = "Exporting file " + Current + "/" + AllFiles.Count; string check = FileTest.FileCheck(Directory); switch (check) { case "Future": ErrorsCount++; break; case "RS2": byte[] bytesfile = File.ReadAllBytes(Directory); string JSONfile = Encoding.ASCII.GetString(bytesfile); FilesClass Files; Files = JsonUtility.FromJson <FilesClass>(JSONfile); InfoFiles.Add(Path.GetFileNameWithoutExtension(Directory)); CompFiles.Add(Files); break; case "RS1.5": ErrorsCount++; break; case "RS1": string[] ScoutFiles = RS1Files.LoadRS1Files(Directory); FilesClass FilesRS1 = new FilesClass(); FilesRS1.CreatedWith = "RS1"; FilesRS1.LastOpenedWith = "Unknown"; FilesRS1.Scouter = "Unknown"; FilesRS1.QuestionsInt = 11; FilesRS1.QuestionsType = new int[11] { 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1 }; FilesRS1.Questions = new string[11] { "Unknown Title", "Unknown Question", "Unknown Question", "Unknown Title", "Unknown Question", "Unknown Question", "Unknown Question", "Unknown Title", "Unknown Question", "Unknown Question", "Comment" }; FilesRS1.Answers = new string[11] { "", ScoutFiles[0], ScoutFiles[1], "", ScoutFiles[2], ScoutFiles[3], ScoutFiles[4], "", ScoutFiles[5], ScoutFiles[6], ScoutFiles[7] }; InfoFiles.Add(Path.GetFileNameWithoutExtension(Directory)); CompFiles.Add(FilesRS1); break; case "Error": ErrorsCount++; break; } Current++; Errors.text = "Exported: " + CompFiles.Count + " Errors: " + ErrorsCount.ToString(); } string[] Rounds = new string[InfoFiles.Count]; string[] Teams = new string[InfoFiles.Count]; int i; i = 0; foreach (string Round in Rounds) { Rounds[i] = InfoFiles[i].Split('-')[0]; } i = 0; foreach (string Team in Teams) { Teams[i] = InfoFiles[i].Split('-')[1]; } string[] Output; if (IgnoreQuestions.isOn) { Output = new string[10]; int x = 0; int y = 0; foreach (FilesClass File in CompFiles) { } } else { Output = new string[1]; } StreamWriter outputFile = new StreamWriter(path); foreach (string line in Output) { outputFile.WriteLine(line); } outputFile.Close(); if (ErrorsCount == 0) { Manager.GetComponent <ErrorManager>().Log("Scouting package exported as " + Path.GetFileName(path)); } else { Manager.GetComponent <ErrorManager>().Warning("Scouting package exported as " + Path.GetFileName(path) + " with " + ErrorsCount + " Errors"); } ConfirmButton.SetActive(true); yield return(null); }
IEnumerator ExportRSE(string path) { List <string> AllFiles = GetFiles(); List <string> InfoFiles = new List <string>(); List <FilesClass> CompFiles = new List <FilesClass>(); int ErrorsCount = 0; IgnoreButton.SetActive(false); OverwriteButton.SetActive(false); ConfirmButton.SetActive(false); PackageManager.SetActive(true); Title.text = "Exporting " + Path.GetFileName(path); Total.text = "Scouting files to export: " + AllFiles.Count; DateInfo.text = "Created on " + DateTime.Now.Month.ToString() + "/" + DateTime.Now.Day.ToString() + "/" + DateTime.Now.Year.ToString() + ":v1"; int Current = 1; foreach (string Directory in AllFiles) { Percent.text = (Current / AllFiles.Count) * 100 + "%"; CurrentFile.text = "Exporting file " + Current + "/" + AllFiles.Count; string check = FileTest.FileCheck(Directory); switch (check) { case "Future": ErrorsCount++; break; case "RS2": byte[] bytesfile = File.ReadAllBytes(Directory); string JSONfile = Encoding.ASCII.GetString(bytesfile); FilesClass Files; Files = JsonUtility.FromJson <FilesClass>(JSONfile); InfoFiles.Add(Path.GetFileNameWithoutExtension(Directory)); CompFiles.Add(Files); break; case "RS1.5": ErrorsCount++; break; case "RS1": string[] ScoutFiles = RS1Files.LoadRS1Files(Directory); FilesClass FilesRS1 = new FilesClass(); FilesRS1.CreatedWith = "RS1"; FilesRS1.LastOpenedWith = "Unknown"; FilesRS1.Scouter = "Unknown"; FilesRS1.QuestionsInt = 11; FilesRS1.QuestionsType = new int[11] { 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1 }; FilesRS1.Questions = new string[11] { "Unknown Title", "Unknown Question", "Unknown Question", "Unknown Title", "Unknown Question", "Unknown Question", "Unknown Question", "Unknown Title", "Unknown Question", "Unknown Question", "Comment" }; FilesRS1.Answers = new string[11] { "", ScoutFiles[0], ScoutFiles[1], "", ScoutFiles[2], ScoutFiles[3], ScoutFiles[4], "", ScoutFiles[5], ScoutFiles[6], ScoutFiles[7] }; InfoFiles.Add(Path.GetFileNameWithoutExtension(Directory)); CompFiles.Add(FilesRS1); break; case "Error": ErrorsCount++; break; } Current++; Errors.text = "Exported: " + CompFiles.Count + " Errors: " + ErrorsCount.ToString(); } FilesPackageClass Package = new FilesPackageClass { SaveVersion = "v1", Date = DateTime.Now.Month.ToString() + "/" + DateTime.Now.Day.ToString() + "/" + DateTime.Now.Year.ToString(), FilesCount = InfoFiles.Count, FilesInfo = InfoFiles.Select(i => i).ToArray(), Files = CompFiles.Select(i => i).ToArray() }; string JSON = JsonUtility.ToJson(Package, false); byte[] bytes = Encoding.ASCII.GetBytes(JSON); File.WriteAllBytes(path, bytes); if (ErrorsCount == 0) { Manager.GetComponent <ErrorManager>().Log("Scouting package exported as " + Path.GetFileName(path)); } else { Manager.GetComponent <ErrorManager>().Warning("Scouting package exported as " + Path.GetFileName(path) + " with " + ErrorsCount + " Errors"); } ConfirmButton.SetActive(true); yield return(null); }
void Open() { string Directory = FilesDataClass.FilePathSaves + "/" + MatchNumber.text + "-" + TeamNumber.text + ".rs"; string check = FileTest.FileCheck(Directory); string[] ScoutFiles; switch (check) { case "Future": QuestionsCount = 0; QuestionsType = null; QuestionsData = null; AnswersData = null; StartCoroutine(LoadQuestions(true)); SetFile(); Manager.GetComponent <ErrorManager>().Warning(MatchNumber.text + "-" + TeamNumber.text + ".rs is from a future version and is unreadable in " + Application.version); break; case "RS2": byte[] bytes = File.ReadAllBytes(Directory); string JSON = Encoding.ASCII.GetString(bytes); FilesClass Files; Files = JsonUtility.FromJson <FilesClass>(JSON); CreatedWithCache = Files.CreatedWith; ScouterCache = Files.Scouter; QuestionsCount = Files.QuestionsInt; QuestionsType = Files.QuestionsType; QuestionsData = Files.Questions; AnswersData = Files.Answers; StartCoroutine(LoadQuestions(true)); SetFile(); Manager.GetComponent <ErrorManager>().Log("Scouting file " + MatchNumber.text + "-" + TeamNumber.text + ".rs loaded"); break; case "RS1.5": /*ScoutFiles = RS1Files.LoadRS1Files(Directory); * CreatedWithCache = "RS1.5"; * ScouterCache = "Unknown"; * QuestionsCount = 11; * foreach (string Part in ScoutFiles) * { * Debug.Log(Part); * } * string[] Type = new string[7] {ScoutFiles[1][0].ToString(), ScoutFiles[1][1].ToString(), ScoutFiles[1][2].ToString(), ScoutFiles[1][3].ToString(), ScoutFiles[1][4].ToString(), ScoutFiles[1][5].ToString(), ScoutFiles[1][6].ToString(), }; * QuestionsType = new int[11] { 0, int.Parse(Type[0]), int.Parse(Type[1]), 0, int.Parse(Type[2]), int.Parse(Type[3]), int.Parse(Type[4]), 0, int.Parse(Type[5]), int.Parse(Type[6]), 1 }; * QuestionsData = new string[11] { "Unknown Title", "Unknown Question", "Unknown Question", "Unknown Title", "Unknown Question", "Unknown Question", "Unknown Question", "Unknown Title", "Unknown Question", "Unknown Question", "Comment" }; * AnswersData = new string[11] { "", ScoutFiles[0], ScoutFiles[1], "", ScoutFiles[2], ScoutFiles[3], ScoutFiles[4], "", ScoutFiles[5], ScoutFiles[6], ScoutFiles[7] }; * StartCoroutine(LoadQuestions(true)); * SetFile(); * Manager.GetComponent<ErrorManager>().Log(MatchNumber.text + "-" + TeamNumber.text + ".rs has been loaded in RS1.5 compatibility mode");*/ QuestionsCount = 0; QuestionsType = null; QuestionsData = null; AnswersData = null; StartCoroutine(LoadQuestions(true)); SetFile(); Manager.GetComponent <ErrorManager>().Warning(MatchNumber.text + "-" + TeamNumber.text + ".rs is a RS1.5 scouting file and is incompatible with RS2"); break; case "RS1": ScoutFiles = RS1Files.LoadRS1Files(Directory); CreatedWithCache = "RS1"; ScouterCache = "Unknown"; QuestionsCount = 11; QuestionsType = new int[11] { 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1 }; QuestionsData = new string[11] { "Unknown Title", "Unknown Question", "Unknown Question", "Unknown Title", "Unknown Question", "Unknown Question", "Unknown Question", "Unknown Title", "Unknown Question", "Unknown Question", "Comment" }; AnswersData = new string[11] { "", ScoutFiles[0], ScoutFiles[1], "", ScoutFiles[2], ScoutFiles[3], ScoutFiles[4], "", ScoutFiles[5], ScoutFiles[6], ScoutFiles[7] }; StartCoroutine(LoadQuestions(true)); SetFile(); Manager.GetComponent <ErrorManager>().Log(MatchNumber.text + "-" + TeamNumber.text + ".rs has been loaded in RS1 compatibility mode"); break; case "Error": QuestionsCount = 0; QuestionsType = null; QuestionsData = null; AnswersData = null; StartCoroutine(LoadQuestions(true)); SetFile(); Manager.GetComponent <ErrorManager>().Error(MatchNumber.text + "-" + TeamNumber.text + ".rs is unreadable"); break; } }
public void GenerateQR() { CurrentQR = 0; string Data = ""; List <string> AllFiles = GetFiles(); List <string> InfoFiles = new List <string>(); List <FilesClass> CompFiles = new List <FilesClass>(); int ErrorsCount = 0; int Current = 1; foreach (string Directory in AllFiles) { string check = FileTest.FileCheck(Directory); switch (check) { case "Future": ErrorsCount++; break; case "RS2": byte[] bytesfile = File.ReadAllBytes(Directory); string JSONfile = Encoding.ASCII.GetString(bytesfile); FilesClass Files; Files = JsonUtility.FromJson <FilesClass>(JSONfile); InfoFiles.Add(Path.GetFileNameWithoutExtension(Directory)); CompFiles.Add(Files); break; case "RS1.5": ErrorsCount++; break; case "RS1": string[] ScoutFiles = RS1Files.LoadRS1Files(Directory); FilesClass FilesRS1 = new FilesClass { CreatedWith = "RS1", LastOpenedWith = "Unknown", Scouter = "Unknown", QuestionsInt = 11, QuestionsType = new int[11] { 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1 }, Questions = new string[11] { "Unknown Title", "Unknown Question", "Unknown Question", "Unknown Title", "Unknown Question", "Unknown Question", "Unknown Question", "Unknown Title", "Unknown Question", "Unknown Question", "Comment" }, Answers = new string[11] { "", ScoutFiles[0], ScoutFiles[1], "", ScoutFiles[2], ScoutFiles[3], ScoutFiles[4], "", ScoutFiles[5], ScoutFiles[6], ScoutFiles[7] } }; InfoFiles.Add(Path.GetFileNameWithoutExtension(Directory)); CompFiles.Add(FilesRS1); break; case "Error": ErrorsCount++; break; } Current++; } FilesQRClass Package = new FilesQRClass { FilesCount = InfoFiles.Count, FilesInfo = InfoFiles.Select(i => i).ToArray(), Files = CompFiles.Select(i => i).ToArray() }; Data = JsonUtility.ToJson(Package, false); if (UseHighDensity.isOn) { if (UseCompression.isOn) { Compress(Data, true, true); } else { Compress(Data, true, false); } } else { if (UseCompression.isOn) { Compress(Data, false, true); } else { Compress(Data, false, false); } } }