/// <summary> /// /// </summary> public Zix(string zixFolderPath, string zixStorageName) { _zixStorageName = zixStorageName; _zixStoragePath = zixFolderPath; //[i] Scan for zix lot file foreach(var zlFilePath in Directory.GetFiles(_zixStoragePath)) { var filePart = new FileInfo(zlFilePath).Name.Split('.'); if (filePart[1] == ZixLotFileExt) { var zlFileSize = (int)new FileInfo(zlFilePath).Length; var zlNew = new ZixLot { FileName = new FileInfo(zlFilePath).Name, FilePath = zlFilePath, FileSize = zlFileSize, LotSequence = int.Parse( filePart[2]) }; _zixLots.Add(zlNew); } } //Initialize and sync zix storage SyncToDisk(); }
/// <summary> /// /// </summary> private void SyncToDisk() { //[i] Sync file to disk and check zix lot size if (_zixLots.Count > 0) { var zlLatest = _zixLots.Last(); //[i] Need to get new file storage. var zlFileSize = (int)new FileInfo(zlLatest.FilePath ).Length; zlLatest.FileSize = zlFileSize; //[i] Check zix lot file size if (zlLatest.FileSize < (ZixSizeMax * 1024 * 1000)) { var zlFstream = new FileStream(zlLatest.FilePath,FileMode.OpenOrCreate,FileAccess.ReadWrite,FileShare.ReadWrite ); _zixStorer = ZipStorer.Open(zlFstream, FileAccess.ReadWrite); _zixLot = zlLatest; } else { var zlNewSeq = _zixLots.Count + 1; var zlNewFileName = _zixStorageName + "." + ZixLotFileExt + "." + zlNewSeq ; var zlNew = new ZixLot { FileName = zlNewFileName, FilePath = _zixStoragePath + zlNewFileName, FileSize = 0, LotSequence = _zixLots.Count + 1 }; _zixStorer = ZipStorer.Create(_zixStoragePath + zlNew.FileName, "engine:db:zix"); _zixLots.Add(zlNew); _zixLot = zlNew; } } else { var zlNewFileName = _zixStorageName + "." + ZixLotFileExt + ".1"; var zlNew = new ZixLot { FileName = zlNewFileName, FilePath = _zixStoragePath + zlNewFileName, FileSize = 0, LotSequence = 1 }; _zixStorer = ZipStorer.Create(zlNew.FilePath, "engine:db:zix"); _zixLots.Add(zlNew); _zixLot = zlNew; } }