public bool IsLeaf(TreePath treePath) { bool result = false; BaseItem item = treePath.LastNode as BaseItem; Type type = item.GetType(); if (_plugins.ContainsKey(type)) { IParserPlugin plugin = _plugins[type]; try { result = plugin.IsLeaf(item); } catch (Exception exc) { if (_windowManager.Logger.LogCatchAll(exc, "Unexpected plugin error")) { throw; } } } else { _windowManager.Logger.LogStr("Warning : No plugin for type : " + type.Name); } return(result); }
public static void OnAlert(IParserPlugin plugin, string message, List<Subscriber> subscribers, Dictionary<string, string> parameters) { string smtpServer = ConfigurationManager.AppSettings["SMTPServer"]; string fromEmail = ConfigurationManager.AppSettings["FromEmail"] ?? "*****@*****.**"; string subscriberSuffix = ConfigurationManager.AppSettings["SubscriberSuffix"]; string bccAddress = ConfigurationManager.AppSettings["NotificationBCCAddress"]; List<string> to; if (null == subscribers || subscribers.Count == 0) { if (!string.IsNullOrEmpty(bccAddress)) { to = new List<string> { bccAddress }; } else { return; } } else { if (string.IsNullOrEmpty(subscriberSuffix)) { to = subscribers.ConvertAll(s => s.Name); } else { to = subscribers.ConvertAll(s => s.Name + subscriberSuffix); } } SendEmail(smtpServer, fromEmail, to, string.Format("LogAlert From {0}", plugin.Name), message, bccAddress); }
private void LoadParserPlugin(string filename, Type t) { try { IParserPlugin plugin = (IParserPlugin)Activator.CreateInstance(t); plugin.SetServiceProvider(_windowManager); // Ignore classes with blank ID, for example a base class. if (!string.IsNullOrEmpty(plugin.GetID())) { _parserPlugins.Add(plugin.GetID(), plugin); List <string> extensions = plugin.HandlesExtensions(); // Set up the parser plugin extension list. foreach (string ext in extensions) { if (_extensions.ContainsKey(ext)) { _extensions[ext].Add(plugin); } else { List <IParserPlugin> list = new List <IParserPlugin>(); list.Add(plugin); _extensions.Add(ext, list); } } _windowManager.Logger.LogStr(string.Format( "Loaded Parser Plugin '{0}'", t.ToString())); } else { _windowManager.Logger.LogStr("Ignored (blank id)"); } } catch (Exception exc) { if (_windowManager.Logger.LogCatchAll(exc, string.Format( "Unexpected error in plugin '{0}'", t.ToString()))) { throw; } } }
public static void OnAlert(IParserPlugin plugin, string message, List <Subscriber> subscribers, Dictionary <string, string> parameters) { string smtpServer = ConfigurationManager.AppSettings["SMTPServer"]; string fromEmail = ConfigurationManager.AppSettings["FromEmail"] ?? "*****@*****.**"; string subscriberSuffix = ConfigurationManager.AppSettings["SubscriberSuffix"]; string bccAddress = ConfigurationManager.AppSettings["NotificationBCCAddress"]; List <string> to; if (null == subscribers || subscribers.Count == 0) { if (!string.IsNullOrEmpty(bccAddress)) { to = new List <string> { bccAddress }; } else { return; } } else { if (string.IsNullOrEmpty(subscriberSuffix)) { to = subscribers.ConvertAll(s => s.Name); } else { to = subscribers.ConvertAll(s => s.Name + subscriberSuffix); } } SendEmail(smtpServer, fromEmail, to, string.Format("LogAlert From {0}", plugin.Name), message, bccAddress); }
public PluginItem(IParserPlugin<DataSample> plugin) { this.context = plugin; }
private void Alert(IParserPlugin plugin, string message, Dictionary <string, string> parameters) { var subscribers = plugin.Settings.Subscribers(this._subscriberService); this.OnAlert(plugin, message, subscribers, parameters); }
private void Alert(IParserPlugin plugin, string message, Dictionary<string, string> parameters) { var subscribers = plugin.Settings.Subscribers(this._subscriberService); this.OnAlert(plugin, message, subscribers, parameters); }
public IEnumerable GetChildren(TreePath treePath) { List <BaseItem> items = null; if (treePath.IsEmpty()) { items = new List <BaseItem>(); foreach (KeyValuePair <string, BaseItem> pair in _files) { items.Add(pair.Value); } } else { BaseItem parent = treePath.LastNode as BaseItem; if (parent != null) { Type type = parent.GetType(); if (_plugins.ContainsKey(type)) { IParserPlugin plugin = _plugins[type]; items = new List <BaseItem>(); try { plugin.FindChildren(parent, items); } catch (Exception exc) { if (_windowManager.Logger.LogCatchAll(exc, "Unexpected plugin error")) { throw; } } } else { _windowManager.Logger.LogStr("Warning : No plugin for type : " + type.Name); } } } if (items.Count > 0) { // Sort the items based on their names. Comparison <BaseItem> comparison = new Comparison <BaseItem>(Comparer); items.Sort(comparison); lock (_workerLock) { // Add to the worker queue. _itemsToRead.AddRange(items); } if (!_worker.IsBusy && _windowManager.AppOptions.RunProjectWorker) { _worker.RunWorkerAsync(); } } return(items); }