//rkprad: possibly there is a better and simpler way to write the series of add /addnearend /addnearbegin functions internal void Add(double time, double[,] parameters) { if (Count == 0 || time > Times[LastIndex]) //if count =0; then time is added to the first spot //if count =/0 then time is added to the next spot based on lastspot value { Times.Add(time); Parameters.Add(parameters); } else //inserting time at some intermediate value { int ub = LastIndex; //ub = upperbound say 5 int lb = 0; //lb = lower bound int i; //counter do { i = (ub - lb) / 2; //2.5 -> 3 if (Times[i] > time) //Times[3]> { ub = i; } else { lb = i; } } while (ub - lb > 1); Times.Insert(i, time); Parameters.Insert(i, parameters); } LastIndex++; }
internal void AddNearEnd(double time, double[,] parameters) { if (Count == 0 || time > Times[LastIndex]) { Times.Add(time); Parameters.Add(parameters); } else if (time < Times[0]) { Times.Insert(0, time); Parameters.Insert(0, parameters); } else { var i = LastIndex; do { if (Times[i] == time) { return; //if it already exists, just don't add it at all! } i--; } while (i > 0 && Times[i] >= time); Times.Insert(i + 1, time); Parameters.Insert(i + 1, parameters); } LastIndex++; }
public async Task LoadCombos(IConfiguration configuration, IToken Token, int gameId) { var path = configuration.GetValue <string>("API") + "/api"; using (var http = new HttpClient()) { http.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Token.Token); var gameContent = await http.GetAsync($"{path}/game/{gameId}"); Jogo jogo = JsonConvert.DeserializeObject <Jogo>(await gameContent.Content.ReadAsStringAsync()); Times.Add(new SelectListItem() { Value = jogo.Time_1.Id.ToString(), Text = jogo.Time_1.Pais }); Times.Add(new SelectListItem() { Value = jogo.Time_2.Id.ToString(), Text = jogo.Time_2.Pais }); var jogadoresContent = await http.GetAsync(path + "/player"); ICollection <Jogador> jogadores = JsonConvert.DeserializeObject <ICollection <Jogador> >(await jogadoresContent.Content.ReadAsStringAsync()); foreach (var item in jogadores) { Jogadores.Add(new SelectListItem() { Value = item.Id.ToString(), Text = item.Nome }); } } }
private void LoadAvailabilityBlock() { if (AvailabilityBlockId > 0) { try { Client client = AuthenticationHelper.GetClient(); AvailabilityBlock = client.AvailabilityService.GetAvailabilityBlock(AvailabilityBlockId); string weekDaysString = AvailabilityBlock.Weekdays .Replace("Weekdays", "Monday, Tuesday, Wednesday, Thursday, Friday") .Replace("Weekend", "Sunday, Saturday") .Replace("All", "Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday"); WeekDays = new List <string> (Array.ConvertAll(weekDaysString.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries), p => p.Trim())); Times = new List <TimeBlock> (AvailabilityBlock.Times); } catch (CntResponseException ex) { Utility.ShowError(ex); } } else { Times.Add(new TimeBlock() { Start = defaultStart, Duration = defaultDuration }); AvailabilityBlock = new AvailabilityBlock() { UserId = AuthenticationHelper.UserData.UserId, Start = Start, End = End, Times = Times }; } }
public Node Term() { var n1 = Pow(); while (Current == TokenCategory.TIMES) { var n2 = new Times() { AnchorToken = Expect(TokenCategory.TIMES) }; n2.Add(n1); n2.Add(Pow()); n1 = n2; } return(n1); }
static void RunAction(dynamic metadata, dynamic content, string cannotApply, string applied, TimeStatus statusToApply, Func <dynamic, bool> validationCondition) { var parentId = content.ParentId.ToString(); var parentName = content.ParentName.ToString(); var groupKey = metadata.GroupKey.ToString(); var memberKey = metadata.MemberKey.ToString(); var id = metadata.ReferenceKey.ToString(); TimeItem lastTime = LastTime(parentId); if (validationCondition(lastTime)) { var item = new TimeItem { Id = id, ActionTime = DateTimeOffset.Now, ParentId = parentId, ParentName = parentName, Status = statusToApply, MemberKey = memberKey, GroupKey = groupKey }; Times.Add(item); SendFeedbackMessage(type: MsgType.Success, actionTime: GetCreateDate(metadata), action: applied, content: item); if (statusToApply == TimeStatus.Start) { //PauseOtherTask(memberKey, parentId); } } else { SendFeedbackMessage(type: MsgType.Error, actionTime: GetCreateDate(metadata), action: cannotApply, content: content); } }
public Node Term() { var result = Pow(); while (Current == TokenCategory.TIMES) { var node = new Times() { AnchorToken = Expect(TokenCategory.TIMES) }; node.Add(result); node.Add(Pow()); result = node; } return(result); }
internal void AddNearBegin(double time, double[,] parameters) { if (Count == 0 || time > Times[LastIndex]) { Times.Add(time); Parameters.Add(parameters); } else if (time < Times[0]) { Times.Insert(0, time); Parameters.Insert(0, parameters); } else { int i = 0; do { if (Times[i] == time) { return; //if it already exists, just don't add it at all! } i++; } while (Times[i] <= time); Times.Insert(i, time); Parameters.Insert(i, parameters); } LastIndex++; }
public Node Term() { var r = Pow(); while (Current == TokenCategory.TIMES) { var p = new Times() { AnchorToken = Expect(TokenCategory.TIMES) }; p.Add(r); p.Add(Pow()); r = p; } return(r); }
private void AddTimeBlock() { TimeBlock newTime = new TimeBlock() { Start = defaultStart, Duration = defaultDuration }; Times.Add(newTime); availabillityTable.ReloadData(); }
private void time_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Return) { if (!string.IsNullOrEmpty(time.Text) && TimeSpan.TryParse(time.Text, out TimeSpan newTime)) { Times.Add(newTime); } time.Text = ""; } }
public void AddDoseTime(TimeOfDay time) { if (!Times.ContainsKey(time)) { Times.Add(time, 1); } else { Times[time] = Times[time] + 1; } }
//Get data private void GetData() { try { var doc = new HtmlDocument(); URL = ConfigurationManager.AppSettings["BaseURL"] + this.ClubID; doc.LoadHtml(ReadData(URL)); var table = doc.GetElementbyId("tblSchedule"); foreach (var tr in table.SelectSingleNode("tbody").SelectNodes("tr")) { string time = tr.SelectSingleNode("th").SelectSingleNode("h5").InnerText; string className = string.Empty; string classDescriptionuri = string.Empty; string classDescription = string.Empty; int currDayInt = 0; foreach (var td in tr.SelectNodes("td")) { string currDay = Days[currDayInt]; if (td.HasChildNodes) { className = td.InnerText; classDescription = className.Split('(')[0].Trim(); try { classDescriptionuri = td.SelectSingleNode(".//strong//a").GetAttributeValue("href", "Class Description Link not found"); } catch (NullReferenceException) { classDescriptionuri = td.SelectSingleNode(".//a").GetAttributeValue("href", "Class Description Link not found"); } if (!ClassDescriptionsURIs.Contains(classDescriptionuri)) { ClassDescriptionsURIs.Add(classDescriptionuri); } } else { className = "No Class"; classDescriptionuri = "No Description URI"; } ClassesList.Add(new Class(time, currDay, className, classDescriptionuri, classDescription)); currDayInt += 1; } //Store unique times if (!Times.Contains(time)) { Times.Add(time); } } } catch (Exception e) { throw new Exception(e.Message); } }
public void Update(Model model, DateTime clockTime) { var config = model.Config; #region BarDrinksSold = model.TotalNDrinksServed; BarAvgCust = model.HourCounterCustomersInBar.AverageCount; BarMaxCust = Math.Max(BarMaxCust, model.HourCounterCustomersInBar.LastCount); var barwaits = model.AllCustomers.Where(c => c.DiningTime < DateTime.MaxValue).Select(c => (c.DiningTime - c.ArrivalTime).TotalMinutes).ToList(); if (barwaits.Count > 0) { BarAvgWait = barwaits.Average(); BarMaxWait = barwaits.Max(); } BarLostCust = model.LostCustomers.Count; if (model.StartedCustomers.Count > 0) { BarAvgDrinksPerCust = BarDrinksSold / model.StartedCustomers.Count; } DiningRoomDinnersServed = model.HourCounterDinnersServing.TotalDecrement; DiningRoomTablesServed = model.HourCounterTablesServing.TotalDecrement; DiningRoomAvgTablesInUse = model.HourCounterTablesServing.AverageCount; if (model.DepartedCustomers.Count > 0) { DiningRoomAvgDiningTime = model.AllCustomers.Where(c => c.DepartureTime < DateTime.MaxValue) .Average(c => (c.DepartureTime - c.DiningTime).TotalMinutes); } DiningRoomAvgCust = model.HourCounterDinnersServing.AverageCount; DiningRoomMaxCust = Math.Max(DiningRoomMaxCust, model.HourCounterDinnersServing.LastCount); DiningRoomAvgUtilization = DiningRoomAvgCust / (model.Config.NDiningTables * 8); FinancialRevenueBar = (model.TotalNDrinksServed - model.TotalNDrinksServedInHappyHours) * config.RevenuePerDrink + model.TotalNDrinksServedInHappyHours * config.RevenuePerDrinkHappyHour; FinancialRevenueDinner = DiningRoomDinnersServed * (model.Config.AdsOption == Model.Statics.AdsOptions.DiscountPromotion ? config.RevenuePerDinnerDiscounted : config.RevenuePerDinner); FinancialRevenueTotal = FinancialRevenueBar + FinancialRevenueDinner; FinancialCostOfDrink = BarDrinksSold * config.CostOfDrink; FinancialCostOfDinner = DiningRoomDinnersServed * config.CostOfDinner; FinancialAdvertisingCost = config.AdsUnitCost[(int)config.AdsOption] * config.AdsLevel; FinancialLaborCost = config.LaborCostPerHour * (17 + 5.5 - config.OpeningHour); FinancialOverheadCost = config.AdsOverheadCost[(int)config.AdsOption]; FinancialCostTotal = FinancialCostOfDrink + FinancialCostOfDinner + FinancialAdvertisingCost + FinancialLaborCost + FinancialOverheadCost; FinancialNightProfit = FinancialRevenueTotal - FinancialCostTotal; #endregion Times.Add(clockTime); CustomersInBar.Add(model.HourCounterCustomersInBar.LastCount); CustomersInDinningRoom.Add(model.HourCounterDinnersServing.LastCount); CustomersLost.Add(model.AllCustomers.Count(c => c.DiningTime == DateTime.MaxValue && c.BarSeatIndex < 0)); TotalServedDinners.Add(DiningRoomDinnersServed); TotalServedDrinks.Add(BarDrinksSold); }
private void SetDefaultValues() { ytimeentryCreate1.Time = TimeSpan.Parse("04:00"); ytimeentryCreate2.Time = TimeSpan.Parse("09:00"); ytimeentryCreate3.Time = TimeSpan.Parse("12:00"); Times.Add(new Time(new TimeSpan(10, 00, 00))); Times.Add(new Time(new TimeSpan(13, 00, 00))); Times.Add(new Time(new TimeSpan(15, 00, 00))); Times.Add(new Time(new TimeSpan(18, 00, 00))); Times.Add(new Time(new TimeSpan(21, 00, 00))); Times.Add(new Time(new TimeSpan(23, 00, 00))); }
public Statistics() { All = new Bumblebee.CodeStatistics(0, "All"); Server = "NULL"; Url = "NULL"; Times.Add(new TimeStatistics(0, 10)); Times.Add(new TimeStatistics(10, 50)); Times.Add(new TimeStatistics(50, 100)); Times.Add(new TimeStatistics(100, 500)); Times.Add(new TimeStatistics(500, 1000)); Times.Add(new TimeStatistics(1000, 5000)); Times.Add(new TimeStatistics(5000, 0)); mData = new StatisticsData(this); }
public void AddPoints(int scanIndex, double time, List <ChromatogramPoint> points) { if (ScanIndexes.Count > 0) { Debug.Assert(scanIndex > ScanIndexes[ScanIndexes.Count - 1]); Debug.Assert(time >= Times[Times.Count - 1]); } ScanIndexes.Add(scanIndex); Times.Add(time); for (int i = 0; i < Chromatograms.Count; i++) { var chromatogram = Chromatograms[i]; chromatogram.Points.Add(points[i]); } }
protected void CalculateBedTimes() { Times.Clear(); // Takes ~14 mins for human to fall asleep var timeWhenAsleep = DateTime.Now.AddMinutes(14); var sleepCycleTime = new TimeSpan(1, 30, 0); for (int i = 0; i < 6; i++) { timeWhenAsleep = timeWhenAsleep.Add(sleepCycleTime); Times.Add(timeWhenAsleep.ToString("h:mm tt")); } }
public MainViewModel() { try { db = new ComputerClub(); } catch (Exception ex) { MessageBox.Show(ex.Message); } Times.Add(30); Times.Add(60); Times.Add(90); Times.Add(120); }
private void FillTimes(string com) { Times.Clear(); List <Week> Item = DFill.FillWeekList(Data.get(com)); List <string> UserNames = new List <string>((UserClassList.Keys.ToList())); UserNames.Sort(); foreach (string Users in UserNames) { Timings Time = new Timings() { Listing = Item.FindAll(o => o.Who == Users), Now = Date.StartOfWeek(DateTime.Now, 0), User = Users }; Times.Add(Time); } }
private SessionDescription(bool initialize) { if (initialize) { Version = 0; Origin = new Origin(); Name = " "; Times.Add(new Time(Time.Zero, Time.Zero)); } else { _version = -1; _origin = null; _name = null; } }
public void AutoSetTimes() { //Autofill time DateTime[] _times = Content.GetTimes(); if (_times != null && _times.Count() > 0) { foreach (var _time in _times) { Times.Add(_time); } } string[] _contains = Content.ToWords().Where(t => t.CountOf("/") == 1).ToArray(); if (_contains != null && _contains.Length > 0) { foreach (string value in _contains) { try { int year = DateTime.Now.Year; int month = int.Parse(value.GetAfter("/")); int day = int.Parse(value.GetBefore("/")); var time = new DateTime(year, month, day) { }; Times.Add(time); } catch (Exception ex) { Console.WriteLine(ex.Message); } } } //BuildTime(); if (this.IsNoTime()) { if (Times == null || Times.Count == 0) { this.SetNow(); } else { this.Start = Times.FirstOrDefault(); this.End = Times.LastOrDefault(); } } }
/// public virtual void Add(int user_id, int item_id, float rating, DateTime time) { Users.Add(user_id); Items.Add(item_id); Values.Add(rating); Times.Add(time); int pos = Users.Count - 1; if (user_id > MaxUserID) { MaxUserID = user_id; } if (item_id > MaxItemID) { MaxItemID = item_id; } // TODO speed up time stuff if (time < EarliestTime) { EarliestTime = time; } if (time > LatestTime) { LatestTime = time; } // update index data structures if necessary if (by_user != null) { for (int u = by_user.Count; u <= user_id; u++) { by_user.Add(new List <int>()); } by_user[user_id].Add(pos); } if (by_item != null) { for (int i = by_item.Count; i <= item_id; i++) { by_item.Add(new List <int>()); } by_item[item_id].Add(pos); } }
bool FillInTheListOfIndications(string NameOfFile) // Заполняем лист из конретного файла { bool ok = false; int count = File.ReadAllLines(IDCounter + NameOfFile).Length; StreamReader CurentF = new StreamReader(IDCounter + NameOfFile); if (count > 5) { for (int i = 0; i < count / 5; i++) { string Date = CurentF.ReadLine(); DateTime myDate = DateTime.ParseExact(Date, "dd.MM.yyyy HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture); // Сериализуем время показания в формат DateTime if (After <= myDate && myDate <= Before) { Times.Add(myDate); // Записываем время ok = true; double[,] Indicate = new double[3, 3]; // m что записываем // n какая фаза for (int m = 0; m < 3; m++) // Записываем показания { string A = CurentF.ReadLine(); for (int n = 0; n < 3; n++) { Indicate[m, n] = Double.Parse(A.Substring(0, A.IndexOf(" "))); A = A.Substring(A.IndexOf(" ") + 1); } } Indications.Add(Indicate); } else // Пропускаем показание { for (int j = 0; j < 3; j++) { CurentF.ReadLine(); } } CurentF.ReadLine(); // Двигаемся к следующему показанию } } return(ok); }
/// <summary> /// Property to add a key frame to the collection. /// </summary> /// <param name="item">Keyframe to add.</param> /// <exception cref="System.ArgumentException">Thrown when a key frame already exists in the collection with the specified time index.</exception> public void Add(IKeyFrame item) { if (item.DataType != _track.DataType) { throw new InvalidCastException(string.Format(Resources.GORANM_KEY_TRACK_TYPE_MISMATCH, item.GetType().FullName, _track.GetType().FullName)); } if (Contains(item.Time)) { throw new ArgumentException(string.Format(Resources.GORANM_KEY_EXISTS_AT_TIME, item.Time)); } _keyFrames.Add(item); Times.Add(item.Time, item); if (_track != null) { _track.SetupSpline(); } }
public void AutoSetTimes() { if (Content.IsNullOrEmptyOrWhiteSpace()) { return; } DateTime[] _times = Content.GetTimes(); if (_times != null && _times.Count() > 0) { foreach (var _time in _times) { Times.Add(_time); } } if (!Content.Contains("/")) { return; } string[] _contains = Content.ToWords().Where(t => t.CountOf("/") == 1).ToArray(); if (_contains != null && _contains.Length > 0) { foreach (string value in _contains) { try { int year = DateTime.Now.Year; int month = int.Parse(value.GetAfter("/")); int day = int.Parse(value.GetBefore("/")); var time = new DateTime(year, month, day) { }; Times.Add(time); } catch (Exception ex) { Console.WriteLine(ex.Message); } } } }
public void LoadActivityTimes(Guid id) { Times.Clear(); var used = 0; foreach (var time in ActivityTimeService.GetAllActivityTimes(id).OrderByDescending(time => time.Timestamp)) { used += time.Hours; Times.Add(new ActivityTimeListItem(time, ActivityTimeService, LanguageService)); } TimeUsed = used; if (Activity.TimeBudget == 0) { TimeUsedFactor = ""; return; } var factor = (double)used / (double)Activity.TimeBudget * 100; TimeUsedFactor = (int)factor + "%"; }
}//end FormatForFile() /// <summary> /// reads in the lines formatted from the FormatForFile() method /// into this object, replacing any previous data /// </summary> /// <param name="Lines">The lines from the </param> /// <exception cref="ArgumentException"></exception> public void ReadFromLines(List<string> lines) { List<string> Lines = new List<string>(); //just make sure our input is good try { foreach(string line in lines) { Lines.Add(new StringBuilder(line).ToString()); }//end copying over all lines so we clear the references if (!Lines.Remove("$BEGINGROUP$")) throw new ArgumentException("The provided lines do not start with $BEGINGROUP$. Please provide all lines."); if (!Lines.Remove("$ENDGROUP$")) throw new ArgumentException("The provided lines do not start with $ENDGROUP$. Please provide all lines."); }//end trying to ensure input is good catch(Exception e) { var except = e.InnerException; throw except; }//end making sure to throw our exception //at this point, BEGIN and END flags should be removed if we've gotten here //get name from the file this.GroupName = Lines[0]; //remove that name from the lines Lines.RemoveAt(0); //get all the times from the lines this.Times = new List<TimedInstance>(); while(Lines.Count > 0) { //adds the first time to this object, read from string Times.Add(new TimedInstance(Lines[0])); //remove the first time from Lines Lines.RemoveAt(0); }//end looping while we have lines to process }//end ReadFromLines(Lines)
//Build Duration Dialog private void DialogMyButton_Click(object sender, EventArgs e) { int a; int.TryParse(DurationDialogET.Text, out a); OAduration += a; OAdurationTV.Text = OAduration.ToString(); if (OAduration <= 50 && OAduration >= 40) { OAdurationTV.SetTextColor(Color.LawnGreen); } else if (OAduration > 50) { OAdurationTV.SetTextColor(Color.Red); } else { OAdurationTV.SetTextColor(Color.Black); } CurrMyButton.Time = a; Times.Add(int.Parse(DurationDialogET.Text)); DurationDialog.Dismiss(); }
/// <summary> /// Add a time value to the given chromatogram. /// </summary> public void AddTime(int chromatogramIndex, float time, BlockWriter writer) { Times.Add(chromatogramIndex, time, writer); }