/// <summary> /// Add changes to batch info. /// </summary> public void AddChanges(SyncSet changes, int batchIndex = 0, bool isLastBatch = true) { if (this.InMemory) { this.InMemoryData = changes; } else { var bpId = this.GenerateNewFileName(batchIndex.ToString()); //var fileName = Path.Combine(this.GetDirectoryFullPath(), bpId); var bpi = BatchPartInfo.CreateBatchPartInfo(batchIndex, changes, bpId, GetDirectoryFullPath(), isLastBatch); // add the batchpartinfo tp the current batchinfo this.BatchPartsInfo.Add(bpi); } }
/// <summary> /// Generate a new BatchPartInfo and add it to the current batchInfo /// </summary> internal BatchPartInfo GenerateBatchInfo(int batchIndex, DmSet changesSet, string batchDirectory) { var hasData = true; if (changesSet == null || changesSet.Tables.Count == 0) { hasData = false; } else { hasData = changesSet.Tables.Any(t => t.Rows.Count > 0); } if (!hasData) { return(null); } BatchPartInfo bpi = null; // Create a batch part // The batch part creation process will serialize the changesSet to the disk if (!InMemory) { var bpId = GenerateNewFileName(batchIndex.ToString()); var fileName = Path.Combine(batchDirectory, this.Directory, bpId); bpi = BatchPartInfo.CreateBatchPartInfo(batchIndex, changesSet, fileName, false, false); } else { bpi = BatchPartInfo.CreateBatchPartInfo(batchIndex, changesSet, null, true, true); } // add the batchpartinfo tp the current batchinfo this.BatchPartsInfo.Add(bpi); return(bpi); }
/// <summary> /// Generate a new BatchPartInfo and add it to the current batchInfo /// </summary> internal BatchPartInfo GenerateBatchInfo(int batchIndex, DmSet changesSet, string batchDirectory) { var hasData = true; if (changesSet == null || changesSet.Tables.Count == 0) { hasData = false; } else { hasData = changesSet.Tables.Any(t => t.Rows.Count > 0); } // Sometimes we can have a last BPI without any data, but we need to generate it to be able to have the IsLast batch property //if (!hasData) // return null; BatchPartInfo bpi = null; // Create a batch part // The batch part creation process will serialize the changesSet to the disk if (!InMemory) { var bpId = GenerateNewFileName(batchIndex.ToString()); var fileName = Path.Combine(batchDirectory, this.Directory, bpId); bpi = BatchPartInfo.CreateBatchPartInfo(batchIndex, changesSet, fileName, false, false); } else { bpi = BatchPartInfo.CreateBatchPartInfo(batchIndex, changesSet, null, true, true); } // add the batchpartinfo tp the current batchinfo this.BatchPartsInfo.Add(bpi); return(bpi); }