コード例 #1
0
        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();
        }
コード例 #2
0
        /// <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);
        }
コード例 #3
0
    public void RegisteReceive(ProtocalType type, Action <string> onReceive)
    {
        if (onReceive != null)
        {
            receiver.RegisterEvent(type.ToString(), onReceive);
        }
#if UNITY_EDITOR
        waitDic[type] = onReceive;
#endif
    }
コード例 #4
0
        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));
        }
コード例 #5
0
        /// <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);
        }
コード例 #6
0
        /// <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);
            }
        }
コード例 #7
0
        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);
        }
コード例 #8
0
ファイル: TransferClient.cs プロジェクト: zouhunter/SAEA
        /// <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());
        }
コード例 #9
0
        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());
        }
コード例 #10
0
        /// <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";
            }
        }
コード例 #11
0
 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();
     }
 }
コード例 #12
0
 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;
 }
コード例 #13
0
        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;
            }
        }
コード例 #14
0
 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;
             }
         }
     }
 }
コード例 #15
0
 public Session(IPEndPoint endPoint, Network network, ProtocalType protocalType)
 {
     this.EPoint  = endPoint;
     this.PType   = protocalType;
     this.Network = network;
 }
コード例 #16
0
 public Session(IPEndPoint endPoint, ProtocalType protocalType)
 {
     this.endPoint     = endPoint;
     this.protocalType = protocalType;
 }
コード例 #17
0
 public NetAcceptorComponent(IPEndPoint endPoint, ProtocalType protocalType)
 {
     this.EndPoint     = endPoint;
     this.ProtocalType = protocalType;
 }
コード例 #18
0
 public NetAcceptorComponent(string httpPrefixed, ProtocalType protocalType)
 {
     this.HttpPrefixed = httpPrefixed;
     this.ProtocalType = protocalType;
 }
コード例 #19
0
 public ApiNetServer()
 {
     Formatter = new NotSupportFormatter();
     Formatter = ObjectContainer.Current.Resolve <FormatterBase>(ProtocalType.ToString());
 }
コード例 #20
0
 public NoAnalyseDatagram(byte[] rawData, ProtocalType protocalType = ProtocalType._)
 {
     this.rawData      = rawData;
     this.protocalType = protocalType;
 }
コード例 #21
0
 public APIContent(string apipath, RequestType type, ProtocalType ptype = ProtocalType.HTTP)
 {
     this.APIPath  = apipath;
     this.ReqType  = type;
     this.ProtType = ptype;
 }
コード例 #22
0
 public Session(string httpPrefixed, Network network, ProtocalType protocalType)
 {
     this.HttpPrefixed = httpPrefixed;
     this.PType        = protocalType;
     this.Network      = network;
 }
コード例 #23
0
 public void AddSendQueue(ProtocalType type, string value)
 {
     sendQueue.Enqueue(new KeyValuePair <string, string>(type.ToString(), value));
 }
コード例 #24
0
        public override string ToString()
        {
            var formatter = ObjectContainer.Current.Resolve <FormatterBase>(ProtocalType.ToString());

            return(formatter.Serialize(this));
        }