Ejemplo n.º 1
0
        public List <webEvent> GetWebEvents(DateTime beginDate, DateTime endDate, List <int> buildingIDs, List <string> eventStatusIDs,
                                            bool viewComboRoomComponents, bool filterByDisplayOnWeb, out string errorMessage)
        {
            errorMessage = "";
            List <BookingsData> events      = new List <BookingsData>();
            Bookings            tmpBookings = null;

            if (buildingIDs == null || buildingIDs.Count == 0)
            {
                tmpBookings = new APIMethods().GetAllBookings(beginDate, endDate, -1, viewComboRoomComponents, out errorMessage);
                if (tmpBookings != null && tmpBookings.Items != null)
                {
                    events = tmpBookings.Items.ToList();
                }
            }
            else
            {
                foreach (var buildingID in buildingIDs)
                {
                    tmpBookings = new APIMethods().GetAllBookings(beginDate, endDate, buildingID, viewComboRoomComponents, out errorMessage);
                    if (tmpBookings != null && tmpBookings.Items != null)
                    {
                        events.AddRange(tmpBookings.Items.ToList());
                    }
                }
            }

            if (filterByDisplayOnWeb)
            {
                if (errorMessage == string.Empty && events != null)
                {
                    return(FilterEventsForWeb(events, false, true, eventStatusIDs, out errorMessage));
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                if (errorMessage == string.Empty && events != null)
                {
                    //TODO Refactor to avoid code duplication below
                    return(FilterEventsForWeb(events, false, false, eventStatusIDs, out errorMessage));
                }
                //return ((Bookings)events).Items.Where(b => webEnabledEventTypes.Contains(b.EventTypeID) && !b.EventName.Trim().StartsWith("SET UP") &&
                //        Settings1.Default.Web_enabled_booking_status_ids.Count == 0 || Settings1.Default.Web_enabled_booking_status_ids.Contains(b.StatusID.ToString()))
                //    .OrderBy(b => DateTime.Parse(b.TimeEventStart)).ThenBy(b => b.EventName)
                //    .Select(b => new webEvent(DateTime.Parse(b.TimeEventStart), b.EventName + " (" + b.StatusID + ")", b.RoomCode, null)).ToList<webEvent>();
                else
                {
                    return(null);
                }
            }
        }
Ejemplo n.º 2
0
        public List <zoneEvent> CombineAdjacentEventsInZone(Bookings events)
        {
            ////dataSet.Tables["Bookings"].Rows) {
            //var zoneEvents = ((Bookings)events).Items.Where(b => b.HVACZone != string.Empty && !b.EventName.Trim().StartsWith("SET UP")
            //        && (Settings1.Default.HVAC_enabled_booking_status_ids.Count == 0 || Settings1.Default.HVAC_enabled_booking_status_ids.Contains(b.StatusID.ToString())))
            //    .OrderBy(b => b.HVACZone).ThenBy(b => DateTime.Parse(b.TimeBookingStart)).ThenBy(b => DateTime.Parse(b.TimeEventEnd))
            //    .Select(b => new zoneEvent(b.HVACZone, DateTime.Parse(b.TimeBookingStart), DateTime.Parse(b.TimeEventEnd), b.BuildingCode + "-" + b.RoomCode)).ToList<zoneEvent>();
            ////.Select(b => new { HVACZone = b.HVACZone, TimeEventStart = DateTime.Parse(b.TimeEventStart), TimeEventEnd = DateTime.Parse(b.TimeEventEnd) });

            var zoneEvents =
                (from b in ((Bookings)events).Items
                 where b.HVACZone != string.Empty && !b.EventName.Trim().StartsWith("SET UP") &&
                 (Settings1.Default.HVAC_enabled_booking_status_ids.Count == 0 || Settings1.Default.HVAC_enabled_booking_status_ids.Contains(b.StatusID.ToString()))
                 from z in b.HVACZone.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
                 orderby z.Trim(), DateTime.Parse(b.TimeBookingStart), DateTime.Parse(b.TimeEventEnd)
                 select new zoneEvent(z.Trim(), DateTime.Parse(b.TimeBookingStart), DateTime.Parse(b.TimeEventEnd), b.BuildingCode + "-" + b.RoomCode)).ToList <zoneEvent>();

            var       zoneEventsCombined = new List <zoneEvent>();
            zoneEvent currZone           = null;

            foreach (var booking in zoneEvents)
            {
                if (currZone == null)
                {
                    currZone = new zoneEvent(booking.HVACZone, booking.TimeBookingStart, booking.TimeEventEnd, booking.Rooms);
                }
                if (currZone.HVACZone != booking.HVACZone || booking.TimeBookingStart.CompareTo(currZone.TimeEventEnd) > 0)
                {
                    //Save current zone
                    zoneEventsCombined.Add(currZone);
                    //Initialize new zone
                    currZone = new zoneEvent(booking.HVACZone, booking.TimeBookingStart, booking.TimeEventEnd, booking.Rooms);
                }
                else
                {
                    //Contiguous event in HVAC zone
                    if (booking.TimeEventEnd > currZone.TimeEventEnd)
                    {
                        currZone.TimeEventEnd = booking.TimeEventEnd;
                    }
                    currZone.Rooms += (currZone.Rooms != string.Empty ? "," : "") + booking.Rooms;
                }
            }
            //Save the last zone
            if (currZone != null)
            {
                zoneEventsCombined.Add(currZone);
            }

            return(zoneEventsCombined);
        }
Ejemplo n.º 3
0
        public List <webEvent> GetWebEvents(DateTime beginDate, DateTime endDate, List <int> buildingIDs, List <string> eventStatusIDs,
                                            bool viewComboRoomComponents, bool filterByDisplayOnWeb, out string errorMessage)
        {
            errorMessage = "";
            List <BookingsData> events      = new List <BookingsData>();
            Bookings            tmpBookings = null;

            if (buildingIDs == null || buildingIDs.Count == 0)
            {
                tmpBookings = new APIMethods().GetAllBookings(beginDate, endDate, -1, viewComboRoomComponents, out errorMessage);
                if (tmpBookings != null && tmpBookings.Items != null)
                {
                    events = tmpBookings.Items.ToList();
                }
            }
            else
            {
                foreach (var buildingID in buildingIDs)
                {
                    tmpBookings = new APIMethods().GetAllBookings(beginDate, endDate, buildingID, viewComboRoomComponents, out errorMessage);
                    if (tmpBookings != null && tmpBookings.Items != null)
                    {
                        events.AddRange(tmpBookings.Items.ToList());
                    }
                }
            }

            if (filterByDisplayOnWeb)
            {
                if (errorMessage == string.Empty && events != null)
                {
                    return(FilterEventsForWeb(events, false, true, eventStatusIDs, out errorMessage));
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                if (errorMessage == string.Empty && events != null)
                {
                    return(FilterEventsForWeb(events, false, false, eventStatusIDs, out errorMessage));
                }
                else
                {
                    return(null);
                }
            }
        }