Exemple #1
0
        public void Initialize()
        {
            if (_timer != null)
            {
                return;
            }

            _refreshCount = 60;

            CrestronEnvironment.ProgramStatusEventHandler += type =>
            {
                _programStopping = type == eProgramStatusEventType.Stopping;
                if (_programStopping)
                {
                    RequestQueue.Enqueue(null);
                }
            };

            _timer = new CTimer(specific =>
            {
                _refreshCount = _refreshCount - 1;

                try
                {
                    if (_refreshCount == 0 || !Receivers.Any())
                    {
                        Receivers.Discover();
                    }
                }
                catch (Exception e)
                {
                    CloudLog.Error("Error getting receiver collection from AvediaServer, {0}", e.Message);
                }

                try
                {
                    if (_refreshCount == 0 || !Channels.Any())
                    {
                        Channels.UpdateChannels();
                    }
                }
                catch (Exception e)
                {
                    CloudLog.Error("Error getting channel collection from AvediaServer, {0}", e.Message);
                }

                if (!_initialized)
                {
                    _initialized = true;
                    OnHasInitialized(this);
                }

                if (_refreshCount == 0)
                {
                    _refreshCount = 60;
                }
            }, null, 1000, (long)TimeSpan.FromMinutes(1).TotalMilliseconds);
        }
Exemple #2
0
        public bool IsEnough()
        {
            if (Login == null)
            {
                Logger.LogEntry("MAIL CONFOG", LogLevel.Warning, "No login in email config");
                return(false);
            }

            if (Password == null)
            {
                Logger.LogEntry("MAIL CONFOG", LogLevel.Warning, "No password in email config");
                return(false);
            }

            if (Subject == null)
            {
                Logger.LogEntry("MAIL CONFOG", LogLevel.Warning, "No subject in email config");
                return(false);
            }

            if (Sender == null)
            {
                Logger.LogEntry("MAIL CONFOG", LogLevel.Warning, "No sender in email config");
                return(false);
            }

            if (Receivers == null || !Receivers.Any())
            {
                Logger.LogEntry("MAIL CONFOG", LogLevel.Warning, "No receivers in email config");
                return(false);
            }

            if (SmtpHost == null)
            {
                Logger.LogEntry("MAIL CONFOG", LogLevel.Warning, "No smtp host in email config");
                return(false);
            }

            if (SmptPort < 1)
            {
                Logger.LogEntry("MAIL CONFOG", LogLevel.Warning, "Incorrect smtp port in email config");
                return(false);
            }

            if (ReportPeriod < 1)
            {
                Logger.LogEntry("MAIL CONFOG", LogLevel.Warning, "Incorrect report period in email config");
                return(false);
            }

            if (MaxQueueSize < 1)
            {
                Logger.LogEntry("MAIL CONFOG", LogLevel.Warning, "Incorrect queue size in email config");
                return(false);
            }

            return(true);
        }
Exemple #3
0
        public void Initialize()
        {
            if (_timer != null)
            {
                return;
            }

            _refreshCount = 60;
            _timer        = new CTimer(specific =>
            {
                _refreshCount = _refreshCount - 1;

                try
                {
                    if (_refreshCount == 0 || !Receivers.Any())
                    {
                        Receivers.Discover();
                    }
                }
                catch (Exception e)
                {
                    CloudLog.Error("Error getting receiver collection from AvediaServer, {0}", e.Message);
                }

                try
                {
                    if (_refreshCount == 0 || !Channels.Any())
                    {
                        Channels.UpdateChannels();
                    }
                }
                catch (Exception e)
                {
                    CloudLog.Error("Error getting channel collection from AvediaServer, {0}", e.Message);
                }

                if (!_initialized)
                {
                    _initialized = true;
                    OnHasInitialized(this);
                }

                if (_refreshCount == 0)
                {
                    _refreshCount = 60;
                }
            }, null, 1000, (long)TimeSpan.FromMinutes(1).TotalMilliseconds);
        }