Ejemplo n.º 1
0
        public IServerSource MergeToConnection(IPhysicalConnection conn)
        {
            if (conn.GetConnKey() != m_conn.GetConnKey())
            {
                throw new InternalError("DAE-00030 Cannot merge connections with different keys");
            }
            GenericServerSource res = new GenericServerSource(conn);

            return(res);
        }
Ejemplo n.º 2
0
        public static ITreeNode FromStoredConnection(ITreeNode parent, IStoredConnection stored, IFileHandler fhandler)
        {
            IPhysicalConnection phys = stored.CreatePhysicalConnection();

            if (stored.DatabaseMode == ConnectionDatabaseMode.All)
            {
                IServerSource conn = new GenericServerSource(phys);
                return(new Server_SourceConnectionTreeNode(conn, parent, fhandler, stored));
            }
            else
            {
                string          exdbname = stored.DatabaseMode == ConnectionDatabaseMode.Explicit ? stored.ExplicitDatabaseName : null;
                IDatabaseSource conn     = new GenericDatabaseSource(null, phys, exdbname);
                return(new Database_SourceConnectionTreeNode(conn, parent, fhandler, stored, false));
            }
        }
Ejemplo n.º 3
0
 public IDatabaseSource GetConnection()
 {
     if (Driver != null)
     {
         if (Connection == null)
         {
             throw new CommandLineError("DAE-00266 missing connection parameter");
         }
         var sc   = (IStoredConnection)StoredConnectionAddonType.Instance.FindHolder(Driver).CreateInstance();
         var conn = sc.CreatePhysicalConnection(Connection);
         if (Database != null)
         {
             var srv = new GenericServerSource(conn);
             var db  = new GenericDatabaseSource(srv, conn, Database);
             return(db);
         }
         else
         {
             var db = new GenericDatabaseSource(null, conn, null);
             return(db);
         }
     }
     if (DbFile != null)
     {
         string fn;
         if (DbFile.StartsWith("data:"))
         {
             fn = Path.Combine(Core.DataDirectory, DbFile.Substring(5));
         }
         else
         {
             fn = DbFile;
         }
         if (fn.ToLower().EndsWith(".con"))
         {
             var doc = new XmlDocument();
             doc.Load(fn);
             var sc   = (IStoredConnection)StoredConnectionAddonType.Instance.LoadAddon(doc.DocumentElement);
             var conn = sc.CreatePhysicalConnection();
             if (sc.DatabaseMode == ConnectionDatabaseMode.All)
             {
                 if (Database == null)
                 {
                     throw new CommandLineError("DAE-00267 database parameter missing");
                 }
                 var srv = new GenericServerSource(conn);
                 var db  = new GenericDatabaseSource(srv, conn, Database);
                 return(db);
             }
             else
             {
                 return(new GenericDatabaseSource(null, conn, null));
             }
         }
         foreach (var hld in FileHandlerAddonType.Instance.CommonSpace.GetAllAddons())
         {
             IFileHandler hnd = FileHandlerAddonType.FindFileHandler(new DiskFile(fn), han => han.Caps.OpenDatabase);
             if (hnd != null)
             {
                 return(hnd.OpenDatabase());
             }
         }
         throw new CommandLineError("DAE-00268 Not registered dbfile extension, file must have extension .con, or one of listed in command \"daci list dbfilehandler\"");
     }
     throw new CommandLineError("DAE-00269 You must provide one of driver or dbfile parameters");
 }