本文整理汇总了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);
}
示例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);
}
示例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)
{
//.........这里部分代码省略.........
示例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)))
//.........这里部分代码省略.........