Ejemplo n.º 1
0
        /// <summary>
        /// 得到登陸字節
        /// </summary>
        /// <param name="SqlDatatable"></param>
        /// <returns></returns>
        public byte[] GetLoginBytes(DataBranch dr)
        {
            byte[] usrname  = System.Text.Encoding.UTF8.GetBytes(serverInfo.LoginName);
            byte[] password = System.Text.Encoding.UTF8.GetBytes(serverInfo.LoginPass);

            //返回字節數
            byte[] ret = new byte[13 + usrname.Length + password.Length];
            Buffer.BlockCopy(dr.GetByte(ReceCommandType.LoginByte), 0, ret, 0, 9);
            ret[9] = (byte)usrname.Length;
            Buffer.BlockCopy(usrname, 0, ret, 10, ret[9]);
            ret[10 + ret[9]] = (byte)password.Length;
            Buffer.BlockCopy(password, 0, ret, 11 + ret[9], ret[10 + ret[9]]);
            dr.AddSumCode(ret, ret.Length);
            return(ret);
        }
Ejemplo n.º 2
0
 //返回按钮发送字节数组
 public byte[] GetButtonClickSendBytes(DataBranch br)
 {
     //获得按钮属性Tag 字节数组
     byte[] sb = System.Text.Encoding.UTF8.GetBytes(ButtonTag.ToString());
     //返回字节数组
     byte[] retSendBytes = new byte[sb.Length + 9];
     //获得指令头字节数组
     byte[] commBytes = br.GetByte(ReceCommandType.ButontClick);
     //复制命令头字节
     Buffer.BlockCopy(commBytes, 0, retSendBytes, 0, commBytes.Length);
     //复制按钮属性Tag
     Buffer.BlockCopy(sb, 0, retSendBytes, commBytes.Length, sb.Length);
     //添加校验码
     br.AddSumCode(retSendBytes, retSendBytes.Length);
     //返回数组
     return(retSendBytes);
 }