/// <summary>
        /// Create database task helper
        /// </summary>
        /// <param name="connInfo">connection info</param>
        /// <param name="databaseExists">flag indicating whether to create taskhelper for existing database or not</param>
        /// <returns></returns>
        internal static DatabaseTaskHelper CreateDatabaseTaskHelper(ConnectionInfo connInfo, bool databaseExists = false)
        {
            var dataContainer = CDataContainer.CreateDataContainer(connInfo, databaseExists);
            var taskHelper    = new DatabaseTaskHelper(dataContainer);

            return(taskHelper);
        }
Beispiel #2
0
        internal void Initialize(CDataContainer context)
        {
            if (context != null)
            {
                this.DataContainer = context;
                this.document      = context.Document;

                int     majorVersionNumber = context.Server.Information.Version.Major;
                Version sql2000sp3         = new Version(8, 0, 760);
                Version sql2005sp2         = new Version(9, 0, 3000);

                if (context.Server.DatabaseEngineType == DatabaseEngineType.SqlAzureDatabase)
                {
                    this.prototype = new DatabasePrototypeAzure(context);
                }
                else if (Utils.IsSql11OrLater(context.Server.Version.Major))
                {
                    this.prototype = new DatabasePrototype110(context);
                }
                else if (majorVersionNumber == 10)
                {
                    this.prototype = new DatabasePrototype100(context);
                }
                else if ((sql2005sp2 <= context.Server.Information.Version) &&
                         (context.Server.Information.EngineEdition == Edition.EnterpriseOrDeveloper))
                {
                    this.prototype = new DatabasePrototype90EnterpriseSP2(context);
                }
                else if (8 < majorVersionNumber)
                {
                    this.prototype = new DatabasePrototype90(context);
                }
                else if (sql2000sp3 <= context.Server.Information.Version)
                {
                    this.prototype = new DatabasePrototype80SP3(context);
                }
                else if (7 < majorVersionNumber)
                {
                    this.prototype = new DatabasePrototype80(context);
                }
                else
                {
                    this.prototype = new DatabasePrototype(context);
                }

                this.prototype.Initialize();
            }
            else
            {
                this.DataContainer = null;
                this.document      = null;
                this.prototype     = null;
            }
        }
Beispiel #3
0
        /// <summary>
        /// called to create SqlConnectionInfo out of the given CDataContainer object
        /// </summary>
        /// <param name="dc"></param>
        /// <returns></returns>
        public static SqlConnectionInfo GetSqlConnectionInfoFromDataContainer(CDataContainer dc)
        {
            if (dc != null)
            {
                // we may have been given conneciton information by the object explorer. in which case there is no need
                // to build it ourselves.
                SqlConnectionInfo result = dc.ConnectionInfo as SqlConnectionInfo;
                if (result == null)
                {
                    throw new InvalidOperationException();
                }

                return(result);
            }
            else
            {
                return(null);
            }
        }
Beispiel #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="dataContainer">Data container</param>
        /// <param name="xmlParameters">XML string with parameters</param>
        public CDataContainer(CDataContainer dataContainer, string xmlParameters)
        {
            Server              = dataContainer.Server;
            this.serverName     = dataContainer.serverName;
            this.serverType     = dataContainer.serverType;
            this.connectionInfo = dataContainer.connectionInfo;
            this.ownConnection  = dataContainer.ownConnection;

            this.sqlCiWithConnection = dataContainer.connectionInfo as SqlConnectionInfoWithConnection;
            if (this.sqlCiWithConnection != null)
            {
                //we want to be notified if it is closed
                this.sqlCiWithConnection.ConnectionClosed += new EventHandler(OnSqlConnectionClosed);
            }

            if (xmlParameters != null)
            {
                XmlDocument doc = GenerateXmlDocumentFromString(xmlParameters);
                this.Init(doc);
            }
        }
Beispiel #5
0
        /// <summary>
        /// Create database task helper
        /// </summary>
        /// <param name="connInfo">connection info</param>
        /// <param name="databaseExists">flag indicating whether to create taskhelper for existing database or not</param>
        /// <returns></returns>
        internal static DatabaseTaskHelper CreateDatabaseTaskHelper(ConnectionInfo connInfo, bool databaseExists = false)
        {
            XmlDocument    xmlDoc = CreateDataContainerDocument(connInfo, databaseExists);
            CDataContainer dataContainer;

            // add alternate port to server name property if provided
            var    connectionDetails = connInfo.ConnectionDetails;
            string serverName        = !connectionDetails.Port.HasValue
                ? connectionDetails.ServerName
                : string.Format("{0},{1}", connectionDetails.ServerName, connectionDetails.Port.Value);

            // check if the connection is using SQL Auth or Integrated Auth
            //TODO: ConnectionQueue try to get an existing connection (ConnectionQueue)
            if (string.Equals(connectionDetails.AuthenticationType, "SqlLogin", StringComparison.OrdinalIgnoreCase))
            {
                var passwordSecureString = BuildSecureStringFromPassword(connectionDetails.Password);
                dataContainer = new CDataContainer(
                    CDataContainer.ServerType.SQL,
                    serverName,
                    false,
                    connectionDetails.UserName,
                    passwordSecureString,
                    xmlDoc.InnerXml);
            }
            else
            {
                dataContainer = new CDataContainer(
                    CDataContainer.ServerType.SQL,
                    serverName,
                    true,
                    null,
                    null,
                    xmlDoc.InnerXml);
            }

            var taskHelper = new DatabaseTaskHelper(dataContainer);

            return(taskHelper);
        }
Beispiel #6
0
        /// <summary>
        /// Create database task helper
        /// </summary>
        /// <param name="connInfo">connection info</param>
        /// <param name="databaseExists">flag indicating whether to create taskhelper for existing database or not</param>
        /// <returns></returns>
        internal static DatabaseTaskHelper CreateDatabaseTaskHelper(ConnectionInfo connInfo, bool databaseExists = false)
        {
            XmlDocument    xmlDoc = CreateDataContainerDocument(connInfo, databaseExists);
            CDataContainer dataContainer;

            // check if the connection is using SQL Auth or Integrated Auth
            if (string.Equals(connInfo.ConnectionDetails.AuthenticationType, "SqlLogin", StringComparison.OrdinalIgnoreCase))
            {
                var passwordSecureString = new System.Security.SecureString();
                foreach (char c in connInfo.ConnectionDetails.Password)
                {
                    passwordSecureString.AppendChar(c);
                }
                dataContainer = new CDataContainer(
                    CDataContainer.ServerType.SQL,
                    connInfo.ConnectionDetails.ServerName,
                    false,
                    connInfo.ConnectionDetails.UserName,
                    passwordSecureString,
                    xmlDoc.InnerXml);
            }
            else
            {
                dataContainer = new CDataContainer(
                    CDataContainer.ServerType.SQL,
                    connInfo.ConnectionDetails.ServerName,
                    true,
                    null,
                    null,
                    xmlDoc.InnerXml);
            }

            var taskHelper = new DatabaseTaskHelper(dataContainer);

            return(taskHelper);
        }
 public DatabasePrototypeAzure(CDataContainer context, DatabaseEngineEdition editionToCreate = DatabaseEngineEdition.SqlDatabase)
     : base(context)
 {
     EditionToCreate = editionToCreate;
 }
Beispiel #8
0
 public DatabaseTaskHelper(CDataContainer context)
 {
     Initialize(context);
 }
 public DatabasePrototype80SP3(CDataContainer context) : base(context)
 {
 }
 public DatabasePrototype110(CDataContainer context)
     : base(context)
 {
 }
 public DatabasePrototype90EnterpriseSP2(CDataContainer context) : base(context)
 {
 }