Ejemplo n.º 1
0
        /// <summary>
        ///   get the current queue  content file to insert the queue item.
        /// </summary>
        /// <returns></returns>
        internal QueueContent <TValue> GetQueueContentFile(int intday)
        {
            if (!_queueContentDictionary.ContainsKey(intday))
            {
                lock (_object)
                {
                    if (!_queueContentDictionary.ContainsKey(intday))
                    {
                        string contentFileName     = GetFileName(intday, this.queueContentExtension);
                        QueueContent <TValue> file = new QueueContent <TValue>(contentFileName);
                        _queueContentDictionary.Add(intday, file);
                    }
                }
            }

            return(_queueContentDictionary[intday]);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// check, remove old files and set the start point for next dequeue.
        /// </summary>
        internal void _init()
        {
            // get list of all files in queue.

            foreach (var item in System.IO.Directory.GetFiles(this.queueFolder))
            {
                if (item.EndsWith(this.queueListExtension))
                {
                    int lastslash = Helper.PathHelper.GetLastSlash(item);
                    if (lastslash > 0)
                    {
                        string filename = item.Substring(lastslash);

                        filename = filename.Replace(this.queueListExtension, "");

                        filename = filename.Replace("\\", "").Replace("/", "");

                        this.queueFileIdList.Add(Convert.ToInt32(filename));
                    }
                    else
                    {
                        lastslash = item.LastIndexOf('/');
                        if (lastslash > 0)
                        {
                            string filename = item.Substring(lastslash);
                            filename.Replace(this.queueListExtension, "");

                            filename.Replace("/", "");

                            this.queueFileIdList.Add(Convert.ToInt32(filename));
                        }
                    }
                }
            }

            foreach (var item in queueFileIdList)
            {
                QueueList list = GetQueueListFile(item);

                if (list.isDequeueFinished() && item < DateTime.Now.DayToInt())
                {
                    list.close();
                    this._queueListDictionary.Remove(item);

                    System.IO.File.Delete(list.FullFileName);

                    QueueContent <TValue> queuecontent = GetQueueContentFile(item);

                    queuecontent.close();

                    this._queueContentDictionary.Remove(item);

                    System.IO.File.Delete(queuecontent.FullFileName);

                    list         = null;
                    queuecontent = null;
                }

                else
                {
                    this._dequeueDateInt     = item;
                    this._dequeueDateCounter = list.GetCounter();
                    return;
                }
            }
        }