Ejemplo n.º 1
0
        public ScheduleModel Schedule(string serverKey, string hardwareKey, string version)
        {
            var container = new eAdDataContainer();
            Mosaic mosaic = null;
            Mosaic profilemosaic = null;
            if ((from s in container.Stations
                 where s.HardwareKey == hardwareKey
                 select s).FirstOrDefault<Station>() != null)
            {
                var grouping = (from m in container.Groupings
                                where m.Mosaic != null
                                select m).FirstOrDefault<Grouping>();

                if (grouping != null)
                {
                    mosaic = grouping.Mosaic;
                    profilemosaic = container.Mosaics.Where(mo => mo.MosaicID == grouping.ProfileMosaicID).FirstOrDefault();
                }
            }

            if (mosaic == null)
            {
                mosaic = container.Mosaics.Where(m => m.Type == "General").FirstOrDefault();
            }

            if (profilemosaic == null)
            {
                profilemosaic = container.Mosaics.Where(m => m.Type == "Profile").FirstOrDefault();
            }
            var schedule = new ScheduleModel()
            {
                Items = new List<ScheduleLayout>()
            {
                new ScheduleLayout()
                {
                    File = mosaic.MosaicID.ToString(),
                    FromDate = "2000-01-01 00:00:00",
                    ToDate = "2030-01-19 00:00:00",
                    ScheduleId = 0,
                    Priority = 0,
                    Default = true,
                    Type =mosaic.Type,
                    Hash = mosaic.Hash
                },
                 new ScheduleLayout()
                {
                    File = profilemosaic.MosaicID.ToString(),
                    FromDate = "2000-01-01 00:00:00",
                    ToDate = "2030-01-19 00:00:00",
                    ScheduleId = 0,
                    Priority = 0,
                    Default = true,
                    Type =profilemosaic.Type,
                    Hash = profilemosaic.Hash
                }
            }
            };


            return schedule;

        }
Ejemplo n.º 2
0
    /// <summary>
    /// Gets the Schedule XML
    /// </summary>
    /// <returns></returns>
    private ScheduleModel GetSchedule()
    {
        Debug.WriteLine("Getting the Schedule Xml", LogType.Info.ToString());

        ScheduleModel schedule = null;

        // Check the schedule file exists
        if (File.Exists(_location))
        {
            using (var stream = File.Open(_location,FileMode.Open,FileAccess.Read))
            {


                // Read the schedule file
                XmlSerializer serializer = new XmlSerializer(typeof(ScheduleModel));


                schedule=      (ScheduleModel) serializer.Deserialize(stream);
            }
        }
        else
        {
            // Use the default XML
            schedule = new ScheduleModel()
            {
                Items = new List<ScheduleLayout>()
            };

        }

        return schedule;
    }