// Token: 0x060012BB RID: 4795 RVA: 0x0006D118 File Offset: 0x0006B318 public OABFile GenerateDiffFile(FileSet fileSet) { this.abortProcessingOnShutdown(); FileStream fileStream = fileSet.Create("CHG"); this.diffFile = new OABFile(fileStream, OABDataFileType.Diff); bool flag = false; using (IOCostStream iocostStream = new IOCostStream(new NoCloseStream(fileStream))) { using (new FileSystemPerformanceTracker("FinishGeneratingAddressListFiles.GenerateDiffFiles", iocostStream, this.stats)) { flag = this.CreatePatch(iocostStream); } } if (flag) { this.diffFile.SequenceNumber = (this.newFile.SequenceNumber += 1U); this.diffFile.DnToUseInOABFile = this.newFile.DnToUseInOABFile; this.diffFile.NameToUseInOABFile = this.newFile.NameToUseInOABFile; this.diffFile.Guid = this.newFile.Guid; this.diffFile.UncompressedFileSize = this.newFile.UncompressedFileSize; this.diffFile.CompressedFileSize = (uint)this.diffFile.UncompressedFileStream.Length; this.diffFile.CompressedFileHash = OABFileHash.GetHash(this.diffFile.UncompressedFileStream); return(this.diffFile); } this.diffFile = null; return(null); }
// Token: 0x06000D05 RID: 3333 RVA: 0x00036658 File Offset: 0x00034858 private void ReadAttachmentIntoStreamAndValidateHash(IStreamAttachment attachment, Stream outputStream, Action abortFileOperation) { using (IOCostStream iocostStream = new IOCostStream(outputStream)) { using (new FileSystemPerformanceTracker("MailboxDownload", iocostStream, this.logger)) { using (HashAlgorithm hashAlgorithm = new SHA1CryptoServiceProvider()) { using (new StorePerformanceTracker("MailboxDownload", this.logger)) { CopyStreamResult arg; using (IOCostStream iocostStream2 = new IOCostStream(attachment.GetContentStream())) { using (new FileSystemPerformanceTracker("MailboxDownload", iocostStream2, this.logger)) { arg = MailboxFileStore.streamCopier.CopyStream(iocostStream2, iocostStream, hashAlgorithm, abortFileOperation); } } this.tracer.TraceDebug <CopyStreamResult>((long)this.GetHashCode(), "Downloaded file attachment from mailbox. {0}", arg); byte[] array = attachment[AttachmentSchema.AttachHash] as byte[]; this.tracer.TraceDebug <ArrayTracer <byte> >((long)this.GetHashCode(), "Expected hash in attachment downloaded from mailbox is: {0}.", new ArrayTracer <byte>(array)); if (!ArrayComparer <byte> .Comparer.Equals(hashAlgorithm.Hash, array)) { throw new InvalidDataException(string.Format("Hash of data content doesn't match hash of original uploaded file. Expected: {0}, actual: {1}.", BitConverter.ToString(array), BitConverter.ToString(hashAlgorithm.Hash))); } } } } } }
// Token: 0x06000D03 RID: 3331 RVA: 0x0003642C File Offset: 0x0003462C private void UploadSingleFile(string fileName, IAttachmentCollection attachmentCollection, Action abortFileOperation) { abortFileOperation(); string fileName2 = Path.GetFileName(fileName); using (IOCostStream iocostStream = new IOCostStream(new FileStream(fileName, FileMode.Open))) { using (new FileSystemPerformanceTracker("MailboxUpload", iocostStream, this.logger)) { using (HashAlgorithm hashAlgorithm = new SHA1CryptoServiceProvider()) { using (IStreamAttachment streamAttachment = (IStreamAttachment)attachmentCollection.CreateIAttachment(AttachmentType.Stream)) { using (new StorePerformanceTracker("MailboxUpload", this.logger)) { CopyStreamResult arg; using (IOCostStream iocostStream2 = new IOCostStream(streamAttachment.GetContentStream())) { arg = MailboxFileStore.streamCopier.CopyStream(iocostStream, iocostStream2, hashAlgorithm, abortFileOperation); iocostStream2.Flush(); } streamAttachment[AttachmentSchema.DisplayName] = fileName2; streamAttachment[AttachmentSchema.AttachLongFileName] = fileName2; streamAttachment[AttachmentSchema.AttachHash] = hashAlgorithm.Hash; streamAttachment.Save(); this.tracer.TraceDebug <string, CopyStreamResult>((long)this.GetHashCode(), "Uploaded file '{0}' to mailbox. {1}", fileName, arg); } } } } } }
// Token: 0x0600133B RID: 4923 RVA: 0x00070070 File Offset: 0x0006E270 private void CreateFlatFileFromSinglePageOfResults(Stream sortedFlatFileStream, ADRawEntry[] sortedEntries) { this.abortProcessingOnShutdown(); using (IOCostStream iocostStream = new IOCostStream(new NoCloseStream(sortedFlatFileStream))) { using (new FileSystemPerformanceTracker("ProduceSortedFlatFile", iocostStream, this.stats)) { using (BinaryWriter binaryWriter = new BinaryWriter(iocostStream)) { using (CRCScratchPad crcscratchPad = new CRCScratchPad()) { OABFileHeader oabfileHeader = new OABFileHeader(); oabfileHeader.WriteTo(binaryWriter); uint defaultSeed = OABCRC.DefaultSeed; OABPropertyDescriptor[] array = new OABPropertyDescriptor[this.propertyManager.OABProperties.Length]; for (int i = 0; i < array.Length; i++) { array[i] = this.propertyManager.OABProperties[i].PropertyDescriptor; } OABFileProperties data = new OABFileProperties { HeaderProperties = this.propertyManager.HeaderProperties, DetailProperties = array }; crcscratchPad.ComputeCRCAndWrite(data, binaryWriter, ref defaultSeed); OABFileRecord data2 = this.CreateHeaderRecord(); crcscratchPad.ComputeCRCAndWrite(data2, binaryWriter, ref defaultSeed); using (new StopwatchPerformanceTracker("ProduceSortedFlatFile", this.stats)) { using (new CpuPerformanceTracker("ProduceSortedFlatFile", this.stats)) { using (new ADPerformanceTracker("ProduceSortedFlatFile", this.stats)) { using (new ActiveManagerPerformanceTracker("ProduceSortedFlatFile", this.stats)) { this.propertyManager.ResolveLinks(sortedEntries); } } } } foreach (ADRawEntry adRawEntry in sortedEntries) { this.abortProcessingOnShutdown(); OABFileRecord data3 = this.CreateDetailsRecord(adRawEntry); crcscratchPad.ComputeCRCAndWrite(data3, binaryWriter, ref defaultSeed); } iocostStream.Seek(0L, SeekOrigin.Begin); oabfileHeader.Version = 32; oabfileHeader.CRC = defaultSeed; oabfileHeader.RecordCount = sortedEntries.Length; oabfileHeader.WriteTo(binaryWriter); this.stats.IODuration += iocostStream.Writing; this.stats.TotalNumberOfRecords += sortedEntries.Length; } } } } }
// Token: 0x0600133C RID: 4924 RVA: 0x00070370 File Offset: 0x0006E570 private void CreateFlatFileFromMultiplePagesOfResults(Stream sortedFlatFileStream, List <FileStream> tempFiles) { this.abortProcessingOnShutdown(); using (IOCostStream iocostStream = new IOCostStream(new NoCloseStream(sortedFlatFileStream))) { using (new FileSystemPerformanceTracker("ProduceSortedFlatFile", iocostStream, this.stats)) { using (BinaryWriter binaryWriter = new BinaryWriter(iocostStream)) { using (CRCScratchPad crcscratchPad = new CRCScratchPad()) { OABFileHeader oabfileHeader = new OABFileHeader(); oabfileHeader.WriteTo(binaryWriter); uint num = OABCRC.DefaultSeed; OABPropertyDescriptor[] array = new OABPropertyDescriptor[this.propertyManager.OABProperties.Length]; for (int i = 0; i < array.Length; i++) { array[i] = this.propertyManager.OABProperties[i].PropertyDescriptor; } OABFileProperties data = new OABFileProperties { HeaderProperties = this.propertyManager.HeaderProperties, DetailProperties = array }; crcscratchPad.ComputeCRCAndWrite(data, binaryWriter, ref num); OABFileRecord data2 = this.CreateHeaderRecord(); crcscratchPad.ComputeCRCAndWrite(data2, binaryWriter, ref num); int num2 = 0; using (TempFileReaderCollection tempFileReaderCollection = new TempFileReaderCollection()) { tempFileReaderCollection.Initialize(this.stats, tempFiles); for (;;) { this.abortProcessingOnShutdown(); byte[] nextRecord = tempFileReaderCollection.GetNextRecord(); if (nextRecord == null) { break; } num = OABCRC.ComputeCRC(num, nextRecord, 0, nextRecord.Length); binaryWriter.Write(nextRecord); num2++; } } iocostStream.Seek(0L, SeekOrigin.Begin); oabfileHeader.Version = 32; oabfileHeader.CRC = num; oabfileHeader.RecordCount = num2; oabfileHeader.WriteTo(binaryWriter); this.stats.IODuration += iocostStream.Writing; this.stats.TotalNumberOfRecords += num2; } } } } }
// Token: 0x060012EB RID: 4843 RVA: 0x0006E0C4 File Offset: 0x0006C2C4 public void Compress(FileSet fileSet, GenerationStats stats, string marker) { this.compressedFileStream = fileSet.Create("LZX"); long length = this.uncompressedFileStream.Length; ulong num = (ulong)-1; this.uncompressedFileSize = (uint)this.uncompressedFileStream.Length; this.uncompressedFileStream.Seek(0L, SeekOrigin.Begin); Stopwatch stopwatch = Stopwatch.StartNew(); byte[] array = new byte[Globals.MaxCompressionBlockSize]; using (IOCostStream iocostStream = new IOCostStream(new NoCloseStream(this.uncompressedFileStream))) { using (new FileSystemPerformanceTracker(marker, iocostStream, stats)) { using (IOCostStream iocostStream2 = new IOCostStream(new OABCompressStream(this.compressedFileStream, Globals.MaxCompressionBlockSize))) { using (new FileSystemPerformanceTracker(marker, iocostStream2, stats)) { for (;;) { int num2 = iocostStream.Read(array, 0, array.Length); if (num2 == 0) { break; } iocostStream2.Write(array, 0, num2); } } } } } stopwatch.Stop(); this.ioDuration += stopwatch.Elapsed; this.compressedFileSize = (uint)this.compressedFileStream.Length; this.compressedFileHash = OABFileHash.GetHash(this.compressedFileStream); }
// Token: 0x0600131F RID: 4895 RVA: 0x0006E8E8 File Offset: 0x0006CAE8 public OABFile GenerateTemplateFile(FileSet fileSet) { int templateEncoding = 0; if (!this.TryGetLcidFromContainerName(out templateEncoding)) { return(null); } FileStream fileStream = fileSet.Create("TPL"); this.oabFile = new OABFile(fileStream, this.oabDataFileType); using (IOCostStream iocostStream = new IOCostStream(new NoCloseStream(fileStream))) { using (new FileSystemPerformanceTracker("GenerateOrLinkTemplateFiles.GenerateTemplateFiles", iocostStream, this.stats)) { this.SetTemplateEncoding(templateEncoding); this.WriteHeader(iocostStream); this.GenerateAddressTemplates(iocostStream); this.GenerateDisplayTemplates(iocostStream); } } this.oabFile.Compress(fileSet, this.stats, "GenerateOrLinkTemplateFiles.GenerateTemplateFiles"); return(this.oabFile); }
// Token: 0x060012BC RID: 4796 RVA: 0x0006D26C File Offset: 0x0006B46C private bool CreatePatch(Stream diffStream) { this.abortProcessingOnShutdown(); bool result; using (DataPatching dataPatching = new DataPatching(Globals.MaxCompressionBlockSize, Globals.MaxCompressionBlockSize, Globals.MaxCompressionBlockSize)) { using (IOCostStream iocostStream = new IOCostStream(new NoCloseStream(this.oldFile.UncompressedFileStream))) { using (new FileSystemPerformanceTracker("FinishGeneratingAddressListFiles.GenerateDiffFiles", iocostStream, this.stats)) { using (IOCostStream iocostStream2 = new IOCostStream(new NoCloseStream(this.newFile.UncompressedFileStream))) { using (new FileSystemPerformanceTracker("FinishGeneratingAddressListFiles.GenerateDiffFiles", iocostStream2, this.stats)) { byte[] array = new byte[Globals.MaxCompressionBlockSize]; byte[] array2 = new byte[Globals.MaxCompressionBlockSize]; int num; uint oldCRC; DiffFileGenerator.ReadFileHeader(iocostStream, array, out num, out oldCRC); int num2; uint newCRC; DiffFileGenerator.ReadFileHeader(iocostStream2, array2, out num2, out newCRC); this.WriteDiffFileHeader(diffStream, oldCRC, newCRC); uint num3 = 0U; uint num4 = 0U; long num5 = iocostStream.Length - (long)num; long num6 = iocostStream2.Length - (long)num2; byte[] array3 = null; byte[] array4 = null; int num7 = 0; int num8 = 0; Guid? guid = null; Guid? guid2 = null; byte[] propertyDescriptorsBuffer = null; byte[] propertyDescriptorsBuffer2 = null; int headerPropertyDescriptorsCount = 0; int headerPropertyDescriptorsCount2 = 0; int num9 = 0; int num10 = 0; bool flag = false; int num11 = 0; for (;;) { this.abortProcessingOnShutdown(); if (num5 != 0L && num11 <= 0 && num7 == 0) { DiffFileGenerator.ReadNextRecord(iocostStream, true, ref num3, ref num5, ref array3, ref num7, ref guid, ref propertyDescriptorsBuffer, ref headerPropertyDescriptorsCount, ref num9); } if (num6 != 0L && num11 >= 0 && num8 == 0) { DiffFileGenerator.ReadNextRecord(iocostStream2, false, ref num4, ref num6, ref array4, ref num8, ref guid2, ref propertyDescriptorsBuffer2, ref headerPropertyDescriptorsCount2, ref num10); } bool flag2 = false; if (guid != null && guid2 != null) { num11 = guid.Value.CompareTo(guid2.Value); } else if (guid == null && guid2 != null) { flag = true; num11 = 2; } else { if (guid == null || guid2 != null) { break; } flag = true; num11 = -2; } if (num11 == 0 && num > 0 && num2 > 0 && (num + array3.Length > Globals.MaxCompressionBlockSize || num2 + array4.Length > Globals.MaxCompressionBlockSize)) { flag2 = true; } else { if (num11 != 0) { flag = true; if (num11 < 0) { this.stats.IncrementRecordsDeletedChurn(); } else { this.stats.IncrementRecordsAddedChurn(); } } else if (num3 == 2U && num4 == 2U) { string a = (string)DiffFileGenerator.GetHeaderPropertyValue(OABFilePropTags.OabName, array3, propertyDescriptorsBuffer, headerPropertyDescriptorsCount, true); string b = (string)DiffFileGenerator.GetHeaderPropertyValue(OABFilePropTags.OabName, array4, propertyDescriptorsBuffer2, headerPropertyDescriptorsCount2, false); flag = (a != b); } else if (array3.Length != array4.Length || !array3.SequenceEqual(array4)) { flag = true; this.stats.IncrementRecordsModifiedChurn(); } if (num11 <= 0) { if (num + array3.Length <= Globals.MaxCompressionBlockSize || array3.Length > Globals.MaxCompressionBlockSize) { DiffFileGenerator.ConsumeRecord(array, ref num, array3, ref num7, ref guid, ref flag2); } else { flag2 = true; } } if (num11 >= 0) { if (num2 + array4.Length <= Globals.MaxCompressionBlockSize || array4.Length > Globals.MaxCompressionBlockSize) { DiffFileGenerator.ConsumeRecord(array2, ref num2, array4, ref num8, ref guid2, ref flag2); } else { flag2 = true; } } } if (flag2) { this.WriteLzxPatch(diffStream, dataPatching, array, num, array2, num2); num = 0; num2 = 0; } } if (num5 == 0L && num6 != 0L) { } if (num != 0 || num2 != 0) { this.WriteLzxPatch(diffStream, dataPatching, array, num, array2, num2); } result = flag; } } } } } return(result); }
// Token: 0x06001337 RID: 4919 RVA: 0x0006F84C File Offset: 0x0006DA4C public AssistantTaskContext ProcessOnePageOfADResults(AssistantTaskContext assistantTaskContext) { OABGeneratorTaskContext oabgeneratorTaskContext = assistantTaskContext as OABGeneratorTaskContext; AssistantStep oabstep = new AssistantStep(this.ProduceSortedFlatFile); OABLogger.LogRecord(TraceType.FunctionTrace, "AddressListFileGenerator.ProcessOnePageOfADResults: start", new object[0]); try { using (new StopwatchPerformanceTracker("Total", this.stats)) { using (new CpuPerformanceTracker("Total", this.stats)) { using (new StopwatchPerformanceTracker("ProcessOnePageOfADResults", this.stats)) { using (new CpuPerformanceTracker("ProcessOnePageOfADResults", this.stats)) { if (this.adAddressListEnumerator.RetrievedAllData == null || !this.adAddressListEnumerator.RetrievedAllData.Value) { this.sortedEntries = this.adAddressListEnumerator.GetNextPageSorted(); this.allResultsInSinglePage = (this.firstPage && this.adAddressListEnumerator.RetrievedAllData != null && this.adAddressListEnumerator.RetrievedAllData.Value); this.firstPage = false; if (!this.allResultsInSinglePage) { using (new StopwatchPerformanceTracker("ProcessOnePageOfADResults.ResolveLinks", this.stats)) { using (new CpuPerformanceTracker("ProcessOnePageOfADResults.ResolveLinks", this.stats)) { using (new ADPerformanceTracker("ProcessOnePageOfADResults.ResolveLinks", this.stats)) { using (new ActiveManagerPerformanceTracker("ProcessOnePageOfADResults.ResolveLinks", this.stats)) { this.propertyManager.ResolveLinks(this.sortedEntries); } } } } FileStream fileStream = this.fileSet.Create("TMP"); this.tempFiles.Add(fileStream); this.stats.TotalNumberOfTempFiles++; using (new StopwatchPerformanceTracker("ProcessOnePageOfADResults.WriteTempFiles", this.stats)) { using (new CpuPerformanceTracker("ProcessOnePageOfADResults.WriteTempFiles", this.stats)) { using (IOCostStream iocostStream = new IOCostStream(new NoCloseStream(fileStream))) { using (new FileSystemPerformanceTracker("ProcessOnePageOfADResults.WriteTempFiles", iocostStream, this.stats)) { using (BinaryWriter binaryWriter = new BinaryWriter(iocostStream)) { foreach (ADRawEntry adrawEntry in this.sortedEntries) { this.abortProcessingOnShutdown(); OABFileRecord oabfileRecord = this.CreateDetailsRecord(adrawEntry); binaryWriter.Write(((Guid)adrawEntry[ADObjectSchema.ExchangeObjectId]).ToByteArray()); oabfileRecord.WriteTo(binaryWriter); } this.stats.IODuration += iocostStream.Writing; } } } } } } } if (this.adAddressListEnumerator.RetrievedAllData == null || !this.adAddressListEnumerator.RetrievedAllData.Value) { oabstep = new AssistantStep(this.ProcessOnePageOfADResults); } } } } } } finally { OABLogger.LogRecord(TraceType.FunctionTrace, "AddressListFileGenerator.ProcessOnePageOfADResults: finish", new object[0]); oabgeneratorTaskContext.OABStep = oabstep; } return(OABGeneratorTaskContext.FromOABGeneratorTaskContext(oabgeneratorTaskContext)); }