Beispiel #1
0
        private bool IsScriptRunDeployInfoTablePresent()
        {
            var statement = string.Format(
                @"SELECT Present = Count(*) FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[{0}]') AND type in (N'U')",
                ScriptsRunDeployInfo.GetTableName());

            using (var connection = _configuration.GetConnection())
            {
                return(connection.Query <int>(statement).FirstOrDefault() > 0);
            }
        }
Beispiel #2
0
        private void UpdateScriptInfoWithDeploymentId(ScriptsRunDeployInfo deployInfo, ScriptsRunInfo runInfo)
        {
            var statement = string.Format("update [{0}] set [DeployInfoId] = {1} where [Id] = {2}",
                                          ScriptsRunInfo.GetTableName(),
                                          deployInfo.Id.ToString(),
                                          runInfo.Id.ToString());

            using (var connection = _configuration.GetConnection())
            {
                connection.Execute(statement);
            }
        }
Beispiel #3
0
        private ScriptsRunDeployInfo CreateDeployInfo(CommandPipelineContext context, VersionInfo versionInfo)
        {
            var packageAsZipFile = GetPackageAsZipFileFromLatestDeploymentDirectory(context);

            if (string.IsNullOrEmpty(packageAsZipFile))
            {
                return(null);
            }

            var packageName    = Path.GetFileName(packageAsZipFile);
            var packageContent = File.ReadAllBytes(packageAsZipFile);

            var info = new ScriptsRunDeployInfo
            {
                VersionInfoId        = versionInfo.Id,
                DeployPackageName    = packageName,
                DeployPackageContent = packageContent,
                DeployedOn           = DateTime.Now,
                DeployedBy           = string.Format(@"{0}\{1}",
                                                     Environment.UserDomainName,
                                                     Environment.UserName)
            };

            using (var connection = _configuration.GetConnection())
            {
                var id = connection.Insert <ScriptsRunDeployInfo>(info);
                if (info.Id == 0)
                {
                    info.Id = id;
                }
            }

            if (!string.IsNullOrEmpty(packageAsZipFile))
            {
                Logger.InfoFormat("Package '{0}' recorded as deployed.", Path.GetFileName(packageAsZipFile));
            }

            return(info);
        }
Beispiel #4
0
 private void CheckForScriptsRunDeployInfoTable()
 {
     Logger.InfoFormat("Creating [{0}] table, if it does not exist..", ScriptsRunDeployInfo.GetTableName());
     CreateInfoTable("scriptsrundeployinfo_create.sql");
 }