当前位置: 首页>>代码示例>>C#>>正文


C# Subscription.Modify方法代码示例

本文整理汇总了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();
        }
开发者ID:yuriik83,项目名称:UA-.NET,代码行数:51,代码来源:ComDaGroupManager.cs

示例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)
                {
//.........这里部分代码省略.........
开发者ID:yuriik83,项目名称:UA-.NET,代码行数:101,代码来源:ComDaGroupManager.cs


注:本文中的Subscription.Modify方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。