public static void save(string name, string value, Bws bws, StringBuilder errors, string section = null) { StringBuilder str = new StringBuilder(); str.Append("UPDATE Settings SET "); str.Append(name); str.Append("="); str.Append(value); if (section != null) { str.Append(" WHERE `Section` = "); str.Append(section); } try { bws.sql.query(str.ToString()); } catch (OleDbException) { if (errors.Length > 0) { errors.Append(", "); } errors.Append(name); } }
public Account() { _auth = null; Key = string.Empty; Task.Run(() => Bws.Connect()).Wait(); Status = "Inactive"; }
public static string load(string name, Bws bws, StringBuilder errors, string section = null, string table = "Settings", string sectionField = "`Section`") { StringBuilder str = new StringBuilder(); str.Append("SELECT "); str.Append(name); str.Append(" FROM "); str.Append(table); if (section != null) { str.Append(" WHERE "); str.Append(sectionField); str.Append(" = "); str.Append(section); } try { return(bws.sql.selectOne(str.ToString())); } catch (OleDbException) { if (errors.Length > 0) { errors.Append(", "); } errors.Append(name); return(""); } }
public Setting(string name, CheckBox field, Bws bws, Version bcsVersion, Version firmwareVersion) { this.name = name; this.field = field; this.bws = bws; this.bcsV = bcsVersion; this.fwV = firmwareVersion; }
private string detectBCSVersion() { RegistryKey[] keys = { Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall"), Registry.CurrentUser.OpenSubKey("Software\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall"), Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall"), Registry.LocalMachine.OpenSubKey("Software\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall") }; foreach (RegistryKey key in keys) { if (key != null) { foreach (var subKey in key.GetSubKeyNames()) { RegistryKey appKey = key.OpenSubKey(subKey); if (appKey != null) { foreach (var value in appKey.GetValueNames()) { string keyValue = Convert.ToString(appKey.GetValue("Publisher")); if (!keyValue.Equals("Bridge Systems BV", StringComparison.OrdinalIgnoreCase)) { continue; } string productName = Convert.ToString(appKey.GetValue("DisplayName")); if (!productName.Equals("Bridgemate Control Software", StringComparison.OrdinalIgnoreCase) && !productName.Equals("Bridgemate Pro Control", StringComparison.OrdinalIgnoreCase)) { continue; } string appPath = Convert.ToString(appKey.GetValue("InstallLocation")); if (appPath != null) { Bws.setAppLocation(appPath); } string version = Convert.ToString(appKey.GetValue("DisplayVersion")); return(version); } } } } } return(null); }
public void PriceProposalRequest(string contractType) { if ((string.IsNullOrEmpty(SelectedBasis.Key)) || (string.IsNullOrEmpty(SelectedCurrency.Key)) || (string.IsNullOrEmpty(SelectedTimeUnit.Key)) || string.IsNullOrEmpty(SelectedSymbol?.symbol) || 0 == Duration) { return; } var priceProposalRequest = new PriceProposalRequest { proposal = 1, amount = BasisValue.ToString(CultureInfo.InvariantCulture), basis = SelectedBasis.Key, contract_type = contractType, currency = SelectedCurrency.Key, duration = Duration.ToString(), duration_unit = SelectedTimeUnit.Key, symbol = SelectedSymbol.symbol // TODO: date_start commented cause it should be tested more carefully // date_start = ViewModel.SelectedStartTime.Key !=0 ? ViewModel.SelectedStartTime.Key : (int)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds }; var jsonPriceProposalRequest = JsonConvert.SerializeObject(priceProposalRequest); Task.Run(() => Bws.SendRequest(jsonPriceProposalRequest)).Wait(); var jsonPriceProposalResponse = Task.Run(() => Bws.StartListen()).Result; var priceProposal = JsonConvert.DeserializeObject <PriceProposalResponse>(jsonPriceProposalResponse); switch (contractType) { case "CALL": CallDisplayValue = priceProposal.proposal != null ? priceProposal.proposal.display_value : string.Empty; CallProposalId = priceProposal.proposal != null ? priceProposal.proposal.id : string.Empty; _callPayout = priceProposal.proposal != null ? priceProposal.proposal.payout : string.Empty; OnPropertyChanged("CallLabel"); break; case "PUT": PutDisplayValue = priceProposal.proposal != null ? priceProposal.proposal.display_value : string.Empty; PutProposalId = priceProposal.proposal != null ? priceProposal.proposal.id : string.Empty; _putPayout = priceProposal.proposal != null ? priceProposal.proposal.payout : string.Empty; OnPropertyChanged("PutLabel"); break; } }
public void Init() { Accounts.Init(); // Open websocket connection to get Market lists for all accounts Task.Run(() => Bws.Connect()).Wait(); Task.Run(() => Bws.SendRequest("{\"trading_times\":\"2015-09-14\"}")).Wait(); var jsonTradingTimesResponse = Task.Run(() => Bws.StartListen()).Result; var tradingTime = JsonConvert.DeserializeObject <TradingTimesResponse>(jsonTradingTimesResponse); foreach (var market in tradingTime.trading_times.markets) { MarketList.Add(new MarketSubmarket(market)); foreach (var submarket in market.submarkets) { MarketList.Add(new MarketSubmarket(submarket)); } } SelectedMarket = MarketList[0]; }
public static void saveSectionGroups(Sql sql, bool value, int teamTableOffset = 0) { if (teamTableOffset == 0) { StringBuilder sb = new StringBuilder("UPDATE Tables SET `Group` = "); sb.Append(value ? "1" : "`Section`"); sb.Append(";"); sql.query(sb.ToString()); } else { int group = 1; StringBuilder tablesQuery = new StringBuilder("SELECT `Section`, (`Table` MOD "); tablesQuery.Append(teamTableOffset); tablesQuery.Append(") FROM `Tables` GROUP BY `Section`, (`Table` MOD "); tablesQuery.Append(teamTableOffset); tablesQuery.Append(");"); OleDbDataReader tables = sql.select(tablesQuery.ToString()); List <string> queries = new List <string>(); while (tables.Read()) { StringBuilder sb = new StringBuilder("UPDATE `Tables` SET `Group` = "); sb.Append(group++); sb.Append(" WHERE `Section` = "); sb.Append(Bws.bwsNumber(tables, 0)); sb.Append(" AND (`Table` MOD "); sb.Append(teamTableOffset); sb.Append(") = "); sb.Append(Bws.bwsNumber(tables, 1)); sb.Append(";"); queries.Add(sb.ToString()); } foreach (string query in queries) { sql.query(query); } } }
public string this[string columnName] { get { var errorMessage = string.Empty; if (("Key" != columnName) || (string.IsNullOrEmpty(Key))) { return(errorMessage); } if (_auth.authorize == null) { Status = "Inactive"; OnPropertyChanged("Status"); errorMessage = "auth.authorize == null"; } else { Status = "Active"; OnPropertyChanged("Status"); Username = _auth.authorize.loginid; OnPropertyChanged("Username"); Name = _auth.authorize.fullname; OnPropertyChanged("Name"); Balance = "USD" == _auth.authorize.currency ? $"${_auth.authorize.balance}" : _auth.authorize.balance; OnPropertyChanged("Balance"); // Request for opens positions Task.Run(() => Bws.SendRequest($"{{\"portfolio\":1}}")).Wait(); var jsonPortfolio = Task.Run(() => Bws.StartListen()).Result; var portfolio = JsonConvert.DeserializeObject <PortfolioResponse>(jsonPortfolio); Opens = portfolio.portfolio.contracts.Length; OnPropertyChanged("Opens"); } return(errorMessage); } }
private void MainForm_Shown(object sender, EventArgs e) { status2.Text = "Wersja " + this.version; status3.Text = "Data: " + this.date; string detectedVersion = detectBCSVersion(); if (detectedVersion != null) { lDetectedVersion.Text = detectedVersion; BCSVersion = new Version(detectedVersion); } else { lDetectedVersion.Text = "nie wykryto"; } string filename; string[] args = Environment.GetCommandLineArgs(); if (args.Length > 1) { filename = args[1]; } else if (open.ShowDialog() == DialogResult.OK) { filename = open.FileName; } else { Close(); return; } bws = new Bws(filename, this); bws.init(); bws.convert(); labelFilename.Text = filename; labelFilename.ToolTipText = filename; this.shortenFilenameLabel(); this.fillSectionSelector(bws.getSections()); cbNamesSection.Items.Clear(); foreach (object i in cbSettingsSection.Items) { cbNamesSection.Items.Add(i); } // cloning Setting List returned from Bws, because we're going to extend it for version tracking purposes this.bwsSettings = new List <Setting>(bws.initSettings()); this.bwsSettings.Add(new Setting("BM2ShowPlayerNames", this.xShowPlayerNames, bws, new Version(2, 0, 0), new Version(1, 3, 1))); this.bwsSettings.Add(new Setting("BM2GameSummary", this.xShowRecap, bws, new Version(3, 6, 0), new Version(3, 0, 1))); bindSettingChanges(); bws.loadSettings(); this.checkRecordsForSectionGroups(); this.scoringOptionsWarning(); tournament = this.detectTeamyTournament(); if (tournament != null) { updateTournamentInfo(tournament); this.rbIMPTeams.Checked = true; } else { syncToolStrip.Visible = false; namesPanel.Visible = false; } this.WindowState = FormWindowState.Normal; }