Exemple #1
0
        public List <SyllabusSchedule> SingleScheTest([PexAssumeUnderTest] ScheduleBLL target, string id)
        {
            List <SyllabusSchedule> result = target.SingleSche(id);

            return(result);
            // TODO: add assertions to method ScheduleBLLTest.SingleScheTest(ScheduleBLL, String)
        }
Exemple #2
0
        public static string GetCurrentTime(int groupId, string startDate, string endDate)
        {
            ScheduleBLL scheduleBLL = new ScheduleBLL();

            scheduleBLL.readGroupSchedule(groupId, Util.StringToDate(startDate), Util.StringToDate(endDate));
            List <Schedule> dss      = scheduleBLL.scheduleList;
            List <string>   allcells = new List <string>();
            List <TimeCell> tmCells  = new List <TimeCell>();

            foreach (Schedule s in dss)
            {
                List <String> cells = convertTimeLinetoTimeCell(s.freeSlotTimeFrom, s.freeSlotTimeTo);
                foreach (String c in cells)
                {
                    TimeCell tc = new TimeCell();
                    tc.cell      = c;
                    tc.colorCode = s.colorCode;
                    tc.userId    = s.userId;
                    tc.userName  = s.user.firstName + " " + s.user.lastName;
                    addTimeCell(tmCells, tc);
                }

                //   allcells.AddRange(cells);
            }

            String json = tmCells.ToJSON();


            return(json);
        }
        private void BindData()
        {
            ScheduleBLL schedule = new ScheduleBLL();

            ScheduleList.DataSource = schedule.GetScheduleOfTrainees();
            ScheduleList.DataBind();
        }
Exemple #4
0
        public bool DelScheTest([PexAssumeUnderTest] ScheduleBLL target, string id)
        {
            bool result = target.DelSche(id);

            return(result);
            // TODO: add assertions to method ScheduleBLLTest.DelScheTest(ScheduleBLL, String)
        }
Exemple #5
0
        public ScheduleBLL ConstructorTest()
        {
            ScheduleBLL target = new ScheduleBLL();

            return(target);
            // TODO: add assertions to method ScheduleBLLTest.ConstructorTest()
        }
        private bool isScheduled(Schedule newSchedule)
        {
            bool isScheduled = false;
            var  schedules   = new ScheduleBLL().RetrieveALL();

            foreach (var item in schedules)
            {
                //if(item.Hall.Id != )
                int n1 = DateTime.Compare(newSchedule.StartTime, item.StartTime);
                int n2 = DateTime.Compare(newSchedule.StartTime, item.EndTime);
                int n3 = DateTime.Compare(newSchedule.StartTime, item.StartTime);
                int n4 = DateTime.Compare(newSchedule.EndTime, item.StartTime);
                if (((n1 > 0 && n2 > 0) || (n3 < 0) && (n4 < 0)))
                {
                    isScheduled = false;
                }
                else
                {
                    if (newSchedule.Hall.Name != item.Hall.Name)
                    {
                        isScheduled = false;
                    }
                    else
                    {
                        isScheduled = true;
                        break;
                    }
                }
            }
            return(isScheduled);
        }
Exemple #7
0
        public string getstoTest([PexAssumeUnderTest] ScheduleBLL target, string idS)
        {
            string result = target.getsto(idS);

            return(result);
            // TODO: add assertions to method ScheduleBLLTest.getstoTest(ScheduleBLL, String)
        }
        public void isEditTest01()
        {
            ScheduleBLL scheduleBLL;
            bool        b;

            scheduleBLL = new ScheduleBLL();
            b           = this.isEditTest(scheduleBLL, (string)null, 0);
        }
        public void DelScheTest01()
        {
            ScheduleBLL scheduleBLL;
            bool        b;

            scheduleBLL = new ScheduleBLL();
            b           = this.DelScheTest(scheduleBLL, (string)null);
        }
        public void getstoTest01()
        {
            ScheduleBLL scheduleBLL;
            string      s;

            scheduleBLL = new ScheduleBLL();
            s           = this.getstoTest(scheduleBLL, (string)null);
        }
        protected void ScheuleList_RowDeleting(Object sender, GridViewDeleteEventArgs e)
        {
            int         scheduleID = Convert.ToInt32(ScheduleList.DataKeys[e.RowIndex].Value);
            ScheduleBLL scbll      = new ScheduleBLL();

            scbll.DeleteSchedule(scheduleID);
            BindData();
        }
        public void ListScheTest01()
        {
            ScheduleBLL             scheduleBLL;
            List <SyllabusSchedule> list;

            scheduleBLL = new ScheduleBLL();
            list        = this.ListScheTest(scheduleBLL, (string)null);
        }
Exemple #13
0
        public static string saveTimeCells(int userId, List <String> timecells, string startDate, string endDate)
        {
            ScheduleBLL bll = new ScheduleBLL();

            bll.userId = userId;
            bll.update(timecells, Util.StringToDate(startDate) ?? DateTime.MaxValue, Util.StringToDate(endDate) ?? DateTime.MinValue);

            return("Successfully saved");
        }
        public void AddScheTest01()
        {
            ScheduleBLL scheduleBLL;
            bool        b;

            scheduleBLL = new ScheduleBLL();
            b           = this.AddScheTest(scheduleBLL, (string)null, default(DateTime), 0,
                                           (string)null, (string)null, (string)null, false);
        }
Exemple #15
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ScheduleBLL scbll = new ScheduleBLL();
            Schedule    sc    = scbll.GetScheduleById(Convert.ToInt32(Request.QueryString["ScheduleID"]));

            if (sc != null)
            {
                ScheduleID.Text = sc.ScheduleID.ToString();
                TraineeID.Text  = sc.TraineeID.ToString();
            }
        }
Exemple #16
0
        public bool isEditTest(
            [PexAssumeUnderTest] ScheduleBLL target,
            string id,
            int number
            )
        {
            bool result = target.isEdit(id, number);

            return(result);
            // TODO: add assertions to method ScheduleBLLTest.isEditTest(ScheduleBLL, String, Int32)
        }
Exemple #17
0
        public bool checkTest(
            [PexAssumeUnderTest] ScheduleBLL target,
            string idS,
            int period
            )
        {
            bool result = target.check(idS, period);

            return(result);
            // TODO: add assertions to method ScheduleBLLTest.checkTest(ScheduleBLL, String, Int32)
        }
Exemple #18
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            Int32 records = ScheduleBLL.getInstance().delete(schedule_id);

            ScriptManager.RegisterStartupScript(Page, Page.GetType(), "confirmMessage", "$('#confirmMessage').modal('toggle');", true);

            if (records > 0)
            {
                lblMessage.Text = "Horario eliminado correctamente.";
            }
            loadData();
        }
Exemple #19
0
        protected void loadData()
        {
            int code = oUser.oProgram.code;

            if (code == 1)
            {
                gvSchedule.DataSource = ScheduleBLL.getInstance().getAll();
            }
            else
            {
                gvSchedule.DataSource = ScheduleBLL.getInstance().getAllByPrgrams(code);
            }

            gvSchedule.DataBind();
        }
Exemple #20
0
        protected void btn_view_Click(object sender, ImageClickEventArgs e)
        {
            ScheduleBLL scheduleBLL = new ScheduleBLL();

            scheduleBLL.userId = (Int32)Session["userId"];
            scheduleBLL.readSchedule(Util.StringToDate(this.tb_dateFrom.Text), Util.StringToDate(this.tb_dateTo.Text));
            List <Schedule> scheduleList = scheduleBLL.scheduleList;

            foreach (Schedule schedule in scheduleList)
            {
                Console.WriteLine(schedule.freeSlotTimeFrom);
                Console.WriteLine(schedule.freeSlotTimeTo);
            }

            //   this.saveChanges.Visible = false;
        }
Exemple #21
0
        protected void gvSchedule_RowEditing(object sender, GridViewEditEventArgs e)
        {
            unlockControls();
            Int32 code = Convert.ToInt32(gvSchedule.Rows[e.NewEditIndex].Cells[0].Text);

            Entities.Schedule oSchedule = ScheduleBLL.getInstance().getSchedule(code);
            txtCode.Text                  = oSchedule.code.ToString();
            txtDescription.Text           = oSchedule.name;
            cboTypeSchedule.SelectedValue = oSchedule.typeSchedule;
            txtStart.Text                 = String.Format("{0:t}", oSchedule.startTime);
            txtEndHour.Text               = String.Format("{0:t}", oSchedule.endTime);
            cboprogram.SelectedValue      = oSchedule.oProgram.code.ToString();
            cboState.SelectedValue        = oSchedule.state.ToString();
            SelectchkDays(oSchedule.codday);
            ScriptManager.RegisterStartupScript(this, this.GetType(), "redirect", "$('html, body').animate({ scrollTop: $('body').offset().top });", true);
        }
Exemple #22
0
        public bool EditScheTest(
            [PexAssumeUnderTest] ScheduleBLL target,
            string id,
            DateTime date,
            int number,
            string content,
            string acitve,
            string doc,
            bool mid
            )
        {
            bool result = target.EditSche(id, date, number, content, acitve, doc, mid);

            return(result);
            // TODO: add assertions to method ScheduleBLLTest.EditScheTest(ScheduleBLL, String, DateTime, Int32, String, String, String, Boolean)
        }
        protected void ScheduleAddButton_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                Schedule sc = new Schedule();
                sc.ScheduleDtTime = System.DateTime.Parse(DateOfAppointment.Text);
                sc.InputDtTime    = System.DateTime.Now;
                sc.TraineeID      = Convert.ToInt32(TraineeList.SelectedValue);

                ScheduleBLL scbll = new ScheduleBLL();
                int         res   = scbll.AddSchedule(sc);

                if (res > 0)
                {
                    Response.Redirect("http://localhost:54175/Scheduler.aspx");
                }
            }
        }
Exemple #24
0
        public static string GetCurrentTime(int userId, string startDate, string endDate)
        {
            ScheduleBLL scheduleBLL = new ScheduleBLL();

            scheduleBLL.userId = userId;
            scheduleBLL.readSchedule(Util.StringToDate(startDate), Util.StringToDate(endDate));
            List <Schedule> scheduleList = scheduleBLL.scheduleList;
            List <string>   allcells     = new List <string>();//E.g 8:00 - 10:00 Then in allcells: 8:00, 8:30, 9:00, 9:30, 10:00

            foreach (Schedule schedule in scheduleList)
            {
                List <String> cells = convertTimeLinetoTimeCell(schedule.freeSlotTimeFrom, schedule.freeSlotTimeTo);
                allcells.AddRange(cells);
            }

            String json = allcells.ToJSON();

            return(json);
        }
        private void setFormScripts()
        {
            ScheduleBLL scheduleDB = new ScheduleBLL();

            string xPath = odsClasses.SelectParameters["parentXPath"].DefaultValue;

            if (string.IsNullOrEmpty(xPath))
            {
                return;
            }

            XElement root = scheduleDB.getXElement.XPathSelectElement(xPath);

            DateTime dateRange = (DateTime)DateTime.Parse(root.Attribute("Date").Value);

            // Set the script to restrict the date picker date range
            string script = "setDateRangeByMonth('" + dateRange.ToShortDateString() + "');";

            ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "setDateRange", script, true);
        }
Exemple #26
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ScheduleBLL scbll = new ScheduleBLL();
                Schedule    sc    = scbll.GetScheduleById(Convert.ToInt32(Request.QueryString["ScheduleID"]));

                // Loading the dropdownlist
                List <TraineeViewModel> trainees = tbll.GetAllTrainees();
                TraineeList.DataSource     = trainees;
                TraineeList.DataTextField  = "FirstName";
                TraineeList.DataValueField = "TraineeID";
                TraineeList.DataBind();
                TraineeList.Items.Insert(0, "--Select a trainee from the list--");
                TraineeList.SelectedValue = sc.TraineeID.ToString();
                DateOfAppointment.Text    = sc.ScheduleDtTime.ToString("yyyy-MM-dd"); //The format has to be like this: "yyyy-mm-dd" otherwise it won't show in the browser
                //DateOfAppointment.Text = sc.DisplayScheduleDtTime.ToString();
                TimeOfAppointment.Text = sc.InputDtTime.ToString("HH:mm");
            }
        }
Exemple #27
0
        public static string GetGroupTime(int groupId, string name, string startDate, string endDate)
        {
            ScheduleBLL scheduleBLL = new ScheduleBLL();

            // scheduleBLL.userId = (Int32)Session["userId"];
            //scheduleBLL.userId = 1;
            scheduleBLL.readSchedule(Util.StringToDate(startDate), Util.StringToDate(endDate));
            //scheduleBLL.readSchedule(null, null);
            List <Schedule> dss      = scheduleBLL.scheduleList;
            List <string>   allcells = new List <string>();

            foreach (Schedule s in dss)
            {
                List <String> cells = convertTimeLinetoTimeCell(s.freeSlotTimeFrom, s.freeSlotTimeTo);
                allcells.AddRange(cells);
            }

            String json = allcells.ToJSON();


            return(json);
        }
Exemple #28
0
        protected void btnSave_Click(object sender, ImageClickEventArgs e)
        {
            Int32 records = -1;

            if (validateData())
            {
                Entities.Schedule oSchedule = new Entities.Schedule();
                oSchedule.code          = Convert.ToInt32(txtCode.Text);
                oSchedule.name          = txtDescription.Text;
                oSchedule.typeSchedule  = cboTypeSchedule.SelectedValue;
                oSchedule.startTime     = Convert.ToDateTime(txtStart.Text);
                oSchedule.endTime       = Convert.ToDateTime(txtEndHour.Text);
                oSchedule.state         = Convert.ToInt32(cboState.SelectedValue);
                oSchedule.oProgram.code = Convert.ToInt32(cboprogram.SelectedValue);
                oSchedule.codday        = codDays;

                if (ScheduleBLL.getInstance().exists(oSchedule.code))
                {
                    records = ScheduleBLL.getInstance().modify(oSchedule);
                }
                else
                {
                    records = ScheduleBLL.getInstance().insert(oSchedule);
                }

                blockControls();
                loadData();

                if (records > 0)
                {
                    lblMessage.Text = "Datos almacenados correctamente.";
                }
            }
            //no c para que es esto
            else
            {
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "comboBox", "comboBox();", true);
            }
        }
Exemple #29
0
 private void Info_Load(object sender, EventArgs e)
 {
     if (RecordType == Record.Booking)
     {
         var obj = new BookingBLL().Retrieve(RecordID);
         InitData(obj.BaseAuditObject);
     }
     else if (RecordType == Record.CashPaymentDetails)
     {
         var obj = new CashPaymentDetailsBLL().Retrieve(RecordID);
         InitData(obj.BaseAuditObject);
     }
     else if (RecordType == Record.Category)
     {
         var obj = new CategoryBLL().Retrieve(RecordID);
         InitData(obj.BaseAuditObject);
     }
     else if (RecordType == Record.Chair)
     {
         var obj = new ChairBLL().Retrieve(RecordID);
         InitData(obj.BaseAuditObject);
     }
     else if (RecordType == Record.ChairClass)
     {
         var obj = new ChairClassBLL().Retrieve(RecordID);
         InitData(obj.BaseAuditObject);
     }
     else if (RecordType == Record.Cinema)
     {
         var obj = new CinemaBLL().Retrieve(RecordID);
         InitData(obj.BaseAuditObject);
     }
     else if (RecordType == Record.Client)
     {
         var obj = new ClientBLL().Retrieve(RecordID);
         InitData(obj.BaseAuditObject);
     }
     else if (RecordType == Record.ClientPremiumDetails)
     {
         var obj = new ClientPremiumDetailsBLL().Retrieve(RecordID);
         InitData(obj.BaseAuditObject);
     }
     else if (RecordType == Record.Event)
     {
         var obj = new EventBLL().Retrieve(RecordID);
         InitData(obj.BaseAuditObject);
     }
     else if (RecordType == Record.EventDetails)
     {
         var obj = new EventDetailsBLL().Retrieve(RecordID);
         InitData(obj.BaseAuditObject);
     }
     else if (RecordType == Record.EventType)
     {
         var obj = new EventTypeBLL().Retrieve(RecordID);
         InitData(obj.BaseAuditObject);
     }
     else if (RecordType == Record.Genre)
     {
         var obj = new GenderBLL().Retrieve(RecordID);
         InitData(obj.BaseAuditObject);
     }
     else if (RecordType == Record.Hall)
     {
         var obj = new HallBLL().Retrieve(RecordID);
         InitData(obj.BaseAuditObject);
     }
     else if (RecordType == Record.Movie)
     {
         var obj = new MovieBLL().Retrieve(RecordID);
         InitData(obj.BaseAuditObject);
     }
     else if (RecordType == Record.Payment)
     {
         var obj = new PaymentBLL().Retrieve(RecordID);
         InitData(obj.BaseAuditObject);
     }
     else if (RecordType == Record.Role)
     {
         var obj = new RoleBLL().Retrieve(RecordID);
         InitData(obj.BaseAuditObject);
     }
     else if (RecordType == Record.Schedule)
     {
         var obj = new ScheduleBLL().Retrieve(RecordID);
         InitData(obj.BaseAuditObject);
     }
     else if (RecordType == Record.Technology)
     {
         var obj = new TechnologyBLL().Retrieve(RecordID);
         InitData(obj.BaseAuditObject);
     }
     else if (RecordType == Record.Ticket)
     {
         var obj = new TicketBLL().Retrieve(RecordID);
         InitData(obj.BaseAuditObject);
     }
     else if (RecordType == Record.User)
     {
         var obj = new UserBLL().Retrieve(RecordID);
         InitData(obj.BaseAuditObject);
     }
     else if (RecordType == Record.User_Roles)
     {
         var obj = new UserBLL().Retrieve(RecordID);
         InitData(obj.BaseAuditObject);
     }
 }
        protected void btnReport_Click(object sender, EventArgs e)
        {
            try
            {
                List <Entities.Schedule> listSchedule = ScheduleBLL.getInstance().getAll();
                System.IO.MemoryStream   memoryStream = new System.IO.MemoryStream();
                text::Document           pdfDoc       = new text::Document(text::PageSize.A4, 10, 10, 10, 10);
                pdfDoc.SetPageSize(iTextSharp.text.PageSize.A4.Rotate());
                PdfWriter.GetInstance(pdfDoc, memoryStream);
                pdfDoc.Open();

                String imagepath           = Server.MapPath("../../images/page-icons");
                iTextSharp.text.Image deas = iTextSharp.text.Image.GetInstance(imagepath + "/DEAS-logo.jpg");
                deas.ScaleToFit(140f, 120f);
                //Give space before image
                deas.SpacingBefore = 10f;
                //Give some space after the image
                deas.SpacingAfter = 1f;
                deas.Alignment    = text::Element.ALIGN_LEFT;
                pdfDoc.Add(deas);

                text::Paragraph title = new text::Paragraph();
                title.Font      = text::FontFactory.GetFont("dax-black", 32, new text::BaseColor(0, 51, 102));
                title.Alignment = text::Element.ALIGN_CENTER;
                title.Add("\n\n Justificación de Apertura\n\n");
                pdfDoc.Add(title);

                PdfPTable oPTable = new PdfPTable(2);
                oPTable.TotalWidth    = 100;
                oPTable.SpacingBefore = 20f;
                oPTable.SpacingAfter  = 30f;
                oPTable.AddCell("Profesor: " + oJustification.oAcademic.oteacher.name + " " + oJustification.oAcademic.oteacher.lastName);
                oPTable.AddCell("Curso: " + oJustification.oAcademic.oCourse.description);
                oPTable.AddCell("Categoría: " + oJustification.oInternal.description);
                oPTable.AddCell("Nombramiento: " + oJustification.oAcademic.hours.ToString());
                oPTable.AddCell("Anualidade: " + oJustification.CauntAnualities);
                oPTable.AddCell("Salario: " + oJustification.Salary.ToString("0.00"));
                oPTable.AddCell("Anualidades: " + oJustification.Anuality.ToString("0.00"));
                oPTable.AddCell("Cargos Sociales: " + oJustification.CCSS.ToString("0.00"));
                oPTable.AddCell("Publicidad: " + oJustification.publicity.ToString("0.00"));
                oPTable.AddCell("Otros: " + oJustification.Others.ToString("0.00"));
                oPTable.AddCell("Total Mensual: " + oJustification.TotalMensual.ToString("0.00"));
                oPTable.AddCell("Tatal Bimensual: " + oJustification.TotalBimensual.ToString("0.00"));
                oPTable.AddCell("Valor del curso: " + oJustification.oAcademic.price.ToString("0.00"));
                oPTable.AddCell("Estudiantes: " + oJustification.Students);
                oPTable.AddCell("Ingresos: " + oJustification.TotalIncome.ToString("0.00"));
                oPTable.AddCell("Diferencia: " + oJustification.Diference.ToString("0.00"));

                pdfDoc.Add(oPTable);
                pdfDoc.Close();

                byte[] bytes = memoryStream.ToArray();
                memoryStream.Close();
                Response.Clear();
                Response.ContentType = "application/pdf";
                Response.AddHeader("Content-Disposition", "attachment; filename=JustificaciónApertura.pdf");
                Response.ContentType = "application/pdf";
                Response.Buffer      = true;
                Response.Cache.SetCacheability(HttpCacheability.NoCache);
                Response.BinaryWrite(bytes);
                Response.End();
                Response.Close();
            }
            catch (Exception ex)
            {
                Response.Write(ex.ToString());
            }
        }
    public static List<Schedule> GetRecordingTimes(Schedule rec, int days)
    {      
      var recordings = new List<Schedule>();
      var recBLL = new ScheduleBLL(rec);

      DateTime dtDay = DateTime.Now;
      if (recBLL.Entity.ScheduleType == (int)ScheduleRecordingType.Once)
      {
        recordings.Add(recBLL.Entity);
        return recordings;
      }

      if (recBLL.Entity.ScheduleType == (int)ScheduleRecordingType.Daily)
      {
        for (int i = 0; i < days; ++i)
        {
          var recNew = ScheduleFactory.Clone(recBLL.Entity);
          recNew.ScheduleType = (int)ScheduleRecordingType.Once;
          recNew.StartTime = new DateTime(dtDay.Year, dtDay.Month, dtDay.Day, recBLL.Entity.StartTime.Hour, recBLL.Entity.StartTime.Minute,
                                          0);
          if (recBLL.Entity.EndTime.Day > recBLL.Entity.StartTime.Day)
          {
            dtDay = dtDay.AddDays(1);
          }
          recNew.EndTime = new DateTime(dtDay.Year, dtDay.Month, dtDay.Day, recBLL.Entity.EndTime.Hour, recBLL.Entity.EndTime.Minute, 0);
          if (recBLL.Entity.EndTime.Day > recBLL.Entity.StartTime.Day)
          {
            dtDay = dtDay.AddDays(-1);
          }
          recNew.Series = true;
          if (recNew.StartTime >= DateTime.Now)
          {
            if (recBLL.IsSerieIsCanceled(recNew.StartTime))
            {
              recNew.Canceled = recNew.StartTime;
            }
            recordings.Add(recNew);
          }
          dtDay = dtDay.AddDays(1);
        }
        return recordings;
      }

      if (recBLL.Entity.ScheduleType == (int)ScheduleRecordingType.WorkingDays)
      {
        for (int i = 0; i < days; ++i)
        {
          if (WeekEndTool.IsWorkingDay(dtDay.DayOfWeek))
          {
            Schedule recNew = ScheduleFactory.Clone(recBLL.Entity);
            recNew.ScheduleType = (int)ScheduleRecordingType.Once;
            recNew.StartTime = new DateTime(dtDay.Year, dtDay.Month, dtDay.Day, recBLL.Entity.StartTime.Hour, recBLL.Entity.StartTime.Minute,
                                            0);
            if (recBLL.Entity.EndTime.Day > recBLL.Entity.StartTime.Day)
            {
              dtDay = dtDay.AddDays(1);
            }
            recNew.EndTime = new DateTime(dtDay.Year, dtDay.Month, dtDay.Day, recBLL.Entity.EndTime.Hour, recBLL.Entity.EndTime.Minute, 0);
            if (recBLL.Entity.EndTime.Day > recBLL.Entity.StartTime.Day)
            {
              dtDay = dtDay.AddDays(-1);
            }
            recNew.Series = true;
            if (recBLL.IsSerieIsCanceled(recNew.StartTime))
            {
              recNew.Canceled = recNew.StartTime;
            }
            if (recNew.StartTime >= DateTime.Now)
            {
              recordings.Add(recNew);
            }
          }
          dtDay = dtDay.AddDays(1);
        }
        return recordings;
      }

      if (recBLL.Entity.ScheduleType == (int)ScheduleRecordingType.Weekends)
      {
        IEnumerable<Program> progList = ProgramManagement.GetProgramsByChannelAndTitleAndStartEndTimes(recBLL.Entity.IdChannel,
                                                                        recBLL.Entity.ProgramName, dtDay,
                                                                        dtDay.AddDays(days));        
        foreach (Program prog in progList)
        {
          if ((recBLL.IsRecordingProgram(prog, false)) &&
              (WeekEndTool.IsWeekend(prog.StartTime.DayOfWeek)))
          {
            Schedule recNew = ScheduleFactory.Clone(recBLL.Entity);
            recNew.ScheduleType = (int)ScheduleRecordingType.Once;
            recNew.StartTime = prog.StartTime;
            recNew.EndTime = prog.EndTime;
            recNew.Series = true;

            if (recBLL.IsSerieIsCanceled(recNew.StartTime))
            {
              recNew.Canceled = recNew.StartTime;
            }
            recordings.Add(recNew);
          }
        }
        return recordings;
      }
      if (recBLL.Entity.ScheduleType == (int)ScheduleRecordingType.Weekly)
      {
        for (int i = 0; i < days; ++i)
        {
          if ((dtDay.DayOfWeek == recBLL.Entity.StartTime.DayOfWeek) && (dtDay.Date >= recBLL.Entity.StartTime.Date))
          {
            Schedule recNew = ScheduleFactory.Clone(recBLL.Entity);
            recNew.ScheduleType = (int)ScheduleRecordingType.Once;
            recNew.StartTime = new DateTime(dtDay.Year, dtDay.Month, dtDay.Day, recBLL.Entity.StartTime.Hour, recBLL.Entity.StartTime.Minute,
                                            0);
            if (recBLL.Entity.EndTime.Day > recBLL.Entity.StartTime.Day)
            {
              dtDay = dtDay.AddDays(1);
            }
            recNew.EndTime = new DateTime(dtDay.Year, dtDay.Month, dtDay.Day, recBLL.Entity.EndTime.Hour, recBLL.Entity.EndTime.Minute, 0);
            if (recBLL.Entity.EndTime.Day > recBLL.Entity.StartTime.Day)
            {
              dtDay = dtDay.AddDays(-1);
            }
            recNew.Series = true;
            if (recBLL.IsSerieIsCanceled(recNew.StartTime))
            {
              recNew.Canceled = recNew.StartTime;
            }
            if (recNew.StartTime >= DateTime.Now)
            {
              recordings.Add(recNew);
            }
          }
          dtDay = dtDay.AddDays(1);
        }
        return recordings;
      }

      IEnumerable<Program> programs;
      if (recBLL.Entity.ScheduleType == (int)ScheduleRecordingType.WeeklyEveryTimeOnThisChannel)
      {
        //this.LogDebug("get {0} {1} EveryTimeOnThisChannel", rec.ProgramName, rec.ReferencedChannel().Name);
        programs = ProgramManagement.GetProgramsByChannelAndTitleAndStartEndTimes(recBLL.Entity.IdChannel,
                                                                        recBLL.Entity.ProgramName, dtDay,
                                                                        dtDay.AddDays(days));        
        foreach (Program prog in programs)
        {
          // dtDay.DayOfWeek == rec.startTime.DayOfWeek
          // this.LogDebug("BusinessLayer.cs Program prog in programs WeeklyEveryTimeOnThisChannel: {0} {1} prog.startTime.DayOfWeek == rec.startTime.DayOfWeek {2} == {3}", rec.ProgramName, rec.ReferencedChannel().Name, prog.startTime.DayOfWeek, rec.startTime.DayOfWeek);
          if (prog.StartTime.DayOfWeek == recBLL.Entity.StartTime.DayOfWeek && recBLL.IsRecordingProgram(prog, false))
          {
            Schedule recNew = ScheduleFactory.Clone(recBLL.Entity);
            recNew.ScheduleType = (int)ScheduleRecordingType.Once;
            recNew.IdChannel = prog.IdChannel;
            recNew.StartTime = prog.StartTime;
            recNew.EndTime = prog.EndTime;
            recNew.Series = true;
            if (recBLL.IsSerieIsCanceled(recNew.StartTime))
            {
              recNew.Canceled = recNew.StartTime;
            }
            recordings.Add(recNew);
            //this.LogDebug("BusinessLayer.cs Added Recording WeeklyEveryTimeOnThisChannel: {0} {1} prog.startTime.DayOfWeek == rec.startTime.DayOfWeek {2} == {3}", rec.ProgramName, rec.ReferencedChannel().Name, prog.startTime.DayOfWeek, rec.startTime.DayOfWeek);
          }
        }
        return recordings;
      }

      programs = recBLL.Entity.ScheduleType == (int)ScheduleRecordingType.EveryTimeOnThisChannel
                   ? ProgramManagement.GetProgramsByChannelAndTitleAndStartEndTimes(recBLL.Entity.IdChannel,
                                          recBLL.Entity.ProgramName, dtDay,
                                          dtDay.AddDays(days))
                   : ProgramManagement.GetProgramsByTitleAndStartEndTimes(recBLL.Entity.ProgramName, dtDay, dtDay.AddDays(days));

      foreach (Program prog in programs)
      {
        if (recBLL.IsRecordingProgram(prog, false))
        {
          Schedule recNew = ScheduleFactory.Clone(recBLL.Entity);
          recNew.ScheduleType = (int)ScheduleRecordingType.Once;
          recNew.IdChannel = prog.IdChannel;
          recNew.StartTime = prog.StartTime;
          recNew.EndTime = prog.EndTime;
          recNew.Series = true;
          if (recBLL.IsSerieIsCanceled(recBLL.GetSchedStartTimeForProg(prog), prog.IdChannel))
          {
            recNew.Canceled = recNew.StartTime;
          }
          recordings.Add(recNew);
        }
      }
      return recordings;
    }
 private static bool AssignSchedulesToCard(Schedule schedule, List<Schedule>[] cardSchedules, out IList<Schedule> overlappingSchedules, out List<Schedule> notViewabledSchedules)
 {
   overlappingSchedules = new List<Schedule>();
   notViewabledSchedules = new List<Schedule>();
   Log.Info("AssignSchedulesToCard: schedule = " + schedule);
   Log.Debug("assigning schedule " + schedule.ProgramName + " s=" + schedule.StartTime.ToString() + " id=" + schedule.IdChannel.ToString());
   //IEnumerable<Card> cards = CardManagement.ListAllCards(CardIncludeRelationEnum.None); //SEB
   IList<Card> cards = CardManagement.ListAllCards(); //huha
     
     bool assigned = false;
   bool canView = false;
   int count = 0;
   foreach (Card card in cards)
   {
     Log.Debug("checking card="+card.Name+" enabled="+card.Enabled.ToString());
     Log.Debug("CardManagement.CanViewTvChannel(card, schedule.IdChannel)=" + CardManagement.CanViewTvChannel(card, schedule.IdChannel).ToString());
     ScheduleBLL scheduleBll = new ScheduleBLL(schedule);
     if (card.Enabled && CardManagement.CanViewTvChannel(card, schedule.IdChannel))
     {
       canView = true;
       Log.Debug("can view =true");
       // 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 = scheduleBll.IsOverlapping(assignedSchedule);
         if (hasOverlappingSchedule)
         {
           bool isSameTransponder = (scheduleBll.IsSameTransponder(assignedSchedule));
           Log.Debug("isSameTransponder=" + isSameTransponder.ToString());
           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 (!canView)
   {
       Log.Debug("notViewabledSchedules.Add(schedule)");
     notViewabledSchedules.Add(schedule);
   }
   Log.Debug("canView=" + canView.ToString() + "  assigned=" + assigned.ToString());
   return (canView && assigned);
 }
    public static IList<Schedule> GetConflictingSchedules(Schedule sched, out List<Schedule> notViewableSchedules)
    {
      notViewableSchedules = new List<Schedule>();
      sched.Channel = ChannelManagement.GetChannel(sched.IdChannel);
      Log.Debug("huha: GetConflictingSchedules: Schedule = " + sched.ToString());
      Log.Debug("sched=" + sched.ProgramName);
      var conflicts = new List<Schedule>();
      IEnumerable<Schedule> schedulesList = ListAllSchedules();

      IList<Card> cards = CardManagement.ListAllCards(CardIncludeRelationEnum.None).ToList(); //SEB
      if (cards.Count == 0)
      {
        return conflicts;
      }
      Log.Info("huha GetConflictingSchedules: Cards.Count = {0}", cards.Count);

      List<Schedule>[] cardSchedules = new List<Schedule>[cards.Count];
      for (int i = 0; i < cards.Count; i++)
      {
        cardSchedules[i] = new List<Schedule>();
      }

      // GEMX: Assign all already scheduled timers to cards. Assume that even possibly overlapping schedulues are ok to the user,
      // as he decided to keep them before. That's why they are in the db
      foreach (Schedule schedule in schedulesList)
      {
          Log.Debug("existing schedule "+schedule.ProgramName+" s="+schedule.StartTime.ToString()+" id="+schedule.IdChannel.ToString());

        List<Schedule> episodes = GetRecordingTimes(schedule);
        Log.Debug("episodes.count=" + episodes.Count.ToString());
        foreach (Schedule episode in episodes)
        {
          if (DateTime.Now > episode.EndTime)
          {
            continue;
          }
          var episodeBLL = new ScheduleBLL(episode);
          if (episodeBLL.IsSerieIsCanceled(episode.StartTime))
          {
            continue;
          }
          IList<Schedule> overlapping;
          Log.Debug("assigning schedules to card");
          AssignSchedulesToCard(episode, cardSchedules, out overlapping, out notViewableSchedules);
          Log.Debug("ênd of assigning schedules to card");
        }
      }

      List<Schedule> newEpisodes = GetRecordingTimes(sched);
      Log.Debug("newEpisodes.count=" + newEpisodes.Count.ToString());
      foreach (Schedule newEpisode in newEpisodes)
      {
        if (DateTime.Now > newEpisode.EndTime)
        {
          continue;
        }
        var newEpisodeBLL = new ScheduleBLL(newEpisode);
        if (newEpisodeBLL.IsSerieIsCanceled(newEpisode.StartTime))
        {
          continue;
        }
        IList<Schedule> overlapping;
        List<Schedule> notViewable;
        Log.Debug("assigning schedules to card");
        if (!AssignSchedulesToCard(newEpisode, cardSchedules, out overlapping, out notViewable))
        {
          Log.Info("GetConflictingSchedules: newEpisode can not be assigned to a card = " + newEpisode);
          conflicts.AddRange(overlapping);
          notViewableSchedules.AddRange(notViewable);
        }
        Log.Debug("ênd of assigning schedules to card");
      }
      return conflicts;
    }