private List<BandwidthSetting> ParseBandwidthSetting(XmlDocument document)
        {
            List<BandwidthSetting> bandwidthSettingList = new List<BandwidthSetting>();
            XmlNodeList nodeList = document.SelectNodes(@"//BandwidthTemplate");
            foreach (XmlNode node in nodeList)
            {
                BandwidthSetting bandwidthSetting = new BandwidthSetting();
                bandwidthSetting.Name = node.Attributes["Name"].Value;
                bandwidthSetting.InstanceId = node.Attributes["Id"].Value;
                bandwidthSetting.CreatedFromTemplateId = int.Parse(node.Attributes["CreatedFromTemplateId"].Value);
                bandwidthSetting.Schedules = new List<BandwidthSchedule>();
                foreach (XmlNode childNode in node.ChildNodes)
                {
                    if ("BanbdwidthSchedule" == childNode.Name)
                    {
                        BandwidthSchedule schedule = new BandwidthSchedule();
                        XmlAttribute dayNodeAtt = childNode.Attributes["Days"];
                        if (null != dayNodeAtt && !string.IsNullOrEmpty(dayNodeAtt.Value))
                        {
                            string[] days = dayNodeAtt.Value.Split(',');
                            schedule.Days = new List<int>();
                            foreach (string day in days)
                            {
                                schedule.Days.Add((int)((DayOfWeek)Enum.Parse(typeof(DayOfWeek), day, true)));
                            }
                        }

                        schedule.Rate = int.Parse(childNode.Attributes["Rate"].Value);
                        schedule.Start = childNode.Attributes["StartTime"].Value;
                        schedule.Stop = childNode.Attributes["StopTime"].Value;
                        bandwidthSetting.Schedules.Add(schedule);
                    }
                }
                

                bandwidthSettingList.Add(bandwidthSetting);
            }

            return bandwidthSettingList;
        }
        /// <summary>
        /// Parses the Bandwidth setting from Legacy appliance config
        /// </summary>
        private void ParseBandwidthSettings()
        {
            this.bandwidthSettingList = new List<BandwidthSetting>();
            var qosTemplatesList = this.GetSubElements(doc.Root, "QosTemplates");
            foreach (var qosTemplate in qosTemplatesList)
            {
                var qosTemplateElementList = this.GetSubElements(qosTemplate, "QosTemplateInfo");
                foreach (var qosTemplateElement in qosTemplateElementList)
                {
                    BandwidthSetting bandWidthSetting = new BandwidthSetting();
                    bandWidthSetting.Schedules = new List<BandwidthSchedule>();
                    foreach (var bandWidthSettingElement in qosTemplateElement.Elements())
                    {
                        switch (bandWidthSettingElement.Name.LocalName)
                        {
                            case "Name":
                            {
                                bandWidthSetting.Name = bandWidthSettingElement.Value;
                                break;
                            }

                            case "Id":
                            {
                                bandWidthSetting.InstanceId = bandWidthSettingElement.Value;
                                break;
                            }

                            case "Schedule":
                            {
                                var scheduleInfoElementList = this.GetSubElements(bandWidthSettingElement,
                                    "QosScheduleInfo");
                                foreach (var scheduleInfo in scheduleInfoElementList)
                                {
                                    // Assuming ScheduleInfo has only one element                                    
                                    BandwidthSchedule schedule = new BandwidthSchedule();
                                    bandWidthSetting.Schedules.Add(schedule);
                                    TimeSpan duration = TimeSpan.Zero;
                                    foreach (var scheduleElement in scheduleInfo.Elements())
                                    {
                                        switch (scheduleElement.Name.LocalName)
                                        {
                                            case "Days":
                                            {
                                                schedule.Days = new List<int>();
                                                foreach (var dayElem in scheduleElement.Elements())
                                                {
                                                    schedule.Days.Add(
                                                        (int) Enum.Parse(typeof (DayOfWeek), dayElem.Value, true));
                                                }

                                                break;
                                            }
                                            case "Duration":
                                            {
                                                duration = XmlConvert.ToTimeSpan(scheduleElement.Value.TrimEnd('T'));
                                                break;
                                            }
                                            case "RateInBytes":
                                            {
                                                schedule.Rate = 0;

                                                int rate = 0;
                                                if (int.TryParse(scheduleElement.Value, out rate))
                                                {
                                                    if (rate > MaxBandwidthRateSupportedBps)
                                                    {
                                                        rate = MaxBandwidthRateSupportedBps;
                                                    }
                                                    else
                                                    {
                                                        if (0 != rate)
                                                        {
                                                            // In firenze appliance you can set bandwidth rate from 0 - 1000 Mbps
                                                            rate = (rate*8)/(1000*1000);
                                                        }
                                                    }

                                                    schedule.Rate = rate;
                                                }

                                                break;
                                            }
                                            case "Start":
                                            {
                                                // Convert Start time to HH:mm:ss format as expected by service
                                                if (string.IsNullOrEmpty(scheduleElement.Value))
                                                {
                                                    schedule.Start = TimeSpan.Zero.ToString();
                                                }
                                                else
                                                {
                                                    // start time should be in universal time. 
                                                    schedule.Start =
                                                        DateTime.Parse(scheduleElement.Value)
                                                            .ToUniversalTime()
                                                            .ToString("HH:mm:ss");
                                                }

                                                break;
                                            }
                                            default:
                                            {
                                                break;
                                            }

                                        }
                                    }

                                    // Calculating the schedule stop time from start time and duration. [stop time will also be in universal time zone] 
                                    // The stop time should be in HH:mm:ss format. This is a per day schedule and cannot spill to next day
                                    if (!string.IsNullOrEmpty(schedule.Start))
                                    {
                                        schedule.Stop = DateTime.Parse(schedule.Start)
                                            .Add(duration)
                                            .ToString("HH:mm:ss");
                                    }
                                    else
                                    {
                                        schedule.Stop =
                                            DateTime.Parse(TimeSpan.Zero.ToString()).Add(duration).ToString("HH:mm:ss");
                                    }

                                    // For whole day schedule
                                    if (schedule.Start == schedule.Stop)
                                    {
                                        schedule.Start = TimeSpan.Zero.ToString();
                                        schedule.Stop = MaxTimeSpan;
                                    }
                                }

                                break;
                            }
                            default:
                            {
                                break;
                            }
                        }
                    }

                    this.bandwidthSettingList.Add(bandWidthSetting);
                }
            }
        }