Exportar (0) Imprimir
Expandir todo

Clase MergePullSubscription

Represents a pull subscription to a merge publication.

Espacio de nombres:  Microsoft.SqlServer.Replication
Ensamblado:  Microsoft.SqlServer.Rmo (en Microsoft.SqlServer.Rmo.dll)

public sealed class MergePullSubscription : PullSubscription

El tipo MergePullSubscription expone los siguientes miembros.

  NombreDescripción
Método públicoMergePullSubscription()()()()Creates a new instance of the MergePullSubscription class.
Método públicoMergePullSubscription(String, String, String, String, ServerConnection)Creates a new instance of the MergePullSubscription class with the specified database, Publisher, publication, and Subscriber connection.
Método públicoMergePullSubscription(String, String, String, String, ServerConnection, Boolean)Creates a new instance of the MergePullSubscription class with the specified database, Publisher, publication, Subscriber connection, and whether the agent job is created.
Arriba

  NombreDescripción
Propiedad públicaAgentJobIdGets the ID of the agent job used to synchronize the subscription. (Se hereda de PullSubscription.)
Propiedad públicaAgentOffloadGets or sets whether or not the Synchronization Agent runs on a computer other than the one where the agent job was created. This property is no longer supported for Distributors running Microsoft SQL Server 2005 and later. (Se hereda de PullSubscription.)
Propiedad públicaAgentOffloadServerGets or sets the name of the remote computer where the agent runs when using remote agent activation. (Se hereda de PullSubscription.)
Propiedad públicaAgentScheduleGets the schedule for the agent job used to synchronize the subscription. (Se hereda de PullSubscription.)
Propiedad públicaAltSnapshotFolderGets or sets the location where the publication snapshot files are obtained when the default snapshot location at the Distributor is not used. (Se hereda de PullSubscription.)
Propiedad públicaCachePropertyChangesGets or sets whether to cache changes made to the replication properties or to apply them immediately. (Se hereda de ReplicationObject.)
Propiedad públicaConnectionContextGets or sets the connection to an instance of Microsoft SQL Server. (Se hereda de ReplicationObject.)
Propiedad públicaCreateSyncAgentByDefaultGets or sets whether or not the agent job used to start the Replication Agent to synchronize the subscription is created when the subscription is created. (Se hereda de PullSubscription.)
Propiedad públicaDatabaseNameGets or sets the name of the subscription database. (Se hereda de PullSubscription.)
Propiedad públicaDescriptionGets or sets a textual description of the pull subscription. (Se hereda de PullSubscription.)
Propiedad públicaDistributorNameGets or sets the instance of Microsoft SQL Server that is the Distributor and is distributing the publication to which the subscription subscribes. (Se hereda de PullSubscription.)
Propiedad públicaDistributorSecurityGets the security context used to connect to the Distributor. (Se hereda de PullSubscription.)
Propiedad públicaDynamicSnapshotLocationGets or sets the file location for the subscription-specific snapshot files when the publication uses a parameterized row filter.
Propiedad públicaEnabledForSynchronizationManagerSpecifies whether or not the subscription can be synchronized using Windows Synchronization Manager. (Se hereda de PullSubscription.)
Propiedad públicaFtpAddressInfraestructura. (Se hereda de PullSubscription.)
Propiedad públicaFtpLoginInfraestructura. (Se hereda de PullSubscription.)
Propiedad públicaFtpPasswordInfraestructura. (Se hereda de PullSubscription.)
Propiedad públicaFtpPortInfraestructura. (Se hereda de PullSubscription.)
Propiedad públicaHostNameGets or sets the value supplied to the HOST_NAME function when this function is used in the parameterized row filter that defines the Subscriber's data partition.
Propiedad públicaInternetLoginGets or sets the login used with HTTP Basic Authentication when connecting to the Web server during Web synchronization.
Propiedad públicaInternetPasswordGets or sets the password for the supplied InternetLogin value when connecting to the Web server during Web synchronization.
Propiedad públicaInternetSecurityModeGets or sets the HTTP authentication method used when connecting to the Web server during Web synchronization.
Propiedad públicaInternetTimeoutGets or sets the HTTP timeout, in seconds, when connecting to the Web server during Web synchronization.
Propiedad públicaInternetUrlGets or sets the URL to use when synchronizing the subscription using Web synchronization.
Propiedad públicaIsExistingObjectGets whether the object exists on the server or not. (Se hereda de ReplicationObject.)
Propiedad públicaLastAgentDateTimeGets the date and time when the subscription was last synchronized. (Se hereda de PullSubscription.)
Propiedad públicaLastAgentStatusGets the status of the most recent synchronization of the subscription. (Se hereda de PullSubscription.)
Propiedad públicaLastAgentSummaryGets a summary of the result of the most recent synchronization of the subscription. (Se hereda de PullSubscription.)
Propiedad públicaNameGets the name generated for the pull subscription. (Se hereda de PullSubscription.)
Propiedad públicaPriorityGets or sets the weighting of this server subscription relative to other server subscriptions when resolving conflicts between subscriptions.
Propiedad públicaPublicationDBNameGets or sets the name of the publication database. (Se hereda de PullSubscription.)
Propiedad públicaPublicationNameGets or sets the name of the publication to which the subscription subscribes. (Se hereda de PullSubscription.)
Propiedad públicaPublisherNameGets or sets the name of the Publisher. (Se hereda de PullSubscription.)
Propiedad públicaPublisherSecurityGets or sets the security context used by the Synchronization Agent when connecting to the Publisher. (Se hereda de PullSubscription.)
Propiedad públicaSecureFtpPasswordInfraestructura. (Se hereda de PullSubscription.)
Propiedad públicaSecureInternetPasswordSets the password (as a SecureString object) used when connecting to the Web server using HTTP Basic Authentication.
Propiedad públicaSqlServerNameGets the name of the Microsoft SQL Server instance to which this object is connected. (Se hereda de ReplicationObject.)
Propiedad públicaSubscriberSecurityGets the security context that is used by the Synchronization Agent when connecting to the Subscriber. (Se hereda de PullSubscription.)
Propiedad públicaSubscriberTypeGets or sets whether the subscription is a server or client subscription.
Propiedad públicaSubscriptionIdGets the subscription ID value. (Se hereda de PullSubscription.)
Propiedad públicaSubscriptionTypeGets whether the subscription registration is for a push, pull, or anonymous subscription. (Se hereda de PullSubscription.)
Propiedad públicaSynchronizationAgentGets an object that represents an instance of the Merge Agent that can be used to synchronize the subscription.
Propiedad públicaSynchronizationAgentProcessSecurityGets the security context that is used to specify the Microsoft Windows account under which the Synchronization Agent job runs to synchronize the subscription. (Se hereda de PullSubscription.)
Propiedad públicaSyncTypeGets or sets the manner in which data is initialized at the Subscriber.
Propiedad públicaTypeInfraestructura. (Se hereda de PullSubscription.)
Propiedad públicaUseFtpGets or sets whether or not the snapshot files needed to initialize the pull subscription are accessed by the Synchronization Agent using File Transfer Protocol (FTP). (Se hereda de PullSubscription.)
Propiedad públicaUseInteractiveResolverGets or sets whether the Interactive Resolver is used during the synchronization process.
Propiedad públicaUserDataGets or sets an object property that allows users to attach their own data to the object. (Se hereda de ReplicationObject.)
Propiedad públicaUseWebSynchronizationGets or sets whether the subscription is synchronized using Web synchronization.
Propiedad públicaWorkingDirectoryGets or sets the path of the directory at the Subscriber that is used to temporarily store and decompress downloaded snapshot files. (Se hereda de PullSubscription.)
Arriba

  NombreDescripción
Método protegidoCheckValidCreationInfraestructura. (Se hereda de ReplicationObject.)
Método protegidoCheckValidDefinitionInfraestructura. (Se hereda de PullSubscription.)
Método públicoCommitPropertyChangesSends all the cached property change statements to the instance of Microsoft SQL Server. (Se hereda de ReplicationObject.)
Método públicoCreateCreates the pull subscription on the Subscriber. (Se hereda de PullSubscription.)
Método protegidoCustomEnabledForSyncMgrInfraestructura. (Se hereda de PullSubscription.)
Método públicoDecoupleDecouples the referenced replication object from the server. (Se hereda de ReplicationObject.)
Método públicoEnumSynchronizationPartnersReturns the Alternate Synchronization Partners
Método públicoEquals (Se hereda de Object.)
Método protegidoFinalize (Se hereda de Object.)
Método protegidoGetChangeCommandInfraestructura. (Se hereda de ReplicationObject.)
Método protegidoGetCreateCommandInfraestructura. (Se hereda de ReplicationObject.)
Método protegidoGetDropCommandInfraestructura. (Se hereda de ReplicationObject.)
Método públicoGetHashCode (Se hereda de Object.)
Método públicoGetType (Se hereda de Object.)
Método protegidoInitMemberVariablesInfraestructura. (Se hereda de PullSubscription.)
Método protegidoInternalRefreshInfraestructura. (Se hereda de ReplicationObject.)
Método públicoLastAgentJobHistoryInfoReturns information on the last Synchronization Agent job that was run. (Se hereda de PullSubscription.)
Método públicoLoadLoads the properties of an existing object from the server. (Se hereda de ReplicationObject.)
Método públicoLoadPropertiesLoads the properties of an existing object from the server. (Se hereda de ReplicationObject.)
Método protegidoMemberwiseClone (Se hereda de Object.)
Método públicoRefreshReloads the properties of the object. (Se hereda de ReplicationObject.)
Método públicoReinitializeMarks the merge pull subscription for reinitialization.
Método públicoRemoveRemoves the pull subscription. (Se hereda de PullSubscription.)
Método públicoScriptReturns a Transact-SQL script to create or delete the pull subscription based on the current property setting of the PullSubscription object. (Se hereda de PullSubscription.)
Método públicoStopSynchronizationJobAttempts to stop a running Merge Agent job that is currently synchronizing the subscription. (Invalida PullSubscription..::..StopSynchronizationJob()()()().)
Método públicoSynchronizeWithJobStarts the agent job asynchronously to synchronize the pull subscription. (Invalida PullSubscription..::..SynchronizeWithJob()()()().)
Método públicoToString (Se hereda de Object.)
Arriba

For a pull subscription, the Merge Agent runs at the Subscriber.

This namespace, class, or member is supported only in version 2.0 of the Microsoft .NET Framework.

Thread Safety

Any public static (Shared in Microsoft Visual Basic) members of this type are safe for multithreaded operations. Any instance members are not guaranteed to be thread safe.

			// Define the Publisher, publication, and databases.
			string publicationName = "AdvWorksSalesOrdersMerge";
			string publisherName = publisherInstance;
			string subscriberName = subscriberInstance;
            string subscriptionDbName = "AdventureWorks2008R2Replica";
            string publicationDbName = "AdventureWorks2008R2";
			string hostname = @"adventure-works\garrett1";

			//Create connections to the Publisher and Subscriber.
			ServerConnection subscriberConn = new ServerConnection(subscriberName);
			ServerConnection publisherConn = new ServerConnection(publisherName);

			// Create the objects that we need.
			MergePublication publication;
			MergePullSubscription subscription;

			try
			{
				// Connect to the Subscriber.
				subscriberConn.Connect();

				// Ensure that the publication exists and that 
				// it supports pull subscriptions.
				publication = new MergePublication();
				publication.Name = publicationName;
				publication.DatabaseName = publicationDbName;
				publication.ConnectionContext = publisherConn;

				if (publication.LoadProperties())
				{
					if ((publication.Attributes & PublicationAttributes.AllowPull) == 0)
					{
						publication.Attributes |= PublicationAttributes.AllowPull;
					}

					// Define the pull subscription.
					subscription = new MergePullSubscription();
					subscription.ConnectionContext = subscriberConn;
					subscription.PublisherName = publisherName;
					subscription.PublicationName = publicationName;
					subscription.PublicationDBName = publicationDbName;
					subscription.DatabaseName = subscriptionDbName;
					subscription.HostName = hostname;

					// Specify the Windows login credentials for the Merge Agent job.
					subscription.SynchronizationAgentProcessSecurity.Login = winLogin;
					subscription.SynchronizationAgentProcessSecurity.Password = winPassword;

					// Make sure that the agent job for the subscription is created.
					subscription.CreateSyncAgentByDefault = true;

					// Create the pull subscription at the Subscriber.
					subscription.Create();

					Boolean registered = false;

					// Verify that the subscription is not already registered.
					foreach (MergeSubscription existing
						in publication.EnumSubscriptions())
					{
						if (existing.SubscriberName == subscriberName
							&& existing.SubscriptionDBName == subscriptionDbName
							&& existing.SubscriptionType == SubscriptionOption.Pull)
						{
							registered = true;
						}
					}
					if (!registered)
					{
						// Register the local subscription with the Publisher.
						publication.MakePullSubscriptionWellKnown(
							subscriberName, subscriptionDbName,
							SubscriptionSyncType.Automatic,
							MergeSubscriberType.Local, 0);
					}
				}
				else
				{
					// Do something here if the publication does not exist.
					throw new ApplicationException(String.Format(
						"The publication '{0}' does not exist on {1}.",
						publicationName, publisherName));
				}
			}
			catch (Exception ex)
			{
				// Implement the appropriate error handling here.
				throw new ApplicationException(String.Format(
					"The subscription to {0} could not be created.", publicationName), ex);
			}
			finally
			{
				subscriberConn.Disconnect();
				publisherConn.Disconnect();
			}


' Define the Publisher, publication, and databases.
Dim publicationName As String = "AdvWorksSalesOrdersMerge"
Dim publisherName As String = publisherInstance
Dim subscriberName As String = subscriberInstance
Dim subscriptionDbName As String = "AdventureWorks2008R2Replica"
Dim publicationDbName As String = "AdventureWorks2008R2"
Dim hostname As String = "adventure-works\garrett1"

'Create connections to the Publisher and Subscriber.
Dim subscriberConn As ServerConnection = New ServerConnection(subscriberName)
Dim publisherConn As ServerConnection = New ServerConnection(publisherName)

' Create the objects that we need.
Dim publication As MergePublication
Dim subscription As MergePullSubscription

Try
    ' Connect to the Subscriber.
    subscriberConn.Connect()

    ' Ensure that the publication exists and that 
    ' it supports pull subscriptions.
    publication = New MergePublication()
    publication.Name = publicationName
    publication.DatabaseName = publicationDbName
    publication.ConnectionContext = publisherConn

    If publication.LoadProperties() Then
        If (publication.Attributes And PublicationAttributes.AllowPull) = 0 Then
            publication.Attributes = publication.Attributes _
            Or PublicationAttributes.AllowPull
        End If

        ' Define the pull subscription.
        subscription = New MergePullSubscription()
        subscription.ConnectionContext = subscriberConn
        subscription.PublisherName = publisherName
        subscription.PublicationName = publicationName
        subscription.PublicationDBName = publicationDbName
        subscription.DatabaseName = subscriptionDbName
        subscription.HostName = hostname

        ' Specify the Windows login credentials for the Merge Agent job.
        subscription.SynchronizationAgentProcessSecurity.Login = winLogin
        subscription.SynchronizationAgentProcessSecurity.Password = winPassword

        ' Make sure that the agent job for the subscription is created.
        subscription.CreateSyncAgentByDefault = True

        ' Create the pull subscription at the Subscriber.
        subscription.Create()

        Dim registered As Boolean = False

        ' Verify that the subscription is not already registered.
        For Each existing As MergeSubscription In _
        publication.EnumSubscriptions()
            If existing.SubscriberName = subscriberName Then
                registered = True
            End If
        Next
        If Not registered Then
            ' Register the local subscription with the Publisher.
            publication.MakePullSubscriptionWellKnown( _
             subscriberName, subscriptionDbName, _
             SubscriptionSyncType.Automatic, _
             MergeSubscriberType.Local, 0)
        End If
    Else
        ' Do something here if the publication does not exist.
        Throw New ApplicationException(String.Format( _
         "The publication '{0}' does not exist on {1}.", _
         publicationName, publisherName))
    End If
Catch ex As Exception
    ' Implement the appropriate error handling here.
    Throw New ApplicationException(String.Format( _
        "The subscription to {0} could not be created.", publicationName), ex)
Finally
    subscriberConn.Disconnect()
    publisherConn.Disconnect()
End Try


Cualquier miembro público static (Shared en Visual Basic) de este tipo es seguro para subprocesos. No se garantiza que los miembros de instancia sean seguros para subprocesos.

Adiciones de comunidad

AGREGAR
Mostrar:
© 2014 Microsoft