I have followed the instructions listed in this https://msdn.microsoft.com/en-us/library/ms365150.aspx MSDN article but cannot get it working. Can anyone shed some light on how to debug? I have insalled VS 2015 on the subscriber and have the DLL dropped into the C:\Program Files\Microsoft SQL Server\120\COM folder. I have my code listed below
public class ReplicationBusinessLogicModule : BusinessLogicModule
{
private string _PublisherName;
private string _SubscriberName;
private string _ArticleName;
private string _ReplicationTime;
public ReplicationBusinessLogicModule()
{
var sb = new StringBuilder();
sb.AppendLine("-------------------------------------");
sb.AppendLine("In ReplicationBusinessLogicModule: " + DateTime.Now);
sb.AppendLine("-------------------------------------");
sb.AppendLine();
System.IO.File.AppendAllText(@"C:\Temp\ReplicationBusinessLogicModule.txt", sb.ToString());
}
public override void Initialize(string publisher, string subscriber, string distributor, string publisherDB, string subscriberDB, string articleName)
{
_PublisherName = publisher;
_SubscriberName = subscriber;
_ArticleName = articleName;
_ReplicationTime = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss.fffffff", CultureInfo.InvariantCulture);
var sb = new StringBuilder();
sb.AppendLine("-------------------------------------");
sb.AppendLine("In Initialize: " + DateTime.Now);
sb.AppendLine("ArticleName: " + _ArticleName);
sb.AppendLine("-------------------------------------");
sb.AppendLine();
System.IO.File.AppendAllText(@"C:\Temp\ReplicationBusinessLogicModule.txt", sb.ToString());
}
public override ChangeStates HandledChangeStates
{
get
{
return ChangeStates.SubscriberInserts | ChangeStates.SubscriberUpdates | ChangeStates.SubscriberDeletes | ChangeStates.UpdateConflicts |
ChangeStates.PublisherInserts | ChangeStates.PublisherUpdates | ChangeStates.PublisherDeletes;
}
}
public override void CommitHandler(SourceIdentifier source, Guid rowGuid)
{
var sb = new StringBuilder();
sb.AppendLine("-------------------------------------");
sb.AppendLine("In CommitHandler: " + DateTime.Now);
sb.AppendLine("Source: " + source.ToString());
sb.AppendLine("ArticleName: " + _ArticleName);
sb.AppendLine("RowGuid: " + rowGuid.ToString());
sb.AppendLine("-------------------------------------");
System.IO.File.AppendAllText(@"C:\Temp\ReplicationBusinessLogicModule.txt", sb.ToString());
base.CommitHandler(source, rowGuid);
}
public override ActionOnDataChange InsertHandler(SourceIdentifier insertSource, DataSet insertedDataSet, ref DataSet customDataSet, ref int historyLogLevel, ref string historyLogMessage)
{
var sb = new StringBuilder();
sb.AppendLine("-------------------------------------");
sb.AppendLine("In InsertHandler: " + DateTime.Now);
sb.AppendLine("Source: " + insertSource.ToString());
sb.AppendLine("InsertHandler: " + _ArticleName);
sb.AppendLine("-------------------------------------");
System.IO.File.AppendAllText(@"C:\Temp\ReplicationBusinessLogicModule.txt", sb.ToString());
return base.InsertHandler(insertSource, insertedDataSet, ref customDataSet, ref historyLogLevel, ref historyLogMessage);
}
public override ActionOnDataChange UpdateHandler(SourceIdentifier updateSource, DataSet updatedDataSet, ref DataSet customDataSet, ref int historyLogLevel, ref string historyLogMessage)
{
var sb = new StringBuilder();
sb.AppendLine("-------------------------------------");
sb.AppendLine("In UpdateHandler: " + DateTime.Now);
sb.AppendLine("Source: " + updateSource.ToString());
sb.AppendLine("ArticleName: " + _ArticleName);
sb.AppendLine("-------------------------------------");
System.IO.File.AppendAllText(@"C:\Temp\ReplicationBusinessLogicModule.txt", sb.ToString());
customDataSet = updatedDataSet.Copy();
customDataSet.Tables[0].Rows[0]["NVarCharColumn"] = string.Format("Repl({0})", _ReplicationTime);
return ActionOnDataChange.AcceptCustomData;
}
public override ActionOnUpdateConflict UpdateConflictsHandler(DataSet publisherDataSet, DataSet subscriberDataSet, ref DataSet customDataSet, ref ConflictLogType conflictLogType, ref string customConflictMessage, ref int historyLogLevel, ref string historyLogMessage)
{
var sb = new StringBuilder();
sb.AppendLine("-------------------------------------");
sb.AppendLine("In UpdateConflictsHandler: " + DateTime.Now);
sb.AppendLine("ConflictLogType: " + conflictLogType.ToString());
sb.AppendLine("ArticleName: " + _ArticleName);
sb.AppendLine("-------------------------------------");
System.IO.File.AppendAllText(@"C:\Temp\ReplicationBusinessLogicModule.txt", sb.ToString());
return base.UpdateConflictsHandler(publisherDataSet, subscriberDataSet, ref customDataSet, ref conflictLogType, ref customConflictMessage, ref historyLogLevel, ref historyLogMessage);
}
public override ActionOnDataDelete DeleteHandler(SourceIdentifier deleteSource, DataSet deletedDataSet, ref int historyLogLevel, ref string historyLogMessage)
{
var sb = new StringBuilder();
sb.AppendLine("-------------------------------------");
sb.AppendLine("In DeleteHandler: " + DateTime.Now);
sb.AppendLine("Source: " + deleteSource.ToString());
sb.AppendLine("DeleteHandler: " + _ArticleName);
sb.AppendLine("-------------------------------------");
System.IO.File.AppendAllText(@"C:\Temp\ReplicationBusinessLogicModule.txt", sb.ToString());
return base.DeleteHandler(deleteSource, deletedDataSet, ref historyLogLevel, ref historyLogMessage);
}
}