Showing posts with label method. Show all posts
Showing posts with label method. Show all posts

Monday, March 19, 2012

How to detect at the subscriber that a replication is being (re)initialized.

Is there a method/query to discover that the subscriber's databasereplication is being reinitialized?

The problem is that the applications which is connects to this database crashes when the replication is (re)initializing.

Thanx, RalfYou would have to query the tables at the distribution database, this type of info is not stored at the subscriber. You could also try to reinitialize during offpeak hours.

How to detect at the subscriber that a replication is being (re)initialized.

Is there a method/query to discover that the subscriber's databasereplication is being reinitialized?

The problem is that the applications which is connects to this database crashes when the replication is (re)initializing.

Thanx, RalfYou would have to query the tables at the distribution database, this type of info is not stored at the subscriber. You could also try to reinitialize during offpeak hours.

Monday, March 12, 2012

How to deserialize matchData?

Hi,
I am having problems deserializing the matchData variable returned by the
GetSubscriptionProperties() method.
My matchData looks like this:
"<ScheduleDefinition><StartDateTime>2005-04-27T06:00:00.000-05:00</StartDateTime><WeeklyRecurrence><WeeksInterval>1</WeeksInterval><DaysOfWeek><Wednesday>True</Wednesday></DaysOfWeek></WeeklyRecurrence></ScheduleDefinition>"
I found several code snippets from this newsgroup to figure out how to
convert this to a ScheduleDefinition object but everytime, it returns a
startdatetime of 1/1/1 and the "Item" part of the ScheduleDefinition object
is null...
code snippet I am currently using:
private ScheduleDefinition DeserializeObject (string sMatchData)
{
sMatchData MemoryStream vStream = new
MemoryStream(System.Text.Encoding.Default.GetBytes(sMatchData));
XmlAttributes attrs=new XmlAttributes();
attrs.XmlElements.Add(new
XmlElementAttribute("MinuteRecurrence",typeof(MinuteRecurrence)));
attrs.XmlElements.Add(new
XmlElementAttribute("DailyRecurrence",typeof(DailyRecurrence)));
attrs.XmlElements.Add(new
XmlElementAttribute("WeeklyRecurrence",typeof(WeeklyRecurrence)));
attrs.XmlElements.Add(new
XmlElementAttribute("MonthlyRecurrence",typeof(MonthlyRecurrence)));
attrs.XmlElements.Add(new
XmlElementAttribute("MonthlyDOWRecurrence",typeof(MonthlyDOWRecurrence)));
XmlAttributeOverrides attrOver=new XmlAttributeOverrides();
attrOver.Add(typeof(ScheduleDefinition),"ScheduleDefinition",attrs);
XmlSerializer newSr=new XmlSerializer(typeof(ScheduleDefinition),attrOver);
return (ScheduleDefinition)newSr.Deserialize(vStream);
}
Any help would be greatly appreciated... I am using this to display a
schedule on a web page. I can set subscriptions fine but I am having a hard
time reading them back.
I used the following code to set subscriptions and it works fine:
http://www.odetocode.com/Articles/114.aspx
Thanks in advance for any help!Never mind. I got it.
For those who are interested, call DeserializeObject() first.
private XmlAttributeOverrides GetScheduleOverrides ()
{
XmlAttributeOverrides overrides = new XmlAttributeOverrides();
XmlAttributes attrs = new XmlAttributes();
attrs.Xmlns = false;
overrides.Add(typeof(ScheduleDefinition), attrs);
overrides.Add(typeof(MinuteRecurrence), attrs);
overrides.Add(typeof(WeeklyRecurrence), attrs);
overrides.Add(typeof(MonthlyRecurrence), attrs);
overrides.Add(typeof(MonthlyDOWRecurrence), attrs);
overrides.Add(typeof(DaysOfWeekSelector), attrs);
overrides.Add(typeof(MonthsOfYearSelector), attrs);
return overrides;
}
private ScheduleDefinition DeserializeObject (string sMatchData)
{
sMatchData = sMatchData.Replace("True", "true");
Stream stream = new
MemoryStream(System.Text.Encoding.Default.GetBytes(sMatchData));
XmlAttributeOverrides overrides = GetScheduleOverrides();
XmlSerializer ser = new XmlSerializer(typeof(ScheduleDefinition),
overrides);
stream.Position = 0;
return (ScheduleDefinition)ser.Deserialize(stream);
}
"Pierrick" <email@.nospam.com> wrote in message
news:426f60d7$0$1254$8fcfb975@.news.wanadoo.fr...
> Hi,
> I am having problems deserializing the matchData variable returned by the
> GetSubscriptionProperties() method.
> My matchData looks like this:
> "<ScheduleDefinition><StartDateTime>2005-04-27T06:00:00.000-05:00</StartDateTime><WeeklyRecurrence><WeeksInterval>1</WeeksInterval><DaysOfWeek><Wednesday>True</Wednesday></DaysOfWeek></WeeklyRecurrence></ScheduleDefinition>"
> I found several code snippets from this newsgroup to figure out how to
> convert this to a ScheduleDefinition object but everytime, it returns a
> startdatetime of 1/1/1 and the "Item" part of the ScheduleDefinition
> object is null...
> code snippet I am currently using:
> private ScheduleDefinition DeserializeObject (string sMatchData)
> {
> sMatchData MemoryStream vStream = new
> MemoryStream(System.Text.Encoding.Default.GetBytes(sMatchData));
> XmlAttributes attrs=new XmlAttributes();
> attrs.XmlElements.Add(new
> XmlElementAttribute("MinuteRecurrence",typeof(MinuteRecurrence)));
> attrs.XmlElements.Add(new
> XmlElementAttribute("DailyRecurrence",typeof(DailyRecurrence)));
> attrs.XmlElements.Add(new
> XmlElementAttribute("WeeklyRecurrence",typeof(WeeklyRecurrence)));
> attrs.XmlElements.Add(new
> XmlElementAttribute("MonthlyRecurrence",typeof(MonthlyRecurrence)));
> attrs.XmlElements.Add(new
> XmlElementAttribute("MonthlyDOWRecurrence",typeof(MonthlyDOWRecurrence)));
> XmlAttributeOverrides attrOver=new XmlAttributeOverrides();
> attrOver.Add(typeof(ScheduleDefinition),"ScheduleDefinition",attrs);
> XmlSerializer newSr=new
> XmlSerializer(typeof(ScheduleDefinition),attrOver);
> return (ScheduleDefinition)newSr.Deserialize(vStream);
> }
> Any help would be greatly appreciated... I am using this to display a
> schedule on a web page. I can set subscriptions fine but I am having a
> hard time reading them back.
> I used the following code to set subscriptions and it works fine:
> http://www.odetocode.com/Articles/114.aspx
> Thanks in advance for any help!
>