Example #1
0
        public string GetMySqlAlpacaFormData()
        {
            var server = new JsonMysqlSettingsServer()
            {
                database = cumulus.MySqlDatabase,
                host     = cumulus.MySqlHost,
                pass     = cumulus.MySqlPass,
                port     = cumulus.MySqlPort,
                user     = cumulus.MySqlUser
            };

            var monthly = new JsonMysqlSettingsMonthly()
            {
                enabled = cumulus.MonthlyMySqlEnabled, table = cumulus.MySqlMonthlyTable
            };

            var realtime = new JsonMysqlSettingsRealtime()
            {
                enabled = cumulus.RealtimeMySqlEnabled, retention = cumulus.MySqlRealtimeRetention, table = cumulus.MySqlRealtimeTable
            };

            var dayfile = new JsonMysqlSettingsDayfile()
            {
                enabled = cumulus.DayfileMySqlEnabled, table = cumulus.MySqlDayfileTable
            };

            var customseconds = new JsonMysqlSettingsCustomSeconds()
            {
                command  = cumulus.CustomMySqlSecondsCommandString,
                enabled  = cumulus.CustomMySqlSecondsEnabled,
                interval = cumulus.CustomMySqlSecondsInterval
            };

            var customminutes = new JsonMysqlSettingsCustomMinutes()
            {
                command       = cumulus.CustomMySqlMinutesCommandString,
                enabled       = cumulus.CustomMySqlMinutesEnabled,
                intervalindex = cumulus.CustomMySqlMinutesIntervalIndex
            };

            var customrollover = new JsonMysqlSettingsCustomRollover()
            {
                command = cumulus.CustomMySqlRolloverCommandString, enabled = cumulus.CustomMySqlRolloverEnabled
            };

            var data = new JsonMysqlSettings()
            {
                server         = server,
                monthly        = monthly,
                realtime       = realtime,
                dayfile        = dayfile,
                customseconds  = customseconds,
                customminutes  = customminutes,
                customrollover = customrollover
            };

            return(data.ToJson());
        }
Example #2
0
        public string GetAlpacaFormData()
        {
            var server = new JsonMysqlSettingsServer()
            {
                database = cumulus.MySqlConnSettings.Database,
                host     = cumulus.MySqlConnSettings.Server,
                pass     = cumulus.MySqlConnSettings.Password,
                port     = cumulus.MySqlConnSettings.Port,
                user     = cumulus.MySqlConnSettings.UserID
            };

            var monthly = new JsonMysqlSettingsMonthly()
            {
                enabled = cumulus.MySqlSettings.Monthly.Enabled,
                table   = cumulus.MySqlSettings.Monthly.TableName
            };

            var reten     = cumulus.MySqlSettings.RealtimeRetention.Split(' ');
            var retenVal  = string.IsNullOrEmpty(reten[0]) ? 7 : int.Parse(reten[0]);
            var retenUnit = reten.Length > 1 && !string.IsNullOrEmpty(reten[1]) ? reten[1].ToUpper().TrimEnd('S') : "DAY";

            var realtime = new JsonMysqlSettingsRealtime()
            {
                enabled       = cumulus.MySqlSettings.Realtime.Enabled,
                retentionVal  = retenVal,
                retentionUnit = retenUnit,
                table         = cumulus.MySqlSettings.Realtime.TableName,
                limit1min     = cumulus.MySqlSettings.RealtimeLimit1Minute && cumulus.RealtimeInterval < 60000              // do not enable if real time interval is greater than 1 minute
            };

            var dayfile = new JsonMysqlSettingsDayfile()
            {
                enabled = cumulus.MySqlSettings.Dayfile.Enabled,
                table   = cumulus.MySqlSettings.Dayfile.TableName
            };

            var customseconds = new JsonMysqlSettingsCustomSeconds()
            {
                enabled  = cumulus.MySqlSettings.CustomSecs.Enabled,
                command  = cumulus.MySqlSettings.CustomSecs.Command,
                interval = cumulus.MySqlSettings.CustomSecs.Interval
            };

            var customminutes = new JsonMysqlSettingsCustomMinutes()
            {
                enabled       = cumulus.MySqlSettings.CustomMins.Enabled,
                command       = cumulus.MySqlSettings.CustomMins.Command,
                intervalindex = cumulus.CustomMySqlMinutesIntervalIndex
            };

            var customrollover = new JsonMysqlSettingsCustomRollover()
            {
                enabled = cumulus.MySqlSettings.CustomRollover.Enabled,
                command = cumulus.MySqlSettings.CustomRollover.Command,
            };

            var options = new JsonMysqlSettingsOptions()
            {
                updateonedit  = cumulus.MySqlSettings.UpdateOnEdit,
                bufferonerror = cumulus.MySqlSettings.BufferOnfailure,
            };

            var data = new JsonMysqlSettings()
            {
                accessible     = cumulus.ProgramOptions.EnableAccessibility,
                server         = server,
                options        = options,
                monthly        = monthly,
                realtime       = realtime,
                dayfile        = dayfile,
                customseconds  = customseconds,
                customminutes  = customminutes,
                customrollover = customrollover
            };

            return(data.ToJson());
        }