TransPublication 클래스
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
거래적 출판물을 대표합니다.
public ref class TransPublication sealed : Microsoft::SqlServer::Replication::Publication
public sealed class TransPublication : Microsoft.SqlServer.Replication.Publication
type TransPublication = class
inherit Publication
Public NotInheritable Class TransPublication
Inherits Publication
- 상속
예제
이 예시는 트랜잭션 출판물을 생성합니다.
// Set the Publisher, publication database, and publication names.
string publicationName = "AdvWorksProductTran";
string publicationDbName = "AdventureWorks2012";
string publisherName = publisherInstance;
ReplicationDatabase publicationDb;
TransPublication publication;
// Create a connection to the Publisher using Windows Authentication.
ServerConnection conn;
conn = new ServerConnection(publisherName);
try
{
// Connect to the Publisher.
conn.Connect();
// Enable the AdventureWorks2012 database for transactional publishing.
publicationDb = new ReplicationDatabase(publicationDbName, conn);
// If the database exists and is not already enabled,
// enable it for transactional publishing.
if (publicationDb.LoadProperties())
{
if (!publicationDb.EnabledTransPublishing)
{
publicationDb.EnabledTransPublishing = true;
}
// If the Log Reader Agent does not exist, create it.
if (!publicationDb.LogReaderAgentExists)
{
// Specify the Windows account under which the agent job runs.
// This account will be used for the local connection to the
// Distributor and all agent connections that use Windows Authentication.
publicationDb.LogReaderAgentProcessSecurity.Login = winLogin;
publicationDb.LogReaderAgentProcessSecurity.Password = winPassword;
// Explicitly set authentication mode for the Publisher connection
// to the default value of Windows Authentication.
publicationDb.LogReaderAgentPublisherSecurity.WindowsAuthentication = true;
// Create the Log Reader Agent job.
publicationDb.CreateLogReaderAgent();
}
}
else
{
throw new ApplicationException(String.Format(
"The {0} database does not exist at {1}.",
publicationDb, publisherName));
}
// Set the required properties for the transactional publication.
publication = new TransPublication();
publication.ConnectionContext = conn;
publication.Name = publicationName;
publication.DatabaseName = publicationDbName;
// Specify a transactional publication (the default).
publication.Type = PublicationType.Transactional;
// Activate the publication so that we can add subscriptions.
publication.Status = State.Active;
// Enable push and pull subscriptions and independent Distribition Agents.
publication.Attributes |= PublicationAttributes.AllowPull;
publication.Attributes |= PublicationAttributes.AllowPush;
publication.Attributes |= PublicationAttributes.IndependentAgent;
// Specify the Windows account under which the Snapshot Agent job runs.
// This account will be used for the local connection to the
// Distributor and all agent connections that use Windows Authentication.
publication.SnapshotGenerationAgentProcessSecurity.Login = winLogin;
publication.SnapshotGenerationAgentProcessSecurity.Password = winPassword;
// Explicitly set the security mode for the Publisher connection
// Windows Authentication (the default).
publication.SnapshotGenerationAgentPublisherSecurity.WindowsAuthentication = true;
if (!publication.IsExistingObject)
{
// Create the transactional publication.
publication.Create();
// Create a Snapshot Agent job for the publication.
publication.CreateSnapshotAgent();
}
else
{
throw new ApplicationException(String.Format(
"The {0} publication already exists.", publicationName));
}
}
catch (Exception ex)
{
// Implement custom application error handling here.
throw new ApplicationException(String.Format(
"The publication {0} could not be created.", publicationName), ex);
}
finally
{
conn.Disconnect();
}
' Set the Publisher, publication database, and publication names.
Dim publicationName As String = "AdvWorksProductTran"
Dim publicationDbName As String = "AdventureWorks2012"
Dim publisherName As String = publisherInstance
Dim publicationDb As ReplicationDatabase
Dim publication As TransPublication
' Create a connection to the Publisher using Windows Authentication.
Dim conn As ServerConnection
conn = New ServerConnection(publisherName)
Try
' Connect to the Publisher.
conn.Connect()
' Enable the AdventureWorks2012 database for transactional publishing.
publicationDb = New ReplicationDatabase(publicationDbName, conn)
' If the database exists and is not already enabled,
' enable it for transactional publishing.
If publicationDb.LoadProperties() Then
If Not publicationDb.EnabledTransPublishing Then
publicationDb.EnabledTransPublishing = True
End If
' If the Log Reader Agent does not exist, create it.
If Not publicationDb.LogReaderAgentExists Then
' Specify the Windows account under which the agent job runs.
' This account will be used for the local connection to the
' Distributor and all agent connections that use Windows Authentication.
publicationDb.LogReaderAgentProcessSecurity.Login = winLogin
publicationDb.LogReaderAgentProcessSecurity.Password = winPassword
' Explicitly set authentication mode for the Publisher connection
' to the default value of Windows Authentication.
publicationDb.LogReaderAgentPublisherSecurity.WindowsAuthentication = True
' Create the Log Reader Agent job.
publicationDb.CreateLogReaderAgent()
End If
Else
Throw New ApplicationException(String.Format( _
"The {0} database does not exist at {1}.", _
publicationDb, publisherName))
End If
' Set the required properties for the transactional publication.
publication = New TransPublication()
publication.ConnectionContext = conn
publication.Name = publicationName
publication.DatabaseName = publicationDbName
' Specify a transactional publication (the default).
publication.Type = PublicationType.Transactional
'Enable push and pull subscriptions and independent Distribition Agents.
publication.Attributes = _
publication.Attributes Or PublicationAttributes.AllowPull
publication.Attributes = _
publication.Attributes Or PublicationAttributes.AllowPush
publication.Attributes = _
publication.Attributes Or PublicationAttributes.IndependentAgent
' Activate the publication so that we can add subscriptions.
publication.Status = State.Active
' Specify the Windows account under which the Snapshot Agent job runs.
' This account will be used for the local connection to the
' Distributor and all agent connections that use Windows Authentication.
publication.SnapshotGenerationAgentProcessSecurity.Login = winLogin
publication.SnapshotGenerationAgentProcessSecurity.Password = winPassword
' Explicitly set the security mode for the Publisher connection
' Windows Authentication (the default).
publication.SnapshotGenerationAgentPublisherSecurity.WindowsAuthentication = True
If Not publication.IsExistingObject Then
' Create the transactional publication.
publication.Create()
' Create a Snapshot Agent job for the publication.
publication.CreateSnapshotAgent()
Else
Throw New ApplicationException(String.Format( _
"The {0} publication already exists.", publicationName))
End If
Catch ex As Exception
' Implement custom application error handling here.
Throw New ApplicationException(String.Format( _
"The publication {0} could not be created.", publicationName), ex)
Finally
conn.Disconnect()
End Try
이 예시는 트랜잭션 출판물을 삭제합니다.
// Define the Publisher, publication database,
// and publication names.
string publisherName = publisherInstance;
string publicationName = "AdvWorksProductTran";
string publicationDbName = "AdventureWorks2012";
TransPublication publication;
ReplicationDatabase publicationDb;
// Create a connection to the Publisher
// using Windows Authentication.
ServerConnection conn = new ServerConnection(publisherName);
try
{
conn.Connect();
// Set the required properties for the transactional publication.
publication = new TransPublication();
publication.ConnectionContext = conn;
publication.Name = publicationName;
publication.DatabaseName = publicationDbName;
// Delete the publication, if it exists and has no subscriptions.
if (publication.LoadProperties() && !publication.HasSubscription)
{
publication.Remove();
}
else
{
// Do something here if the publication does not exist
// or has subscriptions.
throw new ApplicationException(String.Format(
"The publication {0} could not be deleted. " +
"Ensure that the publication exists and that all " +
"subscriptions have been deleted.",
publicationName, publisherName));
}
// If no other transactional publications exists,
// disable publishing on the database.
publicationDb = new ReplicationDatabase(publicationDbName, conn);
if (publicationDb.LoadProperties())
{
if (publicationDb.TransPublications.Count == 0)
{
publicationDb.EnabledTransPublishing = false;
}
}
else
{
// Do something here if the database does not exist.
throw new ApplicationException(String.Format(
"The database {0} does not exist on {1}.",
publicationDbName, publisherName));
}
}
catch (Exception ex)
{
// Implement application error handling here.
throw new ApplicationException(String.Format(
"The publication {0} could not be deleted.",
publicationName), ex);
}
finally
{
conn.Disconnect();
}
' Define the Publisher, publication database,
' and publication names.
Dim publisherName As String = publisherInstance
Dim publicationName As String = "AdvWorksProductTran"
Dim publicationDbName As String = "AdventureWorks2012"
Dim publication As TransPublication
Dim publicationDb As ReplicationDatabase
' Create a connection to the Publisher
' using Windows Authentication.
Dim conn As ServerConnection = New ServerConnection(publisherName)
Try
conn.Connect()
' Set the required properties for the transactional publication.
publication = New TransPublication()
publication.ConnectionContext = conn
publication.Name = publicationName
publication.DatabaseName = publicationDbName
' Delete the publication, if it exists and has no subscriptions.
If publication.LoadProperties() And Not publication.HasSubscription Then
publication.Remove()
Else
' Do something here if the publication does not exist
' or has subscriptions.
Throw New ApplicationException(String.Format( _
"The publication {0} could not be deleted. " + _
"Ensure that the publication exists and that all " + _
"subscriptions have been deleted.", _
publicationName, publisherName))
End If
' If no other transactional publications exists,
' disable publishing on the database.
publicationDb = New ReplicationDatabase(publicationDbName, conn)
If publicationDb.LoadProperties() Then
If publicationDb.TransPublications.Count = 0 Then
publicationDb.EnabledTransPublishing = False
End If
Else
' Do something here if the database does not exist.
Throw New ApplicationException(String.Format( _
"The database {0} does not exist on {1}.", _
publicationDbName, publisherName))
End If
Catch ex As Exception
' Implement application error handling here.
Throw New ApplicationException(String.Format( _
"The publication {0} could not be deleted.", _
publicationName), ex)
Finally
conn.Disconnect()
End Try
설명
스레드 안전성
이 유형의 공용 정적(SharedMicrosoft Visual Basic) 멤버는 멀티스레드 연산에 안전합니다. 모든 인스턴스 멤버는 스레드로부터 안전하게 보호되지 않습니다.
생성자
| Name | Description |
|---|---|
| TransPublication() |
TransPublication 클래스의 새 인스턴스를 만듭니다. |
| TransPublication(String, String, ServerConnection, Boolean) |
필요한 속성을 가진 클래스의 TransPublication 새 인스턴스를 생성하고, 출판물에 대한 스냅샷 에이전트 작업이 생성되었는지 여부를 나타냅니다. |
| TransPublication(String, String, ServerConnection) |
필요한 속성을 가진 클래스의 TransPublication 새로운 인스턴스를 생성합니다. |
속성
| Name | Description |
|---|---|
| AltSnapshotFolder |
출판물의 대체 스냅샷 파일 위치를 얻거나 설정합니다. (다음에서 상속됨 Publication) |
| Attributes |
출판 속성을 얻거나 설정합니다. (다음에서 상속됨 Publication) |
| CachePropertyChanges |
복제 속성에 가해진 변경 사항을 캐시할지 즉시 적용할지 또는 설정합니다. (다음에서 상속됨 ReplicationObject) |
| CompatibilityLevel |
참조된 출판물이 지원할 수 있는 구독자에서 실행 중인 Microsoft SQL Server의 가장 초기 버전을 받거나 설정합니다. (다음에서 상속됨 Publication) |
| ConflictPolicy |
구독 업데이트 지원을 하는 출판물의 충돌 정책을 수립하거나 설정합니다. |
| ConflictRetention |
충돌 데이터 행이 충돌 테이블에 보존되는 일수를 얻거나 설정합니다. (다음에서 상속됨 Publication) |
| ConnectionContext |
Microsoft SQL Server 인스턴스에 연결을 받거나 설정합니다. (다음에서 상속됨 ReplicationObject) |
| ContinueOnConflict |
충돌이 검색된 후 배포 에이전트에서 변경 내용을 계속 처리할지 여부를 결정합니다. |
| CreateSnapshotAgentByDefault |
출판물이 생성될 때 자동으로 스냅샷 에이전트 작업이 추가될 경우 받거나 설정합니다. (다음에서 상속됨 Publication) |
| DatabaseName |
출판 데이터베이스의 이름을 얻거나 설정합니다. (다음에서 상속됨 Publication) |
| Description |
출판물에 대한 텍스트 설명을 받거나 설정합니다. (다음에서 상속됨 Publication) |
| FtpAddress |
FTP를 통한 구독 초기화가 가능한 출판물에 대해 파일 전송 프로토콜(FTP) 서버 컴퓨터의 주소를 받거나 설정합니다. (다음에서 상속됨 Publication) |
| FtpLogin |
FTP를 통한 구독 초기화가 가능한 출판물에 대해 파일 전송 프로토콜(FTP) 서버에 연결하는 데 사용되는 로그인 정보를 받거나 설정합니다. (다음에서 상속됨 Publication) |
| FtpPassword |
FTP를 통한 구독 초기화가 가능한 출판물의 파일 전송 프로토콜(FTP) 서버에 연결하는 데 사용되는 로그인 비밀번호를 설정합니다. (다음에서 상속됨 Publication) |
| FtpPort |
FTP를 통한 구독 초기화가 가능한 출판물에 대해 파일 전송 프로토콜(FTP) 서버 컴퓨터의 포트를 획득하거나 설정합니다. (다음에서 상속됨 Publication) |
| FtpSubdirectory |
FTP를 통한 구독 초기화가 가능한 출판물에 대해 파일 전송 프로토콜(FTP) 서버에서 하위 디렉터리를 받거나 설정합니다. (다음에서 상속됨 Publication) |
| HasSubscription |
출판물이 하나 이상의 구독자가 있는지 확인합니다. (다음에서 상속됨 Publication) |
| IsExistingObject |
서버에 객체가 존재하는지 여부를 확인합니다. (다음에서 상속됨 ReplicationObject) |
| Name |
출판물의 이름을 얻거나 정하는 역할. (다음에서 상속됨 Publication) |
| PeerConflictDetectionEnabled |
피어 투 피어 충돌 감지가 .을 사용하여 SetPeerConflictDetection(Boolean, Int32)활성화되었는지 확인합니다. |
| PeerOriginatorID |
피어 투 피어 토폴로지에서 노드의 ID를 얻습니다; 이 ID는 가 로 설정 |
| PostSnapshotScript |
초기 스냅샷이 구독자에게 적용된 후 실행되는 Transact-SQL 스크립트 파일의 이름과 전체 경로를 받거나 설정합니다. (다음에서 상속됨 Publication) |
| PreSnapshotScript |
초기 스냅샷이 Subscriber에게 적용되기 전에 실행되는 Transact-SQL 스크립트 파일의 이름과 전체 경로를 받거나 설정합니다. (다음에서 상속됨 Publication) |
| PubId |
출판물을 고유하게 식별하는 값을 얻습니다. (다음에서 상속됨 Publication) |
| PublisherName |
비SQL Server Publisher 이름이나 이름을 설정합니다. |
| QueueType |
구독이 가능한 출판물에 사용할 큐 유형을 받거나 설정합니다. |
| ReplicateDdl |
데이터 정의 언어(DDL) 복제 옵션을 받거나 설정하여 DDL 변경 사항이 복제되는지 결정합니다. (다음에서 상속됨 Publication) |
| RetentionPeriod |
구독이 출판물과 동기화되지 않을 때 구독이 만료되기 전까지 걸리는 시간을 설정합니다. (다음에서 상속됨 Publication) |
| SecureFtpPassword |
FTP를 통한 구독 초기화를 허용하는 출판물에 로그인할 때 로그인 비밀번호( SecureString 객체로서)를 설정합니다. (다음에서 상속됨 Publication) |
| SnapshotAgentExists |
SQL Server 에이전트 작업이 존재하는지 확인하여 이 출판물의 초기 스냅샷을 생성합니다. (다음에서 상속됨 Publication) |
| SnapshotAvailable |
이 출판물의 스냅샷 파일이 사용 가능한지 여부를 확인합니다. |
| SnapshotGenerationAgentProcessSecurity |
스냅샷 에이전트 작업이 실행되는 Windows 계정을 설정하는 객체를 받습니다. (다음에서 상속됨 Publication) |
| SnapshotGenerationAgentPublisherSecurity |
스냅샷 에이전트가 Publisher에 연결할 때 사용하는 보안 컨텍스트를 얻습니다. (다음에서 상속됨 Publication) |
| SnapshotJobId |
현재 출판물의 스냅샷 에이전트 작업 ID를 받습니다. (다음에서 상속됨 Publication) |
| SnapshotMethod |
초기 스냅샷의 데이터 파일 형식을 받거나 설정합니다. (다음에서 상속됨 Publication) |
| SnapshotSchedule |
현재 퍼블리시드의 스냅샷 에이전트 스케줄을 설정하는 객체를 받습니다. (다음에서 상속됨 Publication) |
| SqlServerName |
이 객체가 연결된 Microsoft SQL Server 인스턴스의 이름을 얻습니다. (다음에서 상속됨 ReplicationObject) |
| Status |
출판물의 상태를 획득하거나 설정합니다. (다음에서 상속됨 Publication) |
| TransArticles |
출판물에 실린 기사들을 대표합니다. |
| TransSubscriptions |
출판물 구독을 대표합니다. |
| Type |
출판물 유형을 받거나 정합니다. (다음에서 상속됨 Publication) |
| UserData |
사용자가 자신의 데이터를 객체에 부착할 수 있도록 객체 속성을 얻거나 설정합니다. (다음에서 상속됨 ReplicationObject) |