Ejemplo n.º 1
0
        public Timeslot GetTimeslotById(int id)
        {
            var      fullModel = GetDataFromFile();
            Timeslot timeslot  = fullModel.Timeslots.FirstOrDefault(m => m.Id == id);

            return(timeslot);
        }
Ejemplo n.º 2
0
        private static List <Timeslot> ExtractTimeslots(IEnumerable <TimeregWithTimeslot> listOfTimregsWithTimeslot, Toolkit tk)
        {
            var timeslots = new List <Timeslot>();

            if (tk.TimeslotIsFieldLookup)
            {
                var uniqueTimeslots = listOfTimregsWithTimeslot.GroupBy(tkTimereg => tkTimereg.TimeslotId)
                                      .Select(t => t.First()).OrderBy(t => t.TimeslotId).ToList();
                foreach (var tkTimeslot in uniqueTimeslots)
                {
                    var timeslot = new Timeslot {
                        TimeInterval = ExtractTimeIntervalFromTimeslot(tkTimeslot)
                    };
                    timeslots.Add(timeslot);
                }
            }
            else
            {
                foreach (var tkTimeslot in listOfTimregsWithTimeslot)
                {
                    if (timeslots.Any(ts => ts.TimeInterval.Interval == tkTimeslot.Timeslot))
                    {
                        continue;
                    }
                    var timeslot = new Timeslot {
                        TimeInterval = ExtractTimeIntervalFromTimeslot(tkTimeslot)
                    };
                    timeslots.Add(timeslot);
                }
            }

            return(timeslots);
        }
        public void ThrowingNoFeasibleSolutionIfSpeakerWouldHaveToBeInTwoPlacesAtOnce3SessionsFor1SpeakerWith2Timeslots()
        {
            var speaker1 = Presenter.Create(1);
            var speaker2 = Presenter.Create(2);

            var sessions = new SessionsCollection();

            sessions.Add(1, null, speaker1);
            sessions.Add(2, null, speaker1);
            sessions.Add(3, null, speaker2);
            sessions.Add(4, null, speaker1);

            var rooms = new List <Room>();

            rooms.Add(Room.Create(1, 10));
            rooms.Add(Room.Create(2, 10));

            var timeslots = new List <Timeslot>();

            timeslots.Add(Timeslot.Create(1));
            timeslots.Add(Timeslot.Create(2));

            var engine = (null as IConferenceOptimizer).Create();

            Assert.Throws <Exceptions.NoFeasibleSolutionsException>(() => engine.Process(sessions, rooms, timeslots));
        }
        public void ReturningTheOnlyPossibleAssignmentIfTheSecondSessionIsDependentOnTheFirst()
        {
            var engine = (null as IConferenceOptimizer).Create();

            var sessions = new SessionsCollection();
            var session1 = sessions.Add(1, null, Presenter.Create(1));
            var session2 = sessions.Add(2, null, Presenter.Create(1));

            session2.AddDependency(session1);

            var rooms = new List <Room>();

            rooms.Add(Room.Create(1, 10));

            var timeslots = new List <Timeslot>();

            timeslots.Add(Timeslot.Create(1, 10));
            timeslots.Add(Timeslot.Create(2, 11));

            var assignments        = engine.Process(sessions, rooms, timeslots);
            var session2Assignment = assignments.Where(a => a.SessionId.Value == 2).Single();

            assignments.WriteSchedule();

            // Session 2 must be assigned to timeslot 2 to satisfy the dependencies
            Assert.Equal(2, session2Assignment.TimeslotId);
        }
Ejemplo n.º 5
0
        public IActionResult CreateReservation(ViewModel vm)
        {
            string[] check = AccessCheck();
            if (check != null)
            {
                return(RedirectToAction(check[0], check[1]));
            }
            if (vm.OneReservation.CreatorId == 0 || vm.OneReservation.CustomerId == 0 || vm.OneReservation.PractitionerId == 0 || vm.OneReservation.ServiceId == 0 || vm.OneReservation.TimeslotId == 0)
            {
                ViewBag.errormsg               = "You must select all options!";
                vm.CurrentUser                 = Query.OneReceptionist(UserSession.UserId, dbContext);
                vm.AllUsers                    = Query.AllUsers(dbContext);
                vm.AllCustomers                = Query.AllCustomers(dbContext);
                vm.AllInsurances               = Query.AllInsurances(dbContext);
                vm.AllServices                 = Query.AllServices(dbContext);
                vm.AllTimeslots                = Query.AllTimeslots(dbContext);
                vm.AllPractitioners            = Query.AllPractitioners(dbContext);
                vm.OneReservation.Practitioner = Query.OnePractitioner(vm.OneReservation.PractitionerId, dbContext);
                return(PartialView("NewReservation", vm));
            }
            Timeslot thisTS = Query.OneTimeslot(vm.OneReservation.TimeslotId, dbContext);

            vm.OneTimeslot                 = thisTS;
            vm.AllPractitioners            = Query.AllPractitioners(dbContext);
            vm.OneCustomer                 = Query.OneCustomer(vm.OneReservation.CustomerId, dbContext);
            vm.OneService                  = Query.OneService(vm.OneReservation.ServiceId, dbContext);
            vm.OneInsurance                = Query.OneInsurance(vm.OneCustomer.InsuranceId, dbContext);
            vm.OneReservation.Practitioner = Query.OnePractitioner(vm.OneReservation.PractitionerId, dbContext);
            vm.CurrentUser                 = UserSession;
            return(PartialView("ReservationForm", vm));
        }
Ejemplo n.º 6
0
        public void NotAssigningASessionToARoomWhenItIsNotAvailableInTimesdlot2()
        {
            var engine = (null as IConferenceOptimizer).Create();

            var sessions = new SessionsCollection();

            sessions.Add(1, null, Presenter.Create(1));
            sessions.Add(2, null, Presenter.Create(2));
            sessions.Add(3, null, Presenter.Create(3));

            var rooms = new List <Room>();

            rooms.Add(Room.Create(1, 10));
            rooms.Add(Room.Create(2, 10, 2));

            var timeslots = new List <Timeslot>();

            timeslots.Add(Timeslot.Create(1));
            timeslots.Add(Timeslot.Create(2));

            var assignments     = engine.Process(sessions, rooms, timeslots);
            var checkAssignment = assignments.Where(a => a.RoomId == 2 && a.TimeslotId == 2).SingleOrDefault();

            assignments.WriteSchedule();

            if (checkAssignment == null)
            {
                Assert.Null(checkAssignment);
            }
            else
            {
                // No session should have been assigned to room 2 during timeslot 2
                Assert.Null(checkAssignment.SessionId);
            }
        }
        public void FindingTheOnlyValidTimeslotForASessionWithChainedDependencies()
        {
            var engine = (null as IConferenceOptimizer).Create();

            var sessions = new SessionsCollection();

            var session1 = sessions.Add(1, null, Presenter.Create(1));
            var session2 = sessions.Add(2, null, Presenter.Create(3));
            var session3 = sessions.Add(3, null, Presenter.Create(1));
            var session4 = sessions.Add(4, null, Presenter.Create(2));
            var session5 = sessions.Add(5, null, Presenter.Create(2));
            var session6 = sessions.Add(6, null, Presenter.Create(2));

            session5.AddDependency(session6);
            session4.AddDependency(session5);

            var rooms = new List <Room>();

            rooms.Add(Room.Create(1));
            rooms.Add(Room.Create(2));

            var timeslots = new List <Timeslot>();

            timeslots.Add(Timeslot.Create(1, 8.5));
            timeslots.Add(Timeslot.Create(2, 9.75));
            timeslots.Add(Timeslot.Create(3, 11.0));

            var assignments = engine.Process(sessions, rooms, timeslots);

            assignments.WriteSchedule();
            var testAssignment = assignments.Single(a => a.SessionId == 4);

            // Session 4 must be in the 3rd timeslot
            Assert.Equal(3, testAssignment.TimeslotId);
        }
        public void NotFailIfTwoUnnamedSessionsHaveTheSameTimeslotUnavailability()
        {
            // This test exposes a bug that existed in a version
            // of the tool in early Oct 2018 where failing to add
            // a name caused a collision in naming constraints
            // if the same Timeslot is unavailable for multiple sessions
            var engine = (null as IConferenceOptimizer).Create();

            var sessions = new SessionsCollection();

            sessions.Add(1, null, Presenter.Create(1, new int[] { 2 }));
            sessions.Add(2, null, Presenter.Create(2, new int[] { 2 }));

            var rooms = new List <Room>();

            rooms.Add(Room.Create(1, 10));

            var timeslots = new List <Timeslot>();

            timeslots.Add(Timeslot.Create(1));
            timeslots.Add(Timeslot.Create(2));
            timeslots.Add(Timeslot.Create(3));

            var assignments = engine.Process(sessions, rooms, timeslots);

            assignments.WriteSchedule();
        }
Ejemplo n.º 9
0
        public bool CheckTimeslot(string timeslotId, DateTime date)
        {
            var today = DateTime.Now.TimeOfDay;

            try
            {
                // get data from local db
                if (EnumAppConfig.IsLocal)
                {
                    Timeslot timeslot = _localUnitOfWork.DataContext.Timeslots.FirstOrDefault(item => item.Timeslot_ID == timeslotId);
                    if (date > DateTime.Now.Date)
                    {
                        return(false);
                    }
                    if (timeslot.EndTime < today)
                    {
                        return(true);//is past
                    }
                    return(false);
                }
                else // request from centralized api
                {
                    Timeslot timeslot = _centralizedUnitOfWork.DataContext.Timeslots.FirstOrDefault(item => item.Timeslot_ID == timeslotId);
                    if (timeslot.EndTime < today)
                    {
                        return(true);//is past
                    }
                    return(false);
                }
            }
            catch (Exception ex)
            {
                return(true);
            }
        }
Ejemplo n.º 10
0
        public void SeparatingSessionsInTheSameTrackIntoDifferentTimslots_4Sessions3Tracks()
        {
            var sessions = new SessionsCollection();

            sessions.Add(1, 1, Presenter.Create(1));
            sessions.Add(2, 2, Presenter.Create(2));
            sessions.Add(3, 1, Presenter.Create(3));
            sessions.Add(4, 3, Presenter.Create(4));

            var rooms = new List <Room>();

            rooms.Add(Room.Create(1, 10));
            rooms.Add(Room.Create(2, 10));

            var timeslots = new List <Timeslot>();

            timeslots.Add(Timeslot.Create(1, 9.0));
            timeslots.Add(Timeslot.Create(2, 10.25));

            var engine = (null as IConferenceOptimizer).Create();

            var assignments = engine.Process(sessions, rooms, timeslots);

            assignments.WriteSchedule();

            var s1TimeslotId = assignments.Where(a => a.SessionId == 1).Single().TimeslotId;
            var s3TimeslotId = assignments.Where(a => a.SessionId == 3).Single().TimeslotId;

            Assert.That(s1TimeslotId, Is.Not.EqualTo(s3TimeslotId), "Sessions with the same TopicId should not be in the same timeslot.");
        }
Ejemplo n.º 11
0
        public async Task <ActionResult> InsertTimeslot(CRUDModel <TimeslotViewModel> timeslot)
        {
            try
            {
                var newTimeslot = new Timeslot
                {
                    Label        = timeslot.Value.Label,
                    StartTime    = timeslot.Value.StartTime,
                    EndTime      = timeslot.Value.EndTime,
                    Description  = timeslot.Value.Description,
                    Color        = timeslot.Value.Color != null ? "#FF" + timeslot.Value.Color.Remove(timeslot.Value.Color.Length - 2).Substring(1).ToUpper() : null,
                    DisplayOrder = timeslot.Value.DisplayOrder,
                    IsDeleted    = false
                };
                Timeslot[] addTimeslot = { newTimeslot };
                var        data        = await _prepareService.SaveTimeslots(addTimeslot);

                var currentTimeSlot = data.FirstOrDefault();
                timeslot.Value.TimeslotId      = currentTimeSlot.TimeslotId;
                timeslot.Value.StartTimeString = DateTime.Today.Add(timeslot.Value.StartTime).ToString("HH:mm");
                timeslot.Value.EndTimeString   = DateTime.Today.Add(timeslot.Value.EndTime).ToString("HH:mm");
                return(Json(timeslot.Value, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                var message = string.Join(" | ", ModelState.Values
                                          .SelectMany(v => v.Errors)
                                          .Select(e => e.ErrorMessage));
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, ex.Message));
            }
        }
        private static IList <Timeslot> PopulateWeeksForBeacon(BeaconAvailability beaconAvailability, DateTime startTime)
        {
            var      slots       = new List <Timeslot>();
            DateTime currentDate = startTime;

            while (currentDate < DateTime.Now.AddMonths(3))
            {
                Timeslot newTimeslot = new Timeslot();
                newTimeslot.Start = currentDate;
                newTimeslot.End   = currentDate.AddDays(7);
                newTimeslot.Unit  = TimeslotUnit.Weeks;

                // Select bookings which start or end in this period
                newTimeslot.Bookings = beaconAvailability.Bookings.Where(b =>
                                                                         (b.Start >= newTimeslot.Start && b.Start < newTimeslot.End) ||
                                                                         (b.End > newTimeslot.Start && b.End <= newTimeslot.End)).Select(booking => new TimeslotBooking()
                {
                    ContentId    = booking.ContentId,
                    ContentTitle = booking.Description
                }).ToList();
                newTimeslot.Timeslots = PopulateDaysOfWeekForBeacon(beaconAvailability, currentDate.Date, currentDate.AddDays(7).Date);

                currentDate = currentDate.AddDays(7);
                slots.Add(newTimeslot);
            }

            return(slots);
        }
Ejemplo n.º 13
0
        public void AssigningAllSessions()
        {
            var sessions = new SessionsCollection();

            sessions.Add(1, null, Presenter.Create(1));
            sessions.Add(2, null, Presenter.Create(2));
            sessions.Add(3, null, Presenter.Create(2));
            sessions.Add(4, null, Presenter.Create(3));
            sessions.Add(5, null, Presenter.Create(3));
            sessions.Add(6, null, Presenter.Create(3));
            sessions.Add(7, null, Presenter.Create(3));

            var rooms = new List <Room>();

            rooms.Add(Room.Create(1, 10));
            rooms.Add(Room.Create(2, 10));
            rooms.Add(Room.Create(3, 10));

            var timeslots = new List <Timeslot>();

            timeslots.Add(Timeslot.Create(1));
            timeslots.Add(Timeslot.Create(2));
            timeslots.Add(Timeslot.Create(3));
            timeslots.Add(Timeslot.Create(4));
            timeslots.Add(Timeslot.Create(5));

            var engine = (null as IConferenceOptimizer).Create();

            var assignments             = engine.Process(sessions, rooms, timeslots);
            var assignmentsWithSessions = assignments.Where(a => a.SessionId.HasValue);

            assignments.WriteSchedule();
            Assert.That(assignmentsWithSessions.Count(), Is.EqualTo(sessions.Count()), "The wrong number of assignments were returned.");
        }
        public void ResultInTheSameNumberOfAssignments()
        {
            var sessions = new SessionsCollection();

            sessions.Add(1, null, Presenter.Create(1));
            sessions.Add(2, 1, Presenter.Create(2));
            sessions.Add(3, null, Presenter.Create(3));
            sessions.Add(4, 1, Presenter.Create(4));

            var rooms = new List <Room>();

            rooms.Add(Room.Create(1, 10));
            rooms.Add(Room.Create(2, 10));

            var timeslots = new List <Timeslot>();

            timeslots.Add(Timeslot.Create(1, 9.0));
            timeslots.Add(Timeslot.Create(2, 10.25));

            var solution = new Solution(sessions, rooms, timeslots);

            while (solution.AssignmentsCompleted < sessions.Count())
            {
                solution.AssignSessionsWithOnlyOneOption();
                solution.AssignMostConstrainedSession();
            }

            var s2 = solution.SwapAssignments();

            Assert.AreEqual(solution.Assignments.Count(), s2.Assignments.Count());
        }
        public void PuttingSessionsInTheSameTrackIntoTheSameRoom_4Sessions1Track()
        {
            var sessions = new SessionsCollection();

            sessions.Add(1, 1, Presenter.Create(1));
            sessions.Add(2, 2, Presenter.Create(2));
            sessions.Add(3, 1, Presenter.Create(3));
            sessions.Add(4, 3, Presenter.Create(4));

            var rooms = new List <Room>();

            rooms.Add(Room.Create(1, 10));
            rooms.Add(Room.Create(2, 10));

            var timeslots = new List <Timeslot>();

            timeslots.Add(Timeslot.Create(1, 9.0));
            timeslots.Add(Timeslot.Create(2, 10.25));

            var engine = (null as IConferenceOptimizer).Create();

            var assignments = engine.Process(sessions, rooms, timeslots);

            assignments.WriteSchedule();

            var s1RoomId = assignments.Where(a => a.SessionId == 1).Single().RoomId;
            var s3RoomId = assignments.Where(a => a.SessionId == 3).Single().RoomId;

            // Sessions with the same TopicId should be in the same room whenever possible
            Assert.Equal(s1RoomId, s3RoomId);
        }
Ejemplo n.º 16
0
        public List <Timeslot> getTimeSlotList()
        {
            SqlConnection   scon            = new SqlConnection(conn);
            List <Timeslot> objTimeslotList = new List <Timeslot>();

            using (SqlCommand scmd = new SqlCommand())
            {
                scmd.Connection  = scon;
                scmd.CommandType = CommandType.Text;
                scmd.CommandText = "SELECT * FROM TimeSlot";
                scon.Open();
                SqlDataReader sdr = scmd.ExecuteReader();
                while (sdr.Read())
                {
                    Timeslot objTimeslotMaster = new Timeslot();
                    objTimeslotMaster.timeslotId = Convert.ToInt32(sdr["timeslotId"]);
                    objTimeslotMaster.timeslot   = sdr["timeslot"].ToString();


                    objTimeslotList.Add(objTimeslotMaster);
                }

                if (sdr != null)
                {
                    sdr.Dispose();
                    sdr.Close();
                }
                scon.Close();
                return(objTimeslotList.ToList());;
            }
        }
        public void ReturningTheCorrectAssignmentIfOneSpeakerIsAvailableForOnlyOneSlot()
        {
            var engine = (null as IConferenceOptimizer).Create();

            var sessions = new SessionsCollection();

            sessions.Add(1, null, Presenter.Create(1));
            sessions.Add(2, null, Presenter.Create(2, new int[] { 2, 3 })); // Only available for slot 1
            sessions.Add(3, null, Presenter.Create(3));

            var rooms = new List <Room>();

            rooms.Add(Room.Create(1, 10));

            var timeslots = new List <Timeslot>();

            timeslots.Add(Timeslot.Create(1));
            timeslots.Add(Timeslot.Create(2));
            timeslots.Add(Timeslot.Create(3));

            var assignments     = engine.Process(sessions, rooms, timeslots);
            var checkAssignment = assignments.Where(a => a.SessionId == 2).Single();

            assignments.WriteSchedule();

            // Session 2 should have been assigned to slot 1
            Assert.Equal(1, checkAssignment.TimeslotId);
        }
Ejemplo n.º 18
0
        private void DrawTransparentTimeslot(Graphics g, Timeslot t, Color color)
        {
            var r = TimeslotRectangle(t);

            g.FillRectangle(new SolidBrush(Color.FromArgb(80, color)), r);
            g.DrawRectangle(new Pen(color, 3f), r);
        }
        public void ReturningTheCorrectAssignmentIfTwoSpeakersAreAvailableForTwoOfTheThreeSlots()
        {
            var engine = (null as IConferenceOptimizer).Create();

            var sessions = new SessionsCollection();

            sessions.Add(1, null, Presenter.Create(1, new int[] { 2 })); // Not available for slot 2
            sessions.Add(2, null, Presenter.Create(2, new int[] { 2 })); // Not available for slot 2
            sessions.Add(3, null, Presenter.Create(3));                  // Available for all but must be assigned to slot 2

            var rooms = new List <Room>();

            rooms.Add(Room.Create(1, 10));

            var timeslots = new List <Timeslot>();

            timeslots.Add(Timeslot.Create(1));
            timeslots.Add(Timeslot.Create(2));
            timeslots.Add(Timeslot.Create(3));

            var assignments     = engine.Process(sessions, rooms, timeslots);
            var checkAssignment = assignments.Where(a => a.SessionId == 3).Single();

            assignments.WriteSchedule();

            // Session 3 should have been assigned to slot 2
            Assert.Equal(2, checkAssignment.TimeslotId);
        }
Ejemplo n.º 20
0
        private Rectangle TimeslotRectangle(Timeslot t, ClashRectangle clashRectangle = ClashRectangle.None)
        {
            var r = new Rectangle(_table.Location, CellSize);

            switch (clashRectangle)
            {
            case ClashRectangle.Left:
            {
                r.Width /= 2;
                break;
            }

            case ClashRectangle.Right:
            {
                r.Width /= 2;
                r.Offset(r.Width, 0);
                break;
            }
            }

            r.Offset(CellSize.Width * (t.Day - (_showWeekend ? 0 : 1)),
                     CellSize.Height * (t.Start.DayMinutes - HourStart * 60) / 60);
            r.Height = (int)Math.Ceiling(t.TotalMinutes / 60f * CellSize.Height);
            return(r);
        }
    private static bool InTimeslot(Broadcast broadcast, Timeslot timeslot)
    {
        var startsInTimeslot = timeslot.Start <= broadcast.StartTime && broadcast.StartTime < timeslot.End;
        var endsInTimeslot   = timeslot.End < broadcast.EndTime && broadcast.EndTime <= timeslot.End;

        return(startsInTimeslot || endsInTimeslot);
    }
        public void ReturnThreeIfThereAreTwoConflictsInTheTimeslot()
        {
            // 3 Rooms, 2 timeslots, 6 Sessions

            var sessions = new SessionsCollection();

            sessions.Add(1, 1, Presenter.Create(1));
            sessions.Add(2, 1, Presenter.Create(2));
            sessions.Add(3, 1, Presenter.Create(2));
            sessions.Add(4, 2, Presenter.Create(3));
            sessions.Add(5, 3, Presenter.Create(3));
            sessions.Add(6, 4, Presenter.Create(3));

            var assignments = new List <Assignment>();

            assignments.Add(new Assignment(1, 1, 1));
            assignments.Add(new Assignment(1, 1, 2));
            assignments.Add(new Assignment(2, 1, 3));
            assignments.Add(new Assignment(2, 2, 4));
            assignments.Add(new Assignment(3, 2, 5));
            assignments.Add(new Assignment(3, 2, 6));

            var target = new Timeslot()
            {
                Id = 1, DayIndex = 0, StartHour = 11.0F
            };
            var result = target.GetTopicScore(assignments, sessions);

            Assert.AreEqual(3, result);
        }
        public void ThrowingNoFeasibleSolutionIfAvailableTimeslotsForAMultiPresenterSessionDontIntersect()
        {
            // 2 presenters for one session where neither
            // is available to present when the other is available

            var presenter1 = Presenter.Create(1, 2);
            var presenter2 = Presenter.Create(2, 1);

            var sessions = new SessionsCollection();

            sessions.Add(1, null, presenter1, presenter2);

            var rooms = new List <Room>()
            {
                Room.Create(1, 10)
            };

            var timeslots = new List <Timeslot>();

            timeslots.Add(Timeslot.Create(1));
            timeslots.Add(Timeslot.Create(2));

            var engine = (null as IConferenceOptimizer).Create();

            var assignments = engine.Process(sessions, rooms, timeslots);
        }
Ejemplo n.º 24
0
        private void Handle(MaintenanceJobFinished e)
        {
            MaintenanceJob job            = Jobs.FirstOrDefault(j => j.Id == e.JobId);
            Timeslot       actualTimeslot = Timeslot.Create(e.StartTime, e.EndTime);

            job.Finish(actualTimeslot, e.Notes);
        }
Ejemplo n.º 25
0
 public static void PlannedMaintenanceJobShouldFallWithinOneBusinessDay(this PlanMaintenanceJob command)
 {
     if (!Timeslot.Create(command.StartTime, command.EndTime).IsWithinOneDay())
     {
         throw new BusinessRuleViolationException("Start-time and end-time of a Maintenance Job must be within a 1 day.");
     }
 }
Ejemplo n.º 26
0
        public List <Timeslot> ReadTimeslotsFromID(int id)
        {
            List <Timeslot> timeslots = new List <Timeslot>();

            if (connect.State == ConnectionState.Open)
            {
                command = new SqlCommand("Select * from Constraintt where constraint_id='" + id + "'", connect);
                try
                {
                    reader = command.ExecuteReader();
                    while (reader.Read())
                    {
                        Timeslot timeslot = new Timeslot();

                        timeslot.day    = reader[4].ToString();
                        timeslot.period = reader[5].ToString();

                        timeslots.Add(timeslot);
                    }
                    reader.Close();
                }
                catch (Exception)
                {
                    reader.Close();
                }
            }

            return(timeslots);
        }
Ejemplo n.º 27
0
        public void Finish_Should_Finish_An_Existing_Job()
        {
            // arrange
            MaintenanceJobBuilder maintenanceJobBuilder = new MaintenanceJobBuilder();
            MaintenanceJob        sut = maintenanceJobBuilder
                                        .Build();

            DateTime actualStartTime = maintenanceJobBuilder.StartTime.AddMinutes(30);
            DateTime actualEndTime   = maintenanceJobBuilder.EndTime.AddMinutes(15);
            Timeslot actualTimeslot  = Timeslot.Create(actualStartTime, actualEndTime);
            string   notes           = $"Mechanic notes {maintenanceJobBuilder.JobId}";

            // act
            sut.Finish(actualTimeslot, notes);

            // assert
            Assert.Equal(maintenanceJobBuilder.JobId, sut.Id);
            Assert.Equal(maintenanceJobBuilder.StartTime, sut.PlannedTimeslot.StartTime);
            Assert.Equal(maintenanceJobBuilder.EndTime, sut.PlannedTimeslot.EndTime);
            Assert.Equal(maintenanceJobBuilder.CustomerBuilder.Id, sut.Customer.Id);
            Assert.Equal(maintenanceJobBuilder.CustomerBuilder.Name, sut.Customer.Name);
            Assert.Equal(maintenanceJobBuilder.CustomerBuilder.TelephoneNumber, sut.Customer.TelephoneNumber);
            Assert.Equal(maintenanceJobBuilder.VehicleBuilder.LicenseNumber, sut.Vehicle.Id);
            Assert.Equal(maintenanceJobBuilder.VehicleBuilder.Brand, sut.Vehicle.Brand);
            Assert.Equal(maintenanceJobBuilder.VehicleBuilder.Type, sut.Vehicle.Type);
            Assert.Equal(maintenanceJobBuilder.VehicleBuilder.OwnerId, sut.Vehicle.OwnerId);
            Assert.Equal(maintenanceJobBuilder.Description, sut.Description);
            Assert.Equal(actualTimeslot, sut.ActualTimeslot);
            Assert.Equal(notes, sut.Notes);
            Assert.Equal("Completed", sut.Status);
        }
        public void ThrowingDependencyExceptionIfCircularDependenciesExist()
        {
            var presenter1 = Presenter.Create(1, 2);

            var sessions = new SessionsCollection();

            var session1 = sessions.Add(1, 1, Presenter.Create(1));
            var session2 = sessions.Add(2, 1, Presenter.Create(2));
            var session3 = sessions.Add(3, 1, Presenter.Create(3));

            session1.AddDependency(session2);
            session2.AddDependency(session3);
            session3.AddDependency(session1);

            var rooms = new List <Room>();

            rooms.Add(Room.Create(1, 10));
            rooms.Add(Room.Create(2, 10));

            var timeslots = new List <Timeslot>();

            timeslots.Add(Timeslot.Create(1));
            timeslots.Add(Timeslot.Create(2));

            var engine = (null as IConferenceOptimizer).Create();

            var assignments = engine.Process(sessions, rooms, timeslots);
        }
Ejemplo n.º 29
0
        public async Task <IActionResult> Edit(int id, [Bind("SlotID,TimeSlot")] Timeslot timeslot)
        {
            if (id != timeslot.SlotID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(timeslot);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TimeslotExists(timeslot.SlotID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(timeslot));
        }
Ejemplo n.º 30
0
 public void Plan(Timeslot timeslot, Vehicle vehicle, Customer customer, string description)
 {
     PlannedTimeslot = timeslot;
     Vehicle         = vehicle;
     Customer        = customer;
     Description     = description;
 }
Ejemplo n.º 31
0
        public void Save(Timeslot timeslot)
        {
            this._db.OpenConnection();
            MySqlCommand command = this._db.CreateCommand();

            command.CommandText = "UPDATE timeslot SET time=?time WHERE id = ?id";

            command.Parameters.Add(new MySqlParameter("?id", MySqlDbType.Int32)).Value = timeslot.Id;
            command.Parameters.Add(new MySqlParameter("?time", MySqlDbType.String)).Value = timeslot.Time;

            this._db.ExecuteCommand(command);
            this._db.CloseConnection();
        }
Ejemplo n.º 32
0
        private void btnAddSchedule_Click(object sender, EventArgs e)
        {
            if (cmbGradeLevel.Text != string.Empty && cmbSection.Text != string.Empty && cmbTimeslot.Text != string.Empty &&
                cmbSubject.Text != string.Empty && cmbTeacher.Text != string.Empty && cmbRoom.Text != string.Empty)
            {
                Timeslot t = new Timeslot();
                t = timeslots.Find(x => x.TimeSlotCode == cmbTimeslot.SelectedValue.ToString());

                GradeSection gs = new GradeSection();
                gs = sections.Find(x => x.GradeSectionCode == sectioncode);

                Subject su = new Subject();
                su = subjects.Find(x => x.SubjectCode == cmbSubject.SelectedValue.ToString());

                Room rm = new Room();
                rm = rooms.Find(x => x.RoomId == Int32.Parse(cmbRoom.SelectedValue.ToString()));

                Teacher tc = new Teacher();
                tc = teachers.Find(x => x.TeacherId == cmbTeacher.SelectedValue.ToString());

                SubjectAssignment sa = new SubjectAssignment();
                sa.GradeLevel = cmbGradeLevel.SelectedValue.ToString() ;
                sa.TeacherName = cmbTeacher.Text;
                sa.SY = currentSY;
                sa.Subject = su;
                sa.SubjectCode = su.SubjectCode;
                sa.TimeslotInfo = t.TimeSlotInfo;
                sa.TimeSlotCode = t.TimeSlotCode;
                sa.Room = rm;
                sa.RoomId = rm.RoomId;
                sa.RoomCode = rm.RoomCode;
                sa.Teacher = tc;
                sa.TeacherId = tc.TeacherId;
                sa.Section = section;
                sa.GradeSection = gs;
                sa.GradeSectionCode = gs.GradeSectionCode;
                sa.Timeslot = t;
                sa.Timestart = t.TimeStart;
                sa.TimeEnd = t.TimeEnd;
                sa.Days = t.Days;
                sa.Deactivated = false;
                createdSchedule.Add(sa);

                schedules.Add(sa);

                LoadSchedules();

            }
        }
Ejemplo n.º 33
0
        private void gvTimeSlot_SelectionChanged(object sender, EventArgs e)
        {
            int selectedIndex = gvTimeSlot.CurrentRow.Index;


            if (selectedIndex >= 0)
            {
                string tCode = gvTimeSlot.Rows[selectedIndex].Cells["TimeslotCode"].Value.ToString();
                List<Timeslot> item = new List<Timeslot>();
                item = timeslotList.FindAll(x => x.TimeSlotCode.ToString() == tCode);

                timeslotSelected = new Timeslot();
                timeslotSelected = (Timeslot)item[0];

            }
        }
        public void ReturnOneIfThereIsOneConflictInTheTimeslot()
        {
            // 2 Rooms, 3 timeslots, 6 Sessions

            var sessions = new SessionsCollection();
            sessions.Add(1, 1, Presenter.Create(1));
            sessions.Add(2, 2, Presenter.Create(2));
            sessions.Add(3, 3, Presenter.Create(2));
            sessions.Add(4, 4, Presenter.Create(3));
            sessions.Add(5, 2, Presenter.Create(3));
            sessions.Add(6, 6, Presenter.Create(3));

            var assignments = new List<Assignment>();
            assignments.Add(new Assignment(1, 1, 1));
            assignments.Add(new Assignment(1, 2, 2));
            assignments.Add(new Assignment(1, 3, 3));
            assignments.Add(new Assignment(2, 1, 4));
            assignments.Add(new Assignment(2, 2, 5));
            assignments.Add(new Assignment(2, 3, 6));

            var target = new Timeslot() { Id = 2, DayIndex = 0, StartHour = 11.0F };
            var result = target.GetTopicScore(assignments, sessions);
            Assert.AreEqual(1, result);
        }
Ejemplo n.º 35
0
        private void button1_Click(object sender, EventArgs e)
        {
            using (var ctx = new ScheduleContext())
            {
                if (comboBox1.SelectedItem.ToString() == "")
                {
                    MessageBox.Show("Missing required input from dropdown menu.", "Missing input", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    var timeslot = new Timeslot
                    {
                        From = Convert.ToInt32(textBox2.Text),
                        To = Convert.ToInt32(textBox3.Text),
                        Day = comboBox1.SelectedItem.ToString(),
                    };

                    ctx.Timeslots.Add(timeslot);
                    ctx.SaveChanges();
                    var len = ctx.Timeslots.ToArray().Length;
                    this.Close();
                }
            }
        }
        public void ReturnSevenIfThereAreThreeConflictsInTheTimeslot()
        {
            // 4 Rooms, 2 timeslots, 6 Sessions

            var sessions = new SessionsCollection();
            sessions.Add(1, 1, Presenter.Create(1));
            sessions.Add(2, 1, Presenter.Create(2));
            sessions.Add(3, 1, Presenter.Create(2));
            sessions.Add(4, 1, Presenter.Create(3));
            sessions.Add(5, 3, Presenter.Create(3));
            sessions.Add(6, 4, Presenter.Create(3));

            var assignments = new List<Assignment>();
            assignments.Add(new Assignment(1, 1, 1));
            assignments.Add(new Assignment(2, 1, 2));
            assignments.Add(new Assignment(3, 1, 3));
            assignments.Add(new Assignment(4, 1, 4));
            assignments.Add(new Assignment(1, 2, 5));
            assignments.Add(new Assignment(2, 2, 6));

            var target = new Timeslot() { Id = 1, DayIndex = 0, StartHour = 11.0F };
            var result = target.GetTopicScore(assignments, sessions);
            Assert.AreEqual(7, result);
        }
Ejemplo n.º 37
0
 /// <summary>
 /// Find an unavailable timeslot within the given range.
 /// </summary>
 /// <returns>The first unavailable timeslot found within the range, or null if none were found.</returns>
 public Unavailability FindUnavailableDuring(Timeslot timeslot)
 {
     foreach (Unavailability u in UnavailableList)
     {
         if (u.ClashesWith(timeslot))
             return u;
     }
     return null;
 }
Ejemplo n.º 38
0
 /// <summary>
 /// Check if there is an unavailable timeslot within the given timeslot.
 /// </summary>
 public bool UnavailableDuring(Timeslot timeslot)
 {
     return FindUnavailableDuring(timeslot) != null;
 }
Ejemplo n.º 39
0
 /// <summary>
 /// Check if a given timeslot is free.
 /// </summary>
 /// <returns>True if there is nothing on during the timeslot.</returns>
 public bool FreeDuring(Timeslot timeslot, bool selected)
 {
     return !ClassDuring(timeslot, selected)
         && !UnavailableDuring(timeslot);
 }
Ejemplo n.º 40
0
        public void UpdateTimeslot(Timeslot timeslot)
        {
            //ToDo: Add error handling here. Brian Hall had an unhandled exception when he tried to submit a timeslot that was a past date-time.
            using (OCCDB db = new OCCDB())
            {
                var t = db.Timeslots.Find(timeslot.ID);

                t.Name = timeslot.Name;
                t.StartTime = timeslot.StartTime;
                t.EndTime = timeslot.EndTime;

                db.SaveChanges();
            }
        }
Ejemplo n.º 41
0
        private void DrawTimeslotText(Graphics g, Timeslot t, String text)
        {
            if (text == null || text.Length == 0)
                return;

            StringFormat format = new StringFormat();
            format.Alignment = StringAlignment.Center;
            format.LineAlignment = StringAlignment.Center;

            Rectangle r = TimeslotRectangle(t);
            g.DrawString(text, Font, Brushes.Black, r, format);
        }
Ejemplo n.º 42
0
 private void DrawActive(Graphics g, Timeslot timeslot, Color color)
 {
     Rectangle r = TimeslotRectangle(timeslot);
     r.X++; r.Y++; r.Width--; r.Height--;
     g.FillRectangle(LinearGradientActive(r.Location, Cell_.Width, Cell_.Height, color), r);
 }
Ejemplo n.º 43
0
		internal IEnumerable<BannerQuerySetInfo> BannerQuerySetInfosInDescendingPriorityOrder(Timeslot currentTimeslot)
		{
			ReadOnlyCollection<BannerDataHolder> banners = this.GetBannersSatsfyingQueryConditionsInTimeslot(currentTimeslot);
			List<BannerDataHolder> bannerSetBanners = null;
			for (int i = 0; i < banners.Count; i++)
			{
				bannerSetBanners = new List<BannerDataHolder>();
				int priority = banners[i].Priority;
				bool alwaysShow = banners[i].AlwaysShow;
				bannerSetBanners.Add(banners[i]);
				while (i + 1 < banners.Count && banners[i + 1].Priority == priority && banners[i + 1].AlwaysShow == alwaysShow)
				{
					i++;
					bannerSetBanners.Add(banners[i]);
				}
				if (alwaysShow)
				{
					yield return new AlwaysShowBannerQuerySetInfo(bannerSetBanners);
				}
				else
				{
					TargetHitsBannerQuerySetInfo reqInfo = new TargetHitsBannerQuerySetInfo(bannerSetBanners, currentTimeslot, info => info.RequiredHits);
					#region REMOVED DUE TO BANNER SERVER BUG
					//AddNewIndicesToListForRemoval(bannerSetBanners.Count, i, reqInfo.IndicesOfBannersThatHaveReachedTheirLimits);
					#endregion
					yield return reqInfo;

					TargetHitsBannerQuerySetInfo desInfo = new TargetHitsBannerQuerySetInfo(bannerSetBanners, currentTimeslot, info => info.DesiredHits);
					#region REMOVED DUE TO BANNER SERVER BUG
					//// bump up the indexes from this set to make them apply to master set
					//AddNewIndicesToListForRemoval(bannerSetBanners.Count, i, desInfo.IndicesOfBannersThatHaveReachedTheirLimits);
					#endregion
					yield return desInfo;
				}
			}
		}
Ejemplo n.º 44
0
        protected override void OnDragOver(DragEventArgs drgevent)
        {
            TimeOfWeek time = FindClickTime(PointToClient(new Point(drgevent.X, drgevent.Y)));
            // outside of table bounds?
            if (TimeOfWeek.ReferenceEquals(time, null))
            {
                // clear current preview (at edge of timetable)
                EndPreviewStream();
                // cannot drag outside of the actual table
                drgevent.Effect = DragDropEffects.None;
                return;
            }

            // dragging a class
            if (drgevent.Data.GetDataPresent(typeof(Session)) || drgevent.Data.GetDataPresent(typeof(Type)))
            {
                drgevent.Effect = DragDropEffects.Move;
                Type dragType;
                if (drgevent.Data.GetDataPresent(typeof(Session)))
                    dragType = ((Session)drgevent.Data.GetData(typeof(Session))).Stream.Type;
                else
                    dragType = (Type)drgevent.Data.GetData(typeof(Type));

                Session session = Timetable.From(dragType).FindClassAt(time, false);
                if (session == null)
                {
                    EndPreviewStream();
                }
                else
                {
                    PreviewEquiv(session.Stream);
                }
            }
            // dragging an unavailability
            else if (drgevent.Data.GetDataPresent(typeof(Unavailability)))
            {
                Unavailability dragUnavail = (Unavailability)drgevent.Data.GetData(typeof(Unavailability));
                TimeLength offset = new TimeLength(dragUnavail.StartMinute);
                TimeOfWeek start = time - dragUnavail.Length / 2;
                start -= offset;
                start.RoundToNearestHour();
                start += offset;

                HoverUnavail_ = new Timeslot(start.Day, (TimeOfDay)start, (TimeOfDay)start + dragUnavail.Length);
                if (HoverUnavail_.StartTime < new TimeOfDay(HourStart_, 0) || HoverUnavail_.EndTime > new TimeOfDay(HourEnd_, 0))
                {
                    drgevent.Effect = DragDropEffects.None;
                    HoverUnavail_ = null;
                }
                else
                {
                    drgevent.Effect = DragDropEffects.Move;
                }
                Invalidate();
            }
            else
            {
                base.OnDragOver(drgevent);
            }
        }
Ejemplo n.º 45
0
        private void DrawGrayArea(Graphics g)
        {
            if (Timetable_ == null)
                return;

            for (int day = (ShowWeekend_ ? 0 : 1); day < (ShowWeekend_ ? 7 : 6); day++)
            {
                for (int hour = HourStart_; hour < HourEnd_; hour++)
                {
                    Timeslot time = new Timeslot(day, hour, 0, hour+1, 0);
                    if (!Timetable_.ClassDuring(time, false))
                        DrawTimeslot(g, time, Color.LightGray);
                }
            }
        }
Ejemplo n.º 46
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);

            TimeOfWeek time = FindClickTime(e);
            if (TimeOfWeek.ReferenceEquals(time, null))
                return;

            if (EnableDrag_ && e.Button == MouseButtons.Left && Timetable_ != null)
            {
                DragSession_ = Timetable_.FindClassAt(time, !ShowAll_);
                Unavailability dragUnavail = Timetable_.FindUnavailableAt(time);
                if (DragSession_ != null)
                {
                    BeginDrag(DragSession_.Stream.Type);
                    DragCursor_ = DragCursor(DragSession_);

                    DoDragDrop(DragSession_.Stream.Type, DragDropEffects.Move);

                    EndDrag();
                    DragCursor_ = null;
                }
                else if (dragUnavail != null)
                {
                    HoverUnavail_ = null;
                    Invalidate();
                    DragCursor_ = DragCursor(dragUnavail);

                    DoDragDrop(dragUnavail, DragDropEffects.Move);

                    HoverUnavail_ = null;
                    Invalidate();
                    DragCursor_ = null;
                }
            }

            if (TimetableMouseDown != null)
                TimetableMouseDown(this, new TimetableEventArgs(e, time));
        }
Ejemplo n.º 47
0
 public Rectangle TimeslotRectangle(Timeslot t)
 {
     Rectangle r = new Rectangle(Table_.Location, Cell_);
     r.Offset(Cell_.Width * (t.Day - (ShowWeekend_ ? 0 : 1)), Cell_.Height * (t.Start.DayMinutes - HourStart * 60) / 60);
     r.Height = (int)Math.Ceiling(t.TotalMinutes / 60f * Cell_.Height);
     return r;
 }
Ejemplo n.º 48
0
 private void DrawTransparentTimeslot(Graphics g, Timeslot t, Color color)
 {
     Rectangle r = TimeslotRectangle(t);
     g.FillRectangle(new SolidBrush(Color.FromArgb(80, color)), r);
     g.DrawRectangle(new Pen(color, 3f), r);
 }
Ejemplo n.º 49
0
 /// <summary>
 /// Check if there is a class within a given time range.
 /// </summary>
 public bool ClassDuring(Timeslot timeslot, bool selected)
 {
     return FindClassDuring(timeslot, selected) != null;
 }
Ejemplo n.º 50
0
		internal ReadOnlyCollection<BannerDataHolder> GetBannersSatsfyingQueryConditionsInTimeslot(Timeslot timeslot)
		{
			if (bannersSatsfyingQueryConditionsInTimeslot == null)
			{
				bannersSatsfyingQueryConditionsInTimeslot = Caching.Instances.Main.GetWithLocalCaching(
					"BannersSatsfyingQueryConditionsInTimeslot" + this.GetCacheKey() + timeslot.GetCacheKey(),
					() => GetBannersSatisfyingQueryConditions(),
					Time.Seconds(15),
					Timeslot.Duration
				);
			}
			return bannersSatsfyingQueryConditionsInTimeslot.AsReadOnly();
		}
Ejemplo n.º 51
0
 /// <summary>
 /// Finds a class within a given time range.
 /// </summary>
 /// <returns>The first class found, or null if none were found.</returns>
 public Session FindClassDuring(Timeslot timeslot, bool selected)
 {
     foreach (Session session in ClassList)
     {
         if (selected && !session.Stream.Selected)
             continue;
         if (session.ClashesWith(timeslot))
             return session;
     }
     return null;
 }
Ejemplo n.º 52
0
        private void DrawTimeslotActive(Graphics g, Timeslot t, Color color)
        {
            Rectangle r = TimeslotRectangle(t);

            // solid color
            g.FillRectangle(new SolidBrush(color), r);
            // gradient
            System.Drawing.Drawing2D.LinearGradientBrush brush = LinearGradientActive(r.Location, Cell_.Width, Cell_.Height, color);

            Rectangle q = new Rectangle(r.X, r.Y, r.Width, r.Height);

            if (r.Height > Cell_.Height * 2)
                r.Height = Cell_.Height * 2;
            g.FillRectangle(brush, r);

            g.DrawRectangle(Pens.Black, q);
        }
Ejemplo n.º 53
0
 public DialogResult ShowDialog(Timetable timetable, Timeslot timeslot, int earliest, int latest)
 {
     return ShowDialog(timetable, new Unavailability("", timeslot), earliest, latest);
 }
Ejemplo n.º 54
0
 public Unavailability(string name, Timeslot time)
     : base(time)
 {
     Name_ = name;
 }
Ejemplo n.º 55
0
        private void SaveUser()
        {
            try
            {
                Boolean ret = false;
                string message = String.Empty;

                List<String> list = new List<String>();
                if (chkSunday.Checked == true) list.Add("Su");
                if (chkMonday.Checked == true) list.Add("M");
                if (chkTuesday.Checked == true) list.Add("Tu");
                if (chkWednesday.Checked == true) list.Add("W");
                if (chkThursday.Checked == true) list.Add("Th");
                if (chkFriday.Checked == true) list.Add("F");
                if (chkSaturday.Checked == true) list.Add("S");

                string szDays = string.Empty;
                szDays = string.Join(",", list.ToArray());

                DateTime? dtTimeStart = DateTime.Now;
                DateTime? dtTimeEnd = DateTime.Now;

                dtTimeStart = tPStart.Value;
                dtTimeEnd = tpEnd.Value;

                TimeslotServiceClient tService = new TimeslotServiceClient();
                Timeslot timeslot = new Timeslot()
                {
                    TimeSlotCode = txtTimeslotCode.Text,
                    TimeStart = dtTimeStart.Value.ToString("hh:mm tt"),
                    TimeEnd = dtTimeEnd.Value.ToString("hh:mm tt"),
                    Days = szDays
                };

                if (Op.Equals("edit"))
                {
                    timeslot.TimeSlotCode = SelectedTimeslot.TimeSlotCode;
                    ret = tService.UpdateTimeslot(ref timeslot, ref message);
                }
                else
                    ret = tService.CreateTimeslot(ref timeslot, ref message);


                MessageBox.Show("Saved Successfully!");

                Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.ToString());
            }
        }
Ejemplo n.º 56
0
 public void AddToTimeslots(Timeslot timeslot)
 {
     base.AddObject("Timeslots", timeslot);
 }
Ejemplo n.º 57
0
 public static Timeslot CreateTimeslot(int ID, int event_ID)
 {
     Timeslot timeslot = new Timeslot();
     timeslot.ID = ID;
     timeslot.Event_ID = event_ID;
     return timeslot;
 }
 internal static int IndexOf(this IOrderedEnumerable<Timeslot> timeslots, Timeslot timeslot)
 {
     return Array.IndexOf(timeslots.ToArray(), timeslot);
 }
Ejemplo n.º 59
0
        public void CreateTimeslot(Timeslot timeslot)
        {
            using (OCCDB db = new OCCDB())
            {
                Data.Timeslot t = new Data.Timeslot()
                {
                    Event_ID = timeslot.EventID,
                    Name = timeslot.Name,
                    StartTime = timeslot.StartTime,
                    EndTime = timeslot.EndTime
                };

                db.Timeslots.Add(t);

                db.SaveChanges();
            }
        }
Ejemplo n.º 60
0
        private void SetTimeSlotCombo()
        {
            //Get timeslot that are already assigned
            List<Timeslot> usedtslot = new List<Timeslot>();
            foreach (SubjectAssignment sch in createdSchedule)
            {
                Timeslot ts = new Timeslot();
                ts.TimeSlotCode = sch.TimeSlotCode;
                ts.TimeSlotInfo = sch.TimeslotInfo;
                ts.TimeStart = sch.Timestart;
                ts.TimeEnd = sch.TimeEnd;
                ts.Days = sch.Days;
                usedtslot.Add(ts);
            }

            //get the list of all timeslots
            availTimeSlot = new List<Timeslot>(timeslots); //timeslots;

            //Remove timeslots that are already been used
            if (usedtslot.Count > 0)
            {
                foreach (Timeslot t in usedtslot) {
                  string times = t.TimeSlotCode;
                 availTimeSlot.RemoveAll(a => a.TimeSlotCode == times);
                }
            }

            //Remove timeslots that are conflicting to other schedules
            #region ConflictTimeslotsFilter
            List<Timeslot> compareTimeSlot = new List<Timeslot>();
            List<String> tCodelist;

            foreach (Timeslot t in usedtslot)
            {
                string[] dayArray = t.Days.Split(',');
                int t_TimeStart = timeStringToInt(t.TimeStart);
                int t_TimeEnd = timeStringToInt(t.TimeEnd);
                compareTimeSlot = availTimeSlot;
                tCodelist = new List<String>();

                foreach (Timeslot ct in compareTimeSlot)
                {
                    foreach (string sDay in dayArray)
                    {
                        if (ct.Days.Contains(sDay))
                        {
                            int ct_TimeStart = timeStringToInt(ct.TimeStart);
                            int ct_TimeEnd = timeStringToInt(ct.TimeEnd);

                            if ((ct_TimeStart <= t_TimeStart && ct_TimeEnd <= t_TimeEnd && ct_TimeEnd > t_TimeStart) ||
                                    (ct_TimeStart >= t_TimeStart && ct_TimeEnd <= t_TimeEnd) ||
                                    (ct_TimeStart >= t_TimeStart && ct_TimeStart < t_TimeEnd && ct_TimeEnd > t_TimeEnd))
                            {
                                tCodelist.Add(ct.TimeSlotCode);
                            }
                        }
                    }

                }

                //Remove conflicted schedules against the used schedules
                foreach (string code in tCodelist)
                {
                    availTimeSlot.RemoveAll(x => x.TimeSlotCode == code);
                    compareTimeSlot = null;
                }
            }

            #endregion

            //assign new list of Timeslot on the dropdown box
            if (availTimeSlot.Count > 0)
            {
                cmbTimeslot.Enabled = true;
                cmbTimeslot.ValueMember = "TimeslotCode";
                cmbTimeslot.DisplayMember = "TimeslotInfo";
                cmbTimeslot.DataSource = availTimeSlot;
                cmbTimeslot.SelectedIndex = 0;
            }
        }