Ejemplo n.º 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;
     }
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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);
        }