示例#1
0
 public void Save(IQueueItem item)
 {
     try
     {
         if (CoverProvider == CoverProviders.File)
         {
             string filename = GetFilename(item.Identifier);
             var    stream   = item.BodyStream;
             stream.SaveToFile(filename);
         }
         if (CoverProvider == CoverProviders.Sqlite)
         {
             PersistentQueue bag = new PersistentQueue(dbSettings);
             bag.AddOrUpdate
             //var dt = DbLite.MessageToDataTable(message);
             //using (Nistec.Data.Sqlite.DbLite db = new Nistec.Data.Sqlite.DbLite(CoverPath))
             //{
             //    db.ExecuteNonQuery("",)
             //    //bulk.BulkInsert(dt, CoverTableName, ConnectTimeout, null);
             //}
         }
         else
         {
             //ExecCover(((QueueItemStream)item).Copy());
             ExecCover((QueueItemStream)item);
         }
     }
     catch (Exception ex)
     {
         QLog.Exception("QCover.Save ", ex);
     }
 }
示例#2
0
        protected override IQueueItem GetFirstItem()
        {
            IQueueItem item = null;

            try
            {
                var items = m_fm.DequeueItems(FileOrderTypes.ByName, 1);
                if (items != null)
                {
                    item = items[0];
                }

                //if (Count() > 0)
                //{

                //    foreach (object o in QueueList.Keys)
                //    {
                //        item = Dequeue((Guid)o);
                //        if (item != null)
                //        {
                //            break;
                //        }
                //    }
                //}
            }
            catch (Exception ex)
            {
                QLog.Exception("GetFirstItem file error: ", ex, true, true);
                return(null);
            }
            return(item);
        }
示例#3
0
 protected override bool TryAdd(Ptr ptr, IQueueItem item)
 {
     try
     {
         m_fm.Enqueue((QItemStream)item);
         //((QItemStream)item).SaveFile(ptr);
         return(true);
     }
     catch (Exception ex)
     {
         QLog.Exception("TryAdd file error: ", ex, true, true);
         return(false);
     }
 }
示例#4
0
        protected override bool TryDequeue(Ptr ptr, out IQueueItem item)
        {
            try
            {
                //string qfile = IoAssists.GetQueueFilename(m_fm.RootPath, m_fm.HostName, ptr.Identifier);

                item = m_fm.DequeueItem(ptr.Identifier);//GetFilename(ptr.Identifier));
                return(item != null);

                //item = null;
                //var state = FileMessage.DequeueFile(ptr, QueueSettings.QueuesPath, IsTrans, out item);
                //return state == ReadFileState.Completed;
            }
            catch (Exception ex)
            {
                QLog.Exception("TryDequeue file error: ", ex, true, true);
                item = null;
                return(false);
            }
        }
示例#5
0
        protected override bool TryPeek(Ptr ptr, out IQueueItem item)
        {
            try
            {
                //string qfile = IoAssists.GetQueueFilename(m_fm.RootPath, m_fm.HostName, ptr.Identifier);

                item = m_fm.ReadFile(ptr.Identifier, false);//GetFilename(ptr.Identifier), false);
                return(item != null);

                //item=null;
                //var state= ptr.ReadFile(out item);
                //return state== ReadFileState.Completed;
            }
            catch (Exception ex)
            {
                QLog.Exception("TryPeek file error: ", ex, true, true);
                item = null;
                return(false);
            }
        }
示例#6
0
 public void Save(QueueItemStream message)
 {
     try
     {
         if (CoverProvider == CoverProviders.File)
         {
             string filename = GetFilename(message.Identifier);
             message.SaveToFile(filename);
             //var stream = message.Serialize(true);
             //stream.SaveToFile(filename);
         }
         else
         {
             ExecCover(message);
         }
     }
     catch (Exception ex)
     {
         QLog.Exception("QCover.Save ", ex);
     }
 }