public void LoadAndTransferRecords(string path) { List <string> files = Directory.EnumerateFiles(path, "*" + ScoutingJson.MatchRecordExtension, SearchOption.TopDirectoryOnly).ToList(); foreach (string f in files) { if (!f.EndsWith(ScoutingJson.MatchRecordExtension)) { continue; } string fn = Util.GetFileName(f, false); int position = GetPositionFromFilename(fn); RecordedMatch rec = ScoutingJson.ParseMatchRecord(f); rec.PostJsonLoading(Event); Records[position] = rec; OnPropertyChanged("CanMerge"); MarkReady(position); bool result = MoveFileToEventPath(f); } }
public void MergeMatchRecords() { foreach (RecordedMatch record in Records) { Merging.AdjustTeamInfo(Event, record); } Match merged = Merging.Merge(Event, Records[0], Records[1], Records[2], Records[3], Records[4], Records[5]); int index = Event.Matches.FindIndex((m) => m.Number == merged.Number); if (index != -1) { Event.Matches[index] = merged; } else { Event.Matches.Add(merged); } ScoutingJson.SaveEvent(Event, SavePath + Event.EventName + ScoutingJson.EventExtension); ArchiveRecords(merged.Number); Records = new RecordedMatch[6]; OnPropertyChanged("CanMerge"); }
public UpdateViewModel() { _checkedPaths = new ObservableCollection <UpdateModel>(); ProcessSelectedCmd = new DoStuffCommand(() => ProcessPath(SelectedPathModel), obj => true); MergeMatchCmd = new DoStuffCommand(MergeMatchRecords, obj => true); SuperTimer = new DispatcherTimer(); SuperTimer.Interval = TimeSpan.FromSeconds(2); SuperTimer.Tick += SuperTimer_Tick; SuperTimer.IsEnabled = true; Records = new RecordedMatch[6]; bool prettifySetup = false; RedA = new TeamIndicator(false, -1); RedB = new TeamIndicator(false, -1); RedC = new TeamIndicator(false, -1); BlueA = new TeamIndicator(true, -1); BlueB = new TeamIndicator(true, -1); BlueC = new TeamIndicator(true, -1); if (prettifySetup) { RedA.IsReady = true; RedC.IsReady = true; BlueB.IsReady = true; BlueA.IsReady = true; } _processAllNewFolders = false; }