Galen.Ci.EntityFramework.DeploymentHistory.Create C# (CSharp) Method

Create() public static method

public static Create ( string contextKey, string deployerVersion, string targetAssemblyPath, DbConnection connection, string schemaName ) : void
contextKey string
deployerVersion string
targetAssemblyPath string
connection System.Data.Common.DbConnection
schemaName string
return void
        public static void Create(
            string contextKey,
            string deployerVersion,
            string targetAssemblyPath,
            DbConnection connection,
            string schemaName)
        {
            var targetAssemblyFileInfo = new FileInfo(targetAssemblyPath);

            Stream binariesStream = null;
            Stream hashesStream = null;
            byte[] binaries;
            byte[] hashes;
            try
            {
                GetDeploymentBinaries(targetAssemblyFileInfo.Directory, out binariesStream, out hashesStream);

                binaries = new byte[binariesStream.Length];
                binariesStream.Read(binaries, 0, (int)binariesStream.Length);

                hashes = new byte[hashesStream.Length];
                hashesStream.Read(hashes, 0, (int)hashesStream.Length);
            }
            finally
            {
                binariesStream.SafeDispose();
                hashesStream.SafeDispose();
            }

                var assemblyFileName = targetAssemblyFileInfo.Name;
                Save(contextKey, assemblyFileName, binaries, hashes, deployerVersion, connection, schemaName);
            }

Usage Example

示例#1
0
        private void HandleDeploymentHistory(string schemaName, string contextKey)
        {
            var factory = DbProviderFactories.GetFactory(m_ConnectionInfoBuilder.ProviderName);

            using (var connection = factory.CreateConnection())
            {
                connection.ConnectionString = m_ConnectionInfoBuilder.BuildConnectionString(
                    m_Config.Database,
                    m_Config.AuthMode,
                    m_Config.SqlLogin,
                    m_Config.SqlPassword);

                connection.Open();

                Log.Information(
                    "Creating {contextKey} deployment history in {schemaName} schema " +
                    "on {endPointServer}\\{endpointDatabase} using {targetAssemblyPath}.",
                    contextKey,
                    schemaName,
                    m_Config.Database.ServerName,
                    m_Config.Database.DatabaseName,
                    m_Config.TargetAssemblyPath);

                DeploymentHistory.Create(
                    contextKey,
                    GetVersion().ToString(),
                    m_Config.TargetAssemblyPath,
                    connection,
                    schemaName);

                connection.Close();
            }
        }