コード例 #1
0
ファイル: ScheduleManager.cs プロジェクト: afrog33k/eAd
 private static LayoutSchedule CreateLayoutSchedule(ScheduleLayout layout)
 {
     LayoutSchedule schedule = new LayoutSchedule {
         LayoutFile = layout.File
     };
     string s = schedule.LayoutFile.TrimEnd(".xml".ToCharArray());
     schedule.LayoutFile = Settings.Default.LibraryPath + @"\Layouts\" + s + ".mosaic";
     schedule.ID = int.Parse(s);
     if (schedule.NodeName != "default")
     {
         schedule.Priority = layout.Priority;
         schedule.FromDate = DateTime.Parse(layout.FromDate);
         schedule.ToDate = DateTime.Parse(layout.ToDate);
         int scheduleId = -1;
         if (layout.ScheduleId != -1)
         {
             scheduleId = layout.ScheduleId;
         }
         if (scheduleId != -1)
         {
             schedule.Scheduleid = scheduleId;
         }
     }
     return schedule;
 }
コード例 #2
0
ファイル: ScheduleManager.cs プロジェクト: afrog33k/eAd
        private static LayoutSchedule CreateLayoutSchedule(ScheduleLayout layout)
        {
            LayoutSchedule schedule = new LayoutSchedule {
                LayoutFile = layout.File
            };
            string s = schedule.LayoutFile.TrimEnd(".xml".ToCharArray());

            schedule.LayoutFile = Settings.Default.LibraryPath + @"\Layouts\" + s + ".mosaic";
            schedule.ID         = int.Parse(s);
            if (schedule.NodeName != "default")
            {
                schedule.Priority = layout.Priority;
                schedule.FromDate = DateTime.Parse(layout.FromDate);
                schedule.ToDate   = DateTime.Parse(layout.ToDate);
                int scheduleId = -1;
                if (layout.ScheduleId != -1)
                {
                    scheduleId = layout.ScheduleId;
                }
                if (scheduleId != -1)
                {
                    schedule.Scheduleid = scheduleId;
                }
            }
            return(schedule);
        }
コード例 #3
0
ファイル: ScheduleManager.cs プロジェクト: afrog33k/eAd
        private void LoadScheduleFromFile()
        {
            this._layoutSchedule.Clear();
            ScheduleModel         model  = this.GetSchedule();
            List <ScheduleLayout> second = (from s in model.Items
                                            where s.Type == "General"
                                            select s).ToList <ScheduleLayout>();
            ScheduleLayout layout = model.Items.Except <ScheduleLayout>(second).FirstOrDefault <ScheduleLayout>();

            if (layout != null)
            {
                this.ProfileLayout = CreateLayoutSchedule(layout);
            }
            if (second.Count == 0)
            {
                this.SetEmptySchedule();
            }
            else
            {
                foreach (ScheduleLayout layout2 in second)
                {
                    LayoutSchedule item = CreateLayoutSchedule(layout2);
                    this._layoutSchedule.Add(item);
                }
                second = null;
                model  = null;
            }
        }
コード例 #4
0
ファイル: ScheduleManager.cs プロジェクト: afrog33k/eAd
        private void SetEmptySchedule()
        {
            this._layoutSchedule.Clear();
            LayoutSchedule item = new LayoutSchedule {
                LayoutFile = Settings.Default.LibraryPath + @"\Default.xml",
                ID         = 0,
                Scheduleid = 0
            };

            this._layoutSchedule.Add(item);
        }
コード例 #5
0
        /// <summary>
        /// Sets an empty schedule into the _layoutSchedule Collection
        /// </summary>
        private void SetEmptySchedule()
        {
            Debug.WriteLine("Setting an empty schedule", LogType.Info.ToString());

            // Remove the existing schedule
            _layoutSchedule.Clear();

            // Schedule up the default
            LayoutSchedule temp = new LayoutSchedule();

            temp.LayoutFile = Settings.Default.LibraryPath + @"\Default.xml";
            temp.ID         = 0;
            temp.Scheduleid = 0;

            _layoutSchedule.Add(temp);
        }
コード例 #6
0
ファイル: ScheduleManager.cs プロジェクト: afrog33k/eAd
        private Collection <LayoutSchedule> LoadNewSchdule()
        {
            Collection <LayoutSchedule> collection  = new Collection <LayoutSchedule>();
            Collection <LayoutSchedule> collection2 = new Collection <LayoutSchedule>();
            LayoutSchedule item = new LayoutSchedule();

            foreach (LayoutSchedule schedule2 in this._layoutSchedule)
            {
                try
                {
                    if (!this._cacheManager.IsValidLayout(schedule2.ID + ".mosaic"))
                    {
                        continue;
                    }
                }
                catch
                {
                    Trace.WriteLine("Unable to determine if layout is valid or not");
                    continue;
                }
                if (schedule2.NodeName == "default")
                {
                    item = schedule2;
                }
                else if ((schedule2.FromDate <= DateTime.Now) && (schedule2.ToDate >= DateTime.Now))
                {
                    if (schedule2.Priority != 0)
                    {
                        collection2.Add(schedule2);
                        continue;
                    }
                    collection.Add(schedule2);
                }
            }
            if (collection2.Count > 0)
            {
                return(collection2);
            }
            if (collection.Count == 0)
            {
                collection.Add(item);
            }
            return(collection);
        }
コード例 #7
0
        private static LayoutSchedule CreateLayoutSchedule(ScheduleLayout layout)
        {
            LayoutSchedule temp = new LayoutSchedule();

            // All nodes have file properties
            temp.LayoutFile = layout.File;

            // Replace the .xml extension with nothing
            string replace    = ".xml";
            string layoutFile = temp.LayoutFile.TrimEnd(replace.ToCharArray());

            // Set these on the temp layoutschedule
            temp.LayoutFile = Settings.Default.LibraryPath + "\\" + "Layouts\\" + layoutFile + ".mosaic";
            temp.ID         = int.Parse(layoutFile);

            // Get attributes that only exist on the default
            if (temp.NodeName != "default")
            {
                // Priority flag
                temp.Priority = layout.Priority;

                // Get the fromdt,todt
                temp.FromDate = DateTime.Parse(layout.FromDate);
                temp.ToDate   = DateTime.Parse(layout.ToDate);

                // Pull out the scheduleid if there is one
                int scheduleId = -1;
                if (layout.ScheduleId != -1)
                {
                    scheduleId = layout.ScheduleId;
                }

                // Add it to the layout schedule
                if (scheduleId != -1)
                {
                    temp.Scheduleid = scheduleId;
                }
            }
            return(temp);
        }
コード例 #8
0
        /// <summary>
        /// Loads a new schedule from _layoutSchedules
        /// </summary>
        /// <returns></returns>
        private Collection <LayoutSchedule> LoadNewSchdule()
        {
            // We need to build the current schedule from the layout schedule (obeying date/time)
            Collection <LayoutSchedule> newSchedule      = new Collection <LayoutSchedule>();
            Collection <LayoutSchedule> prioritySchedule = new Collection <LayoutSchedule>();

            // Temporary default Layout incase we have no layout nodes.
            LayoutSchedule defaultLayout = new LayoutSchedule();

            // For each layout in the schedule determine if it is currently inside the _currentSchedule, and whether it should be
            foreach (LayoutSchedule layout in _layoutSchedule)
            {
                // Is the layout valid in the cachemanager?
                try
                {
                    if (!_cacheManager.IsValidLayout(layout.ID + ".mosaic"))
                    {
                        continue;
                    }
                }
                catch
                {
                    // TODO: Ignore this layout.. raise an error?
                    Trace.WriteLine("Unable to determine if layout is valid or not");
                    continue;
                }

                // If this is the default, skip it
                if (layout.NodeName == "default")
                {
                    // Store it before skipping it
                    defaultLayout = layout;
                    continue;
                }

                // Look at the Date/Time to see if it should be on the schedule or not
                if (layout.FromDate <= DateTime.Now && layout.ToDate >= DateTime.Now)
                {
                    // Priority layouts should generate their own list
                    if (layout.Priority != 0)
                    {
                        prioritySchedule.Add(layout);
                    }
                    else
                    {
                        newSchedule.Add(layout);
                    }
                }
            }

            // If we have any priority schedules then we need to return those instead
            if (prioritySchedule.Count > 0)
            {
                return(prioritySchedule);
            }

            // If the current schedule is empty by the end of all this, then slip the default in
            if (newSchedule.Count == 0)
            {
                newSchedule.Add(defaultLayout);
            }

            return(newSchedule);
        }
コード例 #9
0
ファイル: ScheduleManager.cs プロジェクト: afrog33k/eAd
 private void SetEmptySchedule()
 {
     this._layoutSchedule.Clear();
     LayoutSchedule item = new LayoutSchedule {
         LayoutFile = Settings.Default.LibraryPath + @"\Default.xml",
         ID = 0,
         Scheduleid = 0
     };
     this._layoutSchedule.Add(item);
 }
コード例 #10
0
ファイル: ScheduleManager.cs プロジェクト: afrog33k/eAd
 private Collection<LayoutSchedule> LoadNewSchdule()
 {
     Collection<LayoutSchedule> collection = new Collection<LayoutSchedule>();
     Collection<LayoutSchedule> collection2 = new Collection<LayoutSchedule>();
     LayoutSchedule item = new LayoutSchedule();
     foreach (LayoutSchedule schedule2 in this._layoutSchedule)
     {
         try
         {
             if (!this._cacheManager.IsValidLayout(schedule2.ID + ".mosaic"))
             {
                 continue;
             }
         }
         catch
         {
             Trace.WriteLine("Unable to determine if layout is valid or not");
             continue;
         }
         if (schedule2.NodeName == "default")
         {
             item = schedule2;
         }
         else if ((schedule2.FromDate <= DateTime.Now) && (schedule2.ToDate >= DateTime.Now))
         {
             if (schedule2.Priority != 0)
             {
                 collection2.Add(schedule2);
                 continue;
             }
             collection.Add(schedule2);
         }
     }
     if (collection2.Count > 0)
     {
         return collection2;
     }
     if (collection.Count == 0)
     {
         collection.Add(item);
     }
     return collection;
 }
コード例 #11
0
ファイル: ScheduleManager.cs プロジェクト: afrog33k/eAd
    /// <summary>
    /// Sets an empty schedule into the _layoutSchedule Collection
    /// </summary>
    private void SetEmptySchedule()
    {
        Debug.WriteLine("Setting an empty schedule", LogType.Info.ToString());

        // Remove the existing schedule
        _layoutSchedule.Clear();

        // Schedule up the default
        LayoutSchedule temp = new LayoutSchedule();
        temp.LayoutFile = Settings.Default.LibraryPath + @"\Default.xml";
        temp.ID = 0;
        temp.Scheduleid = 0;

        _layoutSchedule.Add(temp);
    }
コード例 #12
0
ファイル: ScheduleManager.cs プロジェクト: afrog33k/eAd
    private static LayoutSchedule CreateLayoutSchedule(ScheduleLayout layout)
    {
        LayoutSchedule temp = new LayoutSchedule();

        // All nodes have file properties
        temp.LayoutFile = layout.File;

        // Replace the .xml extension with nothing
        string replace = ".xml";
        string layoutFile = temp.LayoutFile.TrimEnd(replace.ToCharArray());

        // Set these on the temp layoutschedule
        temp.LayoutFile = Settings.Default.LibraryPath + "\\" + "Layouts\\" + layoutFile + ".mosaic";
        temp.ID = int.Parse(layoutFile);

        // Get attributes that only exist on the default
        if (temp.NodeName != "default")
        {
            // Priority flag
            temp.Priority = layout.Priority;

            // Get the fromdt,todt
            temp.FromDate = DateTime.Parse(layout.FromDate);
            temp.ToDate = DateTime.Parse(layout.ToDate);

            // Pull out the scheduleid if there is one
            int scheduleId = -1;
            if (layout.ScheduleId != -1)
                scheduleId = layout.ScheduleId;

            // Add it to the layout schedule
            if (scheduleId != -1)
                temp.Scheduleid = scheduleId;
        }
        return temp;
    }
コード例 #13
0
ファイル: ScheduleManager.cs プロジェクト: afrog33k/eAd
    /// <summary>
    /// Loads a new schedule from _layoutSchedules
    /// </summary>
    /// <returns></returns>
    private Collection<LayoutSchedule> LoadNewSchdule()
    {
        // We need to build the current schedule from the layout schedule (obeying date/time)
        Collection<LayoutSchedule> newSchedule = new Collection<LayoutSchedule>();
        Collection<LayoutSchedule> prioritySchedule = new Collection<LayoutSchedule>();

        // Temporary default Layout incase we have no layout nodes.
        LayoutSchedule defaultLayout = new LayoutSchedule();

        // For each layout in the schedule determine if it is currently inside the _currentSchedule, and whether it should be
        foreach (LayoutSchedule layout in _layoutSchedule)
        {
            // Is the layout valid in the cachemanager?
            try
            {
                if (!_cacheManager.IsValidLayout(layout.ID + ".mosaic"))
                    continue;
            }
            catch
            {
                // TODO: Ignore this layout.. raise an error?
                Trace.WriteLine("Unable to determine if layout is valid or not");
                continue;
            }

            // If this is the default, skip it
            if (layout.NodeName == "default")
            {
                // Store it before skipping it
                defaultLayout = layout;
                continue;
            }

            // Look at the Date/Time to see if it should be on the schedule or not
            if (layout.FromDate <= DateTime.Now && layout.ToDate >= DateTime.Now)
            {
                // Priority layouts should generate their own list
                if (layout.Priority != 0)
                {
                    prioritySchedule.Add(layout);
                }
                else
                {
                    newSchedule.Add(layout);
                }
            }
        }

        // If we have any priority schedules then we need to return those instead
        if (prioritySchedule.Count > 0)
            return prioritySchedule;

        // If the current schedule is empty by the end of all this, then slip the default in
        if (newSchedule.Count == 0)
            newSchedule.Add(defaultLayout);

        return newSchedule;
    }