protected override object CalculatePropertyValue(PropTag tag)
 {
     if (tag == PropTag.SearchKey)
     {
         return(RuleUtil.SearchKeyFromParticipant(this.recipient.Participant));
     }
     return(null);
 }
示例#2
0
 public virtual void UpdateDeferredError()
 {
     if (this.daeMessageEntryIds == null || this.daeMessageEntryIds.Count == 0)
     {
         return;
     }
     base.DeliveredMessage.Load(DeferredError.EntryId);
     byte[] deliveredMessageEntryId = base.DeliveredMessage[StoreObjectSchema.EntryId] as byte[];
     if (deliveredMessageEntryId == null)
     {
         base.TraceDebug("Delivered Message EntryId is null");
         return;
     }
     using (List <byte[]> .Enumerator enumerator = this.daeMessageEntryIds.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             byte[] daeEntryId = enumerator.Current;
             if (daeEntryId != null)
             {
                 Exception argument;
                 if (!RuleUtil.TryRunStoreCode(delegate
                 {
                     StoreObjectId storeObjectId = StoreObjectId.FromProviderSpecificId(daeEntryId);
                     if (storeObjectId != null)
                     {
                         using (Item item = Microsoft.Exchange.Data.Storage.Item.Bind(this.StoreSession, storeObjectId))
                         {
                             item.OpenAsReadWrite();
                             item[ItemSchema.OriginalMessageEntryId] = deliveredMessageEntryId;
                             item.Save(SaveMode.NoConflictResolution);
                         }
                     }
                 }, out argument))
                 {
                     base.TraceDebug <byte[], Exception>("Can't set pr_dam_original_entryid on DeferredError message id {0}, and the exception is: {1}", daeEntryId, argument);
                 }
             }
         }
     }
 }
        protected override AbstractRuleSet CreateRules(bool useDefault)
        {
            WireRuleSet     wireRuleSet         = new WireRuleSet();
            QuerySet        serialNumberQueries = QuerySet.GetSerialNumberQueries();
            QuerySet        wireQueries         = QuerySet.GetWireQueries();
            QuerySet        portQueries         = QueryablePorts.GetPortQueries();
            List <QuerySet> list = new List <QuerySet>();

            for (int i = WireSetComponent.MIN_WIRES; i <= WireSetComponent.MAX_WIRES; i++)
            {
                List <Rule> list2 = new List <Rule>();
                list.Clear();
                list.Add(serialNumberQueries);
                list.Add(wireQueries);
                if (CommonReflectedTypeInfo.IsModdedSeed)
                {
                    list.Add(portQueries);
                }
                this.queryPropertyWeights.Clear();
                this.solutionWeights.Clear();
                int numRules = GetNumRules();
                for (int j = 0; j < numRules; j++)
                {
                    List <WireColor> listOfWireColors = RuleUtil.GetListOfWireColors();
                    Rule             rule             = new Rule();
                    int numQueriesForRule             = GetNumQueriesForRule();
                    List <WireColor> list3            = new List <WireColor>();
                    int num = i - 1;
                    for (int k = 0; k < numQueriesForRule; k++)
                    {
                        bool compoundQueriesAllowed = k > 0;
                        List <QueryableProperty> possibleQueryableProperties = this.CalculatePossibleQueryableProperties(list, num, compoundQueriesAllowed);
                        QueryableProperty        queryableProperty           = SelectQueryableProperty(possibleQueryableProperties);
                        Query query = new Query();
                        query.Property = queryableProperty;
                        if (queryableProperty is QueryableWireProperty)
                        {
                            QueryableWireProperty queryableWireProperty = (QueryableWireProperty)queryableProperty;
                            num -= queryableWireProperty.WiresInvolvedInQuery;
                            if (queryableWireProperty.UsesColor)
                            {
                                WireColor wireColor = listOfWireColors[this.rand.Next(0, listOfWireColors.Count)];
                                listOfWireColors.Remove(wireColor);
                                query.Args.Add("color", wireColor);
                                if (queryableWireProperty.ColorAvailableForSolution)
                                {
                                    list3.Add(wireColor);
                                }
                            }
                        }
                        rule.Queries.Add(query);
                    }
                    List <Solution> possibleSolutions = this.CalculatePossibleSolutions(i, rule);
                    Solution        solution          = SelectSolution(possibleSolutions);
                    rule.Solution = solution;
                    if (list3.Count > 0)
                    {
                        rule.SolutionArgs.Add("color", list3[this.rand.Next(0, list3.Count)]);
                    }
                    if (CommonReflectedTypeInfo.IsVanillaSeed || IsWireQueryValid(rule))
                    {
                        list2.Add(rule);
                    }
                    else
                    {
                        j--;    //Previous rule was never valid.
                    }
                }
                list2 = list2.OrderByDescending(x => x.Queries.Count).ToList();
                Rule  rule2  = new Rule();
                Query query2 = new Query();
                query2.Property = QueryableProperty.Otherwise;
                rule2.Queries.Add(query2);
                List <Solution> list4 = this.CalculatePossibleSolutions(i, rule2);
                if (CommonReflectedTypeInfo.IsModdedSeed)
                {
                    list4.Remove(list2.Last().Solution);    //Enforce no redundant rules.
                }
                rule2.Solution = list4[this.rand.Next(0, list4.Count)];
                list2.Add(rule2);
                wireRuleSet.RulesDictionary[i] = list2;
            }
            return(wireRuleSet);
        }
示例#4
0
 protected override object CalculatePropertyValue(PropTag tag)
 {
     if (tag <= PropTag.MessageRecipMe)
     {
         if (tag <= PropTag.Sensitivity)
         {
             if (tag == PropTag.Importance)
             {
                 object propertyValue = base.GetPropertyValue(tag);
                 return(propertyValue ?? 1);
             }
             if (tag == PropTag.Sensitivity)
             {
                 object propertyValue2 = base.GetPropertyValue(tag);
                 return(propertyValue2 ?? 0);
             }
         }
         else
         {
             if (tag == PropTag.MessageToMe)
             {
                 return(this.GetRecipientType() == RecipientItemType.To);
             }
             if (tag == PropTag.MessageCcMe)
             {
                 return(this.GetRecipientType() == RecipientItemType.Cc);
             }
             if (tag == PropTag.MessageRecipMe)
             {
                 return(this.GetRecipientType() != RecipientItemType.Unknown);
             }
         }
     }
     else if (tag <= PropTag.MessageFlags)
     {
         if (tag == PropTag.SenderSearchKey)
         {
             return(RuleUtil.SearchKeyFromParticipant(base.Message.Sender));
         }
         if (tag == PropTag.MessageFlags)
         {
             if (base.Message.AttachmentCollection.Count > 0)
             {
                 return(16);
             }
             return(0);
         }
     }
     else if (tag != PropTag.MessageSize)
     {
         if (tag == PropTag.MessageSizeExtended)
         {
             return(base.MimeSize);
         }
         if (tag == PropTag.Body)
         {
             return(this.GetMessageBody());
         }
     }
     else
     {
         if (base.MimeSize > 2147483647L)
         {
             return(int.MaxValue);
         }
         return((int)base.MimeSize);
     }
     return(null);
 }
示例#5
0
 public EmailMessage GenerateTraceReport(SmtpAddress reportToAddress)
 {
     if (base.ProcessingTestMessage && reportToAddress.IsValidAddress)
     {
         EmailMessage   traceReport = EmailMessage.Create();
         RoutingAddress address     = GlobalConfigurationBase <MicrosoftExchangeRecipient, MicrosoftExchangeRecipientConfiguration> .Instance.Address;
         traceReport.From = new EmailRecipient(null, (string)address);
         traceReport.To.Add(new EmailRecipient(null, (string)reportToAddress));
         traceReport.Subject = "Tracing Report: " + base.Message.Subject;
         using (Stream contentWriteStream = traceReport.Body.GetContentWriteStream())
         {
             this.traceFormatter.CopyDataTo(contentWriteStream);
             contentWriteStream.Flush();
         }
         List <Exception> list = new List <Exception>();
         Exception        item;
         if (!RuleUtil.TryRunStoreCode(delegate
         {
             this.AddRuleDumpAttachment(traceReport, this.initialFolder, "mailbox-rules.xml");
         }, out item))
         {
             list.Add(item);
         }
         if (!RuleUtil.TryRunStoreCode(delegate
         {
             MailboxSession mailboxSession = this.StoreSession as MailboxSession;
             StoreObjectId defaultFolderId = mailboxSession.GetDefaultFolderId(DefaultFolderType.Inbox);
             if (defaultFolderId != this.initialFolder.Id.ObjectId)
             {
                 using (Folder folder = Folder.Bind(mailboxSession, defaultFolderId))
                 {
                     this.AddRuleDumpAttachment(traceReport, folder, "inbox-rules.xml");
                 }
             }
         }, out item))
         {
             list.Add(item);
         }
         if (!RuleUtil.TryRunStoreCode(delegate
         {
             this.AddOofHistoryAttachment(traceReport, "automatic-reply-history.xml");
         }, out item))
         {
             list.Add(item);
         }
         if (list.Count > 0)
         {
             Attachment attachment = traceReport.Attachments.Add("inboxrule-report-exceptions.txt");
             using (Stream contentWriteStream2 = attachment.GetContentWriteStream())
             {
                 using (TextWriter textWriter = new StreamWriter(contentWriteStream2))
                 {
                     foreach (Exception ex in list)
                     {
                         textWriter.WriteLine(ex.ToString());
                         textWriter.WriteLine();
                     }
                 }
             }
         }
         return(traceReport);
     }
     return(null);
 }