private static bool AssignSchedulesToCard(Schedule schedule, List<Schedule>[] cardSchedules, out List<Schedule> overlappingSchedules) { overlappingSchedules = new List<Schedule>(); Log.Info("AssignSchedulesToCard: schedule = " + schedule); IList<Card> cards = Card.ListAll(); bool assigned = false; int count = 0; foreach (Card card in cards) { if (card.Enabled && card.canViewTvChannel(schedule.IdChannel)) { // checks if any schedule assigned to this cards overlaps current parsed schedule bool free = true; foreach (Schedule assignedSchedule in cardSchedules[count]) { Log.Info("AssignSchedulesToCard: card {0}, ID = {1} has schedule = " + assignedSchedule, count, card.IdCard); bool hasOverlappingSchedule = schedule.IsOverlapping(assignedSchedule); if (hasOverlappingSchedule) { bool isSameTransponder = (schedule.isSameTransponder(assignedSchedule) && card.supportSubChannels); if (!isSameTransponder) { overlappingSchedules.Add(assignedSchedule); Log.Info("AssignSchedulesToCard: overlapping with " + assignedSchedule + " on card {0}, ID = {1}", count, card.IdCard); free = false; break; } } } if (free) { Log.Info("AssignSchedulesToCard: free on card {0}, ID = {1}", count, card.IdCard); cardSchedules[count].Add(schedule); assigned = true; break; } } count++; } if (!assigned) { return false; } return true; }
//------------------------------------------------------------------------------------------------------------- // assigns a single schedule to the card //------------------------------------------------------------------------------------------------------------- private static bool AssignSchedulesToCard(Schedule schedule, List<Schedule>[] cardSchedules, out Schedule overlappingSchedule,bool Debug) { overlappingSchedule = null; //if (Debug==true) // Log.Debug("AssignSchedulesToCard: schedule = " + schedule.ToString()); #if(TV100) IList cards = Card.ListAll(); #elif(TV101 || TV11 || TV12) IList<Card> cards = Card.ListAll(); #endif bool assigned = false; int count = 0; foreach (Card card in cards) { //if (Debug == true) // Log.Debug("Working on card: "+card.IdCard.ToString()+" ID Channel="+schedule.IdChannel.ToString()); if (card.canViewTvChannel(schedule.IdChannel)) { // checks if any schedule assigned to this cards overlaps current parsed schedule bool free = true; // if (Debug == true) // Log.Debug("card can view channel - free=true"); foreach (Schedule assignedSchedule in cardSchedules[count]) { //if (Debug == true) // Log.Debug("AssignSchedulesToCard: card {0}, ID = {1} has schedule = " + assignedSchedule, count, card.IdCard); if (schedule.IsOverlapping(assignedSchedule)) { //if (Debug == true) // Log.Debug("schedule is overlapping - checking same transponder"); if (!(schedule.isSameTransponder(assignedSchedule) && card.supportSubChannels)) { overlappingSchedule = assignedSchedule; if (Debug == true) Log.Debug("AssignSchedulesToCard: overlapping with " + assignedSchedule + " on card {0}, ID = {1}", card.IdCard); free = false; break; } } } if (free) { if (Debug == true) Log.Debug("AssignSchedulesToCard: free on card "+count.ToString()+", ID = "+ card.IdCard.ToString()); cardSchedules[count].Add(schedule); assigned = true; break; } } count++; } if (!assigned) { return false; } return true; }