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


C# Bus.Connect方法代码示例

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


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

示例1: PublishAsync_Null_Message_Results_In_An_Exception

		public void PublishAsync_Null_Message_Results_In_An_Exception()
		{
			var _busConfigurationBuilder = new BusConfigurationBuilder();
			_busConfigurationBuilder.ConnectionUris.Add(TestingConfiguration.LocalConnectionUri);
			var _busConfirguration = _busConfigurationBuilder.Build();

			var _SUT = new Bus(_busConfirguration);
			_SUT.Connect();

			_SUT.PublishAsync<MyEvent>(null);
		}
开发者ID:pmcgrath,项目名称:PMCG.Messaging,代码行数:11,代码来源:BusSpec.cs

示例2: Status_Connected_And_Then_Closed

		public void Status_Connected_And_Then_Closed()
		{
			var _busConfigurationBuilder = new BusConfigurationBuilder();
			_busConfigurationBuilder.ConnectionUris.Add(TestingConfiguration.LocalConnectionUri);
			var _busConfirguration = _busConfigurationBuilder.Build();

			var _SUT = new Bus(_busConfirguration);

			_SUT.Connect();
			Assert.AreEqual(BusStatus.Connected, _SUT.Status);

			_SUT.Close();
			Assert.AreEqual(BusStatus.Closed, _SUT.Status);
		}
开发者ID:pmcgrath,项目名称:PMCG.Messaging,代码行数:14,代码来源:BusSpec.cs

示例3: switchON

        static void switchON(string _taskguid, string _dtable)
        {
            string _TaskID = string.Empty;
            string _channelGroup = string.Empty;
            string _PillarID = string.Empty;
            string _TaskSubject = string.Empty;
            DateTime _TaskStart = DateTime.Now;
            DateTime _TaskEnd = DateTime.Now;

            using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString))
            {
                string sqlSelect = "SELECT [ID],[ChannelGroup],[PillarID],[Subject],[Start],[End] FROM [db_knx].[dbo].[Scheduler] WHERE [TaskGUID] LIKE N'" + _taskguid + "' AND [Start] = (SELECT MIN([Start]) FROM [db_knx].[dbo].[Scheduler] WHERE [TaskGUID] LIKE N'"+_taskguid+"');";

                conn.Open();

                using (SqlCommand sqlComm = new SqlCommand(sqlSelect, conn))
                {
                    SqlDataReader _dt = sqlComm.ExecuteReader();

                    while (_dt.Read())
                    {
                        _TaskID = _dt["ID"].ToString();
                        _channelGroup = _dt["ChannelGroup"].ToString();
                        _PillarID = _dt["PillarID"].ToString();
                        _TaskSubject = _dt["Subject"].ToString();
                        _TaskStart = (DateTime)_dt["Start"];
                        _TaskEnd = (DateTime)_dt["End"];
                    }

                    _dt.Close();
                }

                conn.Close();
            }

            string[] ChannelsArray = _channelGroup.Split(',');
            for(var i=0; i<ChannelsArray.Count(); i++)
            {
                while(ChannelsArray[i].IndexOf(" ") > -1)
                {
                    ChannelsArray[i] = ChannelsArray[i].Replace(" ", "");
                }
            }

            string AddressIP = string.Empty; string AddressPort = string.Empty; bool AddressNat = false;
            string TypeKNX = string.Empty; string MeterSerial = string.Empty;
            List<string> GroupAddressMeter = new List<string>(); List<string> GroupAddressON = new List<string>();

            using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString))
            {
                string sqlSelect = "SELECT [AddressIP],[AddressPort],[AddressNat],[TypeKNX],[MeterSerialNo] FROM [db_knx].[dbo].[Pillars] WHERE [ID] = " + _PillarID + ";";

                conn.Open();

                using (SqlCommand sqlComm = new SqlCommand(sqlSelect, conn))
                {
                    SqlDataReader _dt = sqlComm.ExecuteReader();

                    while (_dt.Read())
                    {
                        AddressIP = _dt["AddressIP"].ToString();
                        AddressPort = _dt["AddressPort"].ToString();
                        AddressNat = (bool)_dt["AddressNat"];
                        TypeKNX = _dt["TypeKNX"].ToString();
                        MeterSerial = _dt["MeterSerialNo"].ToString();
                    }

                    _dt.Close();
                }

                for (var i = 0; i < ChannelsArray.Count(); i++)
                {
                    sqlSelect = "SELECT [On/Off Address],[MeasureCurrent Address] FROM [db_knx].[dbo].[" + TypeKNX + "_" + MeterSerial + "] WHERE [Departure] = " + ChannelsArray[i] + ";";

                    using (SqlCommand sqlComm = new SqlCommand(sqlSelect, conn))
                    {
                        SqlDataReader _dt = sqlComm.ExecuteReader();

                        while (_dt.Read())
                        {
                            GroupAddressON.Add(_dt["On/Off Address"].ToString());
                            GroupAddressMeter.Add(_dt["MeasureCurrent Address"].ToString());
                        }

                        _dt.Close();
                    }
                }

                conn.Close();
            }

            Ping pingOrder = new Ping();
            for (var i=0; i<4; i++)
            {
                try
                {
                    pingOrder.Send(AddressIP);
                }
                catch (PingException ex)
                {
//.........这里部分代码省略.........
开发者ID:Costas47,项目名称:KNXWorker,代码行数:101,代码来源:Program.cs

示例4: meterCurrent

        static void meterCurrent(string _taskguid, string _dtable)
        {
            string _TaskID = string.Empty;
            string _channelGroup = string.Empty;
            string _PillarID = string.Empty;

            using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString))
            {
                string sqlSelect = "SELECT [ID],[ChannelGroup],[PillarID] FROM [db_knx].[dbo].["+_dtable+"] WHERE [TaskGUID] LIKE N'" + _taskguid + "' AND [Start] = (SELECT MAX([Start]) FROM [db_knx].[dbo].[Scheduler] WHERE [TaskGUID] LIKE N'" + _taskguid + "');";

                conn.Open();

                using (SqlCommand sqlComm = new SqlCommand(sqlSelect, conn))
                {
                    SqlDataReader _dt = sqlComm.ExecuteReader();

                    while (_dt.Read())
                    {
                        _channelGroup = _dt["ChannelGroup"].ToString();
                        _PillarID = _dt["PillarID"].ToString();
                    }

                    _dt.Close();
                }

                conn.Close();
            }

            string[] ChannelsArray = _channelGroup.Split(',');
            for (var i = 0; i < ChannelsArray.Count(); i++)
            {
                while (ChannelsArray[i].IndexOf(" ") > -1)
                {
                    ChannelsArray[i] = ChannelsArray[i].Replace(" ", "");
                }
            }

            string AddressIP = string.Empty; string AddressPort = string.Empty; bool AddressNat = false;
            string TypeKNX = string.Empty; string MeterSerial = string.Empty; List<string> GroupAddressMeasure = new List<string>();

            using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString))
            {
                string sqlSelect = "SELECT [AddressIP],[AddressPort],[AddressNat],[TypeKNX],[MeterSerialNo] FROM [db_knx].[dbo].[Pillars] WHERE [ID] = " + _PillarID + ";";

                conn.Open();

                using (SqlCommand sqlComm = new SqlCommand(sqlSelect, conn))
                {
                    SqlDataReader _dt = sqlComm.ExecuteReader();

                    while (_dt.Read())
                    {
                        AddressIP = _dt["AddressIP"].ToString();
                        AddressPort = _dt["AddressPort"].ToString();
                        AddressNat = (bool)_dt["AddressNat"];
                        TypeKNX = _dt["TypeKNX"].ToString();
                        MeterSerial = _dt["MeterSerialNo"].ToString();
                    }

                    _dt.Close();
                }

                for (var i = 0; i < ChannelsArray.Count(); i++)
                {
                    sqlSelect = "SELECT [MeasureCurrent Address] FROM [db_knx].[dbo].[" + TypeKNX + "_" + MeterSerial + "] WHERE [Departure] = " + ChannelsArray[i] + ";";

                    using (SqlCommand sqlComm = new SqlCommand(sqlSelect, conn))
                    {
                        SqlDataReader _dt = sqlComm.ExecuteReader();

                        while (_dt.Read())
                        {
                            if (!_dt.IsDBNull(0))
                            {
                                GroupAddressMeasure.Add(_dt["MeasureCurrent Address"].ToString());
                            }
                        }

                        _dt.Close();
                    }
                }

                conn.Close();
            }

            Ping pingOrder = new Ping();
            for (var i = 0; i < 4; i++)
            {
                try
                {
                    pingOrder.Send(AddressIP);
                }
                catch (PingException ex)
                {

                }
            }
            pingOrder = null;

            using (Bus _bus = new Bus(new KnxIpTunnelingConnectorParameters(AddressIP, ushort.Parse(AddressPort), AddressNat)))
//.........这里部分代码省略.........
开发者ID:Costas47,项目名称:KNXWorker,代码行数:101,代码来源:Program.cs


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