本文整理汇总了C#中Subscription.Modify方法的典型用法代码示例。如果您正苦于以下问题:C# Subscription.Modify方法的具体用法?C# Subscription.Modify怎么用?C# Subscription.Modify使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Subscription
的用法示例。
在下文中一共展示了Subscription.Modify方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RecoverSessionContext
/// <summary>
/// Recovers the session context.
/// </summary>
/// <param name="group">The group.</param>
public void RecoverSessionContext(ComDaGroup group)
{
// create a new subscription and copy existing one.
Subscription discardSubscription = group.Subscription;
Subscription subscription = new Subscription();
subscription.DisplayName = discardSubscription.DisplayName;
subscription.PublishingInterval = discardSubscription.PublishingInterval;
subscription.KeepAliveCount = discardSubscription.KeepAliveCount;
subscription.LifetimeCount = discardSubscription.LifetimeCount;
subscription.MaxNotificationsPerPublish = discardSubscription.MaxNotificationsPerPublish;
subscription.Priority = discardSubscription.Priority;
subscription.PublishingEnabled = discardSubscription.PublishingEnabled;
subscription.DisableMonitoredItemCache = discardSubscription.DisableMonitoredItemCache;
try
{
discardSubscription.Dispose();
}
catch (Exception)
{
}
m_session.AddSubscription(subscription);
try
{
// create the initial subscription.
subscription.Create();
// set the keep alive interval to 30 seconds and the the lifetime interval to 5 minutes.
subscription.KeepAliveCount = (uint)((30000 / (int)subscription.CurrentPublishingInterval) + 1);
subscription.LifetimeCount = (uint)((600000 / (int)subscription.CurrentPublishingInterval) + 1);
// update the subscription.
subscription.Modify();
}
catch (Exception e)
{
m_session.RemoveSubscription(subscription);
throw ComUtils.CreateComException(e, ResultIds.E_FAIL);
}
// update the group.
group.ActualUpdateRate = (int)(subscription.CurrentPublishingInterval * 2);
group.Subscription = subscription;
group.RecreateItems();
}
示例2: AddGroup
/// <summary>
/// Adds the group.
/// </summary>
/// <param name="groupName">The group name.</param>
/// <param name="active">if set to <c>true</c> the group is active.</param>
/// <param name="updateRate">The update rate.</param>
/// <param name="clientHandle">The client handle.</param>
/// <param name="timeBias">The time bias.</param>
/// <param name="deadband">The deadband.</param>
/// <param name="lcid">The lcid.</param>
/// <returns>The new group.</returns>
public ComDaGroup AddGroup(
string groupName,
bool active,
int updateRate,
int clientHandle,
int timeBias,
float deadband,
int lcid)
{
TraceState("AddGroup", groupName, active, updateRate, clientHandle, timeBias, deadband, lcid);
// check for valid session.
Session session = m_session;
if (session == null)
{
throw ComUtils.CreateComException(ResultIds.E_FAIL);
}
ComDaGroup group = null;
// check for duplicate name.
lock (m_lock)
{
// ensure the name is unique.
if (!String.IsNullOrEmpty(groupName))
{
if (GetGroupByName(groupName) != null)
{
throw ComUtils.CreateComException(ResultIds.E_DUPLICATENAME);
}
}
// assign a unique name.
else
{
groupName = Utils.Format("Group{0}", m_groupCounter+1);
}
// validate the deadband.
if (deadband < 0 || deadband > 100)
{
throw ComUtils.CreateComException(ResultIds.E_INVALIDARG);
}
// create the group.
group = new ComDaGroup(this, groupName, ++m_groupCounter);
m_groups.Add(group);
group.ClientHandle = clientHandle;
group.Active = active;
group.UpdateRate = updateRate;
group.TimeBias = timeBias;
group.Deadband = deadband;
group.Lcid = lcid;
if (updateRate < 100)
{
updateRate = 100;
}
// create a new subscription.
Subscription subscription = new Subscription();
subscription.DisplayName = groupName;
subscription.PublishingInterval = updateRate/2;
subscription.KeepAliveCount = 30;
subscription.LifetimeCount = 600;
subscription.MaxNotificationsPerPublish = 10000;
subscription.Priority = 1;
subscription.PublishingEnabled = active;
subscription.DisableMonitoredItemCache = true;
// create the subscription on the server.
session.AddSubscription(subscription);
try
{
// create the initial subscription.
subscription.Create();
// set the keep alive interval to 30 seconds and the the lifetime interval to 5 minutes.
subscription.KeepAliveCount = (uint)((30000/(int)subscription.CurrentPublishingInterval)+1);
subscription.LifetimeCount = (uint)((600000/(int)subscription.CurrentPublishingInterval)+1);
// update the subscription.
subscription.Modify();
}
catch (Exception e)
{
//.........这里部分代码省略.........