Example #1
0
        public void OnPost(string password, string cbRememberMe)
        {
            base.PreInit();

            string encryptedPassword = EncryptionHelper.Encrypt(password);

            if (encryptedPassword.Equals(PTMagicConfiguration.SecureSettings.MonitorPassword))
            {
                HttpContext.Session.SetString("LoggedIn" + PTMagicConfiguration.GeneralSettings.Monitor.Port.ToString(), DateTime.UtcNow.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fff'Z'"));
                PTMagicConfiguration.GeneralSettings.Monitor.IsPasswordProtected = true;
                PTMagicConfiguration.WriteGeneralSettings();
                if (cbRememberMe != null)
                {
                    if (cbRememberMe.Equals("on", StringComparison.InvariantCultureIgnoreCase))
                    {
                        CookieOptions cookieOption = new CookieOptions();
                        cookieOption.Expires = DateTime.UtcNow.AddYears(1);

                        string cookieValue = EncryptionHelper.Encrypt(encryptedPassword);

                        Response.Cookies.Append("PTMRememberMeKey", cookieValue, cookieOption);
                    }
                }

                Response.Redirect(PTMagicConfiguration.GeneralSettings.Monitor.RootUrl);
            }
        }
Example #2
0
        public void OnPost()
        {
            base.Init();

            // Read the new settings
            PTMagicConfiguration.GeneralSettings.Application.IsEnabled    = HttpContext.Request.Form["Application_IsEnabled"].Equals("on");
            PTMagicConfiguration.GeneralSettings.Application.TestMode     = HttpContext.Request.Form["Application_TestMode"].Equals("on");
            PTMagicConfiguration.GeneralSettings.Application.StartBalance = SystemHelper.TextToDouble(HttpContext.Request.Form["Application_StartBalance"], PTMagicConfiguration.GeneralSettings.Application.StartBalance, "en-US");
            PTMagicConfiguration.GeneralSettings.Application.ProfitTrailerDefaultSettingName = HttpContext.Request.Form["Application_ProfitTrailerDefaultSettingName"];

            PTMagicConfiguration.GeneralSettings.Application.ProfitTrailerServerAPIToken = HttpContext.Request.Form["Application_ProfitTrailerServerAPIToken"];
            PTMagicConfiguration.GeneralSettings.Application.TimezoneOffset   = HttpContext.Request.Form["Application_TimezoneOffset"];
            PTMagicConfiguration.GeneralSettings.Application.MainFiatCurrency = HttpContext.Request.Form["Application_MainFiatCurrency"];


            PTMagicConfiguration.GeneralSettings.Application.FloodProtectionMinutes      = SystemHelper.TextToInteger(HttpContext.Request.Form["Application_FloodProtectionMinutes"], PTMagicConfiguration.GeneralSettings.Application.FloodProtectionMinutes);
            PTMagicConfiguration.GeneralSettings.Application.InstanceName                = HttpContext.Request.Form["Application_InstanceName"];
            PTMagicConfiguration.GeneralSettings.Application.CoinMarketCapAPIKey         = HttpContext.Request.Form["Application_CoinMarketCapAPIKey"];
            PTMagicConfiguration.GeneralSettings.Application.FreeCurrencyConverterAPIKey = HttpContext.Request.Form["Application_FreeCurrencyConverterAPIKey"];

            PTMagicConfiguration.GeneralSettings.Monitor.IsPasswordProtected       = HttpContext.Request.Form["Monitor_IsPasswordProtected"].Equals("on");
            PTMagicConfiguration.GeneralSettings.Monitor.OpenBrowserOnStart        = HttpContext.Request.Form["Monitor_OpenBrowserOnStart"].Equals("on");
            PTMagicConfiguration.GeneralSettings.Monitor.DefaultDCAMode            = HttpContext.Request.Form["Monitor_AnalyzerChart"];
            PTMagicConfiguration.GeneralSettings.Monitor.GraphIntervalMinutes      = SystemHelper.TextToInteger(HttpContext.Request.Form["Monitor_GraphIntervalMinutes"], PTMagicConfiguration.GeneralSettings.Monitor.GraphIntervalMinutes);
            PTMagicConfiguration.GeneralSettings.Monitor.GraphMaxTimeframeHours    = SystemHelper.TextToInteger(HttpContext.Request.Form["Monitor_GraphMaxTimeframeHours"], PTMagicConfiguration.GeneralSettings.Monitor.GraphMaxTimeframeHours);
            PTMagicConfiguration.GeneralSettings.Monitor.RefreshSeconds            = SystemHelper.TextToInteger(HttpContext.Request.Form["Monitor_RefreshSeconds"], PTMagicConfiguration.GeneralSettings.Monitor.RefreshSeconds);
            PTMagicConfiguration.GeneralSettings.Monitor.BagAnalyzerRefreshSeconds = SystemHelper.TextToInteger(HttpContext.Request.Form["Monitor_BagAnalyzerRefreshSeconds"], PTMagicConfiguration.GeneralSettings.Monitor.BagAnalyzerRefreshSeconds);
            PTMagicConfiguration.GeneralSettings.Monitor.BuyAnalyzerRefreshSeconds = SystemHelper.TextToInteger(HttpContext.Request.Form["Monitor_BuyAnalyzerRefreshSeconds"], PTMagicConfiguration.GeneralSettings.Monitor.BuyAnalyzerRefreshSeconds);
            PTMagicConfiguration.GeneralSettings.Monitor.LinkPlatform           = HttpContext.Request.Form["Monitor_LinkPlatform"];
            PTMagicConfiguration.GeneralSettings.Monitor.MaxTopMarkets          = SystemHelper.TextToInteger(HttpContext.Request.Form["Monitor_MaxTopMarkets"], PTMagicConfiguration.GeneralSettings.Monitor.MaxTopMarkets);
            PTMagicConfiguration.GeneralSettings.Monitor.MaxDailySummaries      = SystemHelper.TextToInteger(HttpContext.Request.Form["Monitor_MaxDailySummaries"], PTMagicConfiguration.GeneralSettings.Monitor.MaxDailySummaries);
            PTMagicConfiguration.GeneralSettings.Monitor.MaxMonthlySummaries    = SystemHelper.TextToInteger(HttpContext.Request.Form["Monitor_MaxMonthlySummaries"], PTMagicConfiguration.GeneralSettings.Monitor.MaxMonthlySummaries);
            PTMagicConfiguration.GeneralSettings.Monitor.MaxDashboardBuyEntries = SystemHelper.TextToInteger(HttpContext.Request.Form["Monitor_MaxDashboardBuyEntries"], PTMagicConfiguration.GeneralSettings.Monitor.MaxDashboardBuyEntries);
            PTMagicConfiguration.GeneralSettings.Monitor.MaxDashboardBagEntries = SystemHelper.TextToInteger(HttpContext.Request.Form["Monitor_MaxDashboardBagEntries"], PTMagicConfiguration.GeneralSettings.Monitor.MaxDashboardBagEntries);
            PTMagicConfiguration.GeneralSettings.Monitor.MaxDCAPairs            = SystemHelper.TextToInteger(HttpContext.Request.Form["Monitor_MaxDCAPairs"], PTMagicConfiguration.GeneralSettings.Monitor.MaxDCAPairs);
            PTMagicConfiguration.GeneralSettings.Monitor.DefaultDCAMode         = HttpContext.Request.Form["Monitor_DefaultDCAMode"];

            PTMagicConfiguration.GeneralSettings.Backup.IsEnabled = HttpContext.Request.Form["Backup_IsEnabled"].Equals("on");
            PTMagicConfiguration.GeneralSettings.Backup.MaxHours  = SystemHelper.TextToInteger(HttpContext.Request.Form["Backup_MaxHours"], PTMagicConfiguration.GeneralSettings.Backup.MaxHours);

            PTMagicConfiguration.GeneralSettings.Telegram.IsEnabled  = HttpContext.Request.Form["Telegram_IsEnabled"].Equals("on");
            PTMagicConfiguration.GeneralSettings.Telegram.BotToken   = HttpContext.Request.Form["Telegram_BotToken"].ToString().Trim();
            PTMagicConfiguration.GeneralSettings.Telegram.ChatId     = SystemHelper.TextToInteger64(HttpContext.Request.Form["Telegram_ChatId"], PTMagicConfiguration.GeneralSettings.Telegram.ChatId);
            PTMagicConfiguration.GeneralSettings.Telegram.SilentMode = HttpContext.Request.Form["Telegram_SilentMode"].Equals("on");

            // Save and reload the settings
            PTMagicConfiguration.WriteGeneralSettings();
            PTMagicConfiguration.RefreshSettings();

            // Notify
            NotifyHeadline = "Settings saved!";
            NotifyMessage  = "Settings saved successfully to settings.general.json.";
            NotifyType     = "success";
        }
Example #3
0
        public void OnPost()
        {
            base.Init();

            PTMagicConfiguration.GeneralSettings.Application.IsEnabled      = HttpContext.Request.Form["Application_IsEnabled"].Equals("on");
            PTMagicConfiguration.GeneralSettings.Application.TestMode       = HttpContext.Request.Form["Application_TestMode"].Equals("on");
            PTMagicConfiguration.GeneralSettings.Application.Exchange       = HttpContext.Request.Form["Application_Exchange"];
            PTMagicConfiguration.GeneralSettings.Application.StartBalance   = SystemHelper.TextToDouble(HttpContext.Request.Form["Application_StartBalance"], PTMagicConfiguration.GeneralSettings.Application.StartBalance, "en-US");
            PTMagicConfiguration.GeneralSettings.Application.TimezoneOffset = HttpContext.Request.Form["Application_TimezoneOffset"].ToString().Replace(" ", "");
            PTMagicConfiguration.GeneralSettings.Application.AlwaysLoadDefaultBeforeSwitch = HttpContext.Request.Form["Application_AlwaysLoadDefaultBeforeSwitch"].Equals("on");
            PTMagicConfiguration.GeneralSettings.Application.FloodProtectionMinutes        = SystemHelper.TextToInteger(HttpContext.Request.Form["Application_FloodProtectionMinutes"], PTMagicConfiguration.GeneralSettings.Application.FloodProtectionMinutes);
            PTMagicConfiguration.GeneralSettings.Application.InstanceName = HttpContext.Request.Form["Application_InstanceName"];

            PTMagicConfiguration.GeneralSettings.Monitor.IsPasswordProtected       = HttpContext.Request.Form["Monitor_IsPasswordProtected"].Equals("on");
            PTMagicConfiguration.GeneralSettings.Monitor.OpenBrowserOnStart        = HttpContext.Request.Form["Monitor_OpenBrowserOnStart"].Equals("on");
            PTMagicConfiguration.GeneralSettings.Monitor.GraphIntervalMinutes      = SystemHelper.TextToInteger(HttpContext.Request.Form["Monitor_GraphIntervalMinutes"], PTMagicConfiguration.GeneralSettings.Monitor.GraphIntervalMinutes);
            PTMagicConfiguration.GeneralSettings.Monitor.GraphMaxTimeframeHours    = SystemHelper.TextToInteger(HttpContext.Request.Form["Monitor_GraphMaxTimeframeHours"], PTMagicConfiguration.GeneralSettings.Monitor.GraphMaxTimeframeHours);
            PTMagicConfiguration.GeneralSettings.Monitor.RefreshSeconds            = SystemHelper.TextToInteger(HttpContext.Request.Form["Monitor_RefreshSeconds"], PTMagicConfiguration.GeneralSettings.Monitor.RefreshSeconds);
            PTMagicConfiguration.GeneralSettings.Monitor.BagAnalyzerRefreshSeconds = SystemHelper.TextToInteger(HttpContext.Request.Form["Monitor_BagAnalyzerRefreshSeconds"], PTMagicConfiguration.GeneralSettings.Monitor.BagAnalyzerRefreshSeconds);
            PTMagicConfiguration.GeneralSettings.Monitor.BuyAnalyzerRefreshSeconds = SystemHelper.TextToInteger(HttpContext.Request.Form["Monitor_BuyAnalyzerRefreshSeconds"], PTMagicConfiguration.GeneralSettings.Monitor.BuyAnalyzerRefreshSeconds);
            PTMagicConfiguration.GeneralSettings.Monitor.LinkPlatform           = HttpContext.Request.Form["Monitor_LinkPlatform"];
            PTMagicConfiguration.GeneralSettings.Monitor.MaxTopMarkets          = SystemHelper.TextToInteger(HttpContext.Request.Form["Monitor_MaxTopMarkets"], PTMagicConfiguration.GeneralSettings.Monitor.MaxTopMarkets);
            PTMagicConfiguration.GeneralSettings.Monitor.MaxDailySummaries      = SystemHelper.TextToInteger(HttpContext.Request.Form["Monitor_MaxDailySummaries"], PTMagicConfiguration.GeneralSettings.Monitor.MaxDailySummaries);
            PTMagicConfiguration.GeneralSettings.Monitor.MaxMonthlySummaries    = SystemHelper.TextToInteger(HttpContext.Request.Form["Monitor_MaxMonthlySummaries"], PTMagicConfiguration.GeneralSettings.Monitor.MaxMonthlySummaries);
            PTMagicConfiguration.GeneralSettings.Monitor.MaxDashboardBuyEntries = SystemHelper.TextToInteger(HttpContext.Request.Form["Monitor_MaxDashboardBuyEntries"], PTMagicConfiguration.GeneralSettings.Monitor.MaxDashboardBuyEntries);
            PTMagicConfiguration.GeneralSettings.Monitor.MaxDashboardBagEntries = SystemHelper.TextToInteger(HttpContext.Request.Form["Monitor_MaxDashboardBagEntries"], PTMagicConfiguration.GeneralSettings.Monitor.MaxDashboardBagEntries);
            PTMagicConfiguration.GeneralSettings.Monitor.MaxDCAPairs            = SystemHelper.TextToInteger(HttpContext.Request.Form["Monitor_MaxDCAPairs"], PTMagicConfiguration.GeneralSettings.Monitor.MaxDCAPairs);
            PTMagicConfiguration.GeneralSettings.Monitor.DefaultDCAMode         = HttpContext.Request.Form["Monitor_DefaultDCAMode"];

            PTMagicConfiguration.GeneralSettings.Backup.IsEnabled = HttpContext.Request.Form["Backup_IsEnabled"].Equals("on");
            PTMagicConfiguration.GeneralSettings.Backup.MaxHours  = SystemHelper.TextToInteger(HttpContext.Request.Form["Backup_MaxHours"], PTMagicConfiguration.GeneralSettings.Backup.MaxHours);

            PTMagicConfiguration.GeneralSettings.Telegram.IsEnabled  = HttpContext.Request.Form["Telegram_IsEnabled"].Equals("on");
            PTMagicConfiguration.GeneralSettings.Telegram.BotToken   = HttpContext.Request.Form["Telegram_BotToken"].ToString().Trim();
            PTMagicConfiguration.GeneralSettings.Telegram.ChatId     = SystemHelper.TextToInteger64(HttpContext.Request.Form["Telegram_ChatId"], PTMagicConfiguration.GeneralSettings.Telegram.ChatId);
            PTMagicConfiguration.GeneralSettings.Telegram.SilentMode = HttpContext.Request.Form["Telegram_SilentMode"].Equals("on");

            PTMagicConfiguration.WriteGeneralSettings(PTMagicBasePath);

            NotifyHeadline = "Settings saved!";
            NotifyMessage  = "Settings saved successfully to settings.general.json.";
            NotifyType     = "success";
        }