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";
        }
示例#2
0
        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);
            }
        }