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


C# Subscriber.Start方法代码示例

本文整理汇总了C#中Subscriber.Start方法的典型用法代码示例。如果您正苦于以下问题:C# Subscriber.Start方法的具体用法?C# Subscriber.Start怎么用?C# Subscriber.Start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Subscriber的用法示例。


在下文中一共展示了Subscriber.Start方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: buttonValidate


//.........这里部分代码省略.........
                    rate2 = rates[3];
                }

            // calculate cost from assigned rates by checking cross referencing start/end times with on/off peak times
            if ((IsTimeOfDayBetween(startTime, onpeak, offpeak)) && (IsTimeOfDayBetween(endTime, offpeak, onpeak)))
            {
                double beforePeak = Convert.ToDouble(offpeak.Hours - startTime.TimeOfDay.Hours);
                TravelCost += beforePeak * rate1;
                double afterPeak = Convert.ToDouble(endTime.TimeOfDay.Hours - offpeak.Hours);
                TravelCost += afterPeak * rate2;
            }
            else
                if ((IsTimeOfDayBetween(startTime, offpeak, onpeak)) && (IsTimeOfDayBetween(endTime, onpeak, offpeak)))
                {
                    double beforePeak = Convert.ToDouble(offpeak.Hours - startTime.TimeOfDay.Hours);
                    TravelCost += beforePeak * rate2;
                    double afterPeak = Convert.ToDouble(endTime.TimeOfDay.Hours - offpeak.Hours);
                    TravelCost += afterPeak * rate1;
                }
                else
                    if ((IsTimeOfDayBetween(startTime, onpeak, offpeak)) && (IsTimeOfDayBetween(endTime, onpeak, offpeak)))
                    {
                        TravelCost += destTime * rate1;
                    }
                    else
                        TravelCost += destTime * rate2;
            #endregion
            //
            // Price calculation logic
            //
            #region Message Queue
            connectionFactory = new ConnectionFactory(BROKER, CLIENT_ID);
            connection = connectionFactory.CreateConnection();
            connection.Start();
            session = connection.CreateSession();
            subscriber = new Subscriber(session, TOPIC_NAME);
            subscriber.Start(CONSUMER_ID);
            subscriber.OnMessageReceived += new MessageReceivedDelegate(subscriber_OnMessageReceived);

            using (var publisher = new Publisher(session, TOPIC_NAME))
            {
                publisher.SendMessage(TravelCost.ToString());
            }

            Thread.Sleep(1000);
            try
            {
                subscriber.Dispose();
                session.Close();
                session.Dispose();
                connection.Stop();
                connection.Close();
                connection.Dispose();
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message.ToString();
            }

            #endregion
            //
            // Rebate Processor
            //
            #region Rebate Processor
            // Fetch membership class
            conn.Open();
开发者ID:nathard,项目名称:TruckHire,代码行数:67,代码来源:Default.aspx.cs


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