示例#1
0
        private void CbDatabaseName_DropDownOpened(object sender, EventArgs e)
        {
            try
            {
                Cursor = Cursors.Wait;
                textDatabaseName.Items.Clear();

                TCNodeConfig tcnode = new TCNodeConfig(
                    this.SqlServerName,
                    this.Authentication,
                    this.SqlUserName,
                    this.DatabaseName,
                    this.SqlPassword
                    );

                List <string> localDatabases = tcnode.SqlDatabases;

                foreach (string database in localDatabases)
                {
                    textDatabaseName.Items.Add(database);
                }
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message, Title, MessageBoxButton.OK, MessageBoxImage.Error);
            }
            finally
            {
                Cursor = Cursors.Arrow;
            }
        }
示例#2
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                var txIds = new TxControl(tvWallet, tcBitcoin);
                txIds.OnBalance         += tvWallet_OnBalance;
                txIds.Visibility         = Visibility.Hidden;
                pageTransactions.Content = txIds;

                var toReceive = new InvoicesControl(tvWallet, tcBitcoin, CashMode.Income);
                toReceive.OnBalance  += tvWallet_OnBalance;
                toReceive.Visibility  = Visibility.Hidden;
                pageToReceive.Content = toReceive;

                var toPay = new InvoicesControl(tvWallet, tcBitcoin, CashMode.Expense);
                toPay.OnBalance  += tvWallet_OnBalance;
                toPay.Visibility  = Visibility.Hidden;
                pageToPay.Content = toPay;

                var receiptKeys = new ChangeControl(tvWallet, tcBitcoin, CoinChangeType.Receipt);
                receiptKeys.OnBalance  += tvWallet_OnBalance;
                receiptKeys.Visibility  = Visibility.Hidden;
                pageReceiptKeys.Content = receiptKeys;

                var changeKeys = new ChangeControl(tvWallet, tcBitcoin, CoinChangeType.Change);
                changeKeys.OnBalance  += tvWallet_OnBalance;
                changeKeys.Visibility  = Visibility.Hidden;
                pageChangeKeys.Content = changeKeys;

                if (Properties.Settings.Default.APIAddress.Length > 0)
                {
                    tcBitcoin.ApiAddress = new Uri(Properties.Settings.Default.APIAddress);
                }
                tcBitcoin.MinersFee = (MinerRates.MiningSpeed)Properties.Settings.Default.MinersFeeSpeed;

                using (TCNodeConfig nodeConfig = new TCNodeConfig())
                {
                    SqlServerName  = nodeConfig.SqlServerName;
                    Authentication = nodeConfig.Authentication;
                    SqlUserName    = nodeConfig.SqlUserName;
                    DatabaseName   = nodeConfig.DatabaseName;
                }

                if (SqlServerConnect())
                {
                    ConnectionFooter();
                }
                else
                {
                    SetSqlConnection();
                }

                if (Properties.Settings.Default.WindowHeight > 0)
                {
                    Height = Properties.Settings.Default.WindowHeight;
                    Width  = Properties.Settings.Default.WindowWidth;
                    Top    = Properties.Settings.Default.WindowTop;
                    Left   = Properties.Settings.Default.WindowLeft;
                }
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message, Title, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
示例#3
0
        bool SqlServerConnect()
        {
            bool isDbConnected = false;

            try
            {
                tvWallet.Items.Clear();
                cbCashAccount.ItemsSource = null;
                textNamespace.Text        = string.Empty;


                using (TCNodeConfig tcNode = new TCNodeConfig(
                           SqlServerName,
                           Authentication,
                           SqlUserName,
                           DatabaseName,
                           SqlPassword))
                {
                    if (tcNode.Authenticated)
                    {
                        if (tcNode.IsTCNode)
                        {
                            if (tcNode.InstalledVersion < TCBitcoin.WalletNodeVersion)
                            {
                                lbConnection.Foreground = new SolidColorBrush(Colors.Red);
                                lbConnection.Content    = string.Format(Properties.Resources.NodeVersionIncompatible, TCBitcoin.WalletNodeVersion.ToString());
                            }
                            else
                            {
                                tcBitcoin.NodeCash        = new TCNodeCash(tcNode.ConnectionString);
                                cbCashAccount.ItemsSource = tcBitcoin.NodeCash.CashAccountCodes;

                                if (cbCashAccount.Items.Count > 0)
                                {
                                    cbCashAccount.Text = tcBitcoin.NodeCash.CashAccountTrade;
                                }

                                //InvoicesControl receipts = (InvoicesControl)pageToReceive.Content;
                                //receipts.Refresh();

                                //InvoicesControl payments = (InvoicesControl)pageToPay.Content;
                                //payments.Refresh();

                                lbConnection.Foreground = new SolidColorBrush(Colors.Black);
                                isDbConnected           = true;
                            }
                        }
                        else
                        {
                            lbConnection.Foreground = new SolidColorBrush(Colors.Red);
                            lbConnection.Content    = Properties.Resources.UnrecognisedDatasource;
                        }
                    }
                    else
                    {
                        lbConnection.Foreground = new SolidColorBrush(Colors.Red);
                        lbConnection.Content    = Properties.Resources.ConnectionFailed;
                    }
                }

                if (!isDbConnected)
                {
                    tcBitcoin.NodeCash = null;
                }
            }
            catch (Exception err)
            {
                lbConnection.Content    = $"{err.Source}.{err.TargetSite.Name}: {err.Message}";
                lbConnection.Foreground = new SolidColorBrush(Colors.Red);
            }

            return(isDbConnected);
        }