示例#1
0
        static void button_Click(object sender, RoutedEventArgs e)
        {
            var item = sender as Button;

            if (item != null)
            {
                EnvDTEHelper.LaunchUrl(item.Tag as string);
            }
        }
        internal void ScanConnections(SqlCeToolboxPackage package)
        {
            var          dte       = package.GetServiceHelper(typeof(EnvDTE.DTE)) as EnvDTE.DTE;
            var          helper    = Helpers.DataConnectionHelper.CreateEngineHelper(DatabaseType.SQLCE40);
            EnvDTEHelper dteHelper = new EnvDTEHelper();
            var          list      = dteHelper.GetSqlCeFilesInActiveSolution(dte);

            foreach (var path in list)
            {
                if (File.Exists(path))
                {
                    bool         versionFound = false;
                    SQLCEVersion version      = SQLCEVersion.SQLCE20;
                    try
                    {
                        version      = helper.DetermineVersion(path);
                        versionFound = true;
                    }
                    catch {}
                    string connectionString = string.Format("Data Source={0}", path);
                    if (versionFound)
                    {
                        if (version == SQLCEVersion.SQLCE35)
                        {
                            SaveDataConnection(connectionString, DatabaseType.SQLCE35, package);
                        }
                        else if (version == SQLCEVersion.SQLCE40)
                        {
                            SaveDataConnection(connectionString, DatabaseType.SQLCE40, package);
                        }
                    }
                    else
                    {
                        var dbInfo = new DatabaseInfo();
                        dbInfo.DatabaseType     = DatabaseType.SQLite;
                        dbInfo.ConnectionString = connectionString;
                        try
                        {
                            using (var repo = CreateRepository(dbInfo))
                            {
                                repo.GetAllTableNames();
                            }
                            SaveDataConnection(connectionString, DatabaseType.SQLite, package);
                        }
                        catch { }
                    }
                }
            }
        }
        internal static string SendError(Exception ex, DatabaseType dbType, bool report = true)
        {
            if (ex != null)
            {
                var dontTrack = ex.GetType().Name == "SqlCeException" ||
                                ex is SqlException ||
                                ex is SQLiteException;

                if (!dontTrack)
                {
                    Telemetry.TrackException(ex);
                }
                EnvDTEHelper.ShowError(CreateEngineHelper(dbType).FormatError(ex));
            }
            return(string.Empty);
        }
 private bool TryGetInitialPath(SqlCeToolboxPackage package, out string path)
 {
     var dte = package.GetServiceHelper(typeof(EnvDTE.DTE)) as EnvDTE.DTE;
     EnvDTEHelper dteHelper = new EnvDTEHelper();
     try
     {
         path = dteHelper.GetInitialFolder(dte);
         return true;
     }
     catch
     {
         path = null;
         return false;
     }
 }
 internal void ScanConnections(SqlCeToolboxPackage package)
 {
     var dte = package.GetServiceHelper(typeof(EnvDTE.DTE)) as EnvDTE.DTE;
     var helper = Helpers.DataConnectionHelper.CreateEngineHelper(DatabaseType.SQLCE40);
     EnvDTEHelper dteHelper = new EnvDTEHelper();
     var list = dteHelper.GetSqlCeFilesInActiveSolution(dte);
     foreach (var path in list)
     {
         if (File.Exists(path))
         {
             bool versionFound = false;
             SQLCEVersion version = SQLCEVersion.SQLCE20;
             try
             {
                 version = helper.DetermineVersion(path);
                 versionFound = true;
             }
             catch {}
             string connectionString = string.Format("Data Source={0}", path);
             if (versionFound)
             {                        
                 if (version == SQLCEVersion.SQLCE35)
                 {
                     SaveDataConnection(connectionString, DatabaseType.SQLCE35, package);
                 }
                 else if (version == SQLCEVersion.SQLCE40)
                 {
                     SaveDataConnection(connectionString, DatabaseType.SQLCE40, package);
                 }
             }
             else
             { 
                 var dbInfo = new DatabaseInfo();
                 dbInfo.DatabaseType = DatabaseType.SQLite;
                 dbInfo.ConnectionString = connectionString;
                 try
                 {
                     using (var repo = CreateRepository(dbInfo))
                     {
                         repo.GetAllTableNames();
                     }
                     SaveDataConnection(connectionString, DatabaseType.SQLite, package);
                 }
                 catch { }
             }
         }
     }
 }