public void ValidateTest() { Day t = new Day(); t.Add(Day.TimeCodes.REGULAR, 16); t.Add(Day.TimeCodes.SICK, 4); t.Add(Day.TimeCodes.VACATION, 5); Assert.IsFalse(t.Validate()); }
public static Day GetFirstValidDay(Day fromDay, int searchDirection) { Day day = fromDay; if (fromDay.StartTime.DayOfWeek == DayOfWeek.Saturday) { day = searchDirection == 1 ? fromDay.Add(2) : fromDay.Add(-1); } else if (fromDay.StartTime.DayOfWeek == DayOfWeek.Sunday) { day = searchDirection == 1 ? fromDay.Add(1) : fromDay.Add(-2); } return(day); }
private Week LoadTimeTable(XElement element) { var timetableList = from timetables in element.Elements("TimeTable") select timetables; Week week = new Week(); foreach (var timetable in timetableList) { var timePairList = new Day(); WeekDays weekDayName = new WeekDays(); var weekdayList = from weekdays in timetable.Elements("WeekDay") select weekdays; foreach (var weekday in weekdayList) { var timePair = new TimePair(); weekDayName = (WeekDays)Enum.Parse(typeof(WeekDays), weekday.Attribute("Day").Value); var workingHoursList = from workingHours in weekday.Elements("WorkingHours") select workingHours; foreach (var workingHoursCell in workingHoursList) { timePair.StartTime = new Time(workingHoursCell.Attribute("StartTime").Value); timePair.EndTime = new Time(workingHoursCell.Attribute("EndTime").Value); } timePairList.Add(timePair); } week.Add(weekDayName, timePairList); } return(week); }
private void PopulateDateCollection() { //populate months for (int i = 1; i < 13; i++) { if (!Months.ContainsKey(CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(i).Substring(0, 3))) { Months.Add(CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(i).Substring(0, 3), CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(i)); } Month.Add(CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(i).Substring(0, 3)); } //populate year for (int i = 1990; i < 2050; i++) { Year.Add(i.ToString()); } //populate Days for (int i = 1; i <= DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month); i++) { if (i < 10) { Day.Add("0" + i); } else { Day.Add(i.ToString()); } } Date.Add(Month); Date.Add(Day); Date.Add(Year); }
// Populates months, years and days which will be available in the picker private void PopulateDateCollection() { for (var i = 1; i <= 12; i++) { if (!Months.ContainsKey(CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(i).Substring(0, 3))) { Months.Add(CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(i).Substring(0, 3), CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(i)); } Month.Add(CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(i).Substring(0, 3)); } // Available years = 2000-2025 for (var i = 2000; i < 2025; i++) { Year.Add(i.ToString()); } for (var i = 1; i <= DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month); i++) { if (i < 10) { Day.Add("0" + i); } else { Day.Add(i.ToString()); } } Date.Add(Month); Date.Add(Day); Date.Add(Year); }
public void AddTest() { DateTime dateTime = new DateTime(2016, 8, 25); Day test = new Day(dateTime); test.Add(Day.TimeCodes.SICK, 7); string expected = "Day: " + test.dateTime + " Reg: " + 0 + " Sick: " + 7 + " Vac: " + 0 + " Total: " + 7;; string result = test.ToString(); Assert.AreEqual(expected, result); }
private List<Day> GetNonEmptyDays(Day fromDay, int searchDirection, int amount) { List<Day> days = new List<Day>(); Day currentDay = fromDay; for (int i = 0; i < amount; i++) { currentDay = currentDay.Add(searchDirection); currentDay = GetFirstValidDay(currentDay, searchDirection); Timetable.UpdateIfNeeded(currentDay, onUpdate, e => Console.WriteLine(e)); days.Add(currentDay); } return days; }
// Use this for initialization void Start() { days = new List <Day>(); // ========== DAY START 1============= { Day day = new Day(); days.Add(day); day.clientsPerDay = 5; { Client client = new Client(getHeroName(), "", HeatType.Low); client.addRequirenment(new Requirenment(ResourceType.Wood, Random.Range(1, 3))); day.Add(client); } { Client client = new Client(getHeroName(), "", HeatType.Low); client.addRequirenment(new Requirenment(ResourceType.Gem, Random.Range(1, 3))); day.Add(client); } { Client client = new Client(getHeroName(), "", HeatType.Low); client.addRequirenment(new Requirenment(ResourceType.Wood, Random.Range(1, 4))); day.Add(client); } { Client client = new Client(getHeroName(), "", HeatType.Low); client.addRequirenment(new Requirenment(ResourceType.Metal, Random.Range(1, 6))); day.Add(client); } { Client client = new Client(getHeroName(), "", HeatType.Low); client.addRequirenment(new Requirenment(ResourceType.Gold, Random.Range(1, 5))); day.Add(client); } } // ======================= // ========== DAY START 2============= { Day day = new Day(); days.Add(day); day.clientsPerDay = 10; { Client client = new Client(getHeroName(), "", HeatType.Low); client.addRequirenment(new Requirenment(ResourceType.Magic, Random.Range(2, 3))); client.addRequirenment(new Requirenment(ResourceType.Metal, Random.Range(2, 3))); day.Add(client); } { Client client = new Client(getHeroName(), "", HeatType.Low); client.addRequirenment(new Requirenment(ResourceType.Wood, Random.Range(2, 3))); client.addRequirenment(new Requirenment(ResourceType.Magic, Random.Range(2, 3))); day.Add(client); } { Client client = new Client(getHeroName(), "", HeatType.Low); client.addRequirenment(new Requirenment(ResourceType.Gem, Random.Range(2, 3))); client.addRequirenment(new Requirenment(ResourceType.Gold, Random.Range(2, 3))); day.Add(client); } { Client client = new Client(getHeroName(), "", HeatType.Low); client.addRequirenment(new Requirenment(ResourceType.Gold, Random.Range(2, 3))); client.addRequirenment(new Requirenment(ResourceType.Gem, Random.Range(2, 3))); day.Add(client); } { Client client = new Client(getHeroName(), "", HeatType.Low); client.addRequirenment(new Requirenment(ResourceType.Magic, Random.Range(2, 6))); day.Add(client); } { Client client = new Client(getHeroName(), "", HeatType.Low); client.addRequirenment(new Requirenment(ResourceType.Gem, Random.Range(3, 5))); client.addRequirenment(new Requirenment(ResourceType.Wood, Random.Range(3, 5))); day.Add(client); } { Client client = new Client(getHeroName(), "", HeatType.Medium); client.addRequirenment(new Requirenment(ResourceType.Gold, Random.Range(4, 8))); client.addRequirenment(new Requirenment(ResourceType.Metal, Random.Range(4, 8))); day.Add(client); } { Client client = new Client(getHeroName(), "", HeatType.Low); client.addRequirenment(new Requirenment(ResourceType.Magic, Random.Range(5, 8))); day.Add(client); } { Client client = new Client(getHeroName(), "", HeatType.Medium); client.addRequirenment(new Requirenment(ResourceType.Gem, Random.Range(4, 9))); day.Add(client); } { Client client = new Client(getHeroName(), "", HeatType.Low); client.addRequirenment(new Requirenment(ResourceType.Magic, Random.Range(2, 6))); client.addRequirenment(new Requirenment(ResourceType.Wood, Random.Range(6, 9))); day.Add(client); } } // ======================= // ========== DAY START 3============= { Day day = new Day(); days.Add(day); day.clientsPerDay = 10; { Client client = new Client(getHeroName(), "", HeatType.Low); client.addRequirenment(new Requirenment(ResourceType.Magic, Random.Range(5, 13))); client.addRequirenment(new Requirenment(ResourceType.Gold, Random.Range(6, 12))); day.Add(client); } { Client client = new Client(getHeroName(), "", HeatType.High); client.addRequirenment(new Requirenment(ResourceType.Metal, Random.Range(5, 14))); day.Add(client); } { Client client = new Client(getHeroName(), "", HeatType.VeryHigh); client.addRequirenment(new Requirenment(ResourceType.Metal, Random.Range(5, 10))); day.Add(client); } { Client client = new Client(getHeroName(), "", HeatType.Low); client.addRequirenment(new Requirenment(ResourceType.Gem, Random.Range(3, 6))); client.addRequirenment(new Requirenment(ResourceType.Wood, Random.Range(3, 6))); day.Add(client); } { Client client = new Client(getHeroName(), "", HeatType.Medium); client.addRequirenment(new Requirenment(ResourceType.Gold, Random.Range(4, 8))); client.addRequirenment(new Requirenment(ResourceType.Metal, Random.Range(4, 8))); day.Add(client); } { Client client = new Client(getHeroName(), "", HeatType.Low); client.addRequirenment(new Requirenment(ResourceType.Metal, Random.Range(10, 14))); day.Add(client); } { Client client = new Client(getHeroName(), "", HeatType.Medium); client.addRequirenment(new Requirenment(ResourceType.Magic, Random.Range(7, 11))); day.Add(client); } { Client client = new Client(getHeroName(), "", HeatType.Low); client.addRequirenment(new Requirenment(ResourceType.Magic, Random.Range(2, 6))); client.addRequirenment(new Requirenment(ResourceType.Wood, Random.Range(6, 9))); day.Add(client); } } // ======================= // ========== DAY START ============= // обязательный medium типок //{ // Day day = new Day(); // days.Add(day); // // day.clientsPerDay = 1; // { // Client client = new Client(getHeroName(), "", HeatType.Medium); // client.addRequirenment(new Requirenment(ResourceType.Metal, Random.Range(2, 3))); // day.Add(client); // } // //} // ======================= // ========== DAY START 4============= { Day day = new Day(); days.Add(day); day.clientsPerDay = 10; { Client client = new Client(getHeroName(), "", HeatType.Medium); client.addRequirenment(new Requirenment(ResourceType.Wood, Random.Range(5, 9))); client.addRequirenment(new Requirenment(ResourceType.Gold, Random.Range(3, 6))); day.Add(client); } { Client client = new Client(getHeroName(), "", HeatType.VeryHigh); client.addRequirenment(new Requirenment(ResourceType.Magic, Random.Range(5, 8))); client.addRequirenment(new Requirenment(ResourceType.Gem, Random.Range(2, 5))); day.Add(client); } { Client client = new Client(getHeroName(), "", HeatType.High); client.addRequirenment(new Requirenment(ResourceType.Gold, Random.Range(2, 3))); client.addRequirenment(new Requirenment(ResourceType.Metal, Random.Range(2, 3))); day.Add(client); } { Client client = new Client(getHeroName(), "", HeatType.Medium); client.addRequirenment(new Requirenment(ResourceType.Magic, Random.Range(2, 3))); client.addRequirenment(new Requirenment(ResourceType.Wood, Random.Range(2, 3))); day.Add(client); } { Client client = new Client(getHeroName(), "", HeatType.Medium); client.addRequirenment(new Requirenment(ResourceType.Gem, Random.Range(1, 4))); client.addRequirenment(new Requirenment(ResourceType.Gold, Random.Range(1, 4))); client.addRequirenment(new Requirenment(ResourceType.Wood, Random.Range(1, 4))); day.Add(client); } } // ======================= // ========== DAY START 5============= { Day day = new Day(); days.Add(day); day.clientsPerDay = 15; { Client client = new Client(getHeroName(), "", HeatType.Low); client.addRequirenment(new Requirenment(ResourceType.Wood, Random.Range(5, 9))); client.addRequirenment(new Requirenment(ResourceType.Gold, Random.Range(3, 6))); client.addRequirenment(new Requirenment(ResourceType.Gem, Random.Range(3, 8))); day.Add(client); } { Client client = new Client(getHeroName(), "", HeatType.High); client.addRequirenment(new Requirenment(ResourceType.Metal, Random.Range(5, 8))); client.addRequirenment(new Requirenment(ResourceType.Gem, Random.Range(3, 7))); day.Add(client); } { Client client = new Client(getHeroName(), "", HeatType.High); client.addRequirenment(new Requirenment(ResourceType.Gold, Random.Range(2, 3))); client.addRequirenment(new Requirenment(ResourceType.Metal, Random.Range(2, 3))); day.Add(client); } { Client client = new Client(getHeroName(), "", HeatType.Medium); client.addRequirenment(new Requirenment(ResourceType.Magic, Random.Range(2, 3))); client.addRequirenment(new Requirenment(ResourceType.Wood, Random.Range(2, 3))); day.Add(client); } { Client client = new Client(getHeroName(), "", HeatType.Medium); client.addRequirenment(new Requirenment(ResourceType.Gem, Random.Range(1, 4))); client.addRequirenment(new Requirenment(ResourceType.Gold, Random.Range(1, 4))); client.addRequirenment(new Requirenment(ResourceType.Wood, Random.Range(1, 4))); day.Add(client); } { Client client = new Client(getHeroName(), "", HeatType.Low); client.addRequirenment(new Requirenment(ResourceType.Magic, Random.Range(5, 7))); client.addRequirenment(new Requirenment(ResourceType.Gem, Random.Range(8, 11))); day.Add(client); } { Client client = new Client(getHeroName(), "", HeatType.VeryHigh); client.addRequirenment(new Requirenment(ResourceType.Magic, Random.Range(3, 6))); client.addRequirenment(new Requirenment(ResourceType.Gold, Random.Range(3, 6))); client.addRequirenment(new Requirenment(ResourceType.Wood, Random.Range(3, 6))); day.Add(client); } { Client client = new Client(getHeroName(), "", HeatType.Low); client.addRequirenment(new Requirenment(ResourceType.Gem, Random.Range(5, 8))); client.addRequirenment(new Requirenment(ResourceType.Metal, Random.Range(3, 7))); client.addRequirenment(new Requirenment(ResourceType.Wood, Random.Range(4, 6))); day.Add(client); } { Client client = new Client(getHeroName(), "", HeatType.High); client.addRequirenment(new Requirenment(ResourceType.Magic, Random.Range(9, 12))); client.addRequirenment(new Requirenment(ResourceType.Gold, Random.Range(9, 12))); day.Add(client); } } // ======================= // ========== DAY START 6============= { Day day = new Day(); days.Add(day); day.clientsPerDay = 15; { Client client = new Client(getHeroName(), "", HeatType.Low); client.addRequirenment(new Requirenment(ResourceType.Wood, Random.Range(5, 9))); client.addRequirenment(new Requirenment(ResourceType.Gold, Random.Range(3, 6))); client.addRequirenment(new Requirenment(ResourceType.Metal, Random.Range(3, 8))); day.Add(client); } { Client client = new Client(getHeroName(), "", HeatType.High); client.addRequirenment(new Requirenment(ResourceType.Magic, Random.Range(5, 8))); client.addRequirenment(new Requirenment(ResourceType.Gem, Random.Range(3, 7))); day.Add(client); } { Client client = new Client(getHeroName(), "", HeatType.High); client.addRequirenment(new Requirenment(ResourceType.Wood, Random.Range(2, 3))); client.addRequirenment(new Requirenment(ResourceType.Metal, Random.Range(2, 3))); day.Add(client); } { Client client = new Client(getHeroName(), "", HeatType.High); client.addRequirenment(new Requirenment(ResourceType.Gold, Random.Range(6, 12))); day.Add(client); } { Client client = new Client(getHeroName(), "", HeatType.Medium); client.addRequirenment(new Requirenment(ResourceType.Magic, Random.Range(2, 3))); client.addRequirenment(new Requirenment(ResourceType.Wood, Random.Range(2, 3))); day.Add(client); } { Client client = new Client(getHeroName(), "", HeatType.Medium); client.addRequirenment(new Requirenment(ResourceType.Gem, Random.Range(2, 4))); client.addRequirenment(new Requirenment(ResourceType.Gold, Random.Range(2, 4))); client.addRequirenment(new Requirenment(ResourceType.Wood, Random.Range(2, 4))); day.Add(client); } { Client client = new Client(getHeroName(), "", HeatType.Low); client.addRequirenment(new Requirenment(ResourceType.Magic, Random.Range(5, 7))); client.addRequirenment(new Requirenment(ResourceType.Gem, Random.Range(8, 11))); day.Add(client); } { Client client = new Client(getHeroName(), "", HeatType.VeryHigh); client.addRequirenment(new Requirenment(ResourceType.Magic, Random.Range(5, 7))); client.addRequirenment(new Requirenment(ResourceType.Gold, Random.Range(4, 6))); client.addRequirenment(new Requirenment(ResourceType.Wood, Random.Range(4, 6))); day.Add(client); } { Client client = new Client(getHeroName(), "", HeatType.Low); client.addRequirenment(new Requirenment(ResourceType.Gem, Random.Range(5, 8))); client.addRequirenment(new Requirenment(ResourceType.Gold, Random.Range(3, 7))); client.addRequirenment(new Requirenment(ResourceType.Wood, Random.Range(4, 6))); day.Add(client); } { Client client = new Client(getHeroName(), "", HeatType.High); client.addRequirenment(new Requirenment(ResourceType.Metal, Random.Range(11, 14))); client.addRequirenment(new Requirenment(ResourceType.Gold, Random.Range(11, 14))); day.Add(client); } { Client client = new Client(getHeroName(), "", HeatType.Low); client.addRequirenment(new Requirenment(ResourceType.Wood, Random.Range(10, 11))); client.addRequirenment(new Requirenment(ResourceType.Metal, Random.Range(10, 11))); client.addRequirenment(new Requirenment(ResourceType.Gem, Random.Range(10, 11))); day.Add(client); } { Client client = new Client(getHeroName(), "", HeatType.Low); client.addRequirenment(new Requirenment(ResourceType.Magic, Random.Range(20, 25))); day.Add(client); } } // ======================= // TODO день для расслабления // ВАЖНО для последнего дня задать day.clientsPerDay = -1; // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // ========== LAST DAY START ============= // ========== LAST DAY START ============= // ========== LAST DAY START ============= // ========== LAST DAY START ============= // ========== LAST DAY START ============= // ========== LAST DAY START ============= // ========== LAST DAY START ============= // обязательный medium типок // ========== DAY START 7============= { Day day = new Day(); days.Add(day); day.clientsPerDay = -1; { Client client = new Client(getHeroName(), "", HeatType.Low); client.addRequirenment(new Requirenment(ResourceType.Wood, Random.Range(5, 9))); client.addRequirenment(new Requirenment(ResourceType.Gold, Random.Range(3, 6))); client.addRequirenment(new Requirenment(ResourceType.Metal, Random.Range(3, 8))); day.Add(client); } { Client client = new Client(getHeroName(), "", HeatType.High); client.addRequirenment(new Requirenment(ResourceType.Magic, Random.Range(5, 8))); client.addRequirenment(new Requirenment(ResourceType.Gem, Random.Range(3, 7))); day.Add(client); } { Client client = new Client(getHeroName(), "", HeatType.High); client.addRequirenment(new Requirenment(ResourceType.Gold, Random.Range(2, 3))); client.addRequirenment(new Requirenment(ResourceType.Metal, Random.Range(2, 3))); day.Add(client); } { Client client = new Client(getHeroName(), "", HeatType.Medium); client.addRequirenment(new Requirenment(ResourceType.Magic, Random.Range(2, 3))); client.addRequirenment(new Requirenment(ResourceType.Wood, Random.Range(2, 3))); day.Add(client); } { Client client = new Client(getHeroName(), "", HeatType.Medium); client.addRequirenment(new Requirenment(ResourceType.Gem, Random.Range(1, 4))); client.addRequirenment(new Requirenment(ResourceType.Gold, Random.Range(1, 4))); client.addRequirenment(new Requirenment(ResourceType.Wood, Random.Range(1, 4))); day.Add(client); } { Client client = new Client(getHeroName(), "", HeatType.Low); client.addRequirenment(new Requirenment(ResourceType.Magic, Random.Range(5, 7))); client.addRequirenment(new Requirenment(ResourceType.Gem, Random.Range(8, 11))); day.Add(client); } { Client client = new Client(getHeroName(), "", HeatType.VeryHigh); client.addRequirenment(new Requirenment(ResourceType.Magic, Random.Range(3, 6))); client.addRequirenment(new Requirenment(ResourceType.Gold, Random.Range(3, 6))); client.addRequirenment(new Requirenment(ResourceType.Wood, Random.Range(3, 6))); day.Add(client); } { Client client = new Client(getHeroName(), "", HeatType.Low); client.addRequirenment(new Requirenment(ResourceType.Metal, Random.Range(5, 8))); client.addRequirenment(new Requirenment(ResourceType.Gold, Random.Range(3, 7))); client.addRequirenment(new Requirenment(ResourceType.Wood, Random.Range(4, 6))); day.Add(client); } { Client client = new Client(getHeroName(), "", HeatType.High); client.addRequirenment(new Requirenment(ResourceType.Gem, Random.Range(9, 12))); client.addRequirenment(new Requirenment(ResourceType.Metal, Random.Range(11, 14))); day.Add(client); } } // ======================= // ======================= InvokeRepeating("spawn", 2f, 5f); }
public LoadBuilder ForDay(Day day) { day.Add(Item); return(MySelf); }