Beispiel #1
0
        private ShortMessage ConvertByteToShortMessage(Byte[] data, int len)
        {
            String       Time;
            ShortMessage Message        = new ShortMessage();
            String       MessageContent = "";
            String       ResponseData   = System.Text.Encoding.UTF8.GetString(data, 0, len);

            String[] Cmd = ResponseData.Split(' ');
            if (Cmd[0] == "")
            {
                messageBox.Dispatcher.Invoke((Action) delegate { messageBox.Show("通讯故障,服务器传入空串。"); });
                System.Threading.Thread.Sleep(3000);
                Environment.Exit(0);
            }
            Message.SetId((int.Parse(Cmd[0])));
            Message.SetSendNumber(Cmd[1]);
            Message.SetReceiveNumber(Cmd[2]);
            Time = Convert.ToDateTime(Cmd[3]) + " " + Convert.ToDateTime(Cmd[4]);
            Message.SetTime(Convert.ToDateTime(Cmd[3] + " " + Cmd[4]));
            for (int i = 5; i < Cmd.Length - 1; i++)
            {
                MessageContent += Cmd[i];
                MessageContent += " ";
            }
            MessageContent += Cmd[Cmd.Length - 1];
            Message.SetContent(MessageContent);
            return(Message);
        }
Beispiel #2
0
        public ArrayList GetMessageListByKeyWord(String keyWord)
        {
            reader.Close();
            ArrayList result = new ArrayList();

            sql    = @"select * from ShortMessage where Owner = '" + Owner + "' and  content like '%" + keyWord + "%'";
            cmd    = new SqlCommand(sql, conn);
            reader = cmd.ExecuteReader();
            while (reader.Read())
            {
                ShortMessage msg = new ShortMessage();
                msg.SetId((int)reader[0]);
                msg.SetSendNumber(reader[2].ToString().Trim());
                msg.SetReceiveNumber(reader[3].ToString().Trim());
                //msg.SetTime(DateTime.Parse(reader[4].ToString().Trim()));
                msg.SetContent(reader[5].ToString().Trim());
                result.Add(msg);
            }
            reader.Close();
            return(result);
        }