public void Hours_Constructor_Degrees_ReturnsTrue() { Hours kut = new Hours(3); Hours kutTest = new Hours(new Degrees(45)); Assert.IsTrue((kut - kutTest).Angle < tolerance); }
private void LoadOrUpdateHours() { for (int i = 0; i < 24; i++) { if (Hours.Count <= i) { var ClockItem = new ClockModelItem() { Value = i, DisplayName = i.ToString(), IsEnabled = IsHourValidated(i), IsChecked = i == SelectedTime.Hour, }; Hours.Add(ClockItem); } else { var ClockItem = Hours[i]; ClockItem.Value = i; ClockItem.DisplayName = i.ToString(); ClockItem.IsEnabled = IsHourValidated(i); ClockItem.IsChecked = i == SelectedTime.Hour; } } }
public DateTime?GetNextTime(DateTime current) { if (SecondType == CronFieldType.Specified && !Seconds.Any()) { throw new ArgumentException("Seconds are Empty."); } if (MinuteType == CronFieldType.Specified && !Minutes.Any()) { throw new ArgumentException("Minutes are Empty."); } if (HourType == CronFieldType.Specified && !Hours.Any()) { throw new ArgumentException("Hours are Empty."); } if (DayType == CronFieldType.Specified && !Days.Any()) { throw new ArgumentException("Days are Empty."); } if (MonthType == CronFieldType.Specified && !Months.Any()) { throw new ArgumentException("Months are Empty."); } if (DayOfWeekType == CronFieldType.Specified && !DayOfWeeks.Any()) { throw new ArgumentException("DayOfWeeks are Empty."); } if (YearType == CronFieldType.Specified && !Years.Any()) { throw new ArgumentException("Years are Empty."); } return(NextSecond(current.Year, current.Month, current.Day, current.Hour, current.Minute, current.Second)); }
public void ShowClock() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(Hours.ToString()); if (Minutes >= 10) { stringBuilder.Append(":"); stringBuilder.Append(Minutes.ToString()); } else { stringBuilder.Append(":0"); stringBuilder.Append(Minutes.ToString()); } if (Seconds >= 10) { stringBuilder.Append(":"); stringBuilder.Append(Seconds.ToString()); } else { stringBuilder.Append(":0"); stringBuilder.Append(Seconds.ToString()); } Console.WriteLine(stringBuilder.ToString()); }
async Task SyncHours() { if (!IsBusy) { Exception Error = null; Hours.Clear(); try { IsBusy = true; var Repository = new Repository(); var Items = await Repository.GetHours(); foreach (var Hour in Items) { Hours.Add(Hour.Hour); HoursAvaliable.Add(Hour); } } catch (Exception ex) { Error = ex; } finally { IsBusy = false; } if (Error != null) { await _pageDialogService.DisplayAlertAsync("Erro", Error.Message, "OK"); } return; } }
public List <Hours> GetHours(int breweryId) { List <Hours> hoursList = new List <Hours>(); try { using (SqlConnection conn = new SqlConnection(connectionString)) { conn.Open(); SqlCommand cmd = new SqlCommand(SQL_GET_HOURS, conn); cmd.Parameters.AddWithValue("@breweryId", breweryId); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { Hours hours = RowToObject(reader); hoursList.Add(hours); } return(hoursList); } } catch (SqlException ex) { throw; } }
// an aide who has more than X (5) hours entered for a single day void EnsureMaxXHoursPerDayPerAide() { var q = (from h in context.CaseAuthHours join p in context.Providers on h.CaseProviderID equals p.ID join pt in context.ProviderTypes on p.ProviderType equals pt.ID where h.HoursDate >= this.StartDate && h.HoursDate <= this.EndDate && pt.ProviderTypeCode == "AIDE" group h by new { h.CaseProviderID, h.HoursDate } into g where g.Sum(x => x.HoursTotal) > 5 select new { g.Key.CaseProviderID, g.Key.HoursDate, Hours = g.Sum(x => x.HoursTotal) }).ToList(); foreach (var o in q) { var hours = Hours.Where(x => x.ProviderID == o.CaseProviderID && x.Date == o.HoursDate).ToList(); foreach (var h in hours) { AddError(ValidationErrors.AideMaxHoursPerDayPerAide, h, null); } } }
// a case who has hours entered which overlap each other by any provider // excluding expected situations such as Direct SUpervision, etc. void EnsureNoOverlapWithinCase() { var groups = Hours.GroupBy(x => x.CaseID); foreach (var group in groups) { foreach (var item in group) { var checkList = group.Where(x => x.ID != item.ID && x.Date == item.Date && x.ServiceCode == "DR" && item.ServiceCode == "DR").ToList(); var matches = checkList.Where(x => (x.TimeIn < item.TimeOut) && (x.TimeOut > item.TimeOut) ).ToList(); matches.AddRange(checkList.Where(x => (x.TimeIn < item.TimeIn) && (x.TimeOut > item.TimeIn) || (x.TimeIn > item.TimeIn) && (x.TimeOut < item.TimeOut) || (x.TimeIn < item.TimeOut) && (x.TimeOut > item.TimeOut) ).ToList()); matches = matches.Distinct().ToList(); foreach (var match in matches) { // create new validation error AddError(ValidationErrors.CaseOverlap, item, match); } } } }
public List<Hours> getHours(int person_id, int month, int year) { SqlConnection conn = new SqlConnection(this.ConnectionString); string sql = "SELECT * FROM it_timeboard_hours WHERE (person_id = @person_id) AND (MONTH(day_date) = @month) AND (YEAR(day_date) = @year) ORDER BY DAY(day_date) DESC, project_id"; SqlCommand cmd = new SqlCommand(sql, conn); cmd.Parameters.Add(new SqlParameter("@person_id", SqlDbType.Int, 4)); cmd.Parameters["@person_id"].Value = person_id; cmd.Parameters.Add(new SqlParameter("@month", SqlDbType.Int, 4)); cmd.Parameters["@month"].Value = month; cmd.Parameters.Add(new SqlParameter("@year", SqlDbType.Int, 4)); cmd.Parameters["@year"].Value = year; List<Hours> hours = new List<Hours>(); try { conn.Open(); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { Hours h = new Hours((int)reader["id"], (int)reader["person_id"], (DateTime)reader["day_date"], (decimal)reader["hours"], (int)reader["project_id"], (string)reader["post_id"], (string)reader["department_id"], (string)reader["company_id"]); hours.Add(h); } reader.Close(); } catch (Exception e) { throw new Exception(e.Message); } finally { conn.Close(); } return hours; }
public void Degrees_Constructor_Seconds_ReturnsTrue() { Hours kut = new Hours(3); Hours kutTest = new Hours(new Seconds(45 * 60 * 60)); Assert.IsTrue((kut - kutTest).Angle < tolerance); }
/// <summary> /// Persistence method for the Reminder object /// </summary> /// <param name="writer">the xmlwriter to write into</param> public void Save(XmlWriter writer) { writer.WriteStartElement(XmlPrefix, XmlName, XmlNameSpace); if (Days > 0) { writer.WriteAttributeString(GDataParserNameTable.XmlAttributeDays, Days.ToString()); } if (Hours > 0) { writer.WriteAttributeString(GDataParserNameTable.XmlAttributeHours, Hours.ToString()); } if (Minutes > 0) { writer.WriteAttributeString(GDataParserNameTable.XmlAttributeMinutes, Minutes.ToString()); } if (AbsoluteTime != new DateTime(1, 1, 1)) { string date = Utilities.LocalDateTimeInUTC(AbsoluteTime); writer.WriteAttributeString(GDataParserNameTable.XmlAttributeAbsoluteTime, date); } if (Method != ReminderMethod.unspecified) { writer.WriteAttributeString(GDataParserNameTable.XmlAttributeMethod, Method.ToString()); } writer.WriteEndElement(); }
// POST: Hours/Delete/5 public ActionResult Delete(int id) { Hours Hours = _store.GetByHoursID(id); _store.Remove(id); return(RedirectToAction("Details", "Restaurants", new { id = Hours.RestaurantID })); }
internal void EditProfile() { //Populate the Excel Sheet GlobalDefinitions.ExcelLib.PopulateInCollection(Base.ExcelPath, "Profile"); Thread.Sleep(1000); // Click the write icon of Availability AvailablityIcon.Click(); // Select the Availability AvailablityType.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "AvailableTime")); Base.test.Log(LogStatus.Info, "Availability updated"); //Click on Hours write icon HoursIcon.Click(); Thread.Sleep(1500); Hours.SendKeys(Keys.ArrowDown + Keys.Enter); //Click on EarnTarget write icon EarnTargetIcon.Click(); //Availability Hours option //EarnTarget.SendKeys(Keys.ArrowDown + Keys.ArrowDown + Keys.Enter); EarnTarget.SendKeys("More than $1000 per month"); //Click on Discription Edit button EditDescription.Click(); //Add Description Description.Clear(); Thread.Sleep(1000); Description.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Description")); Save.Click(); Assert.That(Description != null); Base.test.Log(LogStatus.Info, "Added Description successfully"); }
private void Form1_Shown(object sender, EventArgs e) { // columns have been created in the designer and data property set dataGridView1.AutoGenerateColumns = false; // get people in List<Person> _bindingSource.DataSource = _dataOperations.ReadTimeTable(); // subscribe to current change to handle sync'ing Time ComboBox _bindingSource.CurrentChanged += _bindingSource_CurrentChanged; // bind person list to DataGridView dataGridView1.DataSource = _bindingSource; // using hours range to populate the DomainUpDown control var hours = new Hours(); HoursDomainUpDown.Items.AddRange(hours.Range(TimeIncrement.Quarterly)); timeComboBox1.SelectedIndexChanged += TimeComboBox1_SelectedIndexChanged; // sync current person's start time with Time ComboBox //HandleCurrentChanged(); _bindingSource.MoveLast(); // see comments in ReadDifferences _dataOperations.ReadTimeTableDifferences(); Console.WriteLine(dateTimePicker1.Value.TimeOfDay.Formatted()); }
public Dictionary <string, Hours> GetLandmarkSchedule(int landmarkId) { try { using (SqlConnection conn = new SqlConnection(connectionString)) { conn.Open(); SqlCommand cmd = new SqlCommand(SQL_GetLandmarkSchedule, conn); cmd.Parameters.AddWithValue("@landmarkId", landmarkId); SqlDataReader reader = cmd.ExecuteReader(); Dictionary <string, Hours> schedule = new Dictionary <string, Hours>(); while (reader.Read()) { Hours hours = new Hours(); hours.TimeOpen = Convert.ToDateTime(reader["time_open"]).ToShortTimeString(); hours.TimeClosed = Convert.ToDateTime(reader["time_closed"]).ToShortTimeString(); schedule[Convert.ToString(reader["name"])] = hours; } return(schedule); } } catch (SqlException) { throw; } }
public override int GetHashCode() { int hash = 1; if (Hours != 0) { hash ^= Hours.GetHashCode(); } if (Minutes != 0) { hash ^= Minutes.GetHashCode(); } if (Seconds != 0) { hash ^= Seconds.GetHashCode(); } if (Nanos != 0) { hash ^= Nanos.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public virtual bool addHours(Hours newhours) { Authentication auth = new Authentication(); if (auth.isUser(this) || Authentication.DEBUG_bypassAuth) { WorkEffort tmpWe = WorkEffortDB.WorkEffortList.Find(newhours.workEffortID); //make sure that the new hours are within the work effort's time bounds if ((newhours.timestamp < tmpWe.startDate) || (newhours.timestamp > tmpWe.endDate)) { return(false); } //make sure that a timesheet exists for the period hours are being added to checkForTimesheet(newhours.creator, newhours.timestamp); //add and save new hours HoursDB.HoursList.Add(newhours); HoursDB.SaveChanges(); return(true); } else { return(false); } }
public TimeCard(Hours hour, Days day, Seasons season, uint year) { Ticks = ((uint)hour * MaxHours) + ((uint)day * MaxDays) + ((uint)season * MaxSeasons) + year * TicksInYear; }
// good practice to override this if overriding Equals public override int GetHashCode() { // return a hash (key) value for this object // object with same content should return same hash value return(Hours.GetHashCode() ^ Minutes.GetHashCode() ^ Minutes.GetHashCode()); // simple hash }
public void Hours_Constructor_Gradians_ReturnsTrue() { Hours kut = new Hours(3); Hours kutTest = new Hours(new Gradians(50)); Assert.IsTrue((kut - kutTest).Angle < tolerance); }
internal void EditProfile() { //Populate the Excel Sheet Global.ExcelLib.PopulateInCollection(Base.ExcelPath, "Profile"); GlobalDefinitions.Wait(); EditProfileicon.Click(); EditFirstName.Clear(); EditFirstName.SendKeys(ExcelLib.ReadData(2, "FirstName")); EditLasttName.Clear(); EditLasttName.SendKeys(ExcelLib.ReadData(2, "LastName")); ProfileSaveBtn.Click(); GlobalDefinitions.driver.Navigate().Refresh(); GlobalDefinitions.Wait(); Availability.Click(); AvailabilityTime.SendKeys(ExcelLib.ReadData(2, "Availability")); Hours.Click(); AvailabilityHour.SendKeys(ExcelLib.ReadData(2, "SelectHours")); GlobalDefinitions.Wait(); EarnTarget.Click(); AvailabilityTarget.SendKeys(ExcelLib.ReadData(2, "EarnTraget")); GlobalDefinitions.Wait(); DescriptionBtn.Click(); TxtDescription.Clear(); GlobalDefinitions.Wait(); TxtDescription.SendKeys(ExcelLib.ReadData(2, "EditDesc")); DesSaveButton.Click(); }
// a provider who's entered hours overlaps themselves in any case void EnsureNoOverlapWithinProvider() { // group by provider var groups = Hours.GroupBy(x => x.ProviderID); foreach (var group in groups) { foreach (var item in group) { var checkList = group.Where(x => x.ID != item.ID && x.Date == item.Date).ToList(); var matches = checkList.Where(x => (x.TimeIn < item.TimeOut) && (x.TimeOut > item.TimeIn) ).ToList(); matches.AddRange(checkList.Where(x => (x.TimeOut < item.TimeOut) && (x.TimeOut > item.TimeIn) ).ToList()); matches = matches.Distinct().ToList(); foreach (var match in matches) { // create new validation error AddError(ValidationErrors.ProviderOverlapSelf, item, match); } } } }
public void SaveExecute() { if (String.IsNullOrEmpty(Date.ToString()) || String.IsNullOrEmpty(Hours.ToString()) || String.IsNullOrEmpty(Description) || Hours == 0) { MessageBox.Show("Please fill all fields.", "Notification"); } else { try { MessageBoxResult result = MessageBox.Show("Are you sure you want to save the report?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { string source = string.Format(@"../../Maintenance{0}.txt", Maintenance.MaintenanceId); StreamWriter str = new StreamWriter(source, true); string output = "[" + Date + "][" + Hours + "][" + Description + "]"; str.WriteLine(output); str.Close(); MessageBox.Show("Report is saved.", "Notification", MessageBoxButton.OK); reportView.Close(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } }
void CheckSupervisionOverlapByDSU() { var groups = Hours.Where(x => x.ServiceCode == "DSU" || x.ServiceCode == "SDR").GroupBy(x => x.CaseID); foreach (var group in groups) { var dsuHours = group.Where(x => x.ServiceCode == "DSU"); foreach (var dsuHour in dsuHours) { var sdrHours = group.Where(x => x.ServiceCode == "SDR"); bool hasMatch = false; foreach (var sdrHour in sdrHours) { if (sdrHour.TimeIn == dsuHour.TimeIn && sdrHour.TimeOut == dsuHour.TimeOut) { hasMatch = true; break; } } if (!hasMatch) { AddError(ValidationErrors.SupervisionMismatch, dsuHour, null); } } } }
public override string ToString() { string mins = Minutes < 10 ? "0" + Minutes : Minutes.ToString(); string hours = Hours < 10 ? "0" + Hours : Hours.ToString(); return(hours + ":" + mins); }
/// <summary> /// Przeciążenie tekstowej metody przedstawienia obiektu /// </summary> /// <returns> String w formacie hh:mm:ss </returns> public override string ToString() { string hOut; string mOut; string sOut; if (Hours.ToString().Length == 1) { hOut = "0" + Hours; } else { hOut = Hours.ToString(); } if (Minutes.ToString().Length == 1) { mOut = "0" + Minutes; } else { mOut = Minutes.ToString(); } if (Seconds.ToString().Length == 1) { sOut = "0" + Seconds; } else { sOut = Seconds.ToString(); } return(hOut + ":" + mOut + ":" + sOut); }
internal void PrintHour() { Hours takeHourString = (Hours)GetNumberOfEnum(Hour); string hourString = GetNullToNineString(Hour); Console.WriteLine("Сейчас {0} {1}", hourString, takeHourString); }
protected DateTime?NextHour(int year, int month, int day, int hour, int minute, int second) { switch (HourType) { case CronFieldType.Any: if (hour < 23) { return(new DateTime(year, month, day, hour + 1, minute, second)); } else { return(NextDay(year, month, day, 0, minute, second)); } case CronFieldType.Specified: var values = Hours.Where(x => x > hour); if (values.Any()) { return(new DateTime(year, month, day, values.First(), minute, second)); } else { return(NextDay(year, month, day, Hours.First(), minute, second)); } default: throw new NotImplementedException(); } }
public void Hours_Implicit_Radians_ReturnsTrue() { Hours dms = new Hours(12 / 3); Radians rad = dms; Assert.IsTrue(rad.Angle == Math.PI / 3); }
public async Task <IActionResult> PutHours([FromRoute] int id, [FromBody] Hours hours) { var user = _userManager.GetUserAsync(HttpContext.User); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != hours.Id) { return(BadRequest()); } _context.Entry(hours).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!HoursExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public void Hours_Constructor_DMS_ReturnsTrue() { Hours kut = new Hours(3); Hours kutTest = new Hours(new DMS(45, 0, 0)); Assert.IsTrue((kut - kutTest).Angle < tolerance); }
public void Calculates_overtime_hours_as_hours_additional_to_contracted() { var hoursWorked = new Hours(40); var contractedHours = new Hours(35); // wrap with Micro Types for contextual explicitness var hoursWorkedx = new HoursWorked(hoursWorked); var contractedHoursx = new ContractedHours(contractedHours); var fiveHours = new Hours(5); var fiveHoursOvertime = new OvertimeHours(fiveHours); var result = new OvertimeCalculator().Calculate(hoursWorkedx, contractedHoursx); Assert.AreEqual(fiveHoursOvertime, result); }
public void Add(Hours Hours) { _context.Hours.Add(Hours); _context.SaveChanges(); }
public void Update(Hours Hours) { _context.Entry(Hours).State = EntityState.Modified; _context.SaveChanges(); }