示例#1
0
        private void Publish(eXAlert alert, AlertInterest interest)
        {
            var implementor = ResolveHandler(interest.Notification.Method);

            if (implementor != null)
            {
                implementor.Execute(alert, interest);
            }
        }
示例#2
0
        private static bool Zone(eXAlert alert, AlertTarget target)
        {
            bool b = false;

            if (!String.IsNullOrEmpty(alert.Zone) && alert.Zone.Equals(target.Value))
            {
                b = true;
            }
            return(b);
        }
示例#3
0
        private static bool Category(eXAlert alert, AlertTarget target)
        {
            bool b = false;

            if (alert.Categories != null && alert.Categories.Contains(target.Value))
            {
                b = true;
            }
            return(false);
        }
示例#4
0
        private static bool Target(eXAlert alert, AlertTarget target)
        {
            bool b = false;

            if (alert.Audiences != null && alert.Audiences.Contains(target.Value))
            {
                b = true;
            }
            return(b);
        }
示例#5
0
        private bool Contains(eXAlert alert, AlertTarget target)
        {
            bool b = false;

            if (targetmaps.ContainsKey(target.Key))
            {
                b = targetmaps[target.Key].Invoke(alert, target);
            }
            return(b);
        }
示例#6
0
        public bool Execute(eXAlert model)
        {
            bool b = false;

            if (model != null)
            {
                b = ExecuteAlert(model);
            }
            return(b);
        }
示例#7
0
        private static bool Urgency(eXAlert alert, AlertTarget target)
        {
            bool        b = false;
            ScaleOption alertOpt;
            ScaleOption targetOpt;

            if (!String.IsNullOrEmpty(alert.Urgency) && Enum.TryParse <ScaleOption>(alert.Urgency, out alertOpt))
            {
                if (Enum.TryParse <ScaleOption>(target.Value, out targetOpt))
                {
                    b = alertOpt >= targetOpt;
                }
            }
            return(b);
        }
示例#8
0
        private bool ExecuteAlert(eXAlert alert)
        {
            int alertCount = 0;

            List <string> list = null;

            foreach (var subscriber in subscribers)
            {
                foreach (var interest in subscriber.Interests)
                {
                    bool b = true;
                    for (int i = 0; b && i < interest.Targets.Count; i++)
                    {
                        AlertTarget target = interest.Targets[i];
                        b = Contains(alert, target);
                    }
                    if (b)
                    {
                        alertCount++;
                        Publish(alert, interest);
                    }
                }
            }
            if (alert.Dispositions != null)
            {
                list = new List <string>(alert.Dispositions);
            }
            else
            {
                list = new List <string>();
            }
            string disposition = String.Format("{0} subscribers, {1} alerts :{2}", subscribers.Count, alertCount, DateTime.Now.ToString(XFConstants.DateTimeFormat));

            list.Add(disposition);
            alert.Dispositions = list.ToArray();
            return(true);
        }