示例#1
0
        public void OnErrorModuleFiltering(object sender, ExceptionFilterEventArgs args)
        {
            if (args == null)
            {
                throw new ArgumentNullException(nameof(args));
            }

            if (args.Exception == null)
            {
                throw new ArgumentException(null, nameof(args));
            }

            try
            {
                if (Assertion.Test(new AssertionHelperContext(sender, args.Exception, args.Context)))
                {
                    if (Notifiers.Any())
                    {
                        args.DismissForNotifiers(Notifiers);
                    }
                    args.Dismiss();
                }
            }
            catch (Exception e)
            {
                Trace.WriteLine(e);
                throw;
            }
        }
示例#2
0
        public IComment Reply(string businessKey, string body, int commenterId, string creator = null, bool?encrypted = false)
        {
            if (!AllComments.ContainsKey(businessKey))
            {
                return(null);
            }
            var comment = AllComments[businessKey];

            Notifiers.Add(creator);
            return(comment.Reply(body, commenterId, creator, encrypted));
        }
示例#3
0
        public IComment Reply(string body, int commenterId, string creator = null, bool?encrypted = false)
        {
            if (!CanReply())
            {
                return(null);
            }
            var newComment = Comment.Create(body, commenterId, creator, encrypted);

            Comments.Add((Comment)newComment);
            Notifiers.Add(creator);
            return(newComment);
        }
 public void LoadFromInvalidLocation()
 {
     ConfigurationManager.AppSettings["notifiersFolder"] = "InvalidLocation";
     try
     {
         Notifiers.GetAll();
         Assert.Fail("Expected an exception about an invalid configuration setting for notifiersFolder.");
     }
     catch (NotificationFailedException ex)
     {
         Assert.AreEqual("Failed to load the notifiers from 'InvalidLocation'.", ex.Message);
     }
 }
示例#5
0
        internal void SwapNotifierEntries(NotifierEntry n1, NotifierEntry n2)
        {
            int index1 = Notifiers.FindIndex(c => c.Name == n1.Name);
            int index2 = Notifiers.FindIndex(c => c.Name == n2.Name);

            if (index1 > -1 && index2 > -1 && index1 != index2)
            {
                Notifiers.RemoveAt(index1);
                Notifiers.RemoveAt(index2);
                Notifiers.Insert(index2, n1);
                Notifiers.Insert(index1, n2);
            }
        }
示例#6
0
        public void UpdateSettings()
        {
            Settings.EnableNotifications = NotificationsEnabled;

            var notifications = new MutableLookup <string, NotificationType>();

            foreach (var notifier in Notifiers.Where(vm => vm.IsEnabled))
            {
                string name = notifier.Notifier.GetType().GetSimpleName();
                notifications.Add(name, this.globalNotifications[name].Where(vm => vm.IsEnabled).Select(vm => vm.Type));
            }

            Settings.EnabledNotifications = notifications;
        }
示例#7
0
        public NotificationSettingsViewModel()
        {
            Notifiers = Modules.Notifiers.Concat(Modules.TextToSpeech.Cast <INamedComponent>())
                        .Select(n => new NotifierViewModel(n, Settings.EnabledNotifications.Contains(n.GetType().GetSimpleName())))
                        .ToArray();

            NotificationsEnabled = Settings.EnableNotifications;

            this.globalNotifications = new MutableLookup <string, NotificationTypeViewModel> ();
            foreach (string notifier in Notifiers.Select(n => n.Notifier.GetType().GetSimpleName()))
            {
                this.globalNotifications.Add(notifier,
                                             Enum.GetValues(typeof(NotificationType))
                                             .Cast <NotificationType>()
                                             .Select(t =>
                                                     new NotificationTypeViewModel(t, Settings.EnabledNotifications[notifier].Contains(t))));
            }

            CurrentNotifier = Notifiers.FirstOrDefault();
        }
示例#8
0
 public void HyperNotify(Log logevent)
 {
     if (logevent != null)
     {
         if (this.Notifiers != null)
         {
             this.v_notifiers = Notifiers.ToArray();
         }
         foreach (INotifier notifier in this.v_notifiers)
         {
             try
             {
                 notifier.Append(logevent);
             }
             catch (Exception e)
             {
                 //LogLog
             }
         }
     }
 }
        public void LoadAssemblies()
        {
            var workItems = new WorkItemData[2];

            workItems[0] = new WorkItemData {
                Id = "tcm:0-0-0", Title = "Test Item 01"
            };
            workItems[1] = new WorkItemData {
                Id = "tcm:0-0-0", Title = "Test Item 02"
            };

            var notifiers        = Notifiers.GetAll();
            var notificationData = new WorkflowNotificationData {
                User = new UserData {
                    Title = Environment.UserName
                },
                WorkItems = workItems
            };

            foreach (var notifier in notifiers)
            {
                notifier.Notify(notificationData);
            }
        }
示例#10
0
        /// <summary>
        /// Loading QuickMon monitor pack file
        /// </summary>
        /// <param name="configurationFile">Serialzed monitor pack file</param>
        public void Load(string configurationFile)
        {
            XmlDocument configurationXml = new XmlDocument();

            configurationXml.LoadXml(System.IO.File.ReadAllText(configurationFile, Encoding.UTF8));
            XmlElement root = configurationXml.DocumentElement;

            Name               = root.Attributes.GetNamedItem("name").Value;
            Enabled            = bool.Parse(root.Attributes.GetNamedItem("enabled").Value);
            AgentsAssemblyPath = root.ReadXmlElementAttr("agentRegistrationPath");

            string defaultViewerNotifierName = root.ReadXmlElementAttr("defaultViewerNotifier");

            RunCorrectiveScripts = bool.Parse(root.ReadXmlElementAttr("runCorrectiveScripts", "false"));
            foreach (XmlElement xmlCollectorEntry in root.SelectNodes("collectorEntries/collectorEntry"))
            {
                CollectorEntry newCollectorEntry = CollectorEntry.FromConfig(xmlCollectorEntry);
                ApplyCollectorConfig(newCollectorEntry);
                Collectors.Add(newCollectorEntry);
            }
            foreach (XmlElement xmlNotifierEntry in root.SelectNodes("notifierEntries/notifierEntry"))
            {
                NotifierEntry     newNotifierEntry = NotifierEntry.FromConfig(xmlNotifierEntry);
                AgentRegistration currentNotifier  = null;
                if (AgentRegistrations != null)
                {
                    currentNotifier = (from o in AgentRegistrations
                                       where o.IsNotifier && o.Name == newNotifierEntry.NotifierRegistrationName
                                       select o).FirstOrDefault();
                }
                if (currentNotifier != null)
                {
                    newNotifierEntry.Notifier = NotifierEntry.CreateNotifierEntry(currentNotifier.AssemblyPath, currentNotifier.ClassName);
                    XmlDocument configDoc = new XmlDocument();
                    configDoc.LoadXml(newNotifierEntry.Configuration);
                    try
                    {
                        newNotifierEntry.Notifier.ReadConfiguration(configDoc);
                    }
                    catch                     // (Exception ex)
                    {
                        newNotifierEntry.Enabled = false;
                    }
                }
                else
                {
                    newNotifierEntry.Enabled = false;
                }
                Notifiers.Add(newNotifierEntry);
                if (newNotifierEntry.Name.ToUpper() == defaultViewerNotifierName.ToUpper())
                {
                    DefaultViewerNotifier = newNotifierEntry;
                }
            }
            MonitorPackPath = configurationFile;
            RaiseMonitorPackPathChanged(MonitorPackPath);
            if (Properties.Settings.Default.recentMonitorPacks == null)
            {
                Properties.Settings.Default.recentMonitorPacks = new System.Collections.Specialized.StringCollection();
            }
            if (!Properties.Settings.Default.recentMonitorPacks.Contains(configurationFile))
            {
                Properties.Settings.Default.recentMonitorPacks.Add(configurationFile);
                Properties.Settings.Default.Save();
            }
            InitializeGlobalPerformanceCounters();
        }