コード例 #1
0
ファイル: Queue.cs プロジェクト: xhute/Kooboo
        /// <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;
                }
            }
        }