/// <summary> /// Method that loads history from the corresponding .xml file into the class attribute /// </summary> public void LoadHistory() { if (File.Exists(HISTORY_PATH)) { Stream stream = File.Open(HISTORY_PATH, FileMode.Open); SoapFormatter formatter = new SoapFormatter(); try { CurrentHistory = (Models.History)formatter.Deserialize(stream); } catch (Exception e) { CurrentHistory = new Models.History(); } stream.Close(); } else { Stream stream = File.Open(HISTORY_PATH, FileMode.Create); stream.Close(); this.CurrentHistory = new Models.History(); } if (this.CurrentHistory == null) { throw new Exceptions.InvalidValuedVariableException("CurrentHistory has not been correctly loaded."); } }
private void hslist_Tapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e) { Models.History item = hslist.SelectedItem as Models.History; if (item != null) { Frame.Navigate(typeof(Detail_P), item.Aid, new Windows.UI.Xaml.Media.Animation.DrillInNavigationTransitionInfo()); } }
private bool Filters(object obj) { Models.History history = obj as Models.History; if (history.TransactionType.ToLower().Contains(_Filter) || history.TransactionAmount.ToString().ToLower().Contains(_Filter) || history.Provider.Company.ToLower().Contains(_Filter) || history.Date.ToString("d").ToLower().Contains(_Filter)) { return(true); } else { return(false); } }
/// <summary> /// Add a history record to the SchoolBus /// </summary> /// <param name="text">text for the history entry</param> /// <param name="smUserId">Site Minder User ID for the history entry</param> public void AddHistory(string text, string smUserId) { if (this.History == null) { this.History = new List <History>(); } History history = new Models.History() { LastUpdateTimestamp = DateTime.UtcNow, LastUpdateUserid = smUserId, HistoryText = text }; this.History.Add(history); }
public void EmptyHistory() { this.CurrentHistory = new History(); }
/// <summary> /// Method that returns the list of <seealso cref="Models.HistoryItem"/> from an instance of History /// </summary> /// <param name="history">Instance of <seealso cref="Models.History"/> from which we want to extract <seealso cref="Models.HistoryItem"/></param> /// <returns><seealso cref="ArrayList"/>: List of <seealso cref="HistoryItem"/></returns> public static ArrayList GetListOfItemsFromHistory(Models.History history) { return(history.HistoryOfAddresses); }
private async Task UpdateDetails(Match match, IBinder binder, ILogger log) { foreach (var player in match.players) { if (player.account_id == CATCH_ALL_ACCOUNT) { continue; } var attr = new BlobAttribute(string.Format(DETAILS_PATH, player.account_id)); var blob = await binder.BindAsync <CloudBlockBlob>(attr); Action <PlayerDetail> updateFn = (model) => { var date = DateTimeOffset.FromUnixTimeSeconds(match.start_time); model.History.Add(new Models.History() { MatchId = match.match_id, Region = metaClient.GetRegionId(match.cluster), Date = date, Hero = player.hero_id, Victory = match.Victory(player), Abilities = player.GetAbilities(metaClient).Select(_ => _.Id).ToList() }); foreach (var p in match.players) { if (p.account_id == CATCH_ALL_ACCOUNT) { continue; } if (p.account_id == player.account_id) { continue; } // If Exists var combatant = model.Combatants.Find(_ => _.AccountId == p.account_id); if (combatant == null) { combatant = new Models.PlayerSummary() { AccountId = p.account_id, }; model.Combatants.Add(combatant); } var history = new Models.History() { MatchId = match.match_id, Region = metaClient.GetRegionId(match.cluster), Date = date, Hero = p.hero_id, Victory = match.Victory(p), Abilities = p.GetAbilities(metaClient).Select(_ => _.Id).ToList() }; if (p.GetTeam() == player.GetTeam()) { combatant.With.Add(history); } else { combatant.Against.Add(history); } } }; await ProcessBlob(blob, updateFn, log); } }
public ActionResult History() { var Downloads = new Models.History(true); return View(Downloads); }
public static void TestHistoryController() { Controllers.HistoryController HistoryController = new Controllers.HistoryController(); HistoryController.EmptyHistory(); HistoryController.AddAddress("http://test1.com", false); HistoryController.AddAddress("http://test2.com", false); HistoryController.AddAddress("http://www.amazon.co.uk", false); Console.WriteLine(String.Format("\n[{0}] ---- TEST HISTORY CONTROLLER ----", DateTime.Now)); // // Testing SortHistory Method // Console.WriteLine(String.Format("[{0}] Testing SortHistory Method...", DateTime.Now)); try { Console.WriteLine(String.Format("[{0}] Sorting with 'test', 2 results expected..", DateTime.Now)); Models.History History = HistoryController.SortHistory("test"); if (History.HistoryOfAddresses.Count == 2) { WriteLinePassed(String.Format("[{0}] Test passed..", DateTime.Now)); } else { WriteLineNotPassed(String.Format("[{0}] Test not passed...", DateTime.Now)); } } catch (Exception e) { WriteLineNotPassed(String.Format("[{0}] Test not passed...", DateTime.Now)); } try { Console.WriteLine(String.Format("[{0}] Sorting with null, exception expected..", DateTime.Now)); Models.History History = HistoryController.SortHistory(null); WriteLineNotPassed(String.Format("[{0}] Test not passed...", DateTime.Now)); } catch (Exceptions.InvalidValuedVariableException e) { WriteLinePassed(String.Format("[{0}] Test passed..", DateTime.Now)); } // // Testing AddAddress Method // Console.WriteLine(String.Format("[{0}] Testing AddAddress Method...", DateTime.Now)); try { Console.WriteLine(String.Format("[{0}] Adding null..", DateTime.Now)); HistoryController.AddAddress(null); WriteLineNotPassed(String.Format("[{0}] Test not passed...", DateTime.Now)); } catch (Exceptions.InvalidValuedVariableException e) { WriteLinePassed(String.Format("[{0}] Test passed..", DateTime.Now)); } // // Testing GetAddressAt Method // Console.WriteLine(String.Format("[{0}] Testing GetAddressAt Method...", DateTime.Now)); try { Console.WriteLine(String.Format("[{0}] Getting first element..", DateTime.Now)); HistoryController.GetAddressAt(0); WriteLinePassed(String.Format("[{0}] Test passed...", DateTime.Now)); } catch (Exception e) { WriteLineNotPassed(String.Format("[{0}] Test not passed..", DateTime.Now)); } try { Console.WriteLine(String.Format("[{0}] Getting out of bounds (-1) element..", DateTime.Now)); HistoryController.GetAddressAt(-1); WriteLineNotPassed(String.Format("[{0}] Test not passed...", DateTime.Now)); } catch (IndexOutOfRangeException e) { WriteLinePassed(String.Format("[{0}] Test passed..", DateTime.Now)); } }