public override PriorityDestinationGroupList GetPriorityGroups()
        {
            PriorityDestinationGroupList list = new PriorityDestinationGroupList();
            IDataReader rd = null;

            try
            {
                Database db = DatabaseFactory.GetDatabase();
                rd = db.ExecQuery(_selectPriorityDest, _connection, null);
                while (rd.Read())
                {
                    PriorityDestinationGroup g = new PriorityDestinationGroup(
                        rd.GetDecimal(0), rd.GetDecimal(1));
                    list.Add(g);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("CSMessageConfiguration.GetPriorityGroups error - " + ex.Message);
            }
            finally
            {
                if (rd != null)
                {
                    rd.Close();
                }
            }

            return(list);
        }
        public override DataSet GetPriorityGroupMessages(PriorityDestinationGroup g)
        {
            DataSet retVal = null;

            try
            {
                Database db = DatabaseFactory.GetDatabase();
                retVal = db.FillDataSet(_selectMsgsByPriorityDest, "MSGS", g.Priority, g.Destination);
                int rowCount = retVal.Tables[0].Rows.Count;
                if (rowCount > _maxPacketMessages)
                {
                    for (int i = _maxPacketMessages; i < rowCount; i++)
                    {
                        retVal.Tables[0].Rows[i].Delete();
                    }
                    retVal.AcceptChanges();
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("CSMessageConfiguration.GetPriorityGroupMessages error - " + ex.Message);
                Debug.WriteLine(ex.StackTrace);
            }
            return(retVal);
        }
        /// <summary>
        /// The thread procedure controlling the periodic sending process
        /// </summary>
        protected virtual void SendThreadProc()
        {
            Debug.WriteLine("MessageSender sender thread started");

            _timer.Change(_period, _period);
            while (!_stopping)
            {
                _evtWakeup.WaitOne();
                if (!_stopping)
                {
                    _evtWakeup.Reset();

//					if (Parameterization.MediaContext != null &&
//						Parameterization.MediaContext.IsMediaAvailable(MediaType.CcBase))
//					{
                    PriorityDestinationGroupList groups =
                        _msgCfg.GetPriorityGroups();
                    if (groups.Count > 0)
                    {
                        IEnumerator en = groups.GetEnumerator();
                        while (en.MoveNext())
                        {
                            PriorityDestinationGroup g =
                                (PriorityDestinationGroup)en.Current;
                            DataSet ds = _msgCfg.GetPriorityGroupMessages(g);
                            if (ds != null)
                            {
                                Debug.WriteLine(String.Format("MessageSender - issuing msgs <{0}, {1}>",
                                                              g.Destination, g.Priority));
                                FilterByMediaAvailablility(ds);
                                if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                                {
                                    ThreadPool.QueueUserWorkItem(new WaitCallback(SendOneThreadProc), ds);
                                }
                                else
                                {
                                    Debug.WriteLine("MessageSender - messages not tried (media unavailable?)");
                                }
                            }
                            else
                            {
                                Debug.WriteLine(String.Format("MessageSender - No messages found for <{0}, {1}>",
                                                              g.Destination, g.Priority));
                            }
                        }
                    }
//					}

                    Thread.Sleep(0);
                }
            }
            _timer.Change(Timeout.Infinite, Timeout.Infinite);

            Debug.WriteLine("MessageSender sender thread stopped");
        }
Exemple #4
0
 public void Add(PriorityDestinationGroup group)
 {
     _groups.Add(group);
 }
 /// <summary>
 /// Returns the messages belonging to a priority and destination group
 /// </summary>
 /// <param name="g">The group of the requested messages</param>
 /// <returns>A dataset containing the messages having the same
 /// priority and destination. They are ordered by the values of their
 /// retry policy</returns>
 public virtual DataSet GetPriorityGroupMessages(PriorityDestinationGroup g)
 {
     return(null);
 }