예제 #1
0
 private void ComposeLogItemBody(Body itemBody)
 {
     if (itemBody == null)
     {
         throw new ArgumentNullException("itemBody");
     }
     using (TextWriter textWriter = itemBody.OpenTextWriter(BodyFormat.TextHtml))
     {
         StringBuilder stringBuilder = new StringBuilder();
         using (StreamReader streamReader = new StreamReader(Assembly.GetAssembly(typeof(SearchMailboxExecuter)).GetManifestResourceStream("SimpleLogMailTemplate.htm")))
         {
             stringBuilder.Append(streamReader.ReadToEnd());
         }
         SearchMailbox.ReplaceLogFieldTags(stringBuilder, Globals.LogFields.LastStartTime, this.searchMailboxExecuter.SearchStartTime);
         SearchMailbox.ReplaceLogFieldTags(stringBuilder, Globals.LogFields.SearchQuery, this.SearchQuery);
         SearchMailbox.ReplaceLogFieldTags(stringBuilder, Globals.LogFields.TargetMailbox, this.targetUser.Id.DomainUserName());
         SearchMailbox.ReplaceLogFieldTags(stringBuilder, Globals.LogFields.SearchDumpster, this.SearchDumpster);
         SearchMailbox.ReplaceLogFieldTags(stringBuilder, Globals.LogFields.LogLevel, this.LogLevel);
         SearchMailbox.ReplaceLogFieldTags(stringBuilder, Globals.LogFields.SourceRecipients, (from x in this.searchMailboxExecuter.SearchMailboxCriteria.SearchUserScope
                                                                                               select x.Id.DomainUserName()).AggregateOfDefault((string s, string x) => s + ", " + x));
         ADObjectId adobjectId = null;
         base.TryGetExecutingUserId(out adobjectId);
         SearchMailbox.ReplaceLogFieldTags(stringBuilder, Globals.LogFields.LastRunBy, (adobjectId == null) ? string.Empty : adobjectId.DomainUserName());
         SearchMailbox.ReplaceLogFieldTags(stringBuilder, Globals.LogFields.NumberMailboxesToSearch, this.searchMailboxExecuter.SearchMailboxCriteria.SearchUserScope.Length);
         if (this.DeleteContent.IsPresent)
         {
             if (base.ParameterSetName == "Mailbox")
             {
                 SearchMailbox.ReplaceLogFieldTags(stringBuilder, Globals.LogFields.SearchOperation, Strings.CopyAndDeleteOperation);
             }
             else
             {
                 SearchMailbox.ReplaceLogFieldTags(stringBuilder, Globals.LogFields.SearchOperation, Strings.DeleteOperation);
             }
         }
         else if (this.LogOnly.IsPresent)
         {
             SearchMailbox.ReplaceLogFieldTags(stringBuilder, Globals.LogFields.SearchOperation, Strings.LogOnlyOperation);
         }
         else
         {
             SearchMailbox.ReplaceLogFieldTags(stringBuilder, Globals.LogFields.SearchOperation, Strings.CopyOperation);
         }
         string str = this.errorMessages.AggregateOfDefault((string s, string x) => s + ", " + x);
         SearchMailbox.ReplaceLogFieldTags(stringBuilder, Globals.LogFields.Errors, str.ValueOrDefault(Strings.LogMailNone));
         long num = 0L;
         ByteQuantifiedSize byteQuantifiedSize = ByteQuantifiedSize.Zero;
         if (this.searchMailboxExecuter.SearchState != SearchState.InProgress)
         {
             foreach (SearchMailboxResult searchMailboxResult in this.searchMailboxExecuter.GetSearchResult())
             {
                 num += (long)searchMailboxResult.ResultItemsCount;
                 byteQuantifiedSize += searchMailboxResult.ResultItemsSize;
             }
         }
         SearchMailbox.ReplaceLogFieldTags(stringBuilder, Globals.LogFields.ResultNumber, num);
         SearchMailbox.ReplaceLogFieldTags(stringBuilder, Globals.LogFields.ResultSize, byteQuantifiedSize);
         SearchState searchState = (this.searchMailboxExecuter.SearchState == SearchState.InProgress) ? SearchState.Failed : this.searchMailboxExecuter.SearchState;
         stringBuilder = stringBuilder.Replace(Globals.LogFields.LogMailHeader.ToLabelTag(), Strings.LogMailSimpleHeader(searchState.ToString()));
         stringBuilder = stringBuilder.Replace(Globals.LogFields.LogMailSeeAttachment.ToLabelTag(), Strings.LogMailSeeAttachment);
         stringBuilder = stringBuilder.Replace(Globals.LogFields.LogMailFooter.ToLabelTag(), Strings.LogMailFooter);
         textWriter.Write(stringBuilder.ToString());
     }
 }