Ejemplo n.º 1
0
        private void Initialize(string filename, byte maxkeysize, bool AllowDuplicateKeys)
        {
            filename    = RaptorFileUtil.FileSystemPath(filename);
            _MaxKeySize = RDBDataType <T> .GetByteSize(maxkeysize);

            _Path = Path.GetDirectoryName(filename);
            Directory.CreateDirectory(_Path);
            string dirSep = "" + Path.DirectorySeparatorChar; // "\\";

            _FileName = Path.GetFileNameWithoutExtension(filename);
            string db  = _Path + dirSep + _FileName + _datExtension;
            string idx = _Path + dirSep + _FileName + _idxExtension;

            LogManager.Configure(_Path + dirSep + _FileName + ".txt", 500, false);

            lock (_indexlock) _index = new MGIndex <T>(_Path, _FileName + _idxExtension, _MaxKeySize, Global.PageItemCount, AllowDuplicateKeys);

            lock (_archivelock) _archive = new StorageFile <T>(db);

            lock (_archivelock) _archive.SkipDateTime = true;

            log.Debug("Current Count = " + RecordCount().ToString("#,0"));

            CheckIndexState();

            log.Debug("Starting save timer");
            _savetimer           = new System.Timers.Timer();
            _savetimer.Elapsed  += new System.Timers.ElapsedEventHandler(_savetimer_Elapsed);
            _savetimer.Interval  = Global.SaveIndexToDiskTimerSeconds * 1000;
            _savetimer.AutoReset = true;
            _savetimer.Start();
        }
Ejemplo n.º 2
0
        public void Init(string filename, int sizelimitKB, bool showmethodnames)
        {
            filename        = RaptorFileUtil.FileSystemPath(filename);
            _que            = new Queue();
            _showMethodName = showmethodnames;
            _sizeLimit      = sizelimitKB;
            _filename       = filename;
            // handle folder names as well -> create dir etc.
            _FilePath = Path.GetDirectoryName(filename);
            if (_FilePath != "")
            {
                _FilePath = Directory.CreateDirectory(_FilePath).FullName;
                string dirSep = "" + Path.DirectorySeparatorChar;
                if (_FilePath.EndsWith(dirSep) == false)
                {
                    _FilePath += dirSep;
                }
            }
            filename = RaptorFileUtil.FileSystemPath(filename);

            if (!File.Exists(filename))
            {
                File.WriteAllText(filename, "");
            }
            while (_output == null)
            {
                try
                {
                    _output = new StreamWriter(filename, true);
                }
                catch
                {
                    Thread.Sleep(10);
                }
            }
            FileInfo fi = new FileInfo(filename);

            while (!fi.Exists)
            {
                Thread.Sleep(10);
                fi = new FileInfo(filename);
            }
            _lastSize     = fi.Length;
            _lastFileDate = fi.LastWriteTime;

            _saveTimer           = new System.Timers.Timer(500);
            _saveTimer.Elapsed  += new System.Timers.ElapsedEventHandler(_saveTimer_Elapsed);
            _saveTimer.Enabled   = true;
            _saveTimer.AutoReset = true;
        }
Ejemplo n.º 3
0
 public static bool FileExists(string file)
 {
     return(File.Exists(RaptorFileUtil.FileSystemPath(file)));
 }
Ejemplo n.º 4
0
 public static void FileMove(string from, string to)
 {
     File.Move(RaptorFileUtil.FileSystemPath(from), RaptorFileUtil.FileSystemPath(to));
 }