private void AddDataObjectToCollection(object t) { if (null != _transactionDataSet) { _transactionDataSet.Add(t); return; } lock (_dataSyncObject) { try { _data.Add(t); } catch (Exception x) { AllRecords.Add( new ErrorRecord( x, "SeeShell.DataSource.AddDataException", ErrorCategory.InvalidOperation, t ) ); } EnforceDataCollectionLimit(); } }
/// <summary> /// Add a new record in list of records. /// Can trace all used records after reading a plugin. /// </summary> /// <param name="recordName"> /// The record Name. /// </param> public static void AddRecordToRecordsList(string recordName) { if (AllRecords.IndexOf(recordName, 0) == -1) { AllRecords.Add(recordName); AllRecords.Add(Environment.NewLine); } }
/* * Loads from database all the words scheduled to be reviewed * today. This is calculated based on NextSchedule. */ public void LoadReviewWords() { DateTime today = DateTime.Now; ReviewRecords = new List <Record>(); ReviewRecords = AllRecords.Where( x => x.NextSchedule.CompareTo(today) == 0).ToList(); }
/// <summary> /// Clear all list /// </summary> public static void ClearList() { if (CompressedRecords != null) { CompressedRecords.Clear(); } if (AllRecords != null) { AllRecords.Clear(); } }
/* * Loads from database NewWordsPerDay number of new words, if * there are still enough words to load. */ public void LoadNewWords() { //DateTime today = DateTime.Now.Date; NewRecords = new List <Record>(); var allNewRecords = AllRecords.Where(x => x.TimesStudied == 0).ToList(); if (allNewRecords.Count < NewWordsPerDay) { NewRecords = allNewRecords; } else { if (Shuffle) { // Use the Fisher-Yates shuffle algorithm to shuffle // the indices, and keep the first NewWordsPerDay number // of them. int[] inds = new int[allNewRecords.Count]; for (int i = 0; i < inds.Length; i++) { inds[i] = i; } for (int i = 0; i < Math.Min(NewWordsPerDay, allNewRecords.Count); i++) { // Swap inds[i] with inds[k] for some random k >= i // Upperbound is not inclusive. int k = new Random().Next(i, allNewRecords.Count); int tmp = inds[k]; inds[k] = inds[i]; // We will no longer modify inds[i] = inds[k], so might // as well just add the element here NewRecords.Add(allNewRecords[tmp]); } } else { NewRecords = allNewRecords.GetRange(0, NewWordsPerDay); } } NumNewRecords = NewRecords.Count; //Console.WriteLine(IsListUnique(NewRecords)); }
/* * Loads from database NewWordsPerDay number of new words, if * there are still enough words to load. */ public void LoadNewWords() { // All the unencountered words will have next scheduled date // earlier than any date since the last call to InitDatabase(). //DateTime today = DateTime.Now.Date; NewRecords = new List <Record>(); var allNewRecords = AllRecords.Where(x => x.TimesStudied == 0).ToList(); if (allNewRecords.Count < NewWordsPerDay) { NewRecords = allNewRecords; } else { if (Shuffle) { // Use the Fisher-Yates shuffle algorithm to shuffle // the indices, and keep the first NewWordsPerDay number // of them. int[] inds = new int[allNewRecords.Count]; for (int i = 0; i < inds.Length; i++) { inds[i] = i; } for (int i = 0; i < NewWordsPerDay; i++) { // Swap inds[i] with inds[k] for some random k >= i // Upperbound is not inclusive. int k = new Random().Next(i, allNewRecords.Count); inds[k] = i; // We will no longer modify inds[i] = k, so might // as well just add the element here NewRecords.Add(allNewRecords[k]); } } else { NewRecords = allNewRecords.GetRange(0, NewWordsPerDay); } } }
bool TryConfigureAxes(SolidPSObjectBase o) { try { return(ConfigureAxes(o)); } catch (Exception e) { if (null != AllRecords && null != Dispatcher) { Dispatcher.BeginInvoke( (Action) (() => AllRecords.Add(new ErrorRecord(e, "SeeShell.Charts.AxisConfiguration", ErrorCategory.InvalidData, this)))); } return(true); } }
public void LoadAllRecords() { if (!Directory.Exists(RecordsRoot)) { return; } DirectoryInfo root = new DirectoryInfo(RecordsRoot); List <DirectoryInfo> teamInfos = root.EnumerateDirectories().ToList(); teamInfos.RemoveAll((di) => !di.Name.IsInteger()); AllRecords.Clear(); foreach (DirectoryInfo di in teamInfos) { List <RecordLite> recordSet = new List <RecordLite>(); List <FileInfo> recordFiles = di.EnumerateFiles().ToList(); foreach (FileInfo fi in recordFiles) { RecordLite rec = ScoutingJson.ParseLiteRecord(fi.FullName); if (Event != null && Teams != null) { rec.PostJsonLoading(Event); } recordSet.Add(rec); } AllRecords.Add(recordSet); } if (!hasCrunched) { DoCrunching(); } }
private void DebugRecordAdded(object sender, DataAddedEventArgs e) { var record = _powerShell.Streams.Debug[e.Index]; AllRecords.Add(record); }