Пример #1
0
        private void DetectElement(string source)
        {
            source = source.Substring(1, source.Length - 2);
            var tag   = source.Split(' ').First().ToLower();
            var attrs = ResolveAttributes(source, tag);

            if (RuleActions.ContainsKey(tag))
            {
                var action = RuleActions[tag];
                action.Invoke(tag, attrs);
            }
            else if (tag.FirstOrDefault() == '/')
            {
                var element = OpennedElements.Pop();
            }
            else if (source.LastOrDefault() == '/')
            {
                var elementType     = DomElements[tag];
                var elementInstance = Activator.CreateInstance(elementType) as HTMLElement;

                if (elementInstance != null)
                {
                    elementInstance.IsNeedClose = false;
                }

                ResolveElement(elementInstance, elementType, tag, attrs);
            }
            else if (DomElements.ContainsKey(tag))
            {
                var elementType     = DomElements[tag];
                var elementInstance = Activator.CreateInstance(elementType) as HTMLElement;

                ResolveElement(elementInstance, elementType, tag, attrs);
            }
        }
        public static void Run()
        {
            // ExStart:CreateNewRuleOntheExchangeServers
            // Set Exchange Server 2010 web service URL, Username, password, domain information
            string mailboxURI = "https://ex2010/ews/exchange.asmx";
            string username = "******";
            string password = "******";
            string domain = "ex2010.local";

            // Connect to the Exchange Server
            NetworkCredential credential = new NetworkCredential(username, password, domain);
            IEWSClient client = EWSClient.GetEWSClient(mailboxURI, credential);

            Console.WriteLine("Connected to Exchange server");

            InboxRule rule = new InboxRule();
            rule.DisplayName = "Message from client ABC";

            // Add conditions
            RulePredicates newRules = new RulePredicates();
            // Set Subject contains string "ABC" and Add the conditions
            newRules.ContainsSubjectStrings.Add("ABC");
            newRules.FromAddresses.Add(new MailAddress("*****@*****.**", true));
            rule.Conditions = newRules;

            // Add Actions and Move the message to a folder
            RuleActions newActions = new RuleActions();
            newActions.MoveToFolder = "120:AAMkADFjMjNjMmNjLWE3NzgtNGIzNC05OGIyLTAwNTgzNjRhN2EzNgAuAAAAAABbwP+Tkhs0TKx1GMf0D/cPAQD2lptUqri0QqRtJVHwOKJDAAACL5KNAAA=AQAAAA==";
            rule.Actions = newActions;
            client.CreateInboxRule(rule);
            // ExEnd:CreateNewRuleOntheExchangeServer
        }        
        public static void Run()
        {
            // ExStart:CreateNewRuleOntheExchangeServer
            // Set Exchange Server web service URL, Username, password, domain information
            string mailboxURI = "https://ex2010/ews/exchange.asmx";
            string username   = "******";
            string password   = "******";
            string domain     = "ex2010.local";

            // Connect to the Exchange Server
            NetworkCredential credential = new NetworkCredential(username, password, domain);
            IEWSClient        client     = EWSClient.GetEWSClient(mailboxURI, credential);

            Console.WriteLine("Connected to Exchange server");

            InboxRule rule = new InboxRule();

            rule.DisplayName = "Message from client ABC";

            // Add conditions
            RulePredicates newRules = new RulePredicates();

            // Set Subject contains string "ABC" and Add the conditions
            newRules.ContainsSubjectStrings.Add("ABC");
            newRules.FromAddresses.Add(new MailAddress("*****@*****.**", true));
            rule.Conditions = newRules;

            // Add Actions and Move the message to a folder
            RuleActions newActions = new RuleActions();

            newActions.MoveToFolder = "120:AAMkADFjMjNjMmNjLWE3NzgtNGIzNC05OGIyLTAwNTgzNjRhN2EzNgAuAAAAAABbwP+Tkhs0TKx1GMf0D/cPAQD2lptUqri0QqRtJVHwOKJDAAACL5KNAAA=AQAAAA==";
            rule.Actions            = newActions;
            client.CreateInboxRule(rule);
            // ExEnd:CreateNewRuleOntheExchangeServer
        }
Пример #4
0
     : super()
 {
     //// New rule has priority as 0 by default
     this.priority = 1;
     //// New rule is enabled by default
     this.isEnabled  = true;
     this.conditions = new RulePredicates();
     this.actions    = new RuleActions();
     this.exceptions = new RulePredicates();
 }
Пример #5
0
        public override object Clone()
        {
            RuleActions list = new RuleActions();

            foreach (RuleAction ra in this)
            {
                list.Add((RuleAction)ra.Clone());
            }

            return(list);
        }
Пример #6
0
        public void CreateJunkRule(string senderEmailAddress)
        {
            RuleConditions    ruleConditions           = null;
            TextRuleCondition subjectTextRuleCondition = null;

            RuleActions          ruleActions    = null;
            MoveOrCopyRuleAction moveRuleAction = null;

            string ruleName = "PhishingReporter-Autogenerated";

            NameSpace session = Application.Session;
            Store     store   = session.DefaultStore;
            Rules     rules   = store.GetRules();
            Rule      rule    = GetRuleIfExist(ruleName, rules);

            // No rule found
            if (rule == null)
            {
                rule           = rules.Create(ruleName, OlRuleType.olRuleReceive);
                ruleConditions = rule.Conditions;
                ruleConditions.SenderAddress.Address = new[] { senderEmailAddress };
                ruleConditions.SenderAddress.Enabled = true;

                rule.Actions.MoveToFolder.Folder  = spamFolder;
                rule.Actions.MoveToFolder.Enabled = true;

                rules.Save();
            }
            else // SpamRule already exists
            {
                ruleConditions = rule.Conditions;
                string[] oldAddresses = ruleConditions.SenderAddress.Address;
                string[] newAddresses = new string[oldAddresses.Length + 1];
                oldAddresses.CopyTo(newAddresses, 0);
                newAddresses[oldAddresses.Length] = senderEmailAddress;

                ruleConditions.SenderAddress.Address = newAddresses;
                ruleConditions.SenderAddress.Enabled = true;

                rule.Actions.MoveToFolder.Folder  = spamFolder;
                rule.Actions.MoveToFolder.Enabled = true;

                rules.Save();
            }
        }
        private void ListActions(RuleActions masterlist, RuleActions list)
        {
            listConditions.Items.Clear();
            foreach (RuleAction ra in masterlist)
            {
                LinkLabel ll = new LinkLabel();
                ll.Text     = ra.Text;
                ll.LinkArea = new LinkArea(ra.ValueStart, ra.ValueText.Length);
                RuleViewItem rvi = new RuleViewItem(ll);
                rvi.Tag = ra;

                if (list.FindByFormat(ra.TextFormat) != null)
                {
                    rvi.Checked = true;
                }

                listConditions.Items.Add(rvi);
            }
        }
Пример #8
0
 private void AddRule(string tag, Action <string, List <Attr> > callback)
 {
     RuleActions.Add(tag, callback);
 }
Пример #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Rule"/> class.
 /// </summary>
 public Rule()
     : base()
 {
     //// New rule has priority as 0 by default
     this.priority = 1;
     //// New rule is enabled by default
     this.isEnabled = true;
     this.conditions = new RulePredicates();
     this.actions = new RuleActions();
     this.exceptions = new RulePredicates();
 }