private string CreatePackageForSend(ReplicationPacket packet, out int last) { int maxc = INTERNALLIMIT; WhatItem what = GetBranchConfig(packet.branchname).what; if (what.PackageItemLimit > 0) { maxc = what.PackageItemLimit; } string outFolder = _OutboxPath; int packageNumber = packet.lastrecord; int i = packet.lastrecord; string filename = outFolder + _S + packet.branchname + _S + packageNumber.ToString("0000000000") + ".mgdat"; if (i < _docs.RecordCount()) { StorageFile <Guid> package = new StorageFile <Guid>(filename, SF_FORMAT.JSON, true); while (maxc > 0) { var meta = _docs.GetMeta(i); if (meta == null) { break; } if (meta.isReplicated == false && MatchType(meta.typename, what)) { if (meta.isDeleted == false || what.PropogateHQDeletes) { object obj = _docs.GetObject(i, out meta); package.WriteObject(meta.key, obj); maxc--; } } i++; } package.Shutdown(); packageNumber++; // compress the file using (FileStream read = File.OpenRead(filename)) using (FileStream outp = File.Create(filename + ".gz")) CompressForBackup(read, outp); // delete uncompressed file File.Delete(filename); } last = i; return(filename + ".gz"); }
private string CreatePackageForSend() { int maxc = INTERNALLIMIT; if (_clientConfig.what.PackageItemLimit > 0) { maxc = _clientConfig.what.PackageItemLimit; } string outFolder = _OutboxPath; int packageNumber = _clientConfig.outPackageNumber; int i = _clientConfig.lastCounter; string filename = outFolder + packageNumber.ToString("0000000000") + ".mgdat"; int total = _docs.RecordCount(); if (i < total) { StorageFile <Guid> package = new StorageFile <Guid>(filename, SF_FORMAT.JSON, true); while (maxc > 0 && i < total) { var meta = _docs.GetMeta(i); if (meta == null) { break; } if (meta.isReplicated == false && MatchType(meta.typename)) { object obj = _docs.GetObject(i, out meta); package.WriteObject(meta.key, obj); maxc--; } i++; } package.Shutdown(); packageNumber++; // compress the file using (FileStream read = File.OpenRead(filename)) using (FileStream outp = File.Create(filename + ".gz")) CompressForBackup(read, outp); // delete uncompressed file File.Delete(filename); _clientConfig.lastCounter = i; _clientConfig.outPackageNumber = packageNumber; SaveConfig(); return(filename + ".gz"); } return(""); }