/// <summary> /// 发送消息 到指定的客户端 /// </summary> private void btnSend_Click(object sender, EventArgs e) { TCPServerClient client = lbClientList.SelectedItem as TCPServerClient; if (client != null) { string data = txtCmdTxt.Text.Trim(); List <string> datas = StringPlus.GetStrArray(data, ";"); if (datas.Count < 2) { if (string.IsNullOrWhiteSpace(datas[0])) { UserMessageBox.MessageError("发送内容不能为空!"); return; } bool suc = client.SendString(datas[0]); if (!suc) { UserMessageBox.MessageError("发送失败"); } } else { if (!TmoShare.IsNumricForInt(datas[0])) { UserMessageBox.MessageError("命令ID必须为整数"); return; } bool suc = client.SendCommand(int.Parse(datas[0]), datas[1]); if (!suc) { UserMessageBox.MessageError("发送失败"); } } } else { UserMessageBox.MessageInfo("请选择要发送的客户端"); } }
/// <summary> /// 跟据部门ID得到部门名字 /// </summary> /// <returns></returns> public string GetDepartmentNamesFromIDs(string ids) { if (string.IsNullOrWhiteSpace(ids)) { return(string.Empty); } if (TmoShare.DataTableIsEmpty(tmo_department)) { tmo_department = Tmo_FakeEntityClient.Instance.GetData("tmo_department"); } if (TmoShare.DataTableIsEmpty(tmo_department)) { return(string.Empty); } string[] idarray = ids.Split(','); List <string> idlist = new List <string>(); foreach (string s in idarray) { if (TmoShare.IsNumricForInt(s)) { idlist.Add(s); } } ids = StringPlus.GetArrayStr(idlist, ",", "'{0}'"); if (string.IsNullOrEmpty(ids)) { return(string.Empty); } DataRow[] rows = tmo_department.Select("dpt_id in (" + ids + ")"); StringBuilder sb = new StringBuilder(); foreach (DataRow dataRow in rows) { sb.AppendFormat("{0},", dataRow.GetDataRowStringValue("dpt_name")); } return(sb.ToString().TrimEnd(',')); }