Example #1
0
        public string GetAlpacaFormData()
        {
            // Build the settings data, convert to JSON, and return it

            var websettingsadvanced = new JsonInternetSettingsWebsiteAdvanced()
            {
                autodetect          = cumulus.FtpOptions.AutoDetect,
                activeftp           = cumulus.FtpOptions.ActiveMode,
                disableftpsepsv     = cumulus.FtpOptions.DisableEPSV,
                disableftpsexplicit = cumulus.FtpOptions.DisableExplicit,
                ignorecerts         = cumulus.FtpOptions.IgnoreCertErrors
            };

            var websettingsgeneral = new JsonInternetSettingsWebSettingsGeneral()
            {
                ftpdelete  = cumulus.DeleteBeforeUpload,
                ftprename  = cumulus.FTPRename,
                utf8encode = cumulus.UTF8encode,
            };

            var websitesettings = new JsonInternetSettingsWebsite()
            {
                localcopy       = cumulus.FtpOptions.LocalCopyEnabled,
                localcopyfolder = cumulus.FtpOptions.LocalCopyFolder,
                enabled         = cumulus.FtpOptions.Enabled,
                directory       = cumulus.FtpOptions.Directory,
                ftpport         = cumulus.FtpOptions.Port,
                sslftp          = (int)cumulus.FtpOptions.FtpMode,
                hostname        = cumulus.FtpOptions.Hostname,
                password        = cumulus.FtpOptions.Password,
                username        = cumulus.FtpOptions.Username,
                sshAuth         = cumulus.FtpOptions.SshAuthen,
                pskFile         = cumulus.FtpOptions.SshPskFile,
                general         = websettingsgeneral,
                advanced        = websettingsadvanced
            };

            var websettingsintervalstd = new JsonInternetSettingsWebSettingsIntervalFiles()
            {
                files = new JsonInternetSettingsFileSettings[cumulus.StdWebFiles.Length]
            };

            var websettingsintervalgraph = new JsonInternetSettingsWebSettingsIntervalFiles()
            {
                files = new JsonInternetSettingsFileSettings[cumulus.GraphDataFiles.Length]
            };

            var websettingsintervaleodgraph = new JsonInternetSettingsWebSettingsIntervalFiles()
            {
                files = new JsonInternetSettingsFileSettings[cumulus.GraphDataEodFiles.Length]
            };

            var websettingsinterval = new JsonInternetSettingsWebSettingsInterval()
            {
                enabled           = cumulus.WebIntervalEnabled,
                enableintervalftp = cumulus.FtpOptions.IntervalEnabled,
                ftpinterval       = cumulus.UpdateInterval,
                stdfiles          = websettingsintervalstd,
                graphfiles        = websettingsintervalgraph,
                graphfileseod     = websettingsintervaleodgraph
            };

            for (var i = 0; i < cumulus.StdWebFiles.Length; i++)
            {
                websettingsinterval.stdfiles.files[i] = new JsonInternetSettingsFileSettings()
                {
                    filename = cumulus.StdWebFiles[i].LocalFileName,
                    create   = cumulus.StdWebFiles[i].Create,
                    ftp      = cumulus.StdWebFiles[i].FTP,
                    copy     = cumulus.StdWebFiles[i].Copy
                };
            }

            for (var i = 0; i < cumulus.GraphDataFiles.Length; i++)
            {
                websettingsinterval.graphfiles.files[i] = new JsonInternetSettingsFileSettings()
                {
                    filename = cumulus.GraphDataFiles[i].LocalFileName,
                    create   = cumulus.GraphDataFiles[i].Create,
                    ftp      = cumulus.GraphDataFiles[i].FTP,
                    copy     = cumulus.GraphDataFiles[i].Copy
                };
            }

            for (var i = 0; i < cumulus.GraphDataEodFiles.Length; i++)
            {
                websettingsinterval.graphfileseod.files[i] = new JsonInternetSettingsFileSettings()
                {
                    filename = cumulus.GraphDataEodFiles[i].LocalFileName,
                    create   = cumulus.GraphDataEodFiles[i].Create,
                    ftp      = cumulus.GraphDataEodFiles[i].FTP,
                    copy     = cumulus.GraphDataEodFiles[i].Copy
                };
            }

            var websettingsrealtime = new JsonInternetSettingsWebSettingsRealtime()
            {
                enabled           = cumulus.RealtimeIntervalEnabled,
                enablerealtimeftp = cumulus.FtpOptions.RealtimeEnabled,
                realtimeinterval  = cumulus.RealtimeInterval / 1000,
                files             = new JsonInternetSettingsFileSettings[cumulus.RealtimeFiles.Length]
            };

            for (var i = 0; i < cumulus.RealtimeFiles.Length; i++)
            {
                websettingsrealtime.files[i] = new JsonInternetSettingsFileSettings()
                {
                    filename = cumulus.RealtimeFiles[i].LocalFileName,
                    create   = cumulus.RealtimeFiles[i].Create,
                    ftp      = cumulus.RealtimeFiles[i].FTP,
                    copy     = cumulus.RealtimeFiles[i].Copy
                };
            }

            var websettings = new JsonInternetSettingsWebSettings()
            {
                stdwebsite = false,
                interval   = websettingsinterval,
                realtime   = websettingsrealtime
            };

            var externalprograms = new JsonInternetSettingsExternalPrograms()
            {
                dailyprogram          = cumulus.DailyProgram,
                dailyprogramparams    = cumulus.DailyParams,
                program               = cumulus.ExternalProgram,
                programparams         = cumulus.ExternalParams,
                realtimeprogram       = cumulus.RealtimeProgram,
                realtimeprogramparams = cumulus.RealtimeParams
            };

            var mqttUpdate = new JsonInternetSettingsMqttDataupdate()
            {
                enabled  = cumulus.MQTT.EnableDataUpdate,
                template = cumulus.MQTT.UpdateTemplate
            };

            var mqttInterval = new JsonInternetSettingsMqttInterval()
            {
                enabled  = cumulus.MQTT.EnableInterval,
                time     = cumulus.MQTT.IntervalTime,
                template = cumulus.MQTT.IntervalTemplate
            };

            var mqttsettings = new JsonInternetSettingsMqtt()
            {
                server     = cumulus.MQTT.Server,
                port       = cumulus.MQTT.Port,
                useTls     = cumulus.MQTT.UseTLS,
                username   = cumulus.MQTT.Username,
                password   = cumulus.MQTT.Password,
                dataUpdate = mqttUpdate,
                interval   = mqttInterval
            };

            var moonimagesettings = new JsonInternetSettingsMoonImage()
            {
                enabled          = cumulus.MoonImage.Enabled,
                includemoonimage = cumulus.MoonImage.Ftp,
                size             = cumulus.MoonImage.Size,
                ftpdest          = cumulus.MoonImage.FtpDest,
                copyimage        = cumulus.MoonImage.Copy,
                copydest         = cumulus.MoonImage.CopyDest
            };

            var httpproxy = new JsonInternetSettingsHTTPproxySettings()
            {
                password = cumulus.HTTPProxyPassword,
                port     = cumulus.HTTPProxyPort,
                proxy    = cumulus.HTTPProxyName,
                user     = cumulus.HTTPProxyUser
            };

            var proxy = new JsonInternetSettingsProxySettings()
            {
                httpproxy = httpproxy
            };

            var email = new JsonEmailSettings()
            {
                enabled          = cumulus.SmtpOptions.Enabled,
                server           = cumulus.SmtpOptions.Server,
                port             = cumulus.SmtpOptions.Port,
                ssloption        = cumulus.SmtpOptions.SslOption,
                authenticate     = cumulus.SmtpOptions.RequiresAuthentication,
                user             = cumulus.SmtpOptions.User,
                password         = cumulus.SmtpOptions.Password,
                ignorecerterrors = cumulus.SmtpOptions.IgnoreCertErrors
            };

            var misc = new JsonInternetSettingsMisc()
            {
                forumurl  = cumulus.ForumURL,
                webcamurl = cumulus.WebcamURL
            };

            var data = new JsonInternetSettingsData()
            {
                accessible       = cumulus.ProgramOptions.EnableAccessibility,
                website          = websitesettings,
                websettings      = websettings,
                externalprograms = externalprograms,
                mqtt             = mqttsettings,
                moonimage        = moonimagesettings,
                proxies          = proxy,
                emailsettings    = email,
                misc             = misc
            };

            return(data.ToJson());
        }
Example #2
0
        public string GetInternetAlpacaFormData()
        {
            // Build the settings data, convert to JSON, and return it
            var websitesettings = new JsonInternetSettingsWebsite()
            {
                directory = cumulus.ftp_directory,
                forumurl  = cumulus.ForumURL,
                ftpport   = cumulus.ftp_port,
                sslftp    = (int)cumulus.Sslftp,
                hostname  = cumulus.ftp_host,
                password  = cumulus.ftp_password,
                username  = cumulus.ftp_user,
                sshAuth   = cumulus.SshftpAuthentication,
                pskFile   = cumulus.SshftpPskFile,
                webcamurl = cumulus.WebcamURL
            };

            var websettings = new JsonInternetSettingsWebSettings()
            {
                activeftp             = cumulus.ActiveFTPMode,
                autoupdate            = cumulus.WebAutoUpdate,
                enablerealtime        = cumulus.RealtimeEnabled,
                enablerealtimeftp     = cumulus.RealtimeFTPEnabled,
                realtimetxtftp        = cumulus.RealtimeTxtFTP,
                realtimegaugestxtftp  = cumulus.RealtimeGaugesTxtFTP,
                realtimeinterval      = cumulus.RealtimeInterval / 1000,
                ftpdelete             = cumulus.DeleteBeforeUpload,
                ftpinterval           = cumulus.UpdateInterval,
                ftprename             = cumulus.FTPRename,
                includestdfiles       = cumulus.IncludeStandardFiles,
                includegraphdatafiles = cumulus.IncludeGraphDataFiles,
                includemoonimage      = cumulus.IncludeMoonImage,
                utf8encode            = cumulus.UTF8encode,
                ftplogging            = cumulus.FTPlogging
            };

            var externalprograms = new JsonInternetSettingsExternalPrograms()
            {
                dailyprogram          = cumulus.DailyProgram,
                dailyprogramparams    = cumulus.DailyParams,
                program               = cumulus.ExternalProgram,
                programparams         = cumulus.ExternalParams,
                realtimeprogram       = cumulus.RealtimeProgram,
                realtimeprogramparams = cumulus.RealtimeParams
            };

            var twittersettings = new JsonInternetSettingsTwitterSettings()
            {
                enabled      = cumulus.TwitterEnabled,
                interval     = cumulus.TwitterInterval,
                password     = cumulus.TwitterPW,
                sendlocation = cumulus.TwitterSendLocation,
                user         = cumulus.Twitteruser
            };

            var wusettings = new JsonInternetSettingsWunderground()
            {
                catchup       = cumulus.WundCatchUp,
                enabled       = cumulus.WundEnabled,
                includeindoor = cumulus.SendIndoorToWund,
                includesolar  = cumulus.SendSRToWund,
                includeuv     = cumulus.SendUVToWund,
                interval      = cumulus.WundInterval,
                password      = cumulus.WundPW,
                rapidfire     = cumulus.WundRapidFireEnabled,
                sendavgwind   = cumulus.WundSendAverage,
                stationid     = cumulus.WundID
            };

            var windysettings = new JsonInternetSettingsWindy()
            {
                catchup    = cumulus.WindyCatchUp,
                enabled    = cumulus.WindyEnabled,
                includeuv  = cumulus.WindySendUV,
                interval   = cumulus.WindyInterval,
                apikey     = cumulus.WindyApiKey,
                stationidx = cumulus.WindyStationIdx
            };

            var awekassettings = new JsonInternetSettingsAwekas()
            {
                enabled             = cumulus.AwekasEnabled,
                includesolar        = cumulus.SendSolarToAwekas,
                includesoiltemp     = cumulus.SendSoilTempToAwekas,
                includesoilmoisture = cumulus.SendSoilMoistureToAwekas,
                includeleafwetness  = cumulus.SendLeafWetnessToAwekas,
                includeindoor       = cumulus.SendIndoorToAwekas,
                includeuv           = cumulus.SendUVToAwekas,
                interval            = cumulus.AwekasInterval,
                lang     = cumulus.AwekasLang,
                password = cumulus.AwekasPW,
                user     = cumulus.AwekasUser
            };

            var wcloudsettings = new JsonInternetSettingsWCloud()
            {
                enabled      = cumulus.WCloudEnabled,
                includesolar = cumulus.SendSolarToWCloud,
                includeuv    = cumulus.SendUVToWCloud,
                key          = cumulus.WCloudKey,
                wid          = cumulus.WCloudWid
            };

            var pwssettings = new JsonInternetSettingsPWSweather()
            {
                catchup      = cumulus.PWSCatchUp,
                enabled      = cumulus.PWSEnabled,
                interval     = cumulus.PWSInterval,
                includesolar = cumulus.SendSRToPWS,
                includeuv    = cumulus.SendUVToPWS,
                password     = cumulus.PWSPW,
                stationid    = cumulus.PWSID
            };

            var wowsettings = new JsonInternetSettingsWOW()
            {
                catchup      = cumulus.WOWCatchUp,
                enabled      = cumulus.WOWEnabled,
                includesolar = cumulus.SendSRToWOW,
                includeuv    = cumulus.SendUVToWOW,
                interval     = cumulus.WOWInterval,
                password     = cumulus.WOWPW,
                stationid    = cumulus.WOWID
            };

            var cwopsettings = new JsonInternetSettingsCwop()
            {
                enabled      = cumulus.APRSenabled,
                id           = cumulus.APRSID,
                interval     = cumulus.APRSinterval,
                includesolar = cumulus.SendSRToAPRS,
                password     = cumulus.APRSpass,
                port         = cumulus.APRSport,
                server       = cumulus.APRSserver
            };


            var mqttUpdate = new JsonInternetSettingsMqttDataupdate()
            {
                enabled  = cumulus.MQTTEnableDataUpdate,
                topic    = cumulus.MQTTUpdateTopic,
                template = cumulus.MQTTUpdateTemplate
            };

            var mqttInterval = new JsonInternetSettingsMqttInterval()
            {
                enabled  = cumulus.MQTTEnableInterval,
                time     = cumulus.MQTTIntervalTime,
                topic    = cumulus.MQTTIntervalTopic,
                template = cumulus.MQTTIntervalTemplate
            };

            var mqttsettings = new JsonInternetSettingsMqtt()
            {
                server     = cumulus.MQTTServer,
                port       = cumulus.MQTTPort,
                useTls     = cumulus.MQTTUseTLS,
                username   = cumulus.MQTTUsername,
                password   = cumulus.MQTTPassword,
                dataUpdate = mqttUpdate,
                interval   = mqttInterval
            };

            var moonimagesettings = new JsonInternetSettingsMoonImage()
            {
                enabled = cumulus.MoonImageEnabled,
                size    = cumulus.MoonImageSize,
                ftpdest = cumulus.MoonImageFtpDest
            };

            var httpproxy = new JsonInternetSettingsHTTPproxySettings()
            {
                password = cumulus.HTTPProxyPassword,
                port     = cumulus.HTTPProxyPort,
                proxy    = cumulus.HTTPProxyName,
                user     = cumulus.HTTPProxyUser
            };

            var proxy = new JsonInternetSettingsProxySettings()
            {
                httpproxy = httpproxy
            };

            var customseconds = new JsonInternetSettingsCustomHttpSeconds()
            {
                enabled  = cumulus.CustomHttpSecondsEnabled,
                interval = cumulus.CustomHttpSecondsInterval,
                url      = cumulus.CustomHttpSecondsString
            };

            var customminutes = new JsonInternetSettingsCustomHttpMinutes()
            {
                enabled       = cumulus.CustomHttpMinutesEnabled,
                intervalindex = cumulus.CustomHttpMinutesIntervalIndex,
                url           = cumulus.CustomHttpMinutesString
            };

            var customrollover = new JsonInternetSettingsCustomHttpRollover()
            {
                enabled = cumulus.CustomHttpRolloverEnabled,
                url     = cumulus.CustomHttpRolloverString
            };

            var customhttp = new JsonInternetSettingsCustomHttpSettings()
            {
                customseconds = customseconds, customminutes = customminutes, customrollover = customrollover
            };

            var data = new JsonInternetSettingsData()
            {
                website          = websitesettings,
                websettings      = websettings,
                externalprograms = externalprograms,
                twitter          = twittersettings,
                wunderground     = wusettings,
                windy            = windysettings,
                awekas           = awekassettings,
                weathercloud     = wcloudsettings,
                pwsweather       = pwssettings,
                wow        = wowsettings,
                cwop       = cwopsettings,
                mqtt       = mqttsettings,
                moonimage  = moonimagesettings,
                proxies    = proxy,
                customhttp = customhttp
            };

            return(JsonConvert.SerializeObject(data));
        }