public Outing(TypeOfEvent eventType, int numberOfPeople, DateTime dateOfEvent, double costPerPerson) { EventType = eventType; NumberOfPeople = numberOfPeople; DateOfEvent = dateOfEvent; CostPerPerson = costPerPerson; }
public Outing(TypeOfEvent eventType, int attendance, DateTime eventDate, decimal perPersonCost) { EventType = eventType; Attendance = attendance; EventDate = eventDate; PerPersonCost = perPersonCost; TotalEventCost = attendance * perPersonCost; }
public Outings(TypeOfEvent what, int guests, DateTime date, double individual, double total) { OutingType = what; attendees = guests; dateOfEvent = date; costIndividual = individual; costTotal = total; }
public Outings(DateTime dateOfOuting, int numberOfPeople, decimal costPerPerson, decimal costForEvent, TypeOfEvent eventType) { DateOfOuting = dateOfOuting; NumberOfPeople = numberOfPeople; CostPerPerson = costPerPerson; CostForEvent = costForEvent; EventType = eventType; }
public static void TriggerEvent(TypeOfEvent theType, EventInfo triggerInfo) { MyUnityEvent thisEvent = null; if (eventManager.eventDictionary.TryGetValue(theType, out thisEvent)) { thisEvent.Invoke(triggerInfo); } }
/// <summary> /// Llamamos a este método para desuscribirnos de eventos /// </summary> /// <param name="eventType"></param> /// <param name="listener"></param> public static void UnsubscribeToEvent(TypeOfEvent eventType, EventReceiver listener) { if (_events != null) { if (_events.ContainsKey(eventType)) { _events[eventType] -= listener; } } }
public void ReadUsersFromFile() { try { using (BinaryReader b = new BinaryReader( File.Open("UserData.txt", FileMode.Open))) { int pos = 0; int length = (int)b.BaseStream.Length; while (pos < length) { Dictionary <DateTime, BettingsEvents> betsPlacedUser = new Dictionary <DateTime, BettingsEvents>(); string email = b.ReadString(); int age = b.ReadInt32(); string name = b.ReadString(); string surname = b.ReadString(); string login = b.ReadString(); string password = b.ReadString(); string country = b.ReadString(); string phoneNumber = b.ReadString(); decimal balance = b.ReadDecimal(); string valute = b.ReadString(); int betsPlaced = b.ReadInt32(); for (int i = 0; i < betsPlaced; i++) { string eventStartStr = b.ReadString(); DateTime eventStart = DateTime.Parse(eventStartStr); TypeOfEvent typeOfEvent = (TypeOfEvent)b.ReadInt32(); string teamOne = b.ReadString(); double teamOneCoefitient = b.ReadDouble(); decimal teamOneMonetPlaced = b.ReadDecimal(); string teamTwo = b.ReadString(); double teamTwoCoefitient = b.ReadDouble(); decimal teamTwoMoneyPlaced = b.ReadDecimal(); string eventEndStr = b.ReadString(); DateTime eventEnd = DateTime.Parse(eventEndStr); BettingsEvents bettings = new BettingsEvents { TeamOne = teamOne, TeamOneMonetPlaced = teamOneMonetPlaced, TeamOneCoefitient = teamOneCoefitient, TeamTwo = teamTwo, TeamTwoCoefitient = teamTwoCoefitient, TeamTwoMoneyPlaced = teamTwoMoneyPlaced, EventStart = eventStart, EventEnd = eventEnd, }; betsPlacedUser.Add(eventStart, bettings); pos += eventStartStr.Length * 2 + eventEndStr.Length * 2 + sizeof(int) + teamOne.Length * 2 + sizeof(double) * 2 + sizeof(decimal) * 2 + teamTwo.Length * 2; } User user = new User(name, surname, country, login, password, email, phoneNumber, age, balance, valute, betsPlacedUser); betsPlacedUser.Clear(); users.Add(user.Email, user); pos += sizeof(int) + email.Length * 2 + name.Length * 2 + surname.Length * 2 + login.Length * 2 + password.Length * 2 + country.Length * 2 + phoneNumber.Length * 2 + sizeof(decimal) + valute.Length * 2; } } } catch (IOException e) { Console.WriteLine(e.Message + " Cant open file"); } }
public void ReadFromFile() { try { using (BinaryReader b = new BinaryReader( File.Open("BetEvents.txt", FileMode.Open))) { int pos = 0; int length = (int)b.BaseStream.Length; while (pos < length) { List <BettingsEvents> bettings = new List <BettingsEvents>(); pos += sizeof(int); TypeOfEvent typeOfEvent = (TypeOfEvent)b.ReadInt32(); int eventsCount = b.ReadInt32(); pos += sizeof(int); for (int i = 0; i < eventsCount; i++) { string teamOne = b.ReadString(); double teamOneCoefitient = b.ReadDouble(); decimal teamOneMoneyPlaced = b.ReadDecimal(); string teamTwo = b.ReadString(); double teamTwoCoefitient = b.ReadDouble(); decimal teamTwoMoneyPlaced = b.ReadDecimal(); string startStr = b.ReadString(); string endStr = b.ReadString(); DateTime eventStart = DateTime.Parse(startStr); DateTime eventEnd = DateTime.Parse(endStr); BettingsEvents bet = new BettingsEvents { TeamOne = teamOne, TeamTwo = teamTwo, TeamOneCoefitient = teamOneCoefitient, TeamTwoCoefitient = teamTwoCoefitient, TeamOneMonetPlaced = teamOneMoneyPlaced, TeamTwoMoneyPlaced = teamTwoMoneyPlaced, EventStart = eventStart, EventEnd = eventEnd, BettingEvents = typeOfEvent }; bettings.Add(bet); pos += teamOne.Length * 2 + sizeof(double) + sizeof(decimal) + teamTwo.Length * 2 + sizeof(double) + sizeof(decimal) + startStr.Length * 2 + endStr.Length * 2; } bettingEvents.Add(typeOfEvent, bettings); } } } catch (IOException e) { Console.WriteLine(e.Message + " Cant open file"); } }
// return cost by outing type public decimal GetCostByOutingType(TypeOfEvent _type) { decimal _eventTypeCost = 0; foreach (Outing item in _listOfOutings) { if (item.EventType == _type) { _eventTypeCost += item.TotalEventCost; } } return(_eventTypeCost); }
public static void StopListening(TypeOfEvent theType, UnityAction <EventInfo> listener) { if (_eventManager == null) { return; } MyUnityEvent thisEvent = null; if (eventManager.eventDictionary.TryGetValue(theType, out thisEvent)) { thisEvent.RemoveListener(listener); } }
/// <summary> /// Llamamos a este método para suscribirnos a eventos /// </summary> /// <param name="eventType"></param> /// <param name="listener"></param> public static void SubscribeToEvent(TypeOfEvent eventType, EventReceiver listener) { if (_events == null) { _events = new Dictionary <TypeOfEvent, EventReceiver>(); } if (!_events.ContainsKey(eventType)) { _events.Add(eventType, null); } _events[eventType] += listener; }
public double TotalCostByType(TypeOfEvent whatType) { double totalTypeCost = 0; foreach (Outings outing in allOutings) { if (outing.OutingType == whatType) { totalTypeCost += outing.costTotal; } } Console.WriteLine($"${totalTypeCost.ToString()}"); return(totalTypeCost); }
//This method shows a list of outings by different types public List <Outing> ListByType(TypeOfEvent type) { List <Outing> listByType = new List <Outing>(); foreach (Outing outing in _listOfOutings) { if (outing.EventType == type) { listByType.Add(outing); } } return(listByType); }
public Event[] GetNLastEventsBySourceId(int count, int sourceId, TypeOfEvent typeOfEvent = TypeOfEvent.Trigger, TypeOfObjectRelatedEvent relatedEvent = TypeOfObjectRelatedEvent.Trigger) { var response = _event.Get(new Get { objectids = new[]{sourceId}, /* @object = relatedEvent, source = typeOfEvent, sortfield = new[] { "clock" }, sortorder = new[] { "desc" },*/ //limit = count }); return response; }
public static void startListen(TypeOfEvent theType, UnityAction <EventInfo> listener) { MyUnityEvent thisevent = null; if (eventManager.eventDictionary.TryGetValue(theType, out thisevent)) { thisevent.AddListener(listener); } else { thisevent = new MyUnityEvent(); thisevent.AddListener(listener); eventManager.eventDictionary.Add(theType, thisevent); } }
private Dictionary <string, (int yellowCards, int goals)> GetPlayerStats(Match match) { var events = match.HomeTeamEvents.Concat(match.AwayTeamEvents); var goalTypes = new TypeOfEvent[] { TypeOfEvent.Goal, TypeOfEvent.GoalPenalty, TypeOfEvent.GoalOwn }; var playerGoals = GetEventOccurence(goalTypes, events); var yellowCardTypes = new TypeOfEvent[] { TypeOfEvent.YellowCard, TypeOfEvent.YellowCardSecond }; var playerYellowCards = GetEventOccurence(yellowCardTypes, events); var result = match.HomeTeamStatistics.StartingEleven .Concat(match.AwayTeamStatistics.StartingEleven) .ToDictionary(p => p.Name, p => (playerYellowCards.GetValueIfExists(p.Name, 0), playerGoals.GetValueIfExists(p.Name, 0))); return(result); }
/// <summary> /// Sobrecarga con parametros que queramos /// </summary> /// <param name="eventType"></param> /// <param name="parametersWrapper"></param> public static void TriggerEvent(TypeOfEvent eventType, params object[] parametersWrapper) { if (_events == null) { UnityEngine.Debug.LogWarning("No events subscribed"); return; } if (_events.ContainsKey(eventType)) { if (_events[eventType] != null) { _events[eventType](parametersWrapper); } } }
public Event[] GetInRange(DateTime from, DateTime to, int[] hostids, TypeOfEvent typeOfEvent = TypeOfEvent.Trigger, TypeOfObjectRelatedEvent relatedEvent = TypeOfObjectRelatedEvent.Trigger) { if (from == null || to == null) throw new ArgumentNullException(); var response = _event.Get(new Get { time_from = from.ToUnixTime(), time_till = to.ToUnixTime(), @object = relatedEvent, source = typeOfEvent, sortfield = new []{"eventid"}, output = "extend", sortorder = new[] { "desc" } }); return response; }
public TypeOfEvent GetTypeForCost() { TypeOfEvent what = TypeOfEvent.Unknown; int t = 0; Console.WriteLine("What type of event would you like the total cost for?\n" + "1. Golf\n" + "2. Bowling\n" + "3. Amusement Park\n" + "4. Concert"); try { t = Convert.ToInt32(Console.ReadLine()); } catch (Exception e) { Console.WriteLine("Please select a valid option."); } switch (t) { case 1: what = TypeOfEvent.Golf; break; case 2: what = TypeOfEvent.Bowling; break; case 3: what = TypeOfEvent.AmusementPark; break; case 4: what = TypeOfEvent.Concert; break; default: Console.WriteLine("Please select a valid option."); break; } return(what); }
public Outings GetOutingToAdd() { TypeOfEvent what = TypeOfEvent.Unknown; int guests = -1; DateTime date = new DateTime(); double individual = -1; double total = -1; while (what == TypeOfEvent.Unknown) { Console.WriteLine("What type of event are you adding?\n" + "1. Golf\n" + "2. Bowling\n" + "3. Amusement Park\n" + "4. Concert"); string t = Console.ReadLine(); switch (t) { case "1": what = TypeOfEvent.Golf; break; case "2": what = TypeOfEvent.Bowling; break; case "3": what = TypeOfEvent.AmusementPark; break; case "4": what = TypeOfEvent.Concert; break; default: Console.WriteLine("Please select a valid option."); break; } } while (guests == -1) { Console.WriteLine("How many attendees were there?"); string a = Console.ReadLine(); try { guests = Convert.ToInt32(a); } catch (Exception e) { Console.WriteLine("Please enter a valid number of individuals."); } } while (date == new DateTime()) { Console.WriteLine("When did the event take place? (YYYY, MM, DD)"); string d = Console.ReadLine(); try { date = Convert.ToDateTime(d); } catch (Exception e) { Console.WriteLine("Please enter a date in the given format."); } } while (individual == -1) { Console.WriteLine("What was the cost of an individual ticket?"); try { individual = Convert.ToDouble(Console.ReadLine()); } catch (Exception e) { Console.WriteLine("Please enter a valid number"); } } total = guests * individual; Outings outing = new Outings(what, guests, date, individual, total); Console.WriteLine($"Event: {what.ToString()} \n" + $"Guests: {guests} \n" + $"Date: {date.ToShortDateString()} \n" + $"Ticket Cost: ${individual} \n" + $"Total Cost: ${total}"); Console.ReadLine(); return(outing); }
public void AddListenerToList(IEventSubscriber listener, TypeOfEvent typeOfEvent) { //managerList.Add(listener); //managers.Add(listener, typeOfEvent); }
public Event[] GetLastEventForPeriodByHostIds(TimeSpan span, int[]hostids, TypeOfEvent typeOfEvent = TypeOfEvent.Trigger, TypeOfObjectRelatedEvent relatedEvent = TypeOfObjectRelatedEvent.Trigger) { return GetInRange((DateTime.UtcNow - span), DateTime.UtcNow, hostids, typeOfEvent, relatedEvent); }
public Event[] GetLastEventForPeriod(TimeSpan span, TypeOfEvent typeOfEvent = TypeOfEvent.Trigger, TypeOfObjectRelatedEvent relatedEvent = TypeOfObjectRelatedEvent.Trigger) { return GetInRange((DateTime.UtcNow - span), DateTime.UtcNow, null, typeOfEvent, relatedEvent); }
public DerivedEventArgs(TypeOfEvent type) { EventType = type; }
/// <summary> /// Llamamos a esta función para disparar un evento /// </summary> /// <param name="eventType"></param> public static void TriggerEvent(TypeOfEvent eventType) { TriggerEvent(eventType, null); }
public EventPlanners(int id, TypeOfEvent e, string name, DateTime dt, String loc, Double cost, String eventRelatedInformation) { Id = id; EventType = e; Name = name; DateAndTime = dt; Venue = loc; Cost = cost; eveInfo = new EventInformation(eventRelatedInformation); }