Пример #1
0
        /********************************************************************************/

        public oadrlib.lib.oadr2b.OptSchedule getOptSchedule(oadrlib.lib.oadr2b.OptSchedule optSchedule, eButtonState buttonState)
        {
            DateTime current = new DateTime(StartDate.Year, StartDate.Month, StartDate.Day);
            DateTime end     = new DateTime(EndDate.Year, EndDate.Month, EndDate.Day);

            int      scheduleDuration  = 0;
            DateTime scheduleStartTime = DateTime.Now;

            while (current <= end)
            {
                List <eButtonState> hourButtonState = m_buttonStates[current.DayOfWeek.ToString()];

                for (int hour = 0; hour < 24; hour++)
                {
                    if (hourButtonState[hour] == buttonState)
                    {
                        scheduleDuration++;

                        if (scheduleDuration == 1)
                        {
                            scheduleStartTime = current.AddHours(hour);
                        }
                    }
                    else
                    {
                        if (scheduleDuration > 0)
                        {
                            optSchedule.addOptSchedule(scheduleStartTime.ToUniversalTime(), scheduleDuration);
                            scheduleDuration = 0;
                        }
                    }
                }

                current = current.AddDays(1);
            }

            if (optSchedule.Schedule.Count == 0)
            {
                return(null);
            }

            return(optSchedule);
        }
Пример #2
0
        /********************************************************************************/

        public oadrlib.lib.oadr2b.OptSchedule getOptSchedule()
        {
            oadrlib.lib.oadr2b.OptSchedule optSchedule = new oadrlib.lib.oadr2b.OptSchedule();

            optSchedule.OptReason = convertOptReasonString(OptReason);

            optSchedule.OptType = convertOptTypeString(OptType);
            optSchedule.OptID = OptID;

            optSchedule.MarketContext = MarketContext;
            optSchedule.ResourceID = ResourceID;

            for (int i = 0; i < ScheduleList.Count; i++)
            {
                optSchedule.addOptSchedule(ScheduleList[i].StartDate.ToUniversalTime(), ScheduleList[i].Duration);
            }

            // optSchedule
            if (optSchedule.Schedule.Count == 0)
                return null;

            
            return optSchedule;
        }