示例#1
0
        private void LoadTablesFromDatabase(RecentDataSourceInfo info)
        {
            string connectionString = Configuration.Decrypt(info.ConnStr);
            string name             = info.Name;
            string provider         = info.Provider;

            mruSelectedDatabaseName = name;
            selectedDataProvider    = provider;

            IDbDriverFactory dbFactory = DbDriverFactoryCreator.GetDbDriverFactory(provider);

            if (dbFactory.ArePrerequisitesMet())
            {
                DbConnectionStringBuilder dbCnnStringBuilder = new DbConnectionStringBuilder();
                IDbDriver db = dbFactory.CreateDatabaseObject(dbCnnStringBuilder);
                db.ConnectionString = connectionString;

                try
                {
                    db.TestConnection();

                    cmbDatabaseType.Text = info.ProviderDesc;

                    LoadTablesFromDatabase(db);
                }
                catch (Exception ex)
                {
                    Epi.Windows.MsgBox.ShowException(ex);
                    return;
                }

                this.selectedDataSource = db;
            }
        }
示例#2
0
        private void PopulateRecentDataSource(string dataProviderDesc, string dataProvider, string name, string connString)
        {
            int rowDefStart = grdRecentDataSources.RowDefinitions.Count;

            try
            {
                string conn = Configuration.Decrypt(connString);

                RowDefinition rowDef1 = new RowDefinition();
                rowDef1.Height = GridLength.Auto;

                RowDefinition rowDef2 = new RowDefinition();
                rowDef2.Height = GridLength.Auto;

                grdRecentDataSources.RowDefinitions.Add(rowDef1);
                grdRecentDataSources.RowDefinitions.Add(rowDef2);

                RecentDataSourceInfo recentDsInfo = new RecentDataSourceInfo();
                recentDsInfo.ConnStr      = connString;
                recentDsInfo.Name         = name;
                recentDsInfo.Provider     = dataProvider;
                recentDsInfo.ProviderDesc = dataProviderDesc;

                Border highlightBorder = new Border();
                highlightBorder.Tag                = recentDsInfo;
                highlightBorder.Style              = this.Resources["recentDataBlueHighlightBorderStyle"] as Style;
                highlightBorder.MouseLeftButtonUp += new MouseButtonEventHandler(highlightDataSourceBorder_MouseLeftButtonUp);
                Grid.SetRow(highlightBorder, rowDefStart);
                Grid.SetRowSpan(highlightBorder, 2);
                Grid.SetColumn(highlightBorder, 0);
                Grid.SetColumnSpan(highlightBorder, 2);
                grdRecentDataSources.Children.Add(highlightBorder);

                TextBlock txt = new TextBlock();
                txt.Text             = name;
                txt.IsHitTestVisible = false;
                txt.FontSize         = 15;
                txt.Foreground       = Brushes.White;
                txt.Margin           = new Thickness(2, 8, 2, 2);
                Grid.SetRow(txt, rowDefStart);
                Grid.SetColumn(txt, 1);
                grdRecentDataSources.Children.Add(txt);

                txt                  = new TextBlock();
                txt.Text             = dataProviderDesc;
                txt.IsHitTestVisible = false;
                txt.FontSize         = 12;
                txt.Foreground       = new SolidColorBrush(Color.FromRgb(191, 221, 242));
                txt.Margin           = new Thickness(2, 2, 2, 8);
                Grid.SetRow(txt, rowDefStart + 1);
                Grid.SetColumn(txt, 1);
                grdRecentDataSources.Children.Add(txt);
            }
            catch (System.Security.Cryptography.CryptographicException)
            {
            }
        }
示例#3
0
 void highlightDataSourceBorder_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
 {
     if (sender is Border)
     {
         Border border = sender as Border;
         if (border.Tag is RecentDataSourceInfo)
         {
             RecentDataSourceInfo info = (RecentDataSourceInfo)border.Tag;
             string conn = Configuration.Decrypt(info.ConnStr);
             if (conn.EndsWith(".prj") || conn.EndsWith(".prj7"))
             {
                 Project project = new Project(conn);
                 LoadFormsFromProject(project);
             }
             else
             {
                 LoadTablesFromDatabase(info);
             }
         }
     }
 }
示例#4
0
        private void PopulateRecentDataSource(string dataProviderDesc, string dataProvider, string name, string connString)
        {
            int rowDefStart = grdRecentDataSources.RowDefinitions.Count;

            try
            {
                string conn = Configuration.Decrypt(connString);

                RowDefinition rowDef1 = new RowDefinition();
                rowDef1.Height = GridLength.Auto;

                RowDefinition rowDef2 = new RowDefinition();
                rowDef2.Height = GridLength.Auto;

                grdRecentDataSources.RowDefinitions.Add(rowDef1);
                grdRecentDataSources.RowDefinitions.Add(rowDef2);

                RecentDataSourceInfo recentDsInfo = new RecentDataSourceInfo();
                recentDsInfo.ConnStr = connString;
                recentDsInfo.Name = name;
                recentDsInfo.Provider = dataProvider;
                recentDsInfo.ProviderDesc = dataProviderDesc;

                Border highlightBorder = new Border();
                highlightBorder.Tag = recentDsInfo;
                highlightBorder.Style = this.Resources["recentDataBlueHighlightBorderStyle"] as Style;
                highlightBorder.MouseLeftButtonUp += new MouseButtonEventHandler(highlightDataSourceBorder_MouseLeftButtonUp);
                Grid.SetRow(highlightBorder, rowDefStart);
                Grid.SetRowSpan(highlightBorder, 2);
                Grid.SetColumn(highlightBorder, 0);
                Grid.SetColumnSpan(highlightBorder, 2);
                grdRecentDataSources.Children.Add(highlightBorder);

                TextBlock txt = new TextBlock();
                txt.Text = name;
                txt.IsHitTestVisible = false;
                txt.FontSize = 15;
                txt.Foreground = Brushes.White;
                txt.Margin = new Thickness(2, 8, 2, 2);
                Grid.SetRow(txt, rowDefStart);
                Grid.SetColumn(txt, 1);
                grdRecentDataSources.Children.Add(txt);

                txt = new TextBlock();
                txt.Text = dataProviderDesc;
                txt.IsHitTestVisible = false;
                txt.FontSize = 12;
                txt.Foreground = new SolidColorBrush(Color.FromRgb(191, 221, 242));
                txt.Margin = new Thickness(2, 2, 2, 8);
                Grid.SetRow(txt, rowDefStart + 1);
                Grid.SetColumn(txt, 1);
                grdRecentDataSources.Children.Add(txt);
            }
            catch (System.Security.Cryptography.CryptographicException)
            {
            }
        }
示例#5
0
        private void LoadTablesFromDatabase(RecentDataSourceInfo info)
        {
            string connectionString = Configuration.Decrypt(info.ConnStr);
            string name = info.Name;
            string provider = info.Provider;

            mruSelectedDatabaseName = name;
            selectedDataProvider = provider;

            IDbDriverFactory dbFactory = DbDriverFactoryCreator.GetDbDriverFactory(provider);
            if (dbFactory.ArePrerequisitesMet())
            {
                DbConnectionStringBuilder dbCnnStringBuilder = new DbConnectionStringBuilder();
                IDbDriver db = dbFactory.CreateDatabaseObject(dbCnnStringBuilder);
                db.ConnectionString = connectionString;

                try
                {
                    db.TestConnection();

                    cmbDatabaseType.Text = info.ProviderDesc;

                    LoadTablesFromDatabase(db);
                }
                catch (Exception ex)
                {
                    Epi.Windows.MsgBox.ShowException(ex);
                    return;
                }

                this.selectedDataSource = db;
            }
        }