예제 #1
0
        // Sanding SMS procedure start
        private static void QueueAnalyzeTimer_StartQueueScan(object sender, System.EventArgs e)
        {
            //if there is no running task
            if (!_taskIsRunning)
            {
                List <SMSsendingModel> messagesToSend = new List <SMSsendingModel>();

                //get all alarms to be send
                while (_alarmsToSned.Count > 0)
                {
                    try
                    {
                        //get single queue model
                        SMSsendingModel model = _alarmsToSned.Dequeue();

                        //add to list
                        messagesToSend.Add(model);
                    }
                    catch (Exception ex)
                    {
                        var logger = NLog.LogManager.GetCurrentClassLogger();
                        logger.Error($"Unable to dequeue the wueue of pending alarms to send. Exception: {ex.Message}.");
                    }
                }
                if (messagesToSend.Count > 0)
                {
                    //blosk starting new task is one is still running
                    _taskIsRunning = true;
                    Task.Run(() => CreateNewSendingTask(messagesToSend));
                }
            }
        }
예제 #2
0
        public static void AddNewAlarmToSend(int profileID, int GroupID,
                                             S7AlarmDefinition newAlarm, IRealmProvider realmProvider)
        {
            _realmProvider = realmProvider;

            string text = SaveAlarmOccurencesToDB(newAlarm);

            SMSsendingModel model = new SMSsendingModel()
            {
                AlarmText       = text,
                AlarmProfileID  = profileID,
                AlarmSMSGroupID = GroupID,
            };

            _alarmsToSned.Enqueue(model);
        }