예제 #1
0
 /// <summary>
 /// do the deterministic cleanup
 /// </summary>
 /// <param name="disposing"></param>
 protected virtual void Dispose(bool disposing)
 {
     //dispose CDataContainer if needed
     if (this.dataContainer != null)
     {
         if (this.ownDataContainer)
         {
             this.dataContainer.Dispose();
         }
         this.dataContainer = null;
     }
 }
예제 #2
0
        /// <summary>
        /// Create a data container object
        /// </summary>
        /// <param name="connInfo">connection info</param>
        /// <param name="databaseExists">flag indicating whether to create taskhelper for existing database or not</param>
        internal static CDataContainer CreateDataContainer(
            ConnectionInfo connInfo,
            bool databaseExists      = false,
            XmlDocument containerDoc = null)
        {
            if (containerDoc == null)
            {
                containerDoc = 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,
                    connectionDetails.DatabaseName,
                    containerDoc.InnerXml);
            }
            else
            {
                dataContainer = new CDataContainer(
                    CDataContainer.ServerType.SQL,
                    serverName,
                    true,
                    null,
                    null,
                    connectionDetails.DatabaseName,
                    containerDoc.InnerXml);
            }

            return(dataContainer);
        }
예제 #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);
            }
        }
예제 #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);
            }
        }
예제 #5
0
        /// <summary>
        /// Create a data container object
        /// </summary>
        /// <param name="connInfo">connection info</param>
        /// <param name="databaseExists">flag indicating whether to create taskhelper for existing database or not</param>
        internal static CDataContainer CreateDataContainer(
            ConnectionInfo connInfo,
            bool databaseExists      = false,
            XmlDocument containerDoc = null)
        {
            if (containerDoc == null)
            {
                containerDoc = CreateDataContainerDocument(connInfo, databaseExists);
            }

            var serverConnection = ConnectionService.OpenServerConnection(connInfo, "DataContainer");

            var connectionInfoWithConnection = new SqlConnectionInfoWithConnection();

            connectionInfoWithConnection.ServerConnection = serverConnection;
            CDataContainer dataContainer = new CDataContainer(ServerType.SQL, connectionInfoWithConnection, true);

            dataContainer.Init(containerDoc);

            return(dataContainer);
        }