private void btnSave_Click(object sender, EventArgs e) { if (this.txtName.Text.Trim().IsNullOrWhiteSpace()) { MessageBox.Show("名称不能为空,请输入"); this.txtName.Focus(); return; } //if (ProtocalType.FindAllByName(this.txtName.Text) != null) //{ // MessageBox.Show("名称已经存在"); // this.txtName.Focus(); // return; //} if (this.protocalTypeId != 0) { try { // 更新 var protocalType = new ProtocalType { ID = this.protocalTypeId, //ID =Convert.ToInt32( this.txtId.Text), Name = this.txtName.Text.Trim(), Remark = this.txtRemark.Text.Trim() }; ProtocalType.Update(protocalType); MessageBox.Show("更新成功"); } catch (Exception ex) { XTrace.WriteException(ex); MessageBox.Show("更新失败"); } } else { try { // 保存 var protocalType = new ProtocalType { //ID = Convert.ToInt32(this.txtId.Text), Name = this.txtName.Text.Trim(), Remark = this.txtRemark.Text.Trim() }; ProtocalType.Save(protocalType); MessageBox.Show("保存成功"); } catch (Exception ex) { XTrace.WriteException(ex); MessageBox.Show("保存失败"); } } this.InitProtocalTypeListView(); }
/// <summary> /// 创建一个监听连接的Network。 /// </summary> /// <param name="endPoint">服务端监听IP端口。</param> /// <param name="protocalType">通讯协议类型。</param> /// <returns>Network 网络类对象</returns> public static Network CreateAcceptor(IPEndPoint endPoint, ProtocalType protocalType) { var network = new Network(); var session = new Session(endPoint, network, protocalType); network.Session = session; session.Accept(); return(network); }
public void RegisteReceive(ProtocalType type, Action <string> onReceive) { if (onReceive != null) { receiver.RegisterEvent(type.ToString(), onReceive); } #if UNITY_EDITOR waitDic[type] = onReceive; #endif }
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { var types = ProtocalType.FindAll(); var names = new ArrayList(); if (types != null && types.Count > 0) { names.AddRange(types); } return(new StandardValuesCollection(names)); }
/// <summary> /// 创建一个监听连接的Network。 /// </summary> /// <param name="endPoint">服务端监听IP端口。</param> /// <param name="protocalType">通讯协议类型。</param> /// <param name="connectAction">连接成功回调。</param> /// <param name="disconnectAction">连接断开回调。</param> /// <returns>Network 网络类对象</returns> public static Network CreateAcceptor(IPEndPoint endPoint, ProtocalType protocalType , Action <Network> connectAction, Action <Network> disconnectAction) { var network = new Network(); var session = new Session(endPoint, network, protocalType); network.Session = session; session.OnServerConnected += connectAction; session.OnServerDisconnected += disconnectAction; session.Accept(); return(network); }
/// <summary> /// 初始化数据协议类型列表 /// </summary> private void InitProtocalTypeListView() { this.listView1.Items.Clear(); List <ProtocalType> protocalTypeList = ProtocalType.FindAll(); foreach (var protocalType in protocalTypeList) { var strings = new string[] { protocalType.ID.ToString(), protocalType.Name, protocalType.Remark }; var listViewItem = new ListViewItem(strings); listViewItem.Tag = protocalType; this.listView1.Items.Add(listViewItem); } }
public static bool IsType(this IInternetData data, ProtocalType type) { IInternetData d = data; while (d != null) { if (d.ProtocalType == type) { return(true); } d = d.Super; } return(false); }
/// <summary> /// 基础发送数据 /// </summary> /// <param name="protocalType"></param> /// <param name="data"></param> void BaseSend(ProtocalType protocalType, byte[] data) { var p = new BaseSocketProtocal(); p.Type = (byte)protocalType; p.Content = data; if (p.Content != null) { p.BodyLength = p.Content.Length; } else { p.BodyLength = 0; } _udpClient.SendAsync(p.ToBytes()); }
void BaseReply(string id, ProtocalType protocalType, byte[] data) { var p = new BaseSocketProtocal(); p.Type = (byte)protocalType; p.Content = data; if (p.Content != null) { p.BodyLength = p.Content.Length; } else { p.BodyLength = 0; } _udpServer.SendAsync(id, p.ToBytes()); }
/// <summary> /// 初始化数据协议类型 /// </summary> private void InitProtocalType() { List <ProtocalType> protocalTypeList = ProtocalType.FindAll(); //foreach (var protocalType in protocalTypeList) //{ // this.cbProtocalType.Items.Add(protocalType); // this.cbProtocalType.DisplayMember = protocalType.ID.ToString(); // this.cbProtocalType.ValueMember = protocalType.Name; //} if (protocalTypeList.Count > 0) { this.cbProtocalType.DataSource = protocalTypeList; this.cbProtocalType.DisplayMember = "Name"; this.cbProtocalType.ValueMember = "ID"; } }
private void BaseConfig_Load(object sender, EventArgs e) { if (ClassName.EqualIgnoreCase("CommunicateDeviceType")) { this.Name = "CommunicateDeviceType"; var types = CommunicateDeviceType.FindAll(); this.dataGridViewX1.DataSource = types; } if (ClassName.EqualIgnoreCase("Sensor")) { this.Name = "Sensor"; this.dataGridViewX1.DataSource = Sensor.FindAll(); } if (ClassName.EqualIgnoreCase("RelayType")) { this.Name = "RelayType"; this.dataGridViewX1.DataSource = RelayType.FindAll(); } if (ClassName.EqualIgnoreCase("ControlJobType")) { this.Name = "ControlJobType"; this.dataGridViewX1.DataSource = ControlJobType.FindAll(); } if (ClassName.EqualIgnoreCase("DeviceType")) { this.Name = "DeviceType"; this.dataGridViewX1.DataSource = DeviceType.FindAll(); } if (ClassName.EqualIgnoreCase("FacilityType")) { this.Name = "FacilityType"; this.dataGridViewX1.DataSource = FacilityType.FindAll(); } if (ClassName.EqualIgnoreCase("ProtocalType")) { this.Name = "ProtocalType"; this.dataGridViewX1.DataSource = ProtocalType.FindAll(); } if (ClassName.EqualIgnoreCase("ShowDeviceType")) { this.Name = "ShowDeviceType"; this.dataGridViewX1.DataSource = ShowDeviceType.FindAll(); } }
public IPDatagramHeader(byte version, byte headerLength, byte service, ushort length, ushort identification, byte flag, byte rFFlag, byte dFFlag, byte mFFlag, ushort offset, byte tTL, byte protacalRaw, ProtocalType type, ushort checkSum, IPAddress source, IPAddress dest, byte[] optionRaw) { Version = version; HeaderLength = headerLength; Service = service; Length = length; Identification = identification; Flag = flag; RFFlag = rFFlag; DFFlag = dFFlag; MFFlag = mFFlag; Offset = offset; TTL = tTL; ProtocalRaw = protacalRaw; Type = type; CheckSum = checkSum; Source = source; Dest = dest; OptionRaw = optionRaw; }
public void OnMessage(ClientSession session, ByteBuffer buffer) { byte b = buffer.ReadByte(); ProtocalType type = (ProtocalType)b; //协议类型 switch (type) { case ProtocalType.BINARY: OnBinaryMessage(session, buffer); break; case ProtocalType.PB_LUA: OnPbLuaMessage(session, buffer); break; case ProtocalType.PBC: OnPbcMessage(session, buffer); break; case ProtocalType.SPROTO: OnSprotoMessage(session, buffer); break; } }
private void 除ToolStripMenuItem_Click(object sender, EventArgs e) { if (this.listView1.SelectedItems.Count > 0) { //if (MessageBox.Show("是否删除该数据协议类型?") == DialogResult.OK) if (MessageBox.Show("确定要删除该数据协议类型吗?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes) { if (this.listView1.SelectedItems[0].Tag is FacilityType) { var protocalType = this.listView1.SelectedItems[0].Tag as ProtocalType; var id = protocalType.ID; List <ModularDevice> modularDeviceList = ModularDevice.FindAllByProtocalTypeID(id); if (modularDeviceList != null) { MessageBox.Show("该协议类型已经在使用,不能删除"); return; } ProtocalType.Delete(protocalType); this.InitProtocalTypeListView(); this.protocalTypeId = 0; } } } }
public Session(IPEndPoint endPoint, Network network, ProtocalType protocalType) { this.EPoint = endPoint; this.PType = protocalType; this.Network = network; }
public Session(IPEndPoint endPoint, ProtocalType protocalType) { this.endPoint = endPoint; this.protocalType = protocalType; }
public NetAcceptorComponent(IPEndPoint endPoint, ProtocalType protocalType) { this.EndPoint = endPoint; this.ProtocalType = protocalType; }
public NetAcceptorComponent(string httpPrefixed, ProtocalType protocalType) { this.HttpPrefixed = httpPrefixed; this.ProtocalType = protocalType; }
public ApiNetServer() { Formatter = new NotSupportFormatter(); Formatter = ObjectContainer.Current.Resolve <FormatterBase>(ProtocalType.ToString()); }
public NoAnalyseDatagram(byte[] rawData, ProtocalType protocalType = ProtocalType._) { this.rawData = rawData; this.protocalType = protocalType; }
public APIContent(string apipath, RequestType type, ProtocalType ptype = ProtocalType.HTTP) { this.APIPath = apipath; this.ReqType = type; this.ProtType = ptype; }
public Session(string httpPrefixed, Network network, ProtocalType protocalType) { this.HttpPrefixed = httpPrefixed; this.PType = protocalType; this.Network = network; }
public void AddSendQueue(ProtocalType type, string value) { sendQueue.Enqueue(new KeyValuePair <string, string>(type.ToString(), value)); }
public override string ToString() { var formatter = ObjectContainer.Current.Resolve <FormatterBase>(ProtocalType.ToString()); return(formatter.Serialize(this)); }