private async Task HandleSettingsUpdate(RawWebsocketMessage msg) { var newSettings = SettingsUpdate.Create(msg); if (newSettings.data == null) { return; } var SettingsType = typeof(EventVcSettings); var SettingsProps = SettingsType.GetProperties(); var dt = newSettings.data.GetType(); var tmpSettings = settings.Clone(); foreach (var prop in dt.GetProperties()) { if (SettingsProps.Any(x => x.Name == prop.Name)) { var setProp = SettingsProps.First(x => x.Name == prop.Name); setProp.SetValue(tmpSettings, prop.GetValue(newSettings.data)); } } }
private void ReadJson() { SettingsUpdate settings = jsonService.ReadJson <SettingsUpdate>(Settings.Default.VersionJsonFileName); NewVersion = settings.Version.ToString(); LastChange = settings.LastChangesDe.Replace("<br />", "\n"); // TODO: switching between English and German | locale == "de" ? de : en; Location = settings.Location; }
private void StartSettingsUpdate(SettingsUpdate settingsUpdate) { try { if (startingUp) { uDebugLogAdd("Application is still starting up, skipping settings update"); return; } if (settingsUpdating) { uDebugLogAdd("Settings UI updating, skipping settings update"); return; } SettingsTimerRefresh(); if (!settingsSaveVerificationInProgress) { settingsSaveVerificationInProgress = true; BackgroundWorker worker = new BackgroundWorker() { WorkerReportsProgress = true }; worker.DoWork += (ws, we) => { try { while (settingsTimer > 0) { Thread.Sleep(500); settingsTimer--; } worker.ReportProgress(1); settingsSaveVerificationInProgress = false; SettingsTimerRefresh(); } catch (Exception ex) { LogException(ex); } }; worker.ProgressChanged += (ps, pe) => { if (pe.ProgressPercentage == 1) { tUpdateSettings(settingsUpdate); } }; worker.RunWorkerAsync(); } } catch (Exception ex) { LogException(ex); } }
void Update_Click(object sender, EventArgs e) { if (!isUpdateLoaded) { isUpdateLoaded = true; SettingsUpdate su; //shows the aboutus box su = new SettingsUpdate(); su.ShowDialog(); isUpdateLoaded = false; } Business.Lists.treyIcon.ShowNotification("update"); }
public HttpResponseMessage UpdateSettings(SettingsUpdate req, int id) { if (!ModelState.IsValid) { ModelState.AddModelError("Error", "Model Error"); return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } if (req.Id != id) { return(Request.CreateResponse(HttpStatusCode.BadRequest, new ErrorResponse("Id's do not match"))); } _settingsService.Update(req); return(Request.CreateResponse(HttpStatusCode.OK, new ItemResponse <int> { Item = id })); }
protected async override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e) { TinderSession.CurrentSession.CurrentProfile.InterestedInFilter.Clear(); if (this.showMenCheckbox.IsChecked.Value) TinderSession.CurrentSession.CurrentProfile.InterestedInFilter.Add(0); if (this.showWomenCheckBox.IsChecked.Value) TinderSession.CurrentSession.CurrentProfile.InterestedInFilter.Add(1); SettingsUpdate settingsUpdate = new SettingsUpdate(); settingsUpdate.AgeFilterMaximum = (Int32)maxAge.Value; settingsUpdate.AgeFilterMinimum = (Int32)minAge.Value; settingsUpdate.GenderID = genderDropDown.SelectedIndex; settingsUpdate.InterestedInFilter = TinderSession.CurrentSession.CurrentProfile.InterestedInFilter; await settingsUpdate.SaveSettings(); base.OnBackKeyPress(e); }
public void Update(SettingsUpdate req) { using (SqlConnection conn = new SqlConnection(connectionString)) { conn.Open(); SqlCommand cmd = conn.CreateCommand(); cmd.CommandText = "Settings_Update"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Id", req.Id); cmd.Parameters.AddWithValue("@SearchTerm", req.Term); cmd.Parameters.AddWithValue("@Location", req.Location); cmd.Parameters.AddWithValue("@Radius", req.Radius); cmd.Parameters.AddWithValue("@Price", req.Price); cmd.Parameters.AddWithValue("@OpenNow", req.OpenNow); cmd.ExecuteNonQuery(); } }
protected async override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e) { TinderSession.CurrentSession.CurrentProfile.interested_in.Clear(); if (this.showMenCheckbox.IsChecked.Value) { TinderSession.CurrentSession.CurrentProfile.interested_in.Add(0); } if (this.showWomenCheckBox.IsChecked.Value) { TinderSession.CurrentSession.CurrentProfile.interested_in.Add(1); } SettingsUpdate settingsUpdate = new SettingsUpdate(); settingsUpdate.age_filter_max = (Int32)maxAge.Value; settingsUpdate.age_filter_min = (Int32)minAge.Value; settingsUpdate.gender = genderDropDown.SelectedIndex; settingsUpdate.interested_in = TinderSession.CurrentSession.CurrentProfile.interested_in; await settingsUpdate.SaveSettings(); base.OnBackKeyPress(e); }
static public void Main(string[] Args) { //Upgrade settings System.Reflection.Assembly a = System.Reflection.Assembly.GetExecutingAssembly(); Version appVersion = a.GetName().Version; string appVersionString = appVersion.ToString(); log.DebugFormat("Application version of new settings {0}", appVersionString); try { if (Properties.Settings.Default.ApplicationVersion != appVersion.ToString()) { log.Debug("Upgrading settings..."); Properties.Settings.Default.Upgrade(); // if program's hash has changed (e.g. by upgrading to .NET 4.0), then Upgrade() doesn't import the previous application settings // because it cannot locate a previous user.config file. In this case a new user.config file is created with the default settings. // We will try and find a config file from a previous installation and update the settings from it if (Properties.Settings.Default.ApplicationVersion == "" && Properties.Settings.Default.DoUpgrade) { SettingsUpdate.Update(); } log.DebugFormat("Settings upgraded from '{0}' to '{1}'", Properties.Settings.Default.ApplicationVersion, appVersionString); Properties.Settings.Default.ApplicationVersion = appVersionString; Settings.TrySaveSettings(); } } catch (ConfigurationErrorsException ex) { log.Error("Could not load settings.", ex); var msg = string.Format("{0}\n\n{1}", Messages.MESSAGEBOX_LOAD_CORRUPTED_TITLE, string.Format(Messages.MESSAGEBOX_LOAD_CORRUPTED, Settings.GetUserConfigPath())); var dlog = new ThreeButtonDialog(new ThreeButtonDialog.Details(SystemIcons.Error, msg, Messages.XENCENTER)) { StartPosition = FormStartPosition.CenterScreen, //For reasons I do not fully comprehend at the moment, the runtime //overrides the above StartPosition with WindowsDefaultPosition if //ShowInTaskbar is false. However it's a good idea anyway to show it //in the taskbar since the main form is not launcched at this point. ShowInTaskbar = true }; dlog.ShowDialog(); Application.Exit(); return; } // Reset statics, because XenAdminTests likes to call Main() twice. TestExceptionString = null; Exiting = false; // Clear XenConnections and History so static classes like OtherConfigAndTagsWatcher // listening to changes still work when Main is called more than once. ConnectionsManager.XenConnections.Clear(); ConnectionsManager.History.Clear(); Search.InitSearch(Branding.Search); TreeSearch.InitSearch(); ArgType argType = ArgType.None; AppDomain.CurrentDomain.UnhandledException -= CurrentDomain_UnhandledException; AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; Application.ThreadException -= Application_ThreadException; Application.ThreadException += Application_ThreadException; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); try { if (SystemInformation.FontSmoothingType == 2) // ClearType { TransparentUsually = SystemColors.Window; } } catch (NotSupportedException) { // Leave TransparentUsually == Color.Transparent. This is an old platform // without FontSmoothingType support. } switch (Environment.OSVersion.Version.Major) { case 6: // Vista, 2K8, Win7. if (Application.RenderWithVisualStyles) { // Vista, Win7 with styles. TitleBarStartColor = Color.FromArgb(242, 242, 242); TitleBarEndColor = Color.FromArgb(207, 207, 207); TitleBarBorderColor = Color.FromArgb(160, 160, 160); TitleBarForeColor = Color.FromArgb(60, 60, 60); HeaderGradientForeColor = Color.White; HeaderGradientFont = new Font(DefaultFont.FontFamily, 11.25f); HeaderGradientFontSmall = DefaultFont; TabbedDialogHeaderFont = HeaderGradientFont; TabPageRowBorder = Color.Gainsboro; TabPageRowHeader = Color.WhiteSmoke; } else { // 2K8, and Vista, Win7 without styles. TitleBarForeColor = SystemColors.ControlText; HeaderGradientForeColor = SystemColors.ControlText; HeaderGradientFont = new Font(DefaultFont.FontFamily, DefaultFont.Size + 1f, FontStyle.Bold); HeaderGradientFontSmall = DefaultFontBold; TabbedDialogHeaderFont = HeaderGradientFont; TabPageRowBorder = Color.DarkGray; TabPageRowHeader = Color.Silver; } break; default: TitleBarStartColor = ProfessionalColors.OverflowButtonGradientBegin; TitleBarEndColor = ProfessionalColors.OverflowButtonGradientEnd; TitleBarBorderColor = TitleBarEndColor; TitleBarForeColor = Application.RenderWithVisualStyles ? Color.White : SystemColors.ControlText; HeaderGradientForeColor = TitleBarForeColor; HeaderGradientFont = new Font(DefaultFont.FontFamily, DefaultFont.Size + 1f, FontStyle.Bold); HeaderGradientFontSmall = DefaultFontBold; TabbedDialogHeaderFont = new Font(DefaultFont.FontFamily, DefaultFont.Size + 1.75f, FontStyle.Bold); TabPageRowBorder = Color.DarkGray; TabPageRowHeader = Color.Silver; break; } // Force the current culture, to make the layout the same whatever the culture of the underlying OS (CA-46983). Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture = new CultureInfo(InvisibleMessages.LOCALE, false); if (string.IsNullOrEmpty(Thread.CurrentThread.Name)) { Thread.CurrentThread.Name = "Main program thread"; } ServicePointManager.DefaultConnectionLimit = 20; ServicePointManager.ServerCertificateValidationCallback = SSL.ValidateServerCertificate; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12; XenAPI.Session.UserAgent = string.Format("XenCenter/{0}", ClientVersion()); ReconfigureConnectionSettings(); log.Info("Application started"); logSystemDetails(); OptionsDialog.Log(); if (Args.Length > 0) { log.InfoFormat("Args[0]: {0}", Args[0]); } List <string> sanitizedArgs = new List <string>(Args); // Remove the '--wait' argument, which may have been passed to the splash screen sanitizedArgs.Remove("--wait"); string[] args = null; if (sanitizedArgs.Count > 1) { argType = ParseFileArgs(sanitizedArgs, out args); if (argType == ArgType.Passwords) { log.DebugFormat("Handling password request using '{0}'", args[0]); try { PasswordsRequest.HandleRequest(args[0]); } catch (Exception exn) { log.Fatal(exn, exn); } Application.Exit(); return; } } else if (sanitizedArgs.Count == 1 && sanitizedArgs[0] == "messageboxtest") { new Dialogs.MessageBoxTest().ShowDialog(); Application.Exit(); return; } else if (sanitizedArgs.Count > 0) { log.Warn("Unrecognised command line options"); } try { ConnectPipe(); } catch (System.ComponentModel.Win32Exception exn) { log.Error("Creating named pipe failed. Continuing to launch XenCenter.", exn); } Application.ApplicationExit -= Application_ApplicationExit; Application.ApplicationExit += Application_ApplicationExit; MainWindow mainWindow = new MainWindow(argType, args); Application.Run(mainWindow); log.Info("Application main thread exited"); }
static int RunSettingsUpdate(ILogger logger, SolutionSettingsOptions options) => SettingsUpdate.Run(logger, options);
static int RunSettingsUpdate(ILogger logger, DatabaseConnectionSettings appsettings, SetSettingsOptions options) => SettingsUpdate.Run(logger, appsettings, options);
private void tUpdateSettings(SettingsUpdate settingsUpdate, string value = null) { BackgroundWorker worker = new BackgroundWorker() { WorkerReportsProgress = true }; worker.DoWork += (sender, e) => { try { // Pingcount settings var num = 0; if (value != null) { if (int.TryParse(value, out num)) { worker.ReportProgress(1); } else { if (!settingsBadAlerted) { worker.ReportProgress(99); settingsBadAlerted = true; Thread.Sleep(TimeSpan.FromSeconds(5)); settingsBadAlerted = false; } else { return; } } } // Update All Settings worker.ReportProgress(1); } catch (Exception ex) { LogException(ex); } }; worker.ProgressChanged += (psend, pe) => { try { switch (pe.ProgressPercentage) { case 1: uDebugLogAdd("Starting settings update"); // Set network textbox enter action uDebugLogAdd("SETUPDATE: Enter action"); if (ComboPopSetNetAction.Text == "DNSLookup") { Toolbox.settings.UtilBarEnterAction = EnterAction.DNSLookup; } else if (ComboPopSetNetAction.Text == "Ping") { Toolbox.settings.UtilBarEnterAction = EnterAction.Ping; } // Set beta check uDebugLogAdd("SETUPDATE: Beta check"); if (ChkPopSetGenBeta.IsChecked == true) { Toolbox.settings.BetaUpdate = true; } else { Toolbox.settings.BetaUpdate = false; } // Set startup on windows startup uDebugLogAdd("SETUPDATE: Startup on windows startup"); if ((ChkPopSetGenStartup.IsChecked == true) && !Actions.CheckWinStartupRegKeyExistance()) { Actions.AddToWindowsStartup(true); } else if ((ChkPopSetGenStartup.IsChecked == false) && Actions.CheckWinStartupRegKeyExistance()) { Actions.AddToWindowsStartup(false); } // Set Window/Start profile names uDebugLogAdd("SETUPDATE: Window/Start profile names"); Toolbox.settings.WindowProfileName1 = string.IsNullOrWhiteSpace(TxtPopSetWinPro1.Text) ? "Profile 1" : TxtPopSetWinPro1.Text; Toolbox.settings.WindowProfileName2 = string.IsNullOrWhiteSpace(TxtPopSetWinPro2.Text) ? "Profile 2" : TxtPopSetWinPro2.Text; Toolbox.settings.WindowProfileName3 = string.IsNullOrWhiteSpace(TxtPopSetWinPro3.Text) ? "Profile 3" : TxtPopSetWinPro3.Text; Toolbox.settings.WindowProfileName4 = string.IsNullOrWhiteSpace(TxtPopSetWinPro4.Text) ? "Profile 4" : TxtPopSetWinPro4.Text; Toolbox.settings.StartProfileName1 = string.IsNullOrWhiteSpace(TxtPopSetStartPro1.Text) ? "Start 1" : TxtPopSetStartPro1.Text; Toolbox.settings.StartProfileName2 = string.IsNullOrWhiteSpace(TxtPopSetStartPro2.Text) ? "Start 2" : TxtPopSetStartPro2.Text; Toolbox.settings.StartProfileName3 = string.IsNullOrWhiteSpace(TxtPopSetStartPro3.Text) ? "Start 3" : TxtPopSetStartPro3.Text; Toolbox.settings.StartProfileName4 = string.IsNullOrWhiteSpace(TxtPopSetStartPro4.Text) ? "Start 4" : TxtPopSetStartPro4.Text; // Preferred Window Toolbox.settings.PreferredWindow = ComboPopSetGenWinPref.SelectedItem == Toolbox.FindComboBoxItemByString(ComboPopSetGenWinPref, "Utility Bar") ? WindowPreference.UtilityBar : WindowPreference.DesktopWindow; // Trigger Events Events.TriggerWindowInfoChange(); //Events.TriggerStartInfoChange(); //UpdateUISettings(); break; case 99: ShowNotification("Incorrect format entered"); break; } uDebugLogAdd("Finished settings update"); } catch (Exception ex) { LogException(ex); } }; worker.RunWorkerAsync(); }
static int RunSettingsUpdate(ILogger logger, ApplicationSettingsOptions options) => SettingsUpdate.Run(logger, options);//options.DatabaseHost, options.DatabaseName, options.DatabasePort, options.DatabaseUserName, options.DatabasePassword);