static public MessageTextFlag DetermineMessageTextFlagParam(IListenerInfo listener) { try { MessageTextFlag msgFlags = MessageTextFlag.None; Type msgTextFlagType = typeof(MessageTextFlag); String details = listener.Params["messageDetails"].FullTrim(); if (details != String.Empty) { String[] flags = details.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); foreach (String flag in flags) { if (Enum.IsDefined(msgTextFlagType, flag)) { msgFlags = msgFlags | (MessageTextFlag)Enum.Parse(msgTextFlagType, flag); } } } return(msgFlags); } catch (Exception ex) { throw new ReflectInsightException(String.Format("Error reading message detail parameter configuration values for Listener: '{0}' using details: '{1}'.", listener.Name, listener.Details), ex); } }
public virtual void UpdateParameterVariables(IListenerInfo listener) { FDetails = ListenerFileHelper.DetermineMessageTextFlagParam(listener); FMessagePattern = ListenerFileHelper.DetermineMessageTextPattern(listener); FTimePatterns = RIUtils.GetListOfTimePatterns(FMessagePattern); FColored = listener.Params["colored"].IfNullOrEmptyUseDefault("true").Trim() == "true"; }
public void UpdateParameterVariables(IListenerInfo listener) { String routerName = listener.Params["name"].Trim(); if (string.IsNullOrWhiteSpace(routerName)) { throw new ReflectInsightException(String.Format("Missing name parameter for listener: '{0}' using details: '{1}'.", listener.Name, listener.Details)); } NameValueCollection routerParameters = ReflectInsightConfig.Settings.GetSubsection(String.Format("routers.{0}", routerName)); if (routerParameters == null) { throw new ReflectInsightException(String.Format("Missing router section '{0}' for listener: '{1}' using details: '{2}'.", routerName, listener.Name, listener.Details)); } if (string.IsNullOrWhiteSpace(routerParameters["type"])) { throw new ReflectInsightException(String.Format("Missing type parameter for router: '{0}'. Insure that the router is correctly configured.", routerName)); } ListenerRequest.DestinationBinding = 0; if (!string.IsNullOrWhiteSpace(listener.Params["destinationBindingGroup"])) { ListenerRequest.DestinationBinding = DestinationBindingGroup.GetId(listener.Params["destinationBindingGroup"]); } MessageWriter = ReadWriterFactory.CreateInstance <IMessageWriter>(routerParameters); if (MessageWriter is IThreadExceptionEvent) { (MessageWriter as IThreadExceptionEvent).OnThreadException += OnWriterThreadException; } }
public void UpdateParameterVariables(IListenerInfo listener) { listener.Params["path"] = ListenerFileHelper.DeterminePathParam(listener); FAutoSave = ListenerFileHelper.DetermineAutoSaveParam(listener); FFilePath = listener.Params["path"]; if (string.IsNullOrWhiteSpace(FFilePath)) { throw new ReflectInsightException(String.Format("Missing path parameter for listener: '{0}' using details: '{1}'.", listener.Name, listener.Details)); } FCreateDirectory = true; FOnSize = FAutoSave.SaveOnSize * MBYTE; // MB FAllowPurge = listener.Params["allowPurge"] != "false"; }
static public String DetermineMessageTextPattern(IListenerInfo listener) { String pattern = "%message%"; String patternName = listener.Params["messagePattern"]; if (!string.IsNullOrWhiteSpace(patternName)) { NameValueCollection nvc = ReflectInsightConfig.Settings.GetSubsection(String.Format("messagePatterns.{0}", patternName)); if (nvc != null) { pattern = nvc["pattern"].IfNullOrEmptyUseDefault(pattern); } } return(pattern.Replace("
", String.Empty).Replace("\n", String.Empty).Replace("%newline%", Environment.NewLine)); }
static public RIAutoSaveInfo DetermineAutoSaveParam(IListenerInfo listener) { RIAutoSaveInfo autoSave = new RIAutoSaveInfo(); try { // get auto save values String autoSaveName = listener.Params["autoSave"].Trim(); NameValueCollection nvc = ReflectInsightConfig.Settings.GetSubsection(String.Format("autoSaves.{0}", autoSaveName)); if (nvc == null) { // try the default autoSaveName = ReflectInsightConfig.Settings.GetFilesAttribute("default", String.Empty); nvc = ReflectInsightConfig.Settings.GetSubsection(String.Format("autoSaves.{0}", autoSaveName)); if (nvc == null) { nvc = new NameValueCollection(); } } autoSave.SaveOnNewDay = nvc["onNewDay"].IfNullOrEmptyUseDefault("false").ToLower() == "true"; autoSave.SaveOnMsgLimit = 1000000; autoSave.RecycleFilesEvery = 0; autoSave.SaveOnSize = 0; Int32.TryParse(nvc["onMsgLimit"].IfNullOrEmptyUseDefault("1000000"), out autoSave.SaveOnMsgLimit); Int32.TryParse(nvc["onSize"].IfNullOrEmptyUseDefault("0"), out autoSave.SaveOnSize); Int16.TryParse(nvc["recycleFilesEvery"].IfNullOrEmptyUseDefault("0"), out autoSave.RecycleFilesEvery); const Int32 maxMessages = 1000000; if (autoSave.SaveOnMsgLimit > maxMessages) { autoSave.SaveOnMsgLimit = maxMessages; } if (autoSave.SaveOnMsgLimit < 1000) { autoSave.SaveOnMsgLimit = 1000; } const Int32 maxSize = 102400; if (autoSave.SaveOnSize > maxSize) { autoSave.SaveOnSize = maxSize; } if (autoSave.SaveOnSize < 0) { autoSave.SaveOnSize = 0; } if (autoSave.RecycleFilesEvery < 0) { autoSave.RecycleFilesEvery = 0; } return(autoSave); } catch (Exception ex) { throw new ReflectInsightException(String.Format("Error reading AutoSave configuration values for Listener: '{0}' using details: '{1}'.", listener.Name, listener.Details), ex); } }
static public String DeterminePathParam(IListenerInfo listener) { return(FileHelper.GetFileNameFromPattern(listener.Params["path"])); }